initEditor(); /*配置列表*/ $inc_type = I('get.inc_type', 'shop_info'); $this->assign('inc_type', $inc_type); $qclurl = QCLOUD_IMGURL; $this->assign('qclurl', $qclurl); /*-缓存--*/ $config = tpCache($inc_type, getAdmStoId()); switch ($inc_type) { case "basic"://基本设置 //是否启用客服 $where=time().'where($where)->order('end_time')->find(); $isopenkefu=0; if($kers) $isopenkefu=1; $this->assign('isopenkefu', $isopenkefu); $inv_coupon = M('coupon')->where("type = 3 and store_id=" . getAdmStoId())->select(); //邀请类型的优惠券 $coupon = M('coupon')->where("type = 2 and store_id=" . getAdmStoId())->select(); //注册类型的优惠券 $this->assign('reginfo_coupon', $coupon); $this->assign('inv_coupon', $inv_coupon); break; case "shopping"://购物设置 $feemail=M('area_feemail')->where('store_id='.getAdmStoId())->order('id desc')->select(); $this->assign('feemail',$feemail); $province = M('region')->where(array('parent_id' => 0))->select(); $city = M('region')->where(array('parent_id' => $config['province']))->select(); $area = M('region')->where(array('parent_id' => $config['city']))->select(); $this->assign('province', $province); $this->assign('city', $city); $this->assign('area', $area); // $is_ylpapp = tpCache('shop_info.is_ylpapp', getAdmStoId()); if (isset($is_ylpapp)) { $this->assign('is_ylpapp', $is_ylpapp); } else { $storeinfo = M("store")->where("store_id", getAdmStoId()) ->field("is_ylpapp")->find(); $this->assign('is_ylpapp', $storeinfo['is_ylpapp']); } // if ($config['point_rate']) { $point_rate=json_decode($config['point_rate'],true); } $this->assign('point_rate', $point_rate);//当前配置项 if ($config['quan_rate']) { $quan_rate=json_decode($config['quan_rate'],true); } $this->assign('quanlist', $quan_rate);//当前配置项 break; case "distribut"://分销设置 $distr_goods_id = $config['condition_goods_id']; $gname = ""; if ($distr_goods_id) { $rs = M('goods')->where('goods_id', $distr_goods_id)->field('goods_name')->find(); $gname = $rs['goods_name']; $this->assign('condition_goods_name', $gname); } //分销是否过期 $isbuy=0; $is_out=M("store_module_endtime") ->where('store_id',getAdmStoId()) ->where('type',2)->find(); $all=M('store_distribut')->where('store_id',getAdmStoId())->find(); $allnum=$all['distribut_num']; if($is_out){ //----体验是无限时间--- if($is_out['is_sy']){ $yy=M('distri_price')->where('type',0)->where('money',0)->find(); $allnum=$yy['user_num']; if(empty($all)){ $ud['distribut_num']=$allnum; $ud['store_id']=getAdmStoId(); M('store_distribut')->save($ud); }else{ $ud['distribut_num']=$allnum; M('store_distribut')->where('store_id',getAdmStoId())->save($ud); $count=M("users")->where('store_id',getAdmStoId())->where('is_distribut',1)->count(); if($count>=$allnum){ $this->redirect(U('admin/System/not_distribut',array('out'=>0))); //过期 } } }else{ if($is_out['end_time']>time()) { $isbuy=1; $this->assign('end_time', $is_out['end_time']); }else{ $this->redirect(U('admin/System/not_distribut',array('out'=>1))); //过期 } } }else{ $this->redirect(U('admin/System/not_distribut',array('out'=>2))); //过期 } $disnum=M('users')->where('store_id',getAdmStoId())->where('is_distribut',1)->count(); $this->assign('allnum', $allnum); $this->assign('disnum', $disnum); $this->assign('isbuy', $isbuy); break; case "cardsetup": $storeinfo = tpCache('shop_info', getAdmStoId()); $sto_erpid = $storeinfo['ERPId']; $all0 = Db::name('storage_recharge') ->where("type", 8) ->where("recharge_state", 1) ->where('store_id', getAdmStoId()) ->order("id desc") ->find(); $all = Db::name('store_config')->where('store_id', getAdmStoId())->find(); $allnum = $all['dj_num']; $rs_count = getApiData_java("/api/erp/vip/mem/card/count", $sto_erpid, null, 1, 1); if ($rs_count) { $rs_count = json_decode($rs_count, true); if ($rs_count['code'] == 0) { $count = $rs_count['data']['SumTotal']; } } $is_out = M("store_module_endtime") ->where('store_id', getAdmStoId()) ->where('type', 3)->find(); if ($is_out) { //---如果是试用的话--- if($is_out['is_sy']){ $yy = M('dj_price')->where('type', 0)->where('money', 0)->find(); $all0['buy_num'] = $allnum = $yy['user_num']; if (empty($all)) { $ud['dj_num'] = $allnum; $ud['store_id'] = getAdmStoId(); M('store_config')->save($ud); } else { $ud['dj_num'] = $allnum; M('store_distribut')->where('store_id', getAdmStoId())->save($ud); } }else{ if ($is_out['end_time'] > time()) { $this->assign('end_time', $is_out['end_time']); } else { $this->error("plus卡功能已过期,请及时续费!",U('admin/index/welcome')); } } } else { $this->error("未购买plus卡功能!",U('admin/index/welcome')); } //等级卡列表 $plusinfo = getApiData_java_p("/api/erp/vip/mem/bership/list", $sto_erpid, null, 1, 10, null, "GET"); if ($plusinfo) { $plusinfo = json_decode($plusinfo, true); $this->assign('plusinfo', $plusinfo['data']); } $this->assign('allnum', $allnum); $this->assign('djnum', $count); $this->assign('all0', $all0); break; case "water"://水印默认选项 if (empty($config)) { $config['mark_type'] = 'text'; } break; default: break; } /*---商家是否开启等级卡 --*/ if (getERPId()) { //有ERP $tk = M("store_config")->where("store_id", getAdmStoId()) ->field("dj_num")->find(); if ($tk['dj_num'] > 0) { $iscard = 1; } } if ($inc_type=="basic" || $inc_type=="cardsetup") { //会员中心工具及服务 $usertool = M("user_tool")->order('ordid asc,id asc')->select(); //后台是否开启了初始化 $isBool = 0; if (getERPId()) {//判断是否有ERP商家 $init_data = getApiData_java_p("/api/erp/grade/vip/init/get", getERPId(), null, 1, 10, null, "GET"); if ($init_data) { $init_data = json_decode($init_data, true); if ($init_data['code'] === 0 && $init_data['data']) { $isBool = $init_data['data']['isBool']; $this->assign('isBool', $init_data['data']['isBool']); } } } $switch_list = tpCache('basic.switch_list', getAdmStoId()); //等级卡 $rank_switch =0; $switch_list_decode=json_decode($switch_list, true); if ($switch_list_decode) { if ($switch_list_decode['rank_switch']) { $rank_switch = $switch_list_decode['rank_switch']; } } $vipcard = 0; if ($rank_switch == 2)//默认商城(商家开启等级卡) { $vipcard = 1; } $getdistribut_switch = tpCache('distribut.switch', getAdmStoId()); //过滤工具要显示的条件 if ($usertool) { foreach ($usertool as $k => $v) { //--判断分销--- if (strpos($v['url'], 'Distribut') !== false && $getdistribut_switch != 1) { continue; } //--判断等级卡-- if (strpos($v['url'], 'cardinfo') !== false && $vipcard != 1) { continue; } //我的权益 if (strpos($v['url'], 'gorw_up') !== false && !$isBool) { continue; } //我的权益(旧) if (strpos($v['url'], 'vipqy') !== false && $isBool) { continue; } $usertool_new[] = $v; } $this->assign('usertool', $usertool_new); } } $this->assign('erpid', getERPId()); $this->assign('config', $config);//当前配置项 $this->assign('isopencard',$iscard);//判断当前商家是否开通等级卡 return $this->fetch($inc_type, getAdmStoId()); } /* * 新增修改配置 */ public function handle() { ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $param = I('post.'); $inc_type = $param['inc_type']; mlog($inc_type . ":" . json_encode($param), 'system/' . getAdmStoId()); /*邀请规则*/ if ($inc_type == "basic") { $invitation_rate = array( 'inv_jf' => $param['inv_jf'], 'inv_coupon' => $param['inv_coupon_id'], 'inv_cz' => $param['inv_cz'], ); $param['invitation_rate'] = json_encode($invitation_rate); $reg_default = array( 'reg_def_ty' => $param['reg_def_ty'], 'jf' => $param['jf'], 'coupon' => $param['coupon_id'], 'reg_cz' => $param['reg_cz'], ); $getjfcz=0; $getdhwz=0; $getyckcz=0; if ($param['jfcz']) { $getjfcz=1; } if ($param['dhwz']) { $getdhwz=1; } if ($param['yckcz']) { $getyckcz=1; } $getispt_goods=-1; if ($param['ispt_goods']) { $getispt_goods=0; } $is_tx_wx=0; if ($param['is_tx_wx']) { $is_tx_wx=1; } $getis_brithday=0; if ($param['is_brithday']) { $getis_brithday=1; } $is_flash_return=0; if ($param['is_flash_return']) { $is_flash_return=1; } $if_fast_reg=0; if ($param['is_fast_reg']) { $is_fast_reg=1; } $is_close_quan=0; if ($param['is_close_quan']) { $is_close_quan=1; } $is_newchoosestore=0; if ($param['is_newchoosestore']) { $is_newchoosestore=1; } $is_closecoupon=0; if ($param['is_closecoupon']) { $is_closecoupon=1; } $is_regstores=0; if ($param['is_regstores']) { $is_regstores=1; } $is_newsgoodstype = 0; if ($param['is_newsgoodstype']) { $is_newsgoodstype = 1; } $is_closetxbank = 0; if ($param['is_closetxbank']) { $is_closetxbank = 1; } $is_newsales_rules = 0; if ($param['is_newsales_rules']) { $is_newsales_rules = 1; } $switch = tpCache('shopping.switch_list',getAdmStoId());//获取开关json $switch_list = json_decode($switch,true);//获取开关列表 $switch_list['jfcz_switch']=$getjfcz; $switch_list['dhwz_switch']=$getdhwz; $switch_list['yckcz_switch']=$getyckcz; $switch_list['ispt_goods']=$getispt_goods; $switch_list['is_tx_wx']=$is_tx_wx; $switch_list['is_brithday']=$getis_brithday; $switch_list['is_flash_return']=$is_flash_return; $switch_list['is_fast_reg']=$is_fast_reg; $switch_list['is_close_quan']=$is_close_quan; $switch_list['is_newchoosestore']=$is_newchoosestore; $switch_list['is_closecoupon']=$is_closecoupon; $switch_list['is_regstores']=$is_regstores; $switch_list['is_newsgoodstype'] = $is_newsgoodstype; $switch_list['usertool'] = json_encode($param['usertool']); $switch_list['is_closetxbank'] = $is_closetxbank; $switch_list['is_newsales_rules'] = $is_newsales_rules; $switch_list['user_label_set'] = $param['user_label_set']; $switch_list['user_label_val'] = $param['user_label_val']; $switch_list['user_label_type'] = $param['user_label_type']; unset($param['jfcz']); unset($param['dhwz']); unset($param['yckcz']); unset($param['ispt_goods']); unset($param['is_tx_wx']); unset($param['is_brithday']); unset($param['is_flash_return']); unset($param['is_fast_reg']); unset($param['is_close_quan']); unset($param['is_newchoosestore']); unset($param['is_closecoupon']); unset($param['is_regstores']); unset($param['is_newsgoodstype']); unset($param['usertool']); unset($param['is_closetxbank']); unset($param['is_newsales_rules']); unset($param['user_label_set']); unset($param['user_label_val']); unset($param['user_label_type']); $param['switch_list'] = json_encode($switch_list); $param['reg_default'] = json_encode($reg_default); $reg_info = array( 'name' => (int)$param['name_v'], 'name_val_type' => (int)$param['name_val_type'], 'name_state' => (int)$param['name'], 'birthday' => (int)$param['birthday_v'], 'birthday_type' => (int)$param['birthday_type'], 'birthday_state' => (int)$param['birthday'], 'idcard' => (int)$param['idcard_v'], 'idcard_type' => (int)$param['idcard_type'], 'idcard_state' => (int)$param['idcard'], 'address' => (int)$param['address_v'], 'address_type' => (int)$param['address_type'], 'address_state' => (int)$param['address'], 'pick' => (int)$param['pick_v'], 'pick_type' => (int)$param['pick_type'], 'pick_state' => (int)$param['pick'], 'sex' => (int)$param['sex'], 'sex_state_type' => (int)$param['sex_state_type'], 'sex_state' => (int)$param['sex_state'], 'introducer' => (int)$param['introducer'], 'introducer_type' => (int)$param['introducer_type'], 'introducer_state' => (int)$param['introducer_state'], 'reginfo_coupon' => $param['reginfo_coupon'], ); $param['reg_info'] = json_encode($reg_info); if ($param['categoryset1']) { $param['categoryset'] .= "," . $param['categoryset1']; } if ($param['categoryset2']) { $param['categoryset'] .= "," . $param['categoryset2']; } if ($param['categoryset3']) { $param['categoryset'] .= "," . $param['categoryset3']; } $param['categoryset'] .= ","; unset($param['categoryset1']); unset($param['categoryset2']); unset($param['categoryset3']); } if ($inc_type == 'shop_info') { upload_ylp_log('A01商城信息/确认提交'); } if ($inc_type == 'basic') { upload_ylp_log('A02基本设置/确认提交'); } if ($inc_type == 'shopping') { $switch = tpCache('shopping.switch_list',getAdmStoId());//获取开关json $switch_list = json_decode($switch,true);//获取开关列表 // $switch_list['rank_switch'] = $param['rank_switch']; // unset($param['is_rank']); $param['mzprice_list']['mz_time'] = time(); $param['switch_list'] = json_encode($switch_list); $param['mzprice_list'] = json_encode($param['mzprice_list']); $pjlist['is_autopj']=$param['is_autopj']; $pjlist['auto_pjday']=$param['auto_pjday']; $pjlist['auto_pjremark']=$param['auto_pjremark']; $param['autopj_list'] = json_encode($pjlist); if ($param['ylpapp_list1']) { $param['ylpapp_list'] .= "," . $param['ylpapp_list1']; } if ($param['ylpapp_list2']) { $param['ylpapp_list'] .= "," . $param['ylpapp_list2']; } if ($param['ylpapp_list3']) { $param['ylpapp_list'] .= "," . $param['ylpapp_list3']; } if ($param['ylpapp_list']) { $param['ylpapp_list'] .= ","; } else{ $param['ylpapp_list']=""; } unset($param['ylpapp_list1']); unset($param['ylpapp_list2']); unset($param['ylpapp_list3']); $point_rate['money']=$param['point_rate_money']; $point_rate['integral']=$param['point_rate_integral']; $param['point_rate']=json_encode($point_rate); unset($param['point_rate_money']); unset($param['point_rate_integral']); $param['quan_rate']=json_encode($param['quanlist']); unset($param['quanlist']); //自动评价 upload_ylp_log('A03购物流程/确认提交'); } if ($inc_type == 'sms') { $sms_send_type = array( 'type' => (int)$param['type'], 'time_out' => (int)$param['time_out'], 'is_verifycode' => (int)$param['is_verifycode'], ); $param['sms_send_type'] = json_encode($sms_send_type); unset($param['type']); unset($param['time_out']); upload_ylp_log('A04短信设置/确认提交'); } if ($inc_type == 'water') { upload_ylp_log('A05水印设置/确认提交'); } if ($inc_type == 'distribut') { upload_ylp_log('A06分销设置/确认提交'); } if ($inc_type == 'cardsetup') { $fir_yaoqing_no = $param['fir_yaoqing_no']; if ($fir_yaoqing_no) { $rss = M("users")->where('mobile', $fir_yaoqing_no)->where('store_id', getAdmStoId()) ->field('user_id,erpvipid,store_id') ->find(); if (empty($rss)) $this->error("初始邀请人必须是线上会员", U('System/index', array('inc_type' => $inc_type))); //---读取等级卡项目--- $tk = tpCache('shop_info', $rss['store_id']); $sto_erpid = $tk['ERPId']; // $rs=getApiData("wxd.mem.bershipcard.list.get",$tk['api_token'],null,null,null,null,'CardCode desc');//等级卡项 //$api = "/api/erp/vip/mem/card/renew"; $api = "/api/erp/vip/mem/bership/list"; $rs = getApiData_java_p($api, $sto_erpid, null, 1, 10, null, "GET"); $arrlist = json_decode($rs, true)['data']; if ($arrlist) { $v = $arrlist[0]; $v['CardFee'] = number_format($v['CardFee'], 2, ".", ""); $arrlist = $v; } else { $this->error("商家未设置等级卡项目", U('System/index', array('inc_type' => $inc_type))); } mlog('等级卡,会员id::' . $rss['user_id'], 'recharge/' . $rss['store_id']); $vipid = $rss['erpvipid']; $data1 = array( 'VIPId' => $vipid,//会员ID 'CardId' => $arrlist['CardId'],//等级卡ID 'CardFee' => $arrlist['CardFee'],//等级卡金额 'PayTypeId' => '初始邀请人', 'PayNo' => $tk['ERPId'] . "0001",// ); $data1['Recommon'] = "";//邀请码 $data1['ServiceMan'] = "";//营业员 // $mrs=getApiData("wxd.mem.registration.card.add",$tk['api_token'],$data1); $api = "/api/erp/vip/mem/card/register"; $mrs = getApiData_java_p($api, $sto_erpid, $data1, 1, 10, null, "POST"); mlog('购买:' . json_encode($data1, true) . ' 返回值:' . $mrs, 'recharge_1/' . getAdmStoId()); $mrs = json_decode($mrs, true); //计算有效期 $yxq = strtotime("+" . $arrlist['ExpiryDate'] . " day"); $updateuser['card_expiredate'] = date('Y-m-d H:i:s', $yxq); $updateuser['card_field'] = strtolower($arrlist["Newcorrprice"]); M('users')->where('user_id', $rss['user_id'])->save($updateuser);//更新会员信息表 } $switch = tpCache('shopping.switch_list', getAdmStoId());//获取开关json $switch_list = json_decode($switch, true);//获取开关列表 //$switch_list['rank_switch'] = 2;//$param['rank_switch']; $switch_list['rank_switch'] = $param['rank_switch'] == null ? 0 : $param['rank_switch']; $switch_list['isyaoqingma'] = $param['isyaoqingma'] == null ? 0 : $param['isyaoqingma']; $switch_list['is_staffno'] = $param['is_staffno'] == null ? 0 : $param['is_staffno']; //$switch_list['rank_close'] = $param['rank_close']; unset($param['is_rank']); unset($param['isyaoqingma']); unset($param['is_staffno']); unset($param['rank_close']); $param['switch_list'] = json_encode($switch_list); } //unset($param['__hash__']); unset($param['inc_type']); $arr1 = tpCache($inc_type, getAdmStoId(), $param); ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); // upload_ylp_log('保存商城信息'); if ($arr1 == null) { $this->success("操作成功", U('System/index', array('inc_type' => $inc_type))); exit; } else { if ($arr1['code'] == false) { $this->error($arr1['str'], U('System/index', array('inc_type' => $inc_type))); } $this->success("操作成功", U('System/index', array('inc_type' => $inc_type))); exit; } } /** * 自定义导航 */ public function navigationList() { $model = M("Navigation"); $navigationList = $model->order("id desc")->select(); $this->assign('navigationList', $navigationList); return $this->fetch('navigationList', getAdmStoId()); } /** * 添加修改编辑 前台导航 */ public function addEditNav() { $model = D("Navigation"); if (IS_POST) { if (I('id')) { // upload_ylp_log('编辑前台导航'); $model->update(I('post.')); } else { // upload_ylp_log('添加前台导航'); $model->add(I('post.')); } $this->success("操作成功!!!", U('Admin/System/navigationList')); exit; } // 点击过来编辑时 $id = I('id', 0); $navigation = DB::name('navigation')->where('id', $id)->find(); // 系统菜单 $GoodsLogic = new GoodsLogic(); $cat_list = $GoodsLogic->goods_cat_list(); $select_option = array(); foreach ($cat_list AS $key => $value) { $strpad_count = $value['level'] * 4; $select_val = U("/Home/Goods/goodsList", array('id' => $key)); $select_option[$select_val] = str_pad('', $strpad_count, "-", STR_PAD_LEFT) . $value['name']; } $system_nav = array( 'http://www.tp-shop.cn' => 'tpshop官网', 'http://www.99soubao.com' => '搜豹公司', '/index.php?m=Home&c=Index&a=promoteList' => '限时抢购', '/index.php?m=Home&c=Activity&a=group_list' => '团购', '/index.php?m=Home&c=Goods&a=integralMall' => '积分商城', ); $system_nav = array_merge($system_nav, $select_option); $this->assign('system_nav', $system_nav); $this->assign('navigation', $navigation); return $this->fetch('_navigation', getAdmStoId()); } /** * 删除前台 自定义 导航 */ public function delNav() { // 删除导航 M('Navigation')->where("id", I('id'))->delete(); // upload_ylp_log('删除前台导航'); $this->success("操作成功!!!", U('Admin/System/navigationList')); } public function refreshMenu() { $pmenu = $arr = array(); $rs = M('system_module')->where('level>1 AND visible=1')->order('mod_id ASC')->select(); foreach ($rs as $row) { if ($row['level'] == 2) { $pmenu[$row['mod_id']] = $row['title'];//父菜单 } } foreach ($rs as $val) { if ($row['level'] == 2) { $arr[$val['mod_id']] = $val['title']; } if ($row['level'] == 3) { $arr[$val['mod_id']] = $pmenu[$val['parent_id']] . '/' . $val['title']; } } return $arr; } /** * 清空系统缓存 */ public function cleanCache() { if (IS_POST) { // in_array('cache',$_POST['clear']) && delFile('./Application/Runtime/Cache');// 模板缓存 // in_array('data',$_POST['clear']) && delFile('./Application/Runtime/Data');// 项目数据 // in_array('logs',$_POST['clear']) && delFile('./Application/Runtime/Logs');// logs日志 // in_array('temp',$_POST['clear']) && delFile('./Application/Runtime/Temp');// 临时数据 // in_array('cacheAll',$_POST['clear']) && delFile('./Application/Runtime');// 清除所有 // //in_array('goods_thumb',$_POST['clear']) && delFile('./public/upload/goods/thumb'); // 删除缩略图 // // // 删除静态文件 // $html_arr = glob("./Application/Runtime/Html/*.html"); // foreach ($html_arr as $key => $val) // { // // in_array('index',$_POST['clear']) && strstr($val,'Home_Index_index.html') && unlink($val); // 首页 // in_array('goodsList',$_POST['clear']) && strstr($val,'Home_Goods_goodsList') && unlink($val); // 列表页 // in_array('channel',$_POST['clear']) && strstr($val,'Home_Channel_index') && unlink($val); // 频道页 // // in_array('articleList',$_POST['clear']) && strstr($val,'Index_Article_articleList') && unlink($val); // 文章列表页 // in_array('detail',$_POST['clear']) && strstr($val,'Index_Article_detail') && unlink($val); // 文章详情 // in_array('articleList',$_POST['clear']) && strstr($val,'Doc_Index_index_') && unlink($val); // 文章列表页 // in_array('detail',$_POST['clear']) && strstr($val,'Doc_Index_article_') && unlink($val); // 文章详情 // // // 详情页 // if(in_array('goodsInfo',$_POST['clear'])) // { // if(strstr($val,'Home_Goods_goodsInfo') || strstr($val,'Home_Goods_ajaxComment') || strstr($val,'Home_Goods_ajax_consult')) // unlink($val); // } // } // $this->error("操作完成!!!"); // exit; } //delFile(RUNTIME_PATH); ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); upload_ylp_log('A10清除缓存/确认提交'); $this->success("操作完成!!!", U("admin/index/welcome")); exit(); return $this->fetch('', getAdmStoId()); } /** * 清空静态商品页面缓存 */ public function ClearGoodsHtml() { $goods_id = I('goods_id'); // upload_ylp_log('清空静态商品页面缓存'); if (unlink("./Application/Runtime/Html/Home_Goods_goodsInfo_{$goods_id}.html")) { // 删除静态文件 $html_arr = glob("./Application/Runtime/Html/Home_Goods*.html"); foreach ($html_arr as $key => $val) { strstr($val, "Home_Goods_ajax_consult_{$goods_id}") && unlink($val); // 商品咨询缓存 strstr($val, "Home_Goods_ajaxComment_{$goods_id}") && unlink($val); // 商品评论缓存 } $json_arr = array('status' => 1, 'msg' => '清除成功', 'result' => ''); } else { $json_arr = array('status' => -1, 'msg' => '未能清除缓存', 'result' => ''); } $json_str = json_encode($json_arr); exit($json_str); } /** * 商品静态页面缓存清理 */ public function ClearGoodsThumb() { // upload_ylp_log('商品静态页面缓存清理'); $goods_id = I('goods_id'); delFile(UPLOAD_PATH . "goods/thumb/" . $goods_id); // 删除缩略图 $json_arr = array('status' => 1, 'msg' => '清除成功,请清除对应的静态页面', 'result' => ''); $json_str = json_encode($json_arr); exit($json_str); } /** * 清空 文章静态页面缓存 */ public function ClearAritcleHtml() { // upload_ylp_log('清空文章静态页面缓存'); $article_id = I('article_id'); unlink("./Application/Runtime/Html/Index_Article_detail_{$article_id}.html"); // 清除文章静态缓存 unlink("./Application/Runtime/Html/Doc_Index_article_{$article_id}_api.html"); // 清除文章静态缓存 unlink("./Application/Runtime/Html/Doc_Index_article_{$article_id}_phper.html"); // 清除文章静态缓存 unlink("./Application/Runtime/Html/Doc_Index_article_{$article_id}_android.html"); // 清除文章静态缓存 unlink("./Application/Runtime/Html/Doc_Index_article_{$article_id}_ios.html"); // 清除文章静态缓存 $json_arr = array('status' => 1, 'msg' => '操作完成', 'result' => ''); $json_str = json_encode($json_arr); exit($json_str); } //发送测试邮件 public function send_email() { $param = I('post.'); // upload_ylp_log('发送测试邮件'); tpCache($param['inc_type'], $param); if (send_email($param['test_eamil'], '后台测试', '测试发送验证码:' . mt_rand(1000, 9999))) { exit(json_encode(1)); } else { exit(json_encode(0)); } } /** * 管理员登录后 处理相关操作 */ public function login_task() { $getstoid = getAdmStoId(); /*** 随机清空购物车的垃圾数据*/ $time = time() - 3600; // 删除购物车数据 1小时以前的 M("Cart")->where(" store_id=" . $getstoid . " and user_id = 0 and add_time < $time")->delete(); $today_time = time(); // // 发货后满多少天自动收货确认 // $auto_confirm_date = tpCache('shopping.auto_confirm_date', $getstoid); // $auto_confirm_date = $auto_confirm_date * (60 * 60 * 24); // 7天的时间戳 // $order_id_arr = M('order')->where("store_id=" . $getstoid . " and order_status = 1 and shipping_status = 1 and ($today_time - shipping_time) > $auto_confirm_date")->getField('order_id', true); // foreach ($order_id_arr as $k => $v) { // confirm_order($v); // } // // // 多少天后自动分销记录自动分成 // $switch = tpCache('distribut.switch', $getstoid); // if ($switch == 1 && file_exists(APP_PATH . 'common/logic/DistributLogic.php')) { // $distributLogic = new \app\common\logic\DistributLogic(); // $distributLogic->auto_confirm($getstoid); // 自动确认分成 // } // // //清除不是当天未付款的订单 // //清除不是当天未付款的订单 // $delTempOrder1 = M('order') // ->where('pay_status=0 and order_status=0 and is_zsorder=0') // ->where(" store_id=" . $getstoid . " and from_unixtime(add_time)field("user_id,user_money,coupon_no,store_id,order_id,is_zsorder,pt_prom_id,pt_listno,is_pt_tz,gift_receive_id") // ->select(); // $delTempOrder2 = M('order') // ->where('pt_status=0 and order_status=0 and is_zsorder>1') // ->where(" store_id=" . $getstoid . " and from_unixtime(add_time)field("user_id,user_money,coupon_no,store_id,order_id,is_zsorder,pt_prom_id,pt_listno,is_pt_tz,gift_receive_id") // ->select(); // // $delTempOrder=array_merge($delTempOrder1,$delTempOrder2); // // foreach ($delTempOrder as $k => $v) { // $ur= M('order')->where(array('order_id' => $v['order_id'])) // ->where('order_status<>3') // ->save(['order_status' => 3]); // if($ur) { // $user_id = $v['user_id']; // // mlog($v['order_id'],"temporder"); // // M('ordr_goods')->where(' order_id=') // if ($v['user_money'] > 0) { // //解冻余额 // $rs = M('Users')->where("user_id", $v['user_id']) // ->where('frozen_money>=' . $v['user_money'])->find(); // if ($rs) // M('Users')->where("user_id", $v['user_id'])->setDec('frozen_money', $v['user_money']); // } // // /*---优惠券冻结---*/ // $quanno = $v['coupon_no']; // if (!empty($quanno)) { // $dada = ['CashRepNo' => $quanno, 'user_id' => $user_id]; // //冻结优惠券 // M('frozen_quan')->where($dada)->delete(); // } // // // //$redis = new \Redis(); // //$redis->connect(redisip, 6379); // $redis=get_redis_handle(); // // $stoid= $v['store_id']; // $hh = M('order_goods')->where('order_id', $v['order_id']) // ->where('prom_type',1)->where('store_id',$stoid) // ->field('order_id,goods_num,prom_id,order_sn,rec_id')->select(); // if($hh) { // $odarr0 = get_arr_column($hh, 'order_id'); // //增加队列 // foreach ($hh as $kk => $vv) { // //$name0 ='ms'.$vv['prom_id'] . '-' . $stoid; // $name0=get_redis_name($vv['prom_id'],1,$stoid); // // //不重复退回redis // if(!doublefind($redis,$name0,$vv['rec_id'])) { // for ($i = 0; $i < $vv['goods_num']; $i++) { // $redis->lPush($name0, $vv['rec_id'] . '_' . $i); // } // $jsda['num'] = $vv['goods_num']; // $jsda['order_sn'] = $vv['order_sn']; // $jsda['type'] = 1; //1是5分钟自动补回 // mlog(json_encode($jsda), 'flash_log/' . $stoid . '/' . $vv['prom_id']); // } // } // } // // $hh2 = M('order_goods')->where('order_id', $v['order_id']) // ->where('prom_type',2)->where('store_id',$stoid) // ->field('order_id,goods_num,prom_id,order_sn,rec_id')->select(); // if($hh2){ // $odarr0 = get_arr_column($hh, 'order_id'); // //增加队列 // foreach ($hh2 as $k => $v) { // //$name_g ='grb'.$v['prom_id'] . '-' . $stoid; // $name_g = get_redis_name($v['prom_id'],2 ,$stoid); // // //不重复退回redis // if(!doublefind($redis,$name_g,"2".$v['rec_id'])) { // for ($i = 0; $i < $v['goods_num']; $i++) { // $redis->lPush($name_g, "2".$v['rec_id'] . '_' . $i); // } // // $jsda['num'] = $v['goods_num']; // $jsda['order_sn'] = $v['order_sn']; // $jsda['type'] = 1; //1是5分钟自动补回 // mlog(json_encode($jsda), 'group_buy_log/' . $stoid . '/' . $v['prom_id']); // } // } // } // // if ($v['is_zsorder'] == 3) { // //$name2 = 'pind' . $v['pt_prom_id'] . '-' . $v['pt_listno'] . $stoid; // $name2=get_redis_name($v['pt_prom_id'],6,$stoid); // // if (!doublefind($redis, $name2, $v['order_id'])) { // $redis->lPush($name2, $v['order_id'] . '_0'); // } // //$len = $redis->lLen($name2); // //如果这个团,全部补回,那这个单就没有意思了,要delete掉 // //$teamnum = M('teamlist')->field('ct_num') // // ->where('id', $v['pt_prom_id'])->find(); // // //当取消的单是本人开的团,那么这个团要取消掉 // if ($v['is_pt_tz']==1) { // //$redis->delete($name2); // del_redis($redis,$name2); // //要取消这个团 // $da['state'] = 1; // $map['team_id'] = $v['pt_prom_id']; // $map['listno'] = $v['pt_listno']; // $map['store_id'] = $stoid; // // mlog("取消订单:".$v['pt_listno'].'-'.$v['order_id'],"login_task/".$stoid); // M('teamgroup')->where($map)->save($da); // } // } // // //补回购买的数量 // $hh = M('order_goods')->where('order_id', $v['order_id']) // ->where('prom_type',6)->where('store_id',$stoid) // ->field('order_id,goods_num,prom_id,rec_id')->select(); // if($hh) { // //增加队列 // foreach ($hh as $kq => $vq) { // //$name0 ='pind'.$vq['prom_id'] . '-' . $stoid; // $name0 =get_redis_name($vq['prom_id'] ,6,$stoid); // if(!doublefind($redis,$name0,$vq['rec_id'])) { // for ($i = 0; $i < $vq['goods_num']; $i++) { // $redis->lPush($name0, $vq['rec_id'] . "_" . $i); // // $jsdaa['num'] = $vq['goods_num']; // $jsdaa['order_sn'] = $vq['order_sn']; // $jsdaa['type'] = 1; //1是5分钟自动补回 // mlog(json_encode($jsdaa), 'pt_log/' . $stoid . '/' . $vq['prom_id']."_6"); // } // } // } // } // // if (!empty($v['gift_receive_id'])) { // //M('gift_receive')->where(['id' => ['in', $order['gift_receive_id']]])->delete();//去掉赠品领用记录 // $org=M("order_goods")->where('order_id',$v['order_id']) // ->where('is_gift',1)->where('store_id',$stoid) // ->field('rec_id,gift_id,goods_num,prom_id')->select(); // // if($org){ // foreach($org as $ko=>$vo){ // //从表上删除记录,主表做标记,赠品被取消,同时补回活动的库存 // //M('order_goods')->where('rec_id',$vo['rec_id'])->delete(); // M("order")->where('order_id',$v['order_id'])->where('store_id',$stoid) // ->save(['is_del_gift'=>1]); // M("gift")->where('store_id',$stoid) // ->where('id',$vo['gift_id']) // ->setInc('goods_num',$vo['goods_num']); // M('gift_receive')->where(["orderGoods_id"=>$vo['rec_id'],'user_id'=>$v['user_id']])->delete(); // } // // } // } // } // } //访问计时任务 //httpRequest(curHostURL().'/index.php/timer/index/timeset/stoid/'.$getstoid); //httpRequest(curHostURL().'/index.php/timer/index/time_minutes/stoid/'.$getstoid); } function ajax_get_action() { $control = I('controller'); $advContrl = get_class_methods("app\\admin\\controller\\" . str_replace('.php', '', $control)); //dump($advContrl); $baseContrl = get_class_methods('app\admin\controller\Base'); $diffArray = array_diff($advContrl, $baseContrl); $html = ''; foreach ($diffArray as $val) { $html .= ""; } exit($html); } function right_list() { $group = array('system' => '系统设置', 'content' => '内容管理', 'goods' => '商品中心', 'member' => '会员中心', 'order' => '订单中心', 'marketing' => '营销推广', 'tools' => '插件工具', 'count' => '统计报表' ); $right_list = M('system_menu')->select(); $this->assign('right_list', $right_list); $this->assign('group', $group); return $this->fetch('', getAdmStoId()); } public function edit_right() { if (IS_POST) { $data = I('post.'); $data['right'] = implode(',', $data['right']); if (!empty($data['id'])) { // upload_ylp_log('修改权限'); M('system_menu')->where(array('id' => $data['id']))->save($data); } else { if (M('system_menu')->where(array('name' => $data['name']))->count() > 0) { $this->error('该权限名称已添加,请检查', U('System/right_list')); } unset($data['id']); // upload_ylp_log('新增权限'); M('system_menu')->add($data); } $this->success('操作成功', U('System/right_list')); exit; } $id = I('id'); if ($id) { $info = M('system_menu')->where(array('id' => $id))->find(); $info['right'] = explode(',', $info['right']); $this->assign('info', $info); } $group = array('system' => '系统设置', 'content' => '内容管理', 'goods' => '商品中心', 'member' => '会员中心', 'order' => '订单中心', 'marketing' => '营销推广', 'tools' => '插件工具', 'count' => '统计报表' ); $planPath = APP_PATH . 'Admin/Controller'; $planList = array(); $dirRes = opendir($planPath); while ($dir = readdir($dirRes)) { if (!in_array($dir, array('.', '..', '.svn'))) { $planList[] = basename($dir, '.class.php'); } } $this->assign('planList', $planList); $this->assign('group', $group); return $this->fetch('', getAdmStoId()); } public function right_del() { $id = I('del_id'); if (is_array($id)) { $id = implode(',', $id); } if (!empty($id)) { // upload_ylp_log('删除权限'); $r = M('system_menu')->where("id in ($id)")->delete(); if ($r) { respose(1); } else { respose('删除失败'); } } else { respose('参数有误'); } } private function initEditor() { $this->assign("URL_upload", U('Admin/Ueditor/imageUp', array('savepath' => 'wechat'))); $this->assign("URL_fileUp", U('Admin/Ueditor/fileUp', array('savepath' => 'wechat'))); $this->assign("URL_scrawlUp", U('Admin/Ueditor/scrawlUp', array('savepath' => 'wechat'))); $this->assign("URL_getRemoteImage", U('Admin/Ueditor/getRemoteImage', array('savepath' => 'wechat'))); $this->assign("URL_imageManager", U('Admin/Ueditor/imageManager', array('savepath' => 'wechat'))); $this->assign("URL_imageUp", U('Admin/Ueditor/imageUp', array('savepath' => 'wechat'))); $this->assign("URL_getMovie", U('Admin/Ueditor/getMovie', array('savepath' => 'wechat'))); $this->assign("URL_Home", ""); } /*--设置分销商注册邀请奖励--*/ public function setjiangli() { $is_ajax = I('is_ajax'); $data = I('post.'); /* {"first_money":5,"second_money":3,"third_money":1} */ if ($is_ajax == 1) { ClearALLCache(); delFile(TEMP_PATH . "/" . getAdmStoId()); $jdata['first_money'] = $data['first_money']; $jdata['second_money'] = $data['second_money']; $jdata['third_money'] = $data['third_money']; $da = ['is_invitation_rate' => $data['is_invitation_rate'], 'invitation_ratelist' => json_encode($jdata)]; $rs0 = M('store_distribut')->where("store_id", getAdmStoId())->field('Id')->find(); $rs=null; if($rs0){ $rs = M('store_distribut')->where("store_id", getAdmStoId())->save($da); }else{ $da["store_id"]=getAdmStoId(); $rs = M('store_distribut')->save($da); } if ($rs !== false) { $newData = M('store_distribut')->where("store_id", getAdmStoId())->find(); F("distribut" . "_" . getAdmStoId(), $newData, TEMP_PATH); return json(['code' => 1, 'msg' => '设置成功']); } else { return json(['code' => -1, 'msg' => '设置值未改变或失败']); } } /*--dis--*/ $dis = tpCache('distribut', getAdmStoId()); $json = json_decode($dis['invitation_ratelist'], true); $config = []; if ($json) { $config = $json; }else{ $dis['is_invitation_rate']=1; } $this->assign("distribut", $dis); $this->assign("config", $config); return $this->fetch('', getAdmStoId()); } //选择商品 public function search_goods() { $GoodsLogic = new GoodsLogic; $brandList = $GoodsLogic->getSortBrands(); $this->assign('brandList', $brandList); $categoryList = $GoodsLogic->getSortCategory(); $this->assign('categoryList', $categoryList); $goods_id = I('goods_id'); $price = I('price'); $t=time(); $where = "is_on_sale = 1 and store_count>0 and on_time<".$t." and (down_time>".$t." or down_time=0 or down_time='' or down_time is null)"; if (!empty($goods_id)) { $where .= " and goods_id not in ($goods_id) "; } if (!empty($price)) { $where .= " and market_price >= " . $price; } I('intro') && $where = "$where and " . I('intro') . " = 1"; if (I('cat_id')) { $this->assign('cat_id', I('cat_id')); $grandson_ids = getCatGrandson(I('cat_id')); $where = " $where and cat_id in(" . implode(',', $grandson_ids) . ") "; // 初始化搜索条件 } if (I('brand_id')) { $this->assign('brand_id', I('brand_id')); $where = "$where and brand_id = " . I('brand_id'); } if (!empty($_REQUEST['keywords'])) { $kw = I('keywords'); $kword = urldecode(urldecode($kw)); $this->assign('keywords', $kword); $where = "$where and (goods_sn like '%" . $kword . "%' or goods_name like '%" . $kword . "%' or keywords like '%" . $kword . "%' or sku = '" . $kw . "')"; } $getAdmStoId = getAdmStoId(); $where .= " and store_id=" . $getAdmStoId; $count = M('goods')->where($where)->count(); $Page = new Page($count, 10); $goodsList = M('goods')->where($where)->order('goods_id DESC')->limit($Page->firstRow . ',' . $Page->listRows)->select(); $show = $Page->show();//分页显示输出 $this->assign('page', $show);//赋值分页输出 $this->assign('goodsList', $goodsList); $this->assign('pager', $Page);//赋值分页输出 $tpl = I('get.tpl', 'select_goods'); // upload_ylp_log('搜索商品'); return $this->fetch($tpl, getAdmStoId()); } public function not_distribut(){ $is_out=I('out'); $this -> assign('is_out',$is_out); $ucount=M('users')->where("store_id",getAdmStoId())->where('is_distribut',1)->count(); $this->assign('ucount',$ucount); $yy=M("storage_recharge")->where("store_id",getAdmStoId())->where('recharge_state',1) ->where("distri_price_id>0")->field('distri_price_id')->select(); $aarr = M("distri_price")->order('type desc,money desc')->select(); $barr = null; if($yy) { /*--- $idarr = get_arr_column($yy, 'distri_price_id'); $aarr0 = M("distri_price")->order('type desc,money desc')->where('id', 'in', $idarr)->find(); foreach ($aarr as $k => $v) { if($v['id']!=$aarr0['id']){ $barr[]=$v; }else{ break; } }---*/ foreach ($aarr as $k => $v) { if($v['user_num']>$ucount && $v['type']==0){ if($v['money']<=0) break; else{} $barr[]=$v; }else{ if($v['type']==1) $barr[]=$v; else break; } } }else{ $barr=$aarr; } if($barr){ $this -> assign('price_arr',array_reverse($barr)); } return $this->fetch("", getAdmStoId()); } //更新等级卡信息 public function updateCardInfo() { $getcardid = I('cardid'); $getcardimg = I('cardimg'); $getcardcolor = I('cardcolor'); if (empty($getcardid) || empty($getcardimg) || empty($getcardcolor)) { return json(['code' => -1, 'msg' => '参数不能为空']); } $accdb = tpCache("shop_info.ERPId", getAdmStoId()); $wdata['CardId'] = $getcardid; $wdata['CardColor'] = $getcardcolor; $wdata['CardImg'] = $getcardimg; $rs = getApiData_java_p('/api/erp/vip/mem/bership/update', $accdb, $wdata, 1, 10, null, "PUT"); return json_decode($rs, true); } //plus会员推荐码 public function plusqrcode() { $pagenum = 20;//每页显示多少条 if ((int)I('pagenum/s') > 0) { $pagenum = I('pagenum/s'); } $p = I('p', 1); $keyword = I('keyword');//手机号码 $where = " a.StoreId=" . getAdmStoId(); if ($keyword) { $where .= " and (a.StaffNo like '%$keyword%' or a.StaffMobile like '%$keyword%')"; } $qdrecord = M('plus_qrcode'); $count = $qdrecord->alias('a') ->where($where)->count(); $Page = $pager = new Page($count, $pagenum);// 实例化分页类 传入总记录数和每页显示的记录数 $res = $qdrecord->alias('a') ->where($where) ->limit($Page->firstRow . ',' . $Page->listRows) ->order('a.AddTime desc') ->select();// 查询满足要求的总记录数 $show = $Page->show(); $this->assign('page', $show); $this->assign('pager', $pager); $this->assign('total', $count); $this->assign('info', $res); $this->assign('urlhttp', curHostURL()); $this->assign('getadmstoid', getAdmStoId()); return $this->fetch('', getAdmStoId()); } //创建plus会员推荐码 public function create_plusqrcode() { $qrcodeno = I('qrcodeno'); if (empty($qrcodeno)) { return json(['code' => -1, 'msg' => '营业员编号不能为空']); } $getadmstoid = getAdmStoId(); $qrcodeinfo = M('plus_qrcode')->where(array("StoreId"=>$getadmstoid,'StaffNo'=>$qrcodeno))->find(); if ($qrcodeinfo) { return json(['code' => -1, 'msg' => '生成失败,该营业员已存在!']); } $accdb = tpCache("shop_info.ERPId", $getadmstoid); $wdata['KeyWord'] = $qrcodeno; $rs = getApiData_java_p('/api/erp/vip/mem/referee/staff/check', $accdb, $wdata, 1, 10, null, "POST"); if (empty($rs)) { return json(['code' => -1, 'msg' => '生成失败,不是营业员!']); } $rs = json_decode($rs, true); if ($rs['code']!=0) { return json(['code' => -1, 'msg' => $rs['msg']]); } $getstaffname = $rs['data']['pageData'][0]['StaffName']; $getstaffmobile = $rs['data']['pageData'][0]['Tel']; $userinfo = M('users')->where(array('store_id' => $getadmstoid, 'mobile' => $getstaffmobile,'erpvipid'=>array('neq','')))->find(); if (empty($userinfo)) { return json(['code' => -1, 'msg' => '生成失败,该营业员绑定手机未注册!']); } $wdata1['VIPId'] = urlencode($userinfo['erpvipid']); $rs = getApiData_java_p('/api/erp/vip/mem/list', $accdb, $wdata1, 1, 10, null, "GET"); if (empty($rs)) { return json(['code' => -1, 'msg' => '生成失败,未获取到plus会员!']); } $rs = json_decode($rs, true); //if ($rs['code']!=0 || empty($rs['GradeCardID'])) if ($rs['code']!=0 || empty($rs['data'][0]['GradeCardID'])) { return json(['code' => -1,'msg' => '生成失败,该手机不是plus会员!']); } $getuserid = $userinfo['user_id']; $adddata['StoreId'] = $getadmstoid; $adddata['StaffNo'] = $qrcodeno; $adddata['StaffName'] = $getstaffname; $adddata['StaffMobile'] = $getstaffmobile; $adddata['AddTime'] = time(); $adddata['UserId'] = $getuserid; $saveinfo = M('plus_qrcode')->add($adddata); if (empty($saveinfo)) { return json(['code' => -1, 'msg' => '生成失败,请重试!']); } return json(['code' => 0, 'msg' => '生成成功!']); } //创建plus会员推荐码 public function delplusqrcode() { $getid = I('id/d', 0); if (empty($getid)) { $this->error('删除失败,参数有误!', U('System/plusqrcode')); exit(); } $info = M('plus_qrcode')->where(array('StoreId' => getAdmStoId(), 'Id' => $getid))->find(); if (empty($info)) { $this->error('删除失败,找不到该信息!', U('System/plusqrcode')); exit(); } if ($info['InvitationNum']) { $this->error('删除失败,该二维码已邀请人数!', U('System/plusqrcode')); exit(); } M('plus_qrcode')->where(array('StoreId' => getAdmStoId(), 'Id' => $getid))->delete(); $this->success("删除成功!!!", U('System/plusqrcode')); exit(); } }