Commit 946b54b8d9207b7895211aadab9fc3285e3cd97f

Authored by pengye
1 parent ab438641

no message

  1 +<?php
  2 +namespace app\admin\controller;
  3 +use think\Db;
  4 +use think\facade\Request;
  5 +class Area extends Common
  6 +{
  7 + /**
  8 + ***代理商管理
  9 + ***
  10 + **/
  11 +
  12 +
  13 + /**
  14 + * 商家list
  15 + */
  16 + public function List(){
  17 + if(Request::isAjax()){
  18 + $data = Request::except('file');
  19 + $key= input('post.key') ? input('post.key') : "";
  20 +
  21 + $keywords= @$key['id'] ? @$key['id'] : '';
  22 +
  23 + $channel = @$key['channel'] ? @$key['channel'] : 1;
  24 + $address = @$key['address'] ? @$key['address'] : '';
  25 +
  26 +
  27 + $limit = '&x='.$data["page"].'&y='.$data["limit"].'&keywords='.$keywords.'&account='.session('username').'&channel='.$channel.'&address='.$address;
  28 +
  29 + //获取运营人员列表
  30 + $list= file_get_contents(ON_LINE.'App.Agent.getSellerList'.$limit);
  31 + $array = json_decode($list,TRUE);
  32 + foreach ($array['data']['data'] as $key => $value) {
  33 + $array['data']['data'][$key]['cdate'] = date("Y-m-d H:i:s",$value['cdate']);
  34 + if($value['status']==1)
  35 + $array['data']['data'][$key]['statusVal'] = "启用";
  36 + else
  37 + $array['data']['data'][$key]['statusVal'] = "停用";
  38 +
  39 + $c_name = array();
  40 + $t_name = array();
  41 + //2019-03-05 增加菜系配置、商家类型配置
  42 + if(is_array($value['cuisine'])){
  43 + foreach ($value['cuisine'] as $k => $v) {
  44 + $c_name[] = $v['name'];
  45 + }
  46 + }
  47 + if(is_array($value['type'])){
  48 + foreach ($value['type'] as $k => $v) {
  49 + $t_name[] = $v['type_name'];
  50 + }
  51 + }
  52 + if(!empty($c_name))
  53 + $array['data']['data'][$key]['cuisine'] = implode(',', $c_name);
  54 + if(!empty($t_name))
  55 + $array['data']['data'][$key]['type'] = implode(',', $t_name);
  56 + }
  57 + return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['data'],'count'=>$array['data']['total'],'rel'=>1];
  58 + }
  59 + $this->assign ( 'title','区域内商户维护');
  60 + return $this->fetch();
  61 + }
  62 +
  63 + public function addagent(){
  64 + $data = Request::except('file');
  65 + if(Request::isAjax()){
  66 + //获取运营人员列表
  67 + $list= file_get_contents(ON_LINE.'App.Agent.addAgent&areaid='.$data['areaid'].'&agent_name='.$data['agent_name'].'&agent_phone='.$data['agent_phone']);
  68 + $array = json_decode($list,TRUE);
  69 + return $result = ['code'=>1,'msg'=>'添加成功!','data'=>$array['data'],'rel'=>1];#'count'=>$array['data'][0]['total']
  70 + }
  71 + $this->assign ( 'title','代理商管理');
  72 + $this->assign('areaid',$data['areaid']);
  73 + return $this->fetch();
  74 + }
  75 +
  76 + /**
  77 + * 商家list
  78 + */
  79 + public function agent(){
  80 + if(Request::isAjax()){
  81 + $data = Request::except('file');
  82 + $key= input('post.key') ? input('post.key') : "";
  83 +
  84 + $limit = '&agent_name='.@$key['id'];
  85 +
  86 + //获取运营人员列表
  87 + $list= file_get_contents(ON_LINE.'App.Agent.GetAgentList'.$limit);
  88 + $array = json_decode($list,TRUE);
  89 + return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data'],'rel'=>1];#'count'=>$array['data'][0]['total']
  90 + }
  91 + $this->assign ( 'title','代理商管理');
  92 + return $this->fetch();
  93 + }
  94 +
  95 + /**
  96 + * 代理商运营list
  97 + */
  98 + public function operate(){
  99 + if(Request::isAjax()){
  100 + $data = Request::except('file');
  101 + //获取运营人员列表
  102 + $list= file_get_contents(ON_LINE.'App.Agent.getAgentOperate&account='.session('username'));
  103 + $array = json_decode($list,TRUE);
  104 + foreach ($array['data'] as $key => $value) {
  105 + $array['data'][$key]['cdate'] = date("Y-m-d H:i:s",$value['cdate']);
  106 +
  107 + }
  108 + return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data'],'rel'=>1];#'count'=>$array['data'][0]['total']
  109 + }
  110 + $this->assign ( 'title','代理商管理');
  111 + return $this->fetch();
  112 + }
  113 +
  114 + /**
  115 + * 禁用运营
  116 + */
  117 + public function setagentoperate(){
  118 + $data = Request::except('file');
  119 + $list= file_get_contents(ON_LINE.'App.Agent.SetAgentOperate&id='.$data['id']);
  120 + $array = json_decode($list,TRUE);
  121 +
  122 + if($array['data']){
  123 + //禁止该账号登录PC站点
  124 + db('admin')->where('username='."'".$data["account"]."'")->update(['is_open'=>0]);
  125 + return $result = ['code'=>1,'msg'=>'操作成功!','data'=>$array['data'],'rel'=>1];
  126 + }else{
  127 + return $result = ['code'=>0,'msg'=>'操作失败!','data'=>$array['data'],'rel'=>1];
  128 + }
  129 + $this->assign ( 'title','代理商管理');
  130 + }
  131 +
  132 + /**
  133 + * 冻结商家
  134 + */
  135 + public function setfrozenseller(){
  136 + $data = Request::except('file');
  137 + $list= file_get_contents(ON_LINE.'App.Agent.FrozenAgent&areaid='.$data['area_id']);
  138 + $array = json_decode($list,TRUE);
  139 + if($array['data']){
  140 + foreach ($array['data'] as $key => $value) {
  141 + //禁止该账号登录PC站点
  142 + db('admin')->where('username='."'".$value."'")->update(['is_open'=>0]);
  143 + }
  144 + return $result = ['code'=>1,'msg'=>'操作成功!','data'=>$array['data'],'rel'=>1];
  145 + }else{
  146 + return $result = ['code'=>0,'msg'=>'操作失败!','data'=>$array['data'],'rel'=>1];
  147 + }
  148 +
  149 + $this->assign ( 'title','代理商管理');
  150 + }
  151 +
  152 + //增加运营管理人员
  153 + public function operateAdd(){
  154 + //缓存60秒 不请求。
  155 + /*$arr = cache('qrcod_url');
  156 + if(!$arr){
  157 + $arr= file_get_contents("http://xt.colorcun.com/WechatApi/WechatApi/CreateOperateQrcode/");
  158 + $arr = json_decode($arr,TRUE);
  159 + cache('qrcod_url',$arr, 50);
  160 + }*/
  161 + $list= file_get_contents(ON_LINE.'App.Agent.GetSellerQrcode&account='.session('username'));
  162 + $array = json_decode($list,TRUE);
  163 + $this->assign('qrcode_path',$array['data']['operate_qrcode']);
  164 + return view();
  165 + }
  166 +
  167 + /**
  168 + * 停用商家
  169 + */
  170 + public function configStop(){
  171 + if(Request::isAjax()){
  172 + $data = Request::except('file');
  173 + $data['status'] = $data['status'] ? 0 : 1;
  174 + $list= file_get_contents(ON_LINE.'App.Seller.SetStopBySeller&sellerid='.$data['sellerid'].'&status='.$data['status']);
  175 + $array = json_decode($list,TRUE);
  176 + if($array['ret']==200){
  177 + $result['code'] = 1;
  178 + $result['msg'] = 'SUCCESS!';
  179 + }else{
  180 + $result['code'] = 0;
  181 + $result['msg'] = '请求错误!';
  182 + }
  183 + return $result;
  184 + }
  185 + return view();
  186 + }
  187 +
  188 + /**
  189 + * 从商家维度统计:订单、短信等情况
  190 + */
  191 + public function getStatistics(){
  192 + if(Request::isAjax()){
  193 + $data = Request::except('file');
  194 + $key= input('post.key') ? input('post.key') : "";
  195 +
  196 + $sid = $data['sid'] ? implode(',', $data['sid']) : '';
  197 + $sellername = $data['key'] ? $data['key'] : '';
  198 +
  199 + $time = $data['time'] ? explode(' - ', $data['time']) : '';
  200 +
  201 + $stime = $time ? strtotime(date($time[0],time())) : '';
  202 + $etime = $time ? strtotime(date($time[1],time())) : '';
  203 +
  204 + $data['time_type'] = $data['time_type'] ? $data['time_type'] : 1;
  205 + $data['channel'] = $data['channel'] ? $data['channel'] : 1;
  206 +
  207 + $parame = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$sellername.'&stime='.@$stime.'&etime='.@$etime.'&channel='.@$data['channel'].'&sid='.$sid.'&time_type='.@$data['time_type'];
  208 +
  209 + //获取运营人员列表
  210 + $list= file_get_contents(ON_LINE.'App.Report.GetReserveData'.$parame);
  211 +
  212 + $array = json_decode($list,TRUE);
  213 +
  214 + $new_array = array();
  215 + foreach ($array['data'] as $key => $value) {
  216 + if(is_array($value)){
  217 + $new_array[$key]['id'] = $value['id'];
  218 + $new_array[$key]['sellername'] = $value['sellername'];
  219 + $new_array[$key]['contacts_total'] = $value['contacts_total'];
  220 + $new_array[$key]['inviting'] = $value['inviting'];
  221 + $new_array[$key]['reserve_count'] = $value['appReserveCount'] .'/'. $value['AndroidReserveCount'].'/'. $value['CReserveCount'];
  222 + $new_array[$key]['reserve_count_sort'] = $value['appReserveCount'] + $value['AndroidReserveCount'] + $value['CReserveCount'];
  223 + $new_array[$key]['sms_send_count'] = $value['appSmsCount'] .'/'. $value['AndroidSmsCount'];
  224 + $new_array[$key]['sms_send_count_sort'] = $value['appSmsCount'] + $value['AndroidSmsCount'];
  225 + $new_array[$key]['table_room_total'] = $value['table_total'] .'/'. $value['room_total'];
  226 + $new_array[$key]['address_component'] = $value['address_component']['province'] && $value['address_component']['city'] ? $value['address_component']['province'] .'-'. $value['address_component']['city'] : '无法获取地区,请检查经纬度是否正确!';
  227 + }
  228 + }
  229 + return $result = [
  230 + 'code'=>0,'msg'=>'获取成功!',
  231 + 'data'=>$new_array,
  232 + 'count'=>$array['data']['total'],
  233 + 'countReserve'=>$array['data']['appReserveCount']+$array['data']['AndroidReserveCount']+$array['data']['CReserveCount'],
  234 + 'countSms'=>$array['data']['appSmsCount']+$array['data']['AndroidSmsCount'],
  235 + 'inviteeCount'=>$array['data']['inviteeCount'],
  236 + 'appReserveCount'=>$array['data']['appReserveCount'],
  237 + 'AndroidReserveCount'=>$array['data']['AndroidReserveCount'],
  238 + 'CReserveCount'=>$array['data']['CReserveCount'],
  239 + 'appSmsCount'=>$array['data']['appSmsCount'],
  240 + 'AndroidSmsCount'=>$array['data']['AndroidSmsCount'],
  241 + 'Contacts'=>$array['data']['Contacts'],
  242 + 'rel'=>1
  243 + ];
  244 + }
  245 + $this->assign ( 'title','预定订单统计');
  246 + return $this->fetch();
  247 + }
  248 +
  249 + /**
  250 + * 从设备(电话机)维度统计:订单、短信等情况
  251 + */
  252 + public function getEquipment(){
  253 + if(Request::isAjax()){
  254 + $data = Request::except('file');
  255 + $key= input('post.key') ? input('post.key') : "";
  256 +
  257 + $sid = $data['sid'] ? implode(',', $data['sid']) : '';
  258 + $sellername = $data['key'] ? $data['key'] : '';
  259 +
  260 + $time = $data['time'] ? explode(' - ', $data['time']) : '';
  261 +
  262 + $stime = $time ? strtotime(date($time[0],time())) : '';
  263 + $etime = $time ? strtotime(date($time[1],time())) : '';
  264 +
  265 + $data['time_type'] = $data['time_type'] ? $data['time_type'] : 1;
  266 + $data['channel'] = $data['channel'] ? $data['channel'] : 1;
  267 +
  268 + $parame = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$sellername.'&stime='.@$stime.'&etime='.@$etime.'&channel='.@$data['channel'].'&sid='.$sid.'&time_type='.@$data['time_type'];
  269 +
  270 + //获取运营人员列表
  271 + $list= file_get_contents(ON_LINE.'App.Report.GetReserveDataBydev'.$parame);
  272 + $array = json_decode($list,TRUE);
  273 + return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
  274 + }
  275 + $this->assign ( 'title','设备维度统计预定订单');
  276 + return $this->fetch();
  277 + }
  278 +
  279 + /**
  280 + * 商家菜系、类型配置
  281 + */
  282 + public function sellerconfig(){
  283 + $data = Request::except('file');
  284 + if(Request::isAjax()){
  285 + $cuisine = !empty($data['cuisine']) ? implode(',', array_keys($data['cuisine'])) : '';
  286 + $type = !empty($data['type']) ? implode(',', array_keys($data['type'])) : '';
  287 + $mode = !empty($data['mode']) ? implode(',', array_keys($data['mode'])) : '';
  288 + $sms_code = !empty($data['sms_code']) ? $data['sms_code'] : '';
  289 + $label = !empty($data['label']) ? implode(',', array_keys($data['label'])) : '';
  290 + $brand = !empty($data['brand']) ? implode(',', array_keys($data['brand'])) : '';
  291 + $label_1_ = !empty($data['label_1_']) ? implode(',', array_keys($data['label_1_'])) : '';
  292 + $label_2_ = !empty($data['label_2_']) ? implode(',', array_keys($data['label_2_'])) : '';
  293 + $label_3_ = !empty($data['label_3_']) ? implode(',', array_keys($data['label_3_'])) : '';
  294 +
  295 + if($sms_code)
  296 + $res_sms_code= file_get_contents(ON_LINE.'App.SendSMS.SetSellerSmsTemplate&sid='.$data['sellerid'].'&sms_id='.$sms_code);
  297 +
  298 + if($cuisine)
  299 + $res_cuisine= file_get_contents(ON_LINE.'App.Seller.SetSellerCuisine&sellerid='.$data['sellerid'].'&cid='.$cuisine);
  300 + //$res_cuisine = json_decode($res_cuisine,TRUE);
  301 + if($type)
  302 + $res_type= file_get_contents(ON_LINE.'App.Seller.SetSellerType&sellerid='.$data['sellerid'].'&typeid='.$type);
  303 + //$res_type = json_decode($res_type,TRUE);
  304 +
  305 + if($mode)
  306 + $res_mode= file_get_contents(ON_LINE.'App.Seller.setSellerMode&sellerid='.$data['sellerid'].'&modeid='.$mode);
  307 + //$res_mode = json_decode($res_mode,TRUE);
  308 + if($label)
  309 + $res_label= file_get_contents(ON_LINE.'App.Seller.setSellerLabel&sid='.$data['sellerid'].'&field='.$label);
  310 +
  311 + if($brand){
  312 + $del=Db::query("DELETE FROM `xt-member-two-LINE`.xt_dc_dz_seller_brand_rel WHERE sid =".$data['sellerid']);
  313 + $add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_brand_rel VALUES(".$data['sellerid'].",".$brand.")");
  314 + }
  315 +
  316 + if($label_1_){
  317 + $del=Db::query("DELETE FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel WHERE sid = ".$data['sellerid']." AND lcid in (SELECT id FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c WHERE pid = 1)");
  318 + $add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_1_.")");
  319 + }
  320 +
  321 + if($label_2_){
  322 + $del=Db::query("DELETE FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel WHERE sid = ".$data['sellerid']." AND lcid in (SELECT id FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c WHERE pid = 2)");
  323 + $add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_2_.")");
  324 + }
  325 +
  326 + if($label_3_){
  327 + $del=Db::query("DELETE FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel WHERE sid = ".$data['sellerid']." AND lcid in (SELECT id FROM `xt-member-two-LINE`.xt_dc_dz_seller_label_c WHERE pid = 3)");
  328 + $add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_3_.")");
  329 + }
  330 +
  331 + if(isset($data['edition'])){
  332 + $up=Db::query("UPDATE `xt-member-two-LINE`.xt_seller set is_online_reserve = ".$data['edition']." where id = ".$data['sellerid']);
  333 + }
  334 +
  335 + if(isset($data['is_tele'])){
  336 + $up=Db::query("UPDATE `xt-member-two-LINE`.xt_seller set is_tele = ".$data['is_tele']." where id = ".$data['sellerid']);
  337 + }
  338 +
  339 +
  340 + $result['code'] = 1;
  341 + $result['msg'] = "配置成功!";
  342 + return $result;
  343 + }
  344 +
  345 + //获取商家已有菜系
  346 + $cuisine_list= file_get_contents(ON_LINE.'App.Seller.getSellerCuisine&sellerid='.$data['id']);
  347 + $cuisine_list = json_decode($cuisine_list,TRUE);
  348 + //获取所有菜系
  349 + $list= file_get_contents(ON_LINE.'App.Reserve.GetCustomerConfig');
  350 + $array = json_decode($list,TRUE);
  351 + //组装数据
  352 + foreach ($cuisine_list['data'] as $key => $value) {
  353 + foreach ($array['data']['cate'] as $k => $v) {
  354 + if($value['cid']==$v['id']){
  355 + $array['data']['cate'][$k]['checked'] = 1;
  356 + }
  357 + }
  358 + }
  359 + $this->assign('list',$array['data']['cate']);//获取所有菜系
  360 +
  361 + //获取商家已有来源
  362 + $type_list= file_get_contents(ON_LINE.'App.Seller.GetSellerType&sellerid='.$data['id']);
  363 + $type_list = json_decode($type_list,TRUE);
  364 + //获取来源
  365 + $channel = array(array('id'=>1,'name'=>'合作'),array('id'=>2,'name'=>'推广'),array('id'=>3,'name'=>'测试'));
  366 + //组装数据
  367 + foreach ($type_list['data'] as $key => $value) {
  368 + foreach ($channel as $k => $v) {
  369 + if($value['type_id']==$v['id']){
  370 + $channel[$k]['checked'] = 1;
  371 + }
  372 + }
  373 + }
  374 + $this->assign('channel',$channel);//获取所有来源
  375 +
  376 + //获取商家已有地图显示方式
  377 + $mode_list= file_get_contents(ON_LINE.'App.Seller.getSellerMode&sellerid='.$data['id']);
  378 + $mode_list = json_decode($mode_list,TRUE);
  379 +
  380 + //获取所有地图显示方式
  381 + $mode= array(array('id'=>1,'name'=>'地图上大图标'),array('id'=>2,'name'=>'地图上文字'));
  382 + //组装数据
  383 + foreach ($mode_list['data'] as $key => $value) {
  384 + foreach ($mode as $k => $v) {
  385 + if($value['sm_id']==$v['id']){
  386 + $mode[$k]['checked'] = 1;
  387 + }
  388 + }
  389 + }
  390 + $this->assign('mode',$mode);//获取所有菜系
  391 +
  392 + //获取商家已选短信模板
  393 + $template = file_get_contents(ON_LINE.'App.Reserve.SellerInfo&seller_id='.$data['id']);
  394 + $template = json_decode($template,TRUE);
  395 + //获取短信模板列表
  396 + $template_list = file_get_contents(ON_LINE.'App.SendSMS.GetSmsTemplate');
  397 + $template_list = json_decode($template_list,TRUE);
  398 +
  399 + //组装数据
  400 + foreach ($template_list['data'] as $key => $value) {
  401 + if($value['template_code']==$template['data']['setting']['template_code']){
  402 + $template_list['data'][$key]['checked'] = 1;
  403 + }
  404 + switch ($value['template_code']) {
  405 + case 'SMS_163050401':
  406 + $vowels = array(
  407 + '周到安排演示店' => '${seller_name}',
  408 + '11月25日晚上18:00' => '${date}',
  409 + '金台夕照、卢沟晓月' =>'${region_room_name}',
  410 + '西电路447号南湖金地西门南100米' =>'${seller_addr}',
  411 + '18792581193' =>'${seller_phone}',
  412 + '毛毛' =>'${cusman}',
  413 + );
  414 + break;
  415 + case 'SMS_162733710':
  416 + $vowels = array(
  417 + '4月6日中午' => '${reserve_date}',
  418 + '周到1店西电路447号金台夕照' => '${seller_name_addr_room}',
  419 + '毛毛' =>'${cusman}',
  420 + );
  421 + break;
  422 + case 'SMS_154587043':
  423 + $vowels = array(
  424 + '侯先生' => '${guest}',
  425 + '周到安排演示店' => '${seller_name}',
  426 + '11月25日晚上18:00' =>'${date}',
  427 + '包间(金台夕照)' =>'${region_room_name}',
  428 + '西电路447号南湖金地西门南100米' =>'${seller_addr}',
  429 + '18792581193' =>'${seller_phone}\n',
  430 + '毛毛' =>'${cusman}',
  431 + );
  432 + break;
  433 + case 'SMS_164277855':
  434 + $vowels = array(
  435 + '周到1店西电路447号' => '${seller_name}',
  436 + '11月7日晚上18:30' => '${date}',
  437 + '包间(金台夕照)' =>'${region_room_name}',
  438 + '1879258119' =>'${seller_phone}',
  439 + );
  440 + break;
  441 + case 'SMS_164268239':
  442 + $vowels = array(
  443 + '周到安排演示店' => '${seller_name}',
  444 + '11月7日晚上18:30' => '${date}',
  445 + '包间(金台夕照)' =>'${region_room_name}',
  446 + '西电路447号南湖金地西门南100米' =>'${seller_addr}',
  447 + '1879258119' =>'${seller_phone}',
  448 + );
  449 + break;
  450 + default:
  451 + # code...
  452 + break;
  453 + }
  454 + $template_list['data'][$key]['content'] = str_replace($vowels, array_keys($vowels),$value['content']);
  455 + }
  456 + $this->assign('template_list',$template_list['data']);//获取短信模板列表
  457 +
  458 + //获取商家拥有哪些标签
  459 + $label_list= file_get_contents(ON_LINE.'App.Seller.GetSellerLabel&sid='.$data['id']);
  460 + $label_list = json_decode($label_list,TRUE);
  461 + $this->assign('label_list',$label_list['data']);
  462 +
  463 + //商家标签
  464 + //原生:
  465 + //$label_c=Db::query("SELECT * from xt-member-two-LINE.xt_dc_dz_seller_label_c");
  466 + $label_c=Db::table("xt-member-two-LINE.xt_dc_dz_seller_label_c")->select();
  467 + $label_c_rel=Db::table("xt-member-two-LINE.xt_dc_dz_seller_label_c_rel")->where(array('sid'=>$data['id']))->select();
  468 + //组装数据
  469 + foreach ($label_c as $key => $value) {
  470 + foreach ($label_c_rel as $k => $v) {
  471 + if($value['id']==$v['lcid']){
  472 + $label_c[$key]['checked'] = 1;
  473 + }
  474 + }
  475 + }
  476 + $this->assign('label_c',$label_c);
  477 +
  478 + //商家品牌
  479 + $brand=Db::table("xt-member-two-LINE.xt_dc_dz_seller_brand")->select();
  480 + $brand_rel=Db::table("xt-member-two-LINE.xt_dc_dz_seller_brand_rel")->where(array('sid'=>$data['id']))->select();
  481 + //组装数据
  482 + foreach ($brand as $key => $value) {
  483 + foreach ($brand_rel as $k => $v) {
  484 + if($value['id']==$v['bid']){
  485 + $brand[$key]['checked'] = 1;
  486 + }
  487 + }
  488 + }
  489 + $this->assign('brand',$brand);
  490 +
  491 +
  492 + $is_online_reserve=Db::table("xt-member-two-LINE.xt_seller")->where(array('id'=>$data['id']))->select();
  493 +
  494 + //获取商家在线预定版本情况
  495 + $this->assign('is_online_reserve',$is_online_reserve[0]['is_online_reserve']);
  496 + //是否安装电话机
  497 + $this->assign('is_tele',$is_online_reserve[0]['is_tele']);
  498 +
  499 + //商户信息
  500 + $this->assign ('data',$data);
  501 + $this->assign ( 'title','商户信息配置' );
  502 + return $this->fetch();
  503 + }
  504 +
  505 + /**
  506 + * 商家基础信息配置
  507 + */
  508 + public function setsellerconfig(){
  509 + if(Request::isAjax()){
  510 + $data = Request::except('file');
  511 + $data['status'] = $data['status'] ? 0 : 1;
  512 + $list= file_get_contents(ON_LINE.'App.Seller.SetSellerConfigByPC&sid='.$data['sellerid'].'&field='.$data['field'].'&value='.$data['value']);
  513 + $array = json_decode($list,TRUE);
  514 + if($array['ret']==200){
  515 + $result['code'] = 1;
  516 + $result['msg'] = 'SUCCESS!';
  517 + }else{
  518 + $result['code'] = 0;
  519 + $result['msg'] = '请求错误!';
  520 + }
  521 + return $result;
  522 + }
  523 + return view();
  524 + }
  525 +
  526 + /**
  527 + * 商家详情
  528 + */
  529 + public function sellerdetail(){
  530 + //print_r(Request::except('file'));die;
  531 + $data = Request::except('file');
  532 + //获取运营人员列表
  533 + $list= file_get_contents(ON_LINE.'App.Seller.GetSellerById&sellerid='.$data['sid']);
  534 + $array = json_decode($list,TRUE);
  535 + if($array['data']['data']){
  536 + $array['data']['data']['daily'] = json_decode($array['data']['data']['daily'],TRUE);
  537 + $array['data']['data']['daily_time'] = json_decode($array['data']['data']['daily_time'],TRUE);
  538 + $array['data']['data']['cdate'] = date("Y年m月d日 H时i分s秒",$array['data']['data']['cdate']);
  539 + }
  540 + //获取短信流水
  541 + $sms= file_get_contents(ON_LINE.'App.SendSMS.GetSellerSmsFlowing&sid='.$data['sid']);
  542 + $sms_data = json_decode($sms,TRUE);
  543 + $sms_data_list = $sms_data['data'] ? $sms_data['data'] : array();
  544 + $this->assign ( 'smslist',$sms_data_list);
  545 + $this->assign ( 'data',$array['data']['data']);
  546 + $this->assign ( 'title','商家详情页面');
  547 + return $this->fetch();
  548 + }
  549 +
  550 + //商家列表 用于配置商家活动
  551 + public function seller_activity_list(){
  552 + if(Request::isAjax()){
  553 + $data = Request::except('file');
  554 + $key= input('post.key') ? input('post.key') : "";
  555 + $channel = @$key['channel'] ? @$key['channel'] : 1;
  556 + $limit = '&x='.$data["page"].'&y='.$data["limit"].'&keywords='.@$key['id'].'&channel='.$channel;
  557 +
  558 + //获取运营人员列表
  559 + $list= file_get_contents(ON_LINE.'App.Seller.GetSellerListByActivity'.$limit);
  560 + $array = json_decode($list,TRUE);
  561 + foreach($array['data'][0]['data'] as $key=>$value){
  562 + if(!empty($value['activity'])){
  563 + foreach ($value['activity'] as $k => $v) {
  564 + $str[$key][] = ($k+1).'、'.$v['title'];
  565 + }
  566 + $array['data'][0]['data'][$key]['activity'] = implode('<br/>', $str[$key]);
  567 + //$array['data'][0]['data'][$key]['activity'] = implode('<br/>', array_column($value['activity'], 'title'));
  568 + }
  569 + }
  570 + return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data'][0]['data'],'count'=>$array['data'][0]['total'],'rel'=>1];
  571 + }
  572 + $this->assign ( 'title','商家活动配置');
  573 + return $this->fetch();
  574 + }
  575 +
  576 + /**
  577 + * 商家活动列表页
  578 + */
  579 + public function seller_activity(){
  580 + $data = Request::except('file');
  581 + //获取商家现有活动
  582 + $seller_activity= file_get_contents(ON_LINE.'App.Seller.GetSellerActivity&sid='.$data['id']);
  583 + $seller_activity = json_decode($seller_activity,TRUE);
  584 + //活动列表
  585 + $this->assign('sid',$data['id']);
  586 + $this->assign ( 'seller_activity',$seller_activity['data']);
  587 + $this->assign ( 'title','商家活动配置页面');
  588 + return $this->fetch();
  589 + }
  590 +
  591 + //添加活动
  592 + public function add_activity(){
  593 + $data = Request::except('file');
  594 + if(Request::isAjax()){
  595 + switch ($data['type']) {
  596 + case '1':
  597 + if($data['max_num']==0){
  598 + $data['title'] = '立减'.$data['min_num'];break;
  599 + }else{
  600 + $data['title'] = '满'.$data['max_num'].'立减'.$data['min_num'];break;
  601 + }
  602 + case '2':
  603 + $data['title'] = '满赠';
  604 + break;
  605 + case '3':
  606 + if($data['max_num']==0){
  607 + $data['title'] = $data['min_num'].'折';break;
  608 + }else{
  609 + $data['title'] = '满'.$data['max_num'].'立享'.$data['min_num'].'折';break;
  610 + }
  611 + case '4':
  612 + $data['title'] = $data['max_num'].'元代金券';
  613 + break;
  614 + case '5':
  615 + $data['title'] = '会员价';
  616 + break;
  617 + default:
  618 + # code...
  619 + break;
  620 + }
  621 + //字段空值过滤
  622 + //添加活动
  623 + $res= file_get_contents(ON_LINE.'App.Seller.SetActivity&str='.serialize($data));
  624 + $res = json_decode($res,TRUE);
  625 + if($data['aid']){
  626 + if($res['data']){
  627 + $result = ['code'=>1,'msg'=>'修改成功!','rel'=>1];
  628 + }else{
  629 + $result = ['code'=>0,'msg'=>'修改失败!','rel'=>1];
  630 + }
  631 + }else{
  632 + if($res['data']){
  633 + $result = ['code'=>1,'msg'=>'添加成功!','rel'=>1];
  634 + }else{
  635 + $result = ['code'=>0,'msg'=>'添加失败!','rel'=>1];
  636 + }
  637 + }
  638 + return $result;
  639 + }
  640 + if($data['id']){
  641 + //修改---需要获取对应的数据
  642 + $activity= file_get_contents(ON_LINE.'App.Seller.GetSellerActivityById&id='.$data['id']);
  643 + $activity = json_decode($activity,TRUE);
  644 + $this->assign ('data',$activity['data']);
  645 + $this->assign ( 'title','修改活动');
  646 + }
  647 + $this->assign ( 'hid',$data['sid']);
  648 + $this->assign ( 'title','添加活动');
  649 + return $this->fetch();
  650 + }
  651 +
  652 + //删除活动
  653 + public function del_activity(){
  654 + $data = Request::except('file');
  655 + $res= file_get_contents(ON_LINE.'App.Seller.DelSellerActivity&sid='.$data['sid'].'&aid='.$data['aid']);
  656 + $res = json_decode($res,TRUE);
  657 + $this->redirect('Seller/seller_activity', ['id' => $data['sid']]);
  658 + //return $this->fetch('seller_activity',['id' => $data['sid']]);
  659 + }
  660 +
  661 + //商家设备列表
  662 + public function device_list(){
  663 + //获取类型
  664 + $facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
  665 + if(Request::isAjax()){
  666 + $data = Request::except('file');
  667 + $channel = @$data['channel'] ? @$data['channel'] : 1;
  668 + $manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;
  669 +
  670 + $limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;
  671 +
  672 + //获取运营人员列表
  673 + $list= file_get_contents(ON_LINE.'App.Device.GetDeviceOnlineStatus'.$limit); //GetSellerDevice
  674 + $array = json_decode($list,TRUE);
  675 + foreach ($array['data']['list'] as $key => $value) {
  676 + switch ($value['type']) {
  677 + case '0':
  678 + $array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
  679 + break;
  680 + case '1':
  681 + $array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
  682 + break;
  683 + case '2':
  684 + $array['data']['list'][$key]['type'] = $facturer[1]['facturer'];
  685 + break;
  686 + case '3':
  687 + $array['data']['list'][$key]['type'] = $facturer[2]['facturer'];
  688 + break;
  689 + case '4':
  690 + $array['data']['list'][$key]['type'] = $facturer[3]['facturer'];
  691 + break;
  692 +
  693 + default:
  694 + $array['data']['list'][$key]['type'] = 'error: '.$value['type'];
  695 + break;
  696 + }
  697 +
  698 + }
  699 + return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
  700 + }
  701 + $this->assign ( 'facturer',$facturer);
  702 + $this->assign ( 'title','商家设备列表');
  703 + return $this->fetch();
  704 + }
  705 +
  706 + //商家设备列表
  707 + public function add_gray_user(){
  708 + if(Request::isAjax()){
  709 + $data = Request::except('file');
  710 + $list= file_get_contents(ON_LINE.'App.Device.SetGrayUser&ids='.serialize($data['id']));
  711 + $array = json_decode($list,TRUE);
  712 + if($array['ret']==200){
  713 + $result['code'] = 1;
  714 + $result['msg'] = 'SUCCESS!';
  715 + }else{
  716 + $result['code'] = 0;
  717 + $result['msg'] = '服务器错误,请勿重复将设备号添加到灰度用户!';
  718 + }
  719 + return $result;
  720 + }
  721 + return view();
  722 + }
  723 +
  724 + //灰度用户列表
  725 + public function gray_user_list(){
  726 + //获取类型
  727 + $facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
  728 + $this->assign ( 'facturer',$facturer);
  729 + if(Request::isAjax()){
  730 + $data = Request::except('file');
  731 + $channel = @$data['channel'] ? @$data['channel'] : 1;
  732 + $manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;
  733 +
  734 + $limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;
  735 +
  736 + $list= file_get_contents(ON_LINE.'App.Device.GetGrayUserList'.$limit);
  737 + $array = json_decode($list,TRUE);
  738 + foreach ($array['data']['list'] as $key => $value) {
  739 + switch ($value['type']) {
  740 + case '1':
  741 + $array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
  742 + break;
  743 + case '2':
  744 + $array['data']['list'][$key]['type'] = $facturer[1]['facturer'];
  745 + break;
  746 + case '3':
  747 + $array['data']['list'][$key]['type'] = $facturer[2]['facturer'];
  748 + break;
  749 + case '4':
  750 + $array['data']['list'][$key]['type'] = $facturer[3]['facturer'];
  751 + break;
  752 +
  753 + default:
  754 + $array['data']['list'][$key]['type'] = 'error';
  755 + break;
  756 + }
  757 + }
  758 + return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
  759 + }
  760 + //获取类型
  761 + $facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
  762 + $this->assign ( 'facturer',$facturer);
  763 + $this->assign ( 'title','灰度用户列表');
  764 + return $this->fetch();
  765 + }
  766 +
  767 + //删除灰度用户
  768 + public function del_gray_user(){
  769 + if(Request::isAjax()){
  770 + $data = Request::except('file');
  771 + $list= file_get_contents(ON_LINE.'App.Device.DelGrayUser&jsstr='.serialize($data['id']));
  772 + $array = json_decode($list,TRUE);
  773 +
  774 + if($array['ret']==200){
  775 + $result['code'] = 1;
  776 + $result['msg'] = 'SUCCESS!';
  777 + }else{
  778 + $result['code'] = 0;
  779 + $result['msg'] = '请刷新页面重新尝试!';
  780 + }
  781 + return $result;
  782 + }
  783 + return view();
  784 + }
  785 +
  786 + //获取在线设备情况
  787 + public function get_device_online_status(){
  788 + //获取类型
  789 + $facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
  790 + if(Request::isAjax()){
  791 + $data = Request::except('file');
  792 + $channel = @$data['channel'] ? @$data['channel'] : 1;
  793 + $manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;
  794 +
  795 + $limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;
  796 +
  797 + $list= file_get_contents(ON_LINE.'App.Device.GetDeviceOnlineStatus'.$limit);
  798 + $array = json_decode($list,TRUE);
  799 + foreach ($array['data']['list'] as $key => $value) {
  800 + switch ($value['type']) {
  801 + case '0':
  802 + $array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
  803 + break;
  804 + case '1':
  805 + $array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
  806 + break;
  807 + case '2':
  808 + $array['data']['list'][$key]['type'] = $facturer[1]['facturer'];
  809 + break;
  810 + case '3':
  811 + $array['data']['list'][$key]['type'] = $facturer[2]['facturer'];
  812 + break;
  813 + case '4':
  814 + $array['data']['list'][$key]['type'] = $facturer[3]['facturer'];
  815 + break;
  816 +
  817 + default:
  818 + $array['data']['list'][$key]['type'] = $value['type'];
  819 + break;
  820 + }
  821 + }
  822 + return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
  823 + }
  824 + $this->assign ( 'facturer',$facturer);
  825 + $this->assign ( 'title','商家话机在线设备列表');
  826 + return $this->fetch();
  827 + }
  828 +
  829 + /**
  830 + * 从商家维度统计:订单、短信等情况
  831 + */
  832 + public function GetReserveList(){
  833 + //获取类型
  834 + $facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
  835 + if(Request::isAjax()){
  836 + $data = Request::except('file');
  837 + $key= input('post.key') ? input('post.key') : "";
  838 + $nokey= input('post.nokey') ? input('post.nokey') : "";
  839 +
  840 + $sellername = $data['key'] ? $data['key'] : ''; //商家名称
  841 + $id = $data['nokey'] ? $data['nokey'] : ''; //订单ID
  842 +
  843 + $time = $data['time'] ? explode(' - ', $data['time']) : '';
  844 +
  845 + $stime = $time ? strtotime(date($time[0],time())) : strtotime(date('Y-m-d 00:00:00',time()));
  846 + $etime = $time ? strtotime(date($time[1],time())) : strtotime(date('Y-m-d 23:59:59',time()));
  847 +
  848 + $dtime = $data['dtime'] ? explode(' - ', $data['dtime']) : '';
  849 +
  850 + $sdtime = $dtime ? strtotime(date($dtime[0],time())) : '';
  851 + $edtime = $dtime ? strtotime(date($dtime[1],time())) : '';
  852 +
  853 + $data['status'] = $data['status'] ? $data['status'] : 2;
  854 + $data['channel'] = $data['channel'] ? $data['channel'] : 1;
  855 +
  856 + $parame = '&offset='.$data["page"].'&limit='.$data["limit"].'&sellername='.@$sellername.'&stime='.@$stime.'&etime='.@$etime.'&channel='.@$data['channel'].'&id='.$id.'&status='.@$data['status'].'&sdtime='.$sdtime.'&edtime='.$edtime;
  857 +
  858 + //获取运营人员列表
  859 + $list= file_get_contents(ON_LINE.'App.Customer.GetReserveList'.$parame);
  860 + $array = json_decode($list,TRUE);
  861 +
  862 + $new_array = array();
  863 + foreach ($array['data']['list'] as $key => $value) {
  864 + //有无设备
  865 + if($value['is_tele']==1){
  866 + switch ($value['type']) {
  867 + case '1':
  868 + $array['data']['list'][$key]['dv'] = $facturer[0]['facturer'];
  869 + break;
  870 + case '2':
  871 + $array['data']['list'][$key]['dv'] = $facturer[1]['facturer'];
  872 + break;
  873 + case '3':
  874 + $array['data']['list'][$key]['dv'] = $facturer[2]['facturer'];
  875 + break;
  876 + case '4':
  877 + $array['data']['list'][$key]['dv'] = $facturer[3]['facturer'];
  878 + break;
  879 + default:
  880 + $array['data']['list'][$key]['dv'] = '无';
  881 + break;
  882 + }
  883 + }else{
  884 + $array['data']['list'][$key]['dv'] = '无';
  885 + }
  886 + //订单接受时间段
  887 + switch ($value['ddate_solt']) {
  888 + //'未设置/早市/午市/晚市/夜宵 0/1/2/3/4',
  889 + case 0:
  890 + $value['ddate_solt'] = '未设置';
  891 + break;
  892 + case 1:
  893 + $value['ddate_solt'] = '早市';
  894 + break;
  895 + case 2:
  896 + $value['ddate_solt'] = '午市';
  897 + break;
  898 + case 3:
  899 + $value['ddate_solt'] = '晚市';
  900 + break;
  901 + case 4:
  902 + $value['ddate_solt'] = '夜宵';
  903 + break;
  904 + default:
  905 + # code...
  906 + break;
  907 + }
  908 + $array['data']['list'][$key]['ddate'] = date('Y-m-d H:i:s',$value['ddate']).'['.$value['ddate_solt'].']';
  909 + $array['data']['list'][$key]['cdate'] = date('Y-m-d H:i:s',$value['cdate']);
  910 + $array['data']['list'][$key]['handle_time'] = $value['handle_time'] ? date('Y-m-d H:i:s',$value['handle_time']) : '';
  911 + $array['data']['list'][$key]['rec_date'] = $value['rec_date'] ? date('Y-m-d H:i:s',$value['rec_date']) : '';
  912 + switch ($value['status']) {
  913 + case 0:
  914 + $array['data']['list'][$key]['sta'] = '待确认';
  915 + break;
  916 + case 1:
  917 + $array['data']['list'][$key]['sta'] = '已定座';
  918 + break;
  919 + case 2:
  920 + $array['data']['list'][$key]['sta'] = '到店';
  921 + break;
  922 + case 3:
  923 + $array['data']['list'][$key]['sta'] = '离店';
  924 + break;
  925 + case 4:
  926 + $array['data']['list'][$key]['sta'] = '已取消';
  927 + break;
  928 + case 5:
  929 + $array['data']['list'][$key]['sta'] = '已分配';
  930 + break;
  931 + case 6:
  932 + $array['data']['list'][$key]['sta'] = '拒单';
  933 + break;
  934 + default:
  935 + # code...
  936 + break;
  937 + }
  938 + switch ($value['sex']) {
  939 + case 1:
  940 + $array['data']['list'][$key]['rname'] = $value['rname'].'先生'.'('.$value['phone'].')';
  941 + break;
  942 + case 2:
  943 + $array['data']['list'][$key]['rname'] = $value['rname'].'女士'.'('.$value['phone'].')';
  944 + break;
  945 + case 3:
  946 + $array['data']['list'][$key]['rname'] = $value['rname'].'公司'.'('.$value['phone'].')';
  947 + break;
  948 + default:
  949 + # code...
  950 + break;
  951 + }
  952 +
  953 + if($value['room_demand']){
  954 + $array['data']['list'][$key]['room_demand'] = implode(',',array_column(json_decode($value['room_demand'],true), 'name'));
  955 + }
  956 +
  957 + $array['data']['list'][$key]['sta'] = $value['is_tele']==1 ? $array['data']['list'][$key]['sta'] : $array['data']['list'][$key]['sta'].'无话机';
  958 +
  959 + //根据操作人识别操作终端
  960 + if(isset($template['operator_openid'])){
  961 + if(strstr($template['operator_openid'],'_',-4)=='tele'){ //话机操作
  962 + $array['data']['list'][$key]['operator_openid'] = '电话机';
  963 + }
  964 +
  965 + if(strstr($template['operator_openid'],'_',-4)=='wind'){ //PC操作
  966 + $array['data']['list'][$key]['operator_openid'] = 'PC';
  967 + }
  968 +
  969 + if(strstr($template['operator_openid'],'_',-4)=='chat'){ //PC操作
  970 + $array['data']['list'][$key]['operator_openid'] = '小程序';
  971 + }
  972 + }
  973 + }
  974 + //print_r($array['data']['list']);die;
  975 + return $result = [
  976 + 'code'=>0,'msg'=>'获取成功!',
  977 + 'data'=>$array['data']['list'],
  978 + 'count'=>$array['data']['total'],
  979 + 'rel'=>1
  980 + ];
  981 + }
  982 + $this->assign ( 'title','C端预定订单管理');
  983 + return $this->fetch();
  984 + }
  985 +
  986 + /**
  987 + * 状态设置
  988 + */
  989 + public function setReserveStatus(){
  990 +
  991 + if(Request::isAjax()){
  992 + $data = Request::except('file');
  993 +
  994 + $data['cause'] = json_encode(array('uid'=>-1,'uname'=>session('username'),'desc'=>$data['cause']));
  995 +
  996 + $list= file_get_contents(ON_LINE.'App.Reserve.SetReserveStatus&rid='.$data['id'].'&status='.$data['status'].'&cause='.$data['cause']);
  997 +
  998 + $array = json_decode($list,TRUE);
  999 + if($array['ret']==200){
  1000 + $result['code'] = 1;
  1001 + $result['msg'] = 'SUCCESS!';
  1002 + }else{
  1003 + $result['code'] = 0;
  1004 + $result['msg'] = '请求错误!';
  1005 + }
  1006 + return $result;
  1007 + }
  1008 + return view();
  1009 + }
  1010 +
  1011 + /**
  1012 + * 代理商及代理商下运营人远列表
  1013 + */
  1014 + public function Operatorlist(){
  1015 + $data = Request::except('file');
  1016 +
  1017 + if(Request::isAjax()){
  1018 +
  1019 + $operator_list = Db::query("SELECT
  1020 + a.areaid,
  1021 + a.areaname,
  1022 + t.`level`,
  1023 + t.sub_openid,
  1024 + t.cdate,
  1025 + w.nickname
  1026 + FROM
  1027 + `xt-member-two-LINE`.xt_dc_dz_agent AS a
  1028 + LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_agent_account AS t ON a.areaid = t.areaid
  1029 + LEFT JOIN `xt-member-two-LINE`.xt_wechat AS w ON t.sub_openid = w.openid
  1030 + WHERE
  1031 + a.is_exist = 1
  1032 + AND w.source = 0
  1033 + ORDER BY
  1034 + a.areaid,t.`level`");
  1035 +
  1036 + foreach ($operator_list as $key => $value) {
  1037 + switch ($value['level']) {
  1038 + case '1':
  1039 + $operator_list[$key]['level'] = '代理商';
  1040 + break;
  1041 + case '2':
  1042 + $operator_list[$key]['level'] = '运营';
  1043 + break;
  1044 + default:
  1045 + # code...
  1046 + break;
  1047 + }
  1048 + $operator_list[$key]['cdate'] = date("Y年m月d日 H时i分",$value['cdate']);
  1049 + }
  1050 + return ['code'=>0,'msg'=>'获取成功!','data'=>$operator_list,'rel'=>1];
  1051 + }
  1052 +
  1053 + return $this->fetch();
  1054 + }
  1055 +}
  1 +{include file="common/head"/}
  2 +<div class="admin-main layui-anim layui-anim-upbit">
  3 + <fieldset class="layui-elem-field layui-field-title">
  4 + <legend>评论管理</legend>
  5 + </fieldset>
  6 + <div class="demoTable">
  7 + <div class="layui-inline">
  8 + <input class="layui-input" name="key" id="key" placeholder="{:lang('pleaseEnter')}关键字">
  9 + </div>
  10 + <button class="layui-btn" id="search" data-type="reload">{:lang('search')}</button>
  11 + <a href="{:url('index')}" class="layui-btn">显示全部</a>
  12 + <a href="{:url('add')}" class="layui-btn" style="float:right;"><i class="fa fa-plus" aria-hidden="true"></i>{:lang('add')}评论</a>
  13 + <div style="clear: both;"></div>
  14 + </div>
  15 + <table class="layui-table" id="list" lay-filter="list"></table>
  16 +</div>
  17 +{include file="common/foot"/}
  18 +<script type="text/html" id="order">
  19 + <input name="{{d.id}}" data-id="{{d.id}}" class="list_order layui-input" value=" {{d.sort}}" size="10"/>
  20 +</script>
  21 +<script type="text/html" id="open">
  22 + <input type="checkbox" name="open" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="open" {{ d.open == 1 ? 'checked' : '' }}>
  23 +</script>
  24 +<script type="text/html" id="action">
  25 + <a href="{:url('edit')}?id={{d.id}}" class="layui-btn layui-btn-xs">编辑</a>
  26 + <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  27 +</script>
  28 +<script>
  29 + layui.use(['table','form'], function() {
  30 + var table = layui.table,form = layui.form,$ = layui.jquery;
  31 + var tableIn = table.render({
  32 + id: 'ad',
  33 + elem: '#list',
  34 + url: '{:url("index")}',
  35 + method: 'post',
  36 + page:true,
  37 + cols: [[
  38 + {field: 'id', title: '{:lang("id")}', width: 80, fixed: true},
  39 + {field: 'title', title: '节日名称', width: 200},
  40 + {field: 'feast_date', align: 'center', title: '日期', width: 200},
  41 + {field: 'type', align: 'center', title: '类型', width: 200},
  42 + {field: 'sort', align: 'center', title: '{:lang("order")}', width: 120, templet: '#order'},
  43 + {field: 'open', align: 'center', title: '{:lang("status")}', width: 100, toolbar: '#open'},
  44 + {field: 'addtime', title: '{:lang("add")}{:lang("time")}',width: 150},
  45 + {width: 180, align: 'center', toolbar: '#action'}
  46 + ]],
  47 + limit:10
  48 + });
  49 + form.on('switch(open)', function(obj){
  50 + loading =layer.load(1, {shade: [0.1,'#fff']});
  51 + var id = this.value;
  52 + var open = obj.elem.checked===true?1:0;
  53 + $.post('{:url("editState")}',{'id':id,'open':open},function (res) {
  54 + layer.close(loading);
  55 + if (res.status==1) {
  56 + tableIn.reload();
  57 + }else{
  58 + layer.msg(res.msg,{time:1000,icon:2});
  59 + return false;
  60 + }
  61 + })
  62 + });
  63 + //搜索
  64 + $('#search').on('click', function () {
  65 + var key = $('#key').val();
  66 + if ($.trim(key) === '') {
  67 + layer.msg('{:lang("pleaseEnter")}关键字!', {icon: 0});
  68 + return;
  69 + }
  70 + tableIn.reload({ page: {page: 1}, where: {key: key}});
  71 + });
  72 + table.on('tool(list)', function(obj) {
  73 + var data = obj.data;
  74 + if (obj.event === 'del'){
  75 + layer.confirm('您确定要删除该节日吗?', function(index){
  76 + var loading = layer.load(1, {shade: [0.1, '#fff']});
  77 + $.post("{:url('del')}",{id:data.id},function(res){
  78 + layer.close(loading);
  79 + if(res.code===1){
  80 + layer.msg(res.msg,{time:1000,icon:1});
  81 + tableIn.reload();
  82 + }else{
  83 + layer.msg('操作失败!',{time:1000,icon:2});
  84 + }
  85 + });
  86 + layer.close(index);
  87 + });
  88 + }
  89 + });
  90 + $('body').on('blur','.list_order',function() {
  91 + var id = $(this).attr('data-id');
  92 + var sort = $(this).val();
  93 + var loading = layer.load(1, {shade: [0.1, '#fff']});
  94 + $.post('{:url("feastOrder")}',{id:id,sort:sort},function(res){
  95 + layer.close(loading);
  96 + if(res.code === 1){
  97 + layer.msg(res.msg, {time: 1000, icon: 1});
  98 + tableIn.reload();
  99 + }else{
  100 + layer.msg(res.msg,{time:1000,icon:2});
  101 + }
  102 + })
  103 + });
  104 + })
  105 +</script>