Commit 9e1af9e67568f2b8711cb28eacaac01faede1482

Authored by teemitop
1 parent 21e77736

卡券新建 投放

@@ -102,20 +102,6 @@ class Card extends Common @@ -102,20 +102,6 @@ class Card extends Common
102 * 创建优惠券-选择商户 102 * 创建优惠券-选择商户
103 */ 103 */
104 public function selectseller(){ 104 public function selectseller(){
105 - //获取运营人员列表  
106 - $list= file_get_contents(ON_LINE.'App.Seller.GetSellerById&sellerid='.$data['sid']);  
107 - $array = json_decode($list,TRUE);  
108 - if($array['data']['data']){  
109 - $array['data']['data']['daily'] = json_decode($array['data']['data']['daily'],TRUE);  
110 - $array['data']['data']['daily_time'] = json_decode($array['data']['data']['daily_time'],TRUE);  
111 - $array['data']['data']['cdate'] = date("Y年m月d日 H时i分s秒",$array['data']['data']['cdate']);  
112 - }  
113 - //获取短信流水  
114 - $sms= file_get_contents(ON_LINE.'App.SendSMS.GetSellerSmsFlowing&sid='.$data['sid']);  
115 - $sms_data = json_decode($sms,TRUE);  
116 - $sms_data_list = $sms_data['data'] ? $sms_data['data'] : array();  
117 - $this->assign ( 'smslist',$sms_data_list);  
118 - $this->assign ( 'data',$array['data']['data']);  
119 $this->assign ( 'title','创建卡券'); 105 $this->assign ( 'title','创建卡券');
120 return $this->fetch(); 106 return $this->fetch();
121 } 107 }
@@ -215,1283 +201,76 @@ class Card extends Common @@ -215,1283 +201,76 @@ class Card extends Common
215 return $this->fetch(); 201 return $this->fetch();
216 } 202 }
217 203
218 -  
219 -  
220 -  
221 -  
222 -  
223 -  
224 -  
225 - /**  
226 - * 停用商家  
227 - */  
228 - public function configStop(){  
229 - if(Request::isAjax()){  
230 - $data = Request::except('file');  
231 - $data['status'] = $data['status'] ? 0 : 1;  
232 - $list= file_get_contents(ON_LINE.'App.Seller.SetStopBySeller&sellerid='.$data['sellerid'].'&status='.$data['status']);  
233 - $array = json_decode($list,TRUE);  
234 - if($array['ret']==200){  
235 - $result['code'] = 1;  
236 - $result['msg'] = 'SUCCESS!';  
237 - }else{  
238 - $result['code'] = 0;  
239 - $result['msg'] = '请求错误!';  
240 - }  
241 - return $result;  
242 - }  
243 - return view();  
244 - }  
245 -  
246 - /**  
247 - * 从商家维度统计:订单、短信等情况  
248 - */  
249 - public function getStatistics(){  
250 - if(Request::isAjax()){  
251 - $data = Request::except('file');  
252 - $key= input('post.key') ? input('post.key') : "";  
253 -  
254 - $sid = $data['sid'] ? implode(',', $data['sid']) : '';  
255 - $sellername = $data['key'] ? $data['key'] : '';  
256 -  
257 - $time = $data['time'] ? explode(' - ', $data['time']) : '';  
258 -  
259 - $stime = $time ? strtotime(date($time[0],time())) : '';  
260 - $etime = $time ? strtotime(date($time[1],time())) : '';  
261 -  
262 - $data['time_type'] = $data['time_type'] ? $data['time_type'] : 1;  
263 - $data['channel'] = $data['channel'] ? $data['channel'] : 1;  
264 -  
265 - $parame = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$sellername.'&stime='.@$stime.'&etime='.@$etime.'&channel='.@$data['channel'].'&sid='.$sid.'&time_type='.@$data['time_type'];  
266 -  
267 - //获取运营人员列表  
268 - $list= file_get_contents(ON_LINE.'App.Report.GetReserveData'.$parame);  
269 -  
270 - $array = json_decode($list,TRUE);  
271 -  
272 - $new_array = array();  
273 - foreach ($array['data'] as $key => $value) {  
274 - if(is_array($value)){  
275 - $new_array[$key]['id'] = $value['id'];  
276 - $new_array[$key]['sellername'] = $value['sellername'];  
277 - $new_array[$key]['contacts_total'] = $value['contacts_total'];  
278 - $new_array[$key]['inviting'] = $value['inviting'];  
279 - $new_array[$key]['reserve_count'] = $value['appReserveCount'] .'/'. $value['AndroidReserveCount'].'/'. $value['CReserveCount'];  
280 - $new_array[$key]['reserve_count_sort'] = $value['appReserveCount'] + $value['AndroidReserveCount'] + $value['CReserveCount'];  
281 - $new_array[$key]['sms_send_count'] = $value['appSmsCount'] .'/'. $value['AndroidSmsCount'];  
282 - $new_array[$key]['sms_send_count_sort'] = $value['appSmsCount'] + $value['AndroidSmsCount'];  
283 - $new_array[$key]['table_room_total'] = $value['table_total'] .'/'. $value['room_total'];  
284 - $new_array[$key]['address_component'] = $value['address_component']['province'] && $value['address_component']['city'] ? $value['address_component']['province'] .'-'. $value['address_component']['city'] : '无法获取地区,请检查经纬度是否正确!';  
285 - }  
286 - }  
287 - return $result = [  
288 - 'code'=>0,'msg'=>'获取成功!',  
289 - 'data'=>$new_array,  
290 - 'count'=>$array['data']['total'],  
291 - 'countReserve'=>$array['data']['appReserveCount']+$array['data']['AndroidReserveCount']+$array['data']['CReserveCount'],  
292 - 'countSms'=>$array['data']['appSmsCount']+$array['data']['AndroidSmsCount'],  
293 - 'inviteeCount'=>$array['data']['inviteeCount'],  
294 - 'appReserveCount'=>$array['data']['appReserveCount'],  
295 - 'AndroidReserveCount'=>$array['data']['AndroidReserveCount'],  
296 - 'CReserveCount'=>$array['data']['CReserveCount'],  
297 - 'appSmsCount'=>$array['data']['appSmsCount'],  
298 - 'AndroidSmsCount'=>$array['data']['AndroidSmsCount'],  
299 - 'Contacts'=>$array['data']['Contacts'],  
300 - 'rel'=>1  
301 - ];  
302 - }  
303 - $this->assign ( 'title','预定订单统计');  
304 - return $this->fetch();  
305 - }  
306 -  
307 - /**  
308 - * 从设备(电话机)维度统计:订单、短信等情况  
309 - */  
310 - public function getEquipment(){  
311 - if(Request::isAjax()){  
312 - $data = Request::except('file');  
313 - $key= input('post.key') ? input('post.key') : "";  
314 -  
315 - $sid = $data['sid'] ? implode(',', $data['sid']) : '';  
316 - $sellername = $data['key'] ? $data['key'] : '';  
317 -  
318 - $time = $data['time'] ? explode(' - ', $data['time']) : '';  
319 -  
320 - $stime = $time ? strtotime(date($time[0],time())) : '';  
321 - $etime = $time ? strtotime(date($time[1],time())) : '';  
322 -  
323 - $data['time_type'] = $data['time_type'] ? $data['time_type'] : 1;  
324 - $data['channel'] = $data['channel'] ? $data['channel'] : 1;  
325 -  
326 - $parame = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$sellername.'&stime='.@$stime.'&etime='.@$etime.'&channel='.@$data['channel'].'&sid='.$sid.'&time_type='.@$data['time_type'];  
327 -  
328 - //获取运营人员列表  
329 - $list= file_get_contents(ON_LINE.'App.Report.GetReserveDataBydev'.$parame);  
330 - $array = json_decode($list,TRUE);  
331 - return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];  
332 - }  
333 - $this->assign ( 'title','设备维度统计预定订单');  
334 - return $this->fetch();  
335 - }  
336 -  
337 - /**  
338 - * 商家菜系、类型配置  
339 - */  
340 - public function sellerconfig(){  
341 - $data = Request::except('file');  
342 - if(Request::isAjax()){  
343 - $cuisine = !empty($data['cuisine']) ? implode(',', array_keys($data['cuisine'])) : '';  
344 - $type = !empty($data['type']) ? implode(',', array_keys($data['type'])) : '';  
345 - $mode = !empty($data['mode']) ? implode(',', array_keys($data['mode'])) : '';  
346 - $sms_code = !empty($data['sms_code']) ? $data['sms_code'] : '';  
347 - $label = !empty($data['label']) ? implode(',', array_keys($data['label'])) : '';  
348 - $brand = !empty($data['brand']) ? implode(',', array_keys($data['brand'])) : '';  
349 - $label_1_ = !empty($data['label_1_']) ? implode(',', array_keys($data['label_1_'])) : '';  
350 - $label_2_ = !empty($data['label_2_']) ? implode(',', array_keys($data['label_2_'])) : '';  
351 - $label_3_ = !empty($data['label_3_']) ? implode(',', array_keys($data['label_3_'])) : '';  
352 - $is_checked_call = !empty($data['is_checked_call']) ? $data['is_checked_call'] : '';  
353 - $is_checked_lite = !empty($data['is_checked_lite']) ? $data['is_checked_lite'] : '';  
354 -  
355 - if(isset($data['reserve_mode'])) {  
356 - //需要修改 接单设备信息  
357 - if($data['reserve_mode']==1){  
358 - if($is_checked_lite)  
359 - $up=Db::query("UPDATE `xt-member-two-LINE`.xt_dc_dz_seller_config set is_checked_lite = 1 where sid = ".$data['sellerid']);  
360 - else  
361 - $up=Db::query("UPDATE `xt-member-two-LINE`.xt_dc_dz_seller_config set is_checked_lite = 0 where sid = ".$data['sellerid']);  
362 - if($is_checked_call)  
363 - $up=Db::query("UPDATE `xt-member-two-LINE`.xt_dc_dz_seller_config set is_checked_call = 1 where sid = ".$data['sellerid']);  
364 - else  
365 - $up=Db::query("UPDATE `xt-member-two-LINE`.xt_dc_dz_seller_config set is_checked_call = 0 where sid = ".$data['sellerid']);  
366 - }  
367 - $up=Db::query("UPDATE `xt-member-two-LINE`.xt_dc_dz_seller_config set reserve_mode = ".$data['reserve_mode']." where sid = ".$data['sellerid']);  
368 - }  
369 -  
370 - if($sms_code)  
371 - $res_sms_code= file_get_contents(ON_LINE.'App.SendSMS.SetSellerSmsTemplate&sid='.$data['sellerid'].'&sms_id='.$sms_code);  
372 -  
373 - if($cuisine)  
374 - $res_cuisine= file_get_contents(ON_LINE.'App.Seller.SetSellerCuisine&sellerid='.$data['sellerid'].'&cid='.$cuisine);  
375 - //$res_cuisine = json_decode($res_cuisine,TRUE);  
376 - if($type)  
377 - $res_type= file_get_contents(ON_LINE.'App.Seller.SetSellerType&sellerid='.$data['sellerid'].'&typeid='.$type);  
378 - //$res_type = json_decode($res_type,TRUE);  
379 -  
380 - if($mode)  
381 - $res_mode= file_get_contents(ON_LINE.'App.Seller.setSellerMode&sellerid='.$data['sellerid'].'&modeid='.$mode);  
382 - //$res_mode = json_decode($res_mode,TRUE);  
383 - if($label)  
384 - $res_label= file_get_contents(ON_LINE.'App.Seller.setSellerLabel&sid='.$data['sellerid'].'&field='.$label);  
385 -  
386 - if($brand){  
387 - $del=Db::query("DELETE FROM `xt-member-two-LINE`.xt_dc_dz_seller_brand_rel WHERE sid =".$data['sellerid']);  
388 - $add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_brand_rel VALUES(".$data['sellerid'].",".$brand.")");  
389 - }  
390 -  
391 - if($label_1_){  
392 - $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)");  
393 - $add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_1_.")");  
394 - }  
395 -  
396 - if($label_2_){  
397 - $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)");  
398 - $add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_2_.")");  
399 - }  
400 -  
401 - if($label_3_){  
402 - $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)");  
403 - $add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_3_.")");  
404 - }  
405 -  
406 - if(isset($data['edition'])){  
407 - $up=Db::query("UPDATE `xt-member-two-LINE`.xt_seller set is_online_reserve = ".$data['edition']." where id = ".$data['sellerid']);  
408 - }  
409 -  
410 - if(isset($data['is_tele'])){  
411 - $up=Db::query("UPDATE `xt-member-two-LINE`.xt_seller set is_tele = ".$data['is_tele']." where id = ".$data['sellerid']);  
412 - }  
413 -  
414 -  
415 - $result['code'] = 1;  
416 - $result['msg'] = "配置成功!";  
417 - return $result;  
418 - }  
419 -  
420 - //获取商家已有菜系  
421 - $cuisine_list= file_get_contents(ON_LINE.'App.Seller.getSellerCuisine&sellerid='.$data['id']);  
422 - $cuisine_list = json_decode($cuisine_list,TRUE);  
423 - //获取所有菜系  
424 - $list= file_get_contents(ON_LINE.'App.Reserve.GetCustomerConfig');  
425 - $array = json_decode($list,TRUE);  
426 - //组装数据  
427 - foreach ($cuisine_list['data'] as $key => $value) {  
428 - foreach ($array['data']['cate'] as $k => $v) {  
429 - if($value['cid']==$v['id']){  
430 - $array['data']['cate'][$k]['checked'] = 1;  
431 - }  
432 - }  
433 - }  
434 - $this->assign('list',$array['data']['cate']);//获取所有菜系  
435 -  
436 - //获取商家已有来源  
437 - $type_list= file_get_contents(ON_LINE.'App.Seller.GetSellerType&sellerid='.$data['id']);  
438 - $type_list = json_decode($type_list,TRUE);  
439 - //获取来源  
440 - $channel = array(array('id'=>1,'name'=>'合作'),array('id'=>2,'name'=>'推广'),array('id'=>3,'name'=>'测试'));  
441 - //组装数据  
442 - foreach ($type_list['data'] as $key => $value) {  
443 - foreach ($channel as $k => $v) {  
444 - if($value['type_id']==$v['id']){  
445 - $channel[$k]['checked'] = 1;  
446 - }  
447 - }  
448 - }  
449 - $this->assign('channel',$channel);//获取所有来源  
450 -  
451 - //获取商家已有地图显示方式  
452 - $mode_list= file_get_contents(ON_LINE.'App.Seller.getSellerMode&sellerid='.$data['id']);  
453 - $mode_list = json_decode($mode_list,TRUE);  
454 -  
455 - //获取所有地图显示方式  
456 - $mode= array(array('id'=>1,'name'=>'地图上大图标'),array('id'=>2,'name'=>'地图上文字'));  
457 - //组装数据  
458 - foreach ($mode_list['data'] as $key => $value) {  
459 - foreach ($mode as $k => $v) {  
460 - if($value['sm_id']==$v['id']){  
461 - $mode[$k]['checked'] = 1;  
462 - }  
463 - }  
464 - }  
465 - $this->assign('mode',$mode);//获取所有菜系  
466 -  
467 - //获取商家已选短信模板  
468 - $template = file_get_contents(ON_LINE.'App.Reserve.SellerInfo&seller_id='.$data['id']);  
469 - $template = json_decode($template,TRUE);  
470 - //获取短信模板列表  
471 - $template_list = file_get_contents(ON_LINE.'App.SendSMS.GetSmsTemplate');  
472 - $template_list = json_decode($template_list,TRUE);  
473 -  
474 - //组装数据  
475 - foreach ($template_list['data'] as $key => $value) {  
476 - if($value['template_code']==$template['data']['setting']['template_code']){  
477 - $template_list['data'][$key]['checked'] = 1;  
478 - }  
479 - switch ($value['template_code']) {  
480 - case 'SMS_163050401':  
481 - $vowels = array(  
482 - '周到安排演示店' => '${seller_name}',  
483 - '11月25日晚上18:00' => '${date}',  
484 - '金台夕照、卢沟晓月' =>'${region_room_name}',  
485 - '西电路447号南湖金地西门南100米' =>'${seller_addr}',  
486 - '18792581193' =>'${seller_phone}',  
487 - '毛毛' =>'${cusman}',  
488 - );  
489 - break;  
490 - case 'SMS_162733710':  
491 - $vowels = array(  
492 - '4月6日中午' => '${reserve_date}',  
493 - '周到1店西电路447号金台夕照' => '${seller_name_addr_room}',  
494 - '毛毛' =>'${cusman}',  
495 - );  
496 - break;  
497 - case 'SMS_154587043':  
498 - $vowels = array(  
499 - '侯先生' => '${guest}',  
500 - '周到安排演示店' => '${seller_name}',  
501 - '11月25日晚上18:00' =>'${date}',  
502 - '包间(金台夕照)' =>'${region_room_name}',  
503 - '西电路447号南湖金地西门南100米' =>'${seller_addr}',  
504 - '18792581193' =>'${seller_phone}\n',  
505 - '毛毛' =>'${cusman}',  
506 - );  
507 - break;  
508 - case 'SMS_164277855':  
509 - $vowels = array(  
510 - '周到1店西电路447号' => '${seller_name}',  
511 - '11月7日晚上18:30' => '${date}',  
512 - '包间(金台夕照)' =>'${region_room_name}',  
513 - '1879258119' =>'${seller_phone}',  
514 - );  
515 - break;  
516 - case 'SMS_164268239':  
517 - $vowels = array(  
518 - '周到安排演示店' => '${seller_name}',  
519 - '11月7日晚上18:30' => '${date}',  
520 - '包间(金台夕照)' =>'${region_room_name}',  
521 - '西电路447号南湖金地西门南100米' =>'${seller_addr}',  
522 - '1879258119' =>'${seller_phone}',  
523 - );  
524 - break;  
525 - case 'SMS_181200398':  
526 - $vowels = array(  
527 - '周到安排演示店' => '${sellershortname}',  
528 - '11月7日' => '${date}',  
529 - '晚上' =>'${mealtime}',  
530 - '1F' =>'${regionname}',  
531 - '<<金台夕照>>' =>'${roomname}',  
532 - '西电路447号南湖金地西门南100米' =>'${selleraddr}',  
533 - '1879258119' =>'${sellerphone}',  
534 - );  
535 - break;  
536 - case 'SMS_181210420':  
537 - $vowels = array(  
538 - '周到安排演示店' => '${salename}',  
539 - '11月7日晚上' => '${date_solt}',  
540 - '三楼4号院' =>'${regonname}',  
541 - '【金台夕照】' =>'${roomname}',  
542 - '西电路447号南湖金地西门南100米' =>'${selleraddr}',  
543 - '出门左转' =>'${sellertips}',  
544 - '毛毛' =>'${managername}',  
545 - '1879258119' =>'${managerphone}',  
546 - );  
547 - break;  
548 - default:  
549 - # code...  
550 - break;  
551 - }  
552 - $template_list['data'][$key]['content'] = str_replace($vowels, array_keys($vowels),$value['content']);  
553 - }  
554 - $this->assign('template_list',$template_list['data']);//获取短信模板列表  
555 -  
556 - //获取商家接单方式  
557 - $seller_config_res = Db::query('SELECT * from `xt-member-two-LINE`.xt_dc_dz_seller_config where sid ='.$data['id'].' GROUP by sid');  
558 - if(@$seller_config_res[0])  
559 - $this->assign('seller_config_res',$seller_config_res[0]);  
560 -  
561 - $seller_user_openid_array = array();  
562 - //获取小程序是否可选择  
563 - $seller_user_openid_array = Db::query('SELECT  
564 - a.openid,  
565 - u.nick_name,  
566 - u.phone  
567 - FROM  
568 - `xt-member-two-LINE`.xt_dc_seller_user AS u  
569 - LEFT JOIN `xt-member-two-LINE`.xt_auth_user AS a ON u.auth_user_id = a.id  
570 - WHERE  
571 - u.is_on_call = 1  
572 - AND u.sellerid = '.$data['id']);  
573 - $seller_user_openid = $seller_user_openid_array ? $seller_user_openid_array[0]['openid'] : '';  
574 -  
575 - if($seller_user_openid_array[0]['phone']==NULL || $seller_user_openid_array[0]['phone'] ==''){  
576 - $seller_user_openid_array[0]['phone'] = '电话未填写';  
577 - $seller_user_openid_array[0]['phone_status'] = 1;  
578 - }  
579 - //检测是否关注公众号  
580 - if($seller_user_openid){  
581 - $seller_user_unionid = Db::query('SELECT  
582 - openid  
583 - FROM  
584 - `xt-member-two-LINE`.xt_wechat  
585 - WHERE  
586 - unionid = ( SELECT unionid FROM `xt-member-two-LINE`.xt_wechat WHERE openid = "'.$seller_user_openid.'" )  
587 - AND source = 0');  
588 - $seller_user_unionid = $seller_user_unionid ? $seller_user_unionid[0]['openid'] : '';  
589 - //未关注公众号则不能勾选小程序  
590 - if($seller_user_unionid==''){  
591 - $seller_user_openid_array[0]['is_openid_wechat'] = 0;  
592 - $seller_user_openid_array[0]['is_openid_wechat_str'] = '未关注公众号';  
593 - }else{  
594 - $seller_user_openid_array[0]['is_openid_wechat'] = 1;  
595 - $seller_user_openid_array[0]['is_openid_wechat_str'] = '已关注公众号';  
596 - }  
597 - }  
598 -  
599 - $this->assign('seller_user_openid_array',$seller_user_openid_array[0]);  
600 -  
601 -  
602 - //获取商家拥有哪些标签  
603 - $label_list= file_get_contents(ON_LINE.'App.Seller.GetSellerLabel&sid='.$data['id']);  
604 - $label_list = json_decode($label_list,TRUE);  
605 - $this->assign('label_list',$label_list['data']);  
606 -  
607 - //商家标签  
608 - //原生:  
609 - //$label_c=Db::query("SELECT * from xt-member-two-LINE.xt_dc_dz_seller_label_c");  
610 - $label_c=Db::table("xt-member-two-LINE.xt_dc_dz_seller_label_c")->select();  
611 - $label_c_rel=Db::table("xt-member-two-LINE.xt_dc_dz_seller_label_c_rel")->where(array('sid'=>$data['id']))->select();  
612 - //组装数据  
613 - foreach ($label_c as $key => $value) {  
614 - foreach ($label_c_rel as $k => $v) {  
615 - if($value['id']==$v['lcid']){  
616 - $label_c[$key]['checked'] = 1;  
617 - }  
618 - }  
619 - }  
620 - $this->assign('label_c',$label_c);  
621 -  
622 - //商家品牌  
623 - $brand=Db::table("xt-member-two-LINE.xt_dc_dz_seller_brand")->select();  
624 - $brand_rel=Db::table("xt-member-two-LINE.xt_dc_dz_seller_brand_rel")->where(array('sid'=>$data['id']))->select();  
625 - //组装数据  
626 - foreach ($brand as $key => $value) {  
627 - foreach ($brand_rel as $k => $v) {  
628 - if($value['id']==$v['bid']){  
629 - $brand[$key]['checked'] = 1;  
630 - }  
631 - }  
632 - }  
633 - $this->assign('brand',$brand);  
634 -  
635 -  
636 - $is_online_reserve=Db::table("xt-member-two-LINE.xt_seller")->where(array('id'=>$data['id']))->select();  
637 -  
638 - //获取商家在线预定版本情况  
639 - $this->assign('is_online_reserve',$is_online_reserve[0]['is_online_reserve']);  
640 - //是否安装电话机  
641 - $this->assign('is_tele',$is_online_reserve[0]['is_tele']);  
642 -  
643 - //商户信息  
644 - $this->assign ('data',$data);  
645 - $this->assign ( 'title','商户信息配置' );  
646 - return $this->fetch();  
647 - }  
648 -  
649 - /**  
650 - * 商家基础信息配置  
651 - */  
652 - public function setsellerconfig(){  
653 - if(Request::isAjax()){  
654 - $data = Request::except('file');  
655 - $data['status'] = $data['status'] ? 0 : 1;  
656 - $list= file_get_contents(ON_LINE.'App.Seller.SetSellerConfigByPC&sid='.$data['sellerid'].'&field='.$data['field'].'&value='.$data['value']);  
657 - $array = json_decode($list,TRUE);  
658 - if($array['ret']==200){  
659 - $result['code'] = 1;  
660 - $result['msg'] = 'SUCCESS!';  
661 - }else{  
662 - $result['code'] = 0;  
663 - $result['msg'] = '请求错误!';  
664 - }  
665 - return $result;  
666 - }  
667 - return view();  
668 - }  
669 -  
670 -  
671 - //商家列表 用于配置商家活动  
672 - public function seller_activity_list(){  
673 - if(Request::isAjax()){  
674 - $data = Request::except('file');  
675 - $key= input('post.key') ? input('post.key') : "";  
676 - $channel = @$key['channel'] ? @$key['channel'] : 1;  
677 - $limit = '&x='.$data["page"].'&y='.$data["limit"].'&keywords='.@$key['id'].'&channel='.$channel;  
678 -  
679 - //获取运营人员列表  
680 - $list= file_get_contents(ON_LINE.'App.Seller.GetSellerListByActivity'.$limit);  
681 - $array = json_decode($list,TRUE);  
682 - foreach($array['data'][0]['data'] as $key=>$value){  
683 - if(!empty($value['activity'])){  
684 - foreach ($value['activity'] as $k => $v) {  
685 - $str[$key][] = ($k+1).'、'.$v['title'];  
686 - }  
687 - $array['data'][0]['data'][$key]['activity'] = implode('<br/>', $str[$key]);  
688 - //$array['data'][0]['data'][$key]['activity'] = implode('<br/>', array_column($value['activity'], 'title'));  
689 - }  
690 - }  
691 - return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data'][0]['data'],'count'=>$array['data'][0]['total'],'rel'=>1];  
692 - }  
693 - $this->assign ( 'title','商家活动配置');  
694 - return $this->fetch();  
695 - }  
696 -  
697 /** 204 /**
698 - * 商家活动列表页 205 + * 商家卡券-卡券投放-卡券列表
699 */ 206 */
700 - public function seller_activity(){  
701 - $data = Request::except('file');  
702 - //获取商家现有活动  
703 - $seller_activity= file_get_contents(ON_LINE.'App.Seller.GetSellerActivity&sid='.$data['id']);  
704 - $seller_activity = json_decode($seller_activity,TRUE);  
705 - //活动列表  
706 - $this->assign('sid',$data['id']);  
707 - $this->assign ( 'seller_activity',$seller_activity['data']);  
708 - $this->assign ( 'title','商家活动配置页面');  
709 - return $this->fetch();  
710 - }  
711 -  
712 - //添加活动  
713 - public function add_activity(){  
714 - $data = Request::except('file');  
715 - if(Request::isAjax()){  
716 - switch ($data['type']) {  
717 - case '1':  
718 - if($data['max_num']==0){  
719 - $data['title'] = '立减'.$data['min_num'];break;  
720 - }else{  
721 - $data['title'] = '满'.$data['max_num'].'立减'.$data['min_num'];break;  
722 - }  
723 - case '2':  
724 - if($data['max_num']==0){  
725 - $data['title'] = '赠'.$data['min_num'];break;  
726 - }else{  
727 - $data['title'] = '满'.$data['max_num'].'赠'.$data['min_num'];break;  
728 - }  
729 - break;  
730 - case '3':  
731 - if($data['max_num']==0){  
732 - $data['title'] = $data['min_num'].'折';break;  
733 - }else{  
734 - $data['title'] = '满'.$data['max_num'].'立享'.$data['min_num'].'折';break;  
735 - }  
736 - case '4':  
737 - $data['title'] = $data['max_num'].'元代金券';  
738 - break;  
739 - case '5':  
740 - $data['title'] = '会员价';  
741 - break;  
742 - default:  
743 - # code...  
744 - break;  
745 - }  
746 -  
747 - //字段空值过滤  
748 - //添加活动  
749 - $res= file_get_contents(ON_LINE.'App.Seller.SetActivity&str='.serialize($data));  
750 - $res = json_decode($res,TRUE);  
751 - if($data['aid']){  
752 - if($res['data']){  
753 - $result = ['code'=>1,'msg'=>'修改成功!','rel'=>1];  
754 - }else{  
755 - $result = ['code'=>0,'msg'=>'修改失败!','rel'=>1];  
756 - }  
757 - }else{  
758 - if($res['data']){  
759 - $result = ['code'=>1,'msg'=>'添加成功!','rel'=>1];  
760 - }else{  
761 - $result = ['code'=>0,'msg'=>'添加失败!','rel'=>1];  
762 - }  
763 - }  
764 - return $result;  
765 - }  
766 - if($data['id']){  
767 - //修改---需要获取对应的数据  
768 - $activity= file_get_contents(ON_LINE.'App.Seller.GetSellerActivityById&id='.$data['id']);  
769 - $activity = json_decode($activity,TRUE);  
770 - $this->assign ('data',$activity['data']);  
771 - $this->assign ( 'title','修改活动');  
772 - }  
773 - $this->assign ( 'hid',$data['sid']);  
774 - $this->assign ( 'title','添加活动');  
775 - return $this->fetch();  
776 - }  
777 -  
778 - //删除活动  
779 - public function del_activity(){  
780 - $data = Request::except('file');  
781 - $res= file_get_contents(ON_LINE.'App.Seller.DelSellerActivity&sid='.$data['sid'].'&aid='.$data['aid']);  
782 - $res = json_decode($res,TRUE);  
783 - $this->redirect('Seller/seller_activity', ['id' => $data['sid']]);  
784 - //return $this->fetch('seller_activity',['id' => $data['sid']]);  
785 - }  
786 -  
787 - //商家设备列表  
788 - public function device_list(){  
789 - //获取类型  
790 - $facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer"); 207 + public function cardput(){
791 if(Request::isAjax()){ 208 if(Request::isAjax()){
792 $data = Request::except('file'); 209 $data = Request::except('file');
793 - $channel = @$data['channel'] ? @$data['channel'] : 1;  
794 - $manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;  
795 -  
796 - $limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;  
797 210
798 - //获取运营人员列表  
799 - $list= file_get_contents(ON_LINE.'App.Device.GetDeviceOnlineStatus'.$limit); //GetSellerDevice  
800 - $array = json_decode($list,TRUE);  
801 - foreach ($array['data']['list'] as $key => $value) {  
802 - switch ($value['type']) {  
803 - case '0':  
804 - $array['data']['list'][$key]['type'] = $facturer[0]['facturer'];  
805 - break;  
806 - case '1':  
807 - $array['data']['list'][$key]['type'] = $facturer[0]['facturer'];  
808 - break;  
809 - case '2':  
810 - $array['data']['list'][$key]['type'] = $facturer[1]['facturer'];  
811 - break;  
812 - case '3':  
813 - $array['data']['list'][$key]['type'] = $facturer[2]['facturer'];  
814 - break;  
815 - case '4':  
816 - $array['data']['list'][$key]['type'] = $facturer[3]['facturer'];  
817 - break;  
818 -  
819 - default:  
820 - $array['data']['list'][$key]['type'] = 'error: '.$value['type'];  
821 - break;  
822 - }  
823 -  
824 - }  
825 - return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];  
826 - }  
827 - $this->assign ( 'facturer',$facturer);  
828 - $this->assign ( 'title','商家设备列表');  
829 - return $this->fetch();  
830 - }  
831 -  
832 - //商家设备列表  
833 - public function add_gray_user(){  
834 - if(Request::isAjax()){  
835 - $data = Request::except('file');  
836 - $list= file_get_contents(ON_LINE.'App.Device.SetGrayUser&ids='.serialize($data['id']));  
837 - $array = json_decode($list,TRUE);  
838 - if($array['ret']==200){  
839 - $result['code'] = 1;  
840 - $result['msg'] = 'SUCCESS!';  
841 - }else{  
842 - $result['code'] = 0;  
843 - $result['msg'] = '服务器错误,请勿重复将设备号添加到灰度用户!';  
844 - }  
845 - return $result;  
846 - }  
847 - return view();  
848 - }  
849 -  
850 - //灰度用户列表  
851 - public function gray_user_list(){  
852 - //获取类型  
853 - $facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");  
854 - $this->assign ( 'facturer',$facturer);  
855 - if(Request::isAjax()){  
856 - $data = Request::except('file');  
857 - $channel = @$data['channel'] ? @$data['channel'] : 1;  
858 - $manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;  
859 -  
860 - $limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;  
861 -  
862 - $list= file_get_contents(ON_LINE.'App.Device.GetGrayUserList'.$limit);  
863 - $array = json_decode($list,TRUE);  
864 - foreach ($array['data']['list'] as $key => $value) {  
865 - switch ($value['type']) {  
866 - case '1':  
867 - $array['data']['list'][$key]['type'] = $facturer[0]['facturer'];  
868 - break;  
869 - case '2':  
870 - $array['data']['list'][$key]['type'] = $facturer[1]['facturer'];  
871 - break;  
872 - case '3':  
873 - $array['data']['list'][$key]['type'] = $facturer[2]['facturer'];  
874 - break;  
875 - case '4':  
876 - $array['data']['list'][$key]['type'] = $facturer[3]['facturer'];  
877 - break;  
878 -  
879 - default:  
880 - $array['data']['list'][$key]['type'] = 'error';  
881 - break;  
882 - }  
883 - }  
884 - return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];  
885 - }  
886 - //获取类型  
887 - $facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");  
888 - $this->assign ( 'facturer',$facturer);  
889 - $this->assign ( 'title','灰度用户列表');  
890 - return $this->fetch();  
891 - } 211 + $where = '';
  212 + $channel = $data['channel'] ? $data['channel'] : 1;
892 213
893 - //删除灰度用户  
894 - public function del_gray_user(){  
895 - if(Request::isAjax()){  
896 - $data = Request::except('file');  
897 - $list= file_get_contents(ON_LINE.'App.Device.DelGrayUser&jsstr='.serialize($data['id']));  
898 - $array = json_decode($list,TRUE); 214 + $where .= ($channel && $channel==4) ? ' re.type_id in (1,2,3)' : " re.type_id in ($channel)";
  215 + $where .= $data['key'] ? ' and s.sellername like "%'.$data['key'].'%"' : "";
899 216
900 - if($array['ret']==200){  
901 - $result['code'] = 1;  
902 - $result['msg'] = 'SUCCESS!';  
903 - }else{  
904 - $result['code'] = 0;  
905 - $result['msg'] = '请刷新页面重新尝试!';  
906 - }  
907 - return $result;  
908 - }  
909 - return view();  
910 - }  
911 -  
912 - //获取在线设备情况  
913 - public function get_device_online_status(){  
914 - //获取类型  
915 - $facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");  
916 - if(Request::isAjax()){  
917 - $data = Request::except('file');  
918 - $channel = @$data['channel'] ? @$data['channel'] : 1;  
919 - $manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;  
920 -  
921 - $limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;  
922 -  
923 - $list= file_get_contents(ON_LINE.'App.Device.GetDeviceOnlineStatus'.$limit);  
924 - $array = json_decode($list,TRUE);  
925 - foreach ($array['data']['list'] as $key => $value) {  
926 - switch ($value['type']) {  
927 - case '0':  
928 - $array['data']['list'][$key]['type'] = $facturer[0]['facturer'];  
929 - break;  
930 - case '1':  
931 - $array['data']['list'][$key]['type'] = $facturer[0]['facturer'];  
932 - break;  
933 - case '2':  
934 - $array['data']['list'][$key]['type'] = $facturer[1]['facturer'];  
935 - break;  
936 - case '3':  
937 - $array['data']['list'][$key]['type'] = $facturer[2]['facturer'];  
938 - break;  
939 - case '4':  
940 - $array['data']['list'][$key]['type'] = $facturer[3]['facturer'];  
941 - break;  
942 -  
943 - default:  
944 - $array['data']['list'][$key]['type'] = $value['type'];  
945 - break;  
946 - }  
947 - }  
948 - return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];  
949 - }  
950 - $this->assign ( 'facturer',$facturer);  
951 - $this->assign ( 'title','商家话机在线设备列表');  
952 - return $this->fetch();  
953 - }  
954 -  
955 - private function check($aid) {  
956 -  
957 - }  
958 -  
959 - /**  
960 - * 从商家维度统计:订单、短信等情况  
961 - */  
962 - public function GetReserveList(){  
963 - //获取类型  
964 - $facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");  
965 - if(Request::isAjax()){  
966 - $data = Request::except('file');  
967 - set_time_limit(0);  
968 - $time = $data['time'] ? explode(' - ', $data['time']) : '';  
969 - $data['stime'] = $time ? strtotime(date($time[0],time())) : strtotime(date('Y-m-d 00:00:00',time()));  
970 - $data['etime'] = $time ? strtotime(date($time[1],time())) : strtotime(date('Y-m-d 23:59:59',time()));  
971 -  
972 - $dtime = $data['dtime'] ? explode(' - ', $data['dtime']) : '';  
973 - $data['sdtime'] = $dtime ? strtotime(date($dtime[0],time())) : '';  
974 - $data['edtime'] = $dtime ? strtotime(date($dtime[1],time())) : '';  
975 -  
976 - ////////////////////////////////  
977 - $arr = array();  
978 - $where = '';  
979 -  
980 - $offset = ($data['page']-1)*$data['limit'];  
981 - $limit = " LIMIT $offset,".$data['limit'];  
982 -  
983 - switch ($data['order']) {  
984 - case '1':  
985 - $where .= ' r.type = 1'; # 1 = 顾客下单  
986 - break;  
987 - case '2':  
988 - $where .= ' r.type = 0'; # 0 = 商户下单  
989 - break;  
990 - default:  
991 - $where .= '1=1';  
992 - break;  
993 - }  
994 -  
995 - $data['status'] = $data['status'] ? $data['status'] : 2;  
996 - switch ($data['status']) {  
997 - case 1:  
998 - $where .= ' AND r.status = 0';  
999 - break;  
1000 - case 2:  
1001 - $where .= ' AND r.status = 0';  
1002 - break;  
1003 - case 3:  
1004 - $where .= ' AND r.status = 6';  
1005 - break;  
1006 - case 4:  
1007 - $where .= ' AND r.status = 5';  
1008 - break;  
1009 - case 5:  
1010 - $where .= ' AND r.status = 4';  
1011 - break;  
1012 - case -1:  
1013 - if($data['order']==1){  
1014 - $where .= ' AND r.status in (0,6,5,4)';  
1015 - }else{  
1016 - $where .= ' AND r.status in (0,1,6,5,4)';  
1017 - }  
1018 - break;  
1019 - default:  
1020 - # code...  
1021 - break;  
1022 - }  
1023 -  
1024 - if($data['sdtime'] && $data['edtime']){  
1025 - $where .= $data['status']==2 ? ' AND r.cdate <= UNIX_TIMESTAMP(date_add(NOW(), interval -5 minute)) AND r.ddate BETWEEN '.$data['sdtime'].' AND '.$data['edtime'] : ' AND r.ddate BETWEEN '.$data['sdtime'].' AND '.$data['edtime'];  
1026 - }else{  
1027 - $where .= $data['status']==2 ? ' AND r.cdate <= UNIX_TIMESTAMP(date_add(NOW(), interval -5 minute)) AND r.cdate BETWEEN '.$data['stime'].' AND '.$data['etime'] : ' AND r.cdate BETWEEN '.$data['stime'].' AND '.$data['etime'];  
1028 - }  
1029 -  
1030 - $data['channel'] = $data['channel'] ? implode(',',$data['channel']) : 1;  
1031 -  
1032 - $where .= $data['channel'] == -1 ? '' : ' AND re.type_id in ('.$data['channel'].')';  
1033 - #key  
1034 - $where .= $data['key'] ? ' AND s.sellername like "%'.$data['key'].'%"' : ''; //商家名称  
1035 - #ID  
1036 - $where .= $data['nokey'] ? ' AND r.id ='.$data['nokey'] : ''; //商家ID  
1037 -  
1038 -  
1039 - $offset = ($data['page']-1)*$data['limit']; 217 + $offset = ($data["page"] - 1) * $data["limit"];
1040 $limit = " LIMIT $offset,".$data['limit']; 218 $limit = " LIMIT $offset,".$data['limit'];
1041 219
1042 -  
1043 - //导出操作  
1044 - if($data['export']){  
1045 - $limit = "";  
1046 - }else{  
1047 - $limit = " LIMIT $offset,".$data['limit'];  
1048 - }  
1049 -  
1050 - $admin = db('admin')->where(array('admin_id'=>session('aid')))->find();  
1051 -  
1052 - //当前用户分组为代理商时 获取代理商下面的数据  
1053 - if(in_array($admin['group_id'],array(8))) {  
1054 - //查询账号对应的区域ID  
1055 - $account = Db::query("SELECT  
1056 - *  
1057 - FROM  
1058 - `xt-member-two-LINE`.xt_dc_dz_agent_account  
1059 - WHERE  
1060 - account = '".$admin['username']."'");  
1061 -  
1062 - $where .= ' AND ags.areaid = '.$account[0]['areaid']; //区域ID  
1063 -  
1064 - //检测是否为代理商  
1065 - $rs = Db::query("SELECT  
1066 - dv.type,  
1067 - r.tid,  
1068 - r.tableinfo,  
1069 - r.id,  
1070 - r.rname,  
1071 - r.sex,  
1072 - r.pnum,  
1073 - r.phone,  
1074 - r.cusdem,  
1075 - r.ddate,  
1076 - r.cdate,  
1077 - r.status,  
1078 - r.ddate_solt,  
1079 - r.room_demand,  
1080 - r.operator_openid,  
1081 - s.sellername,  
1082 - s.is_tele,  
1083 - s.seller_tel  
1084 - FROM  
1085 - `xt-member-two-LINE`.xt_dc_reserve AS r  
1086 - LEFT JOIN `xt-member-two-LINE`.xt_seller AS s ON r.sid = s.id  
1087 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS re ON re.sid = r.sid  
1088 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_app_dv AS dv ON dv.sid = s.id  
1089 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_agent_seller AS ags on ags.sellerid = s.id  
1090 - WHERE  
1091 - $where  
1092 - GROUP BY  
1093 - r.id".$limit);  
1094 -  
1095 - $total = Db::query("SELECT  
1096 - r.id  
1097 - FROM  
1098 - `xt-member-two-LINE`.xt_dc_reserve AS r  
1099 - LEFT JOIN `xt-member-two-LINE`.xt_seller AS s ON r.sid = s.id  
1100 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS re ON re.sid = r.sid  
1101 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_app_dv AS dv ON dv.sid = s.id  
1102 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_agent_seller AS ags on ags.sellerid = s.id  
1103 - WHERE  
1104 - $where  
1105 - GROUP BY  
1106 - r.id");  
1107 - }else{  
1108 - //检测是否为代理商  
1109 - $rs = Db::query("SELECT  
1110 - dv.type,  
1111 - r.tid,  
1112 - r.tableinfo,  
1113 - r.id,  
1114 - r.rname,  
1115 - r.sex,  
1116 - r.pnum,  
1117 - r.phone,  
1118 - r.cusdem,  
1119 - r.ddate,  
1120 - r.cdate,  
1121 - r.status,  
1122 - r.ddate_solt,  
1123 - r.room_demand,  
1124 - r.operator_openid,  
1125 - s.sellername,  
1126 - s.is_tele,  
1127 - s.seller_tel  
1128 - FROM  
1129 - `xt-member-two-LINE`.xt_dc_reserve AS r  
1130 - LEFT JOIN `xt-member-two-LINE`.xt_seller AS s ON r.sid = s.id  
1131 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS re ON re.sid = r.sid  
1132 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_app_dv AS dv ON dv.sid = s.id  
1133 - WHERE  
1134 - $where  
1135 - GROUP BY  
1136 - r.id".$limit);  
1137 -  
1138 - $total = Db::query("SELECT  
1139 - r.id  
1140 - FROM  
1141 - `xt-member-two-LINE`.xt_dc_reserve AS r  
1142 - LEFT JOIN `xt-member-two-LINE`.xt_seller AS s ON r.sid = s.id  
1143 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS re ON re.sid = r.sid  
1144 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_app_dv AS dv ON dv.sid = s.id  
1145 - WHERE  
1146 - $where  
1147 - GROUP BY  
1148 - r.id");  
1149 - }  
1150 -  
1151 - foreach ($rs as $key => $value) {  
1152 - $rs[$key]['seller_tel'] = str_replace(',', '、', $value['seller_tel']);  
1153 - $message_time = Db::query("SELECT  
1154 - handle_time,rec_date 220 + //卡券信息
  221 + $rs = Db::query("SELECT
  222 + s.*
1155 FROM 223 FROM
1156 - `xt-member-two-LINE`.xt_dc_dz_message 224 + `xt-member-two-LINE`.xt_dc_dz_card_info AS s
  225 + LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS re ON re.sid = s.id
1157 WHERE 226 WHERE
1158 - rid = ".$value['id']." and message_type = 10");  
1159 - $rs[$key]['handle_time'] = $message_time[0]['handle_time'];  
1160 - $rs[$key]['rec_date'] = $message_time[0]['rec_date'];  
1161 - }  
1162 -  
1163 - $arr['list'] = $rs;  
1164 - $arr['total'] = count($total);  
1165 - ////////////////////////////////  
1166 -  
1167 - foreach ($arr['list'] as $key => $value) {  
1168 - //已分配的订单显示 分配的桌位  
1169 - if($value['status']==5){  
1170 - $arr['list'][$key]['tid'] = explode(',',@$value['tid']);  
1171 - }  
1172 - //有无设备  
1173 - if($value['is_tele']==1){  
1174 - switch ($value['type']) {  
1175 - case '1':  
1176 - $arr['list'][$key]['dv'] = $facturer[0]['facturer'];  
1177 - break;  
1178 - case '2':  
1179 - $arr['list'][$key]['dv'] = $facturer[1]['facturer'];  
1180 - break;  
1181 - case '3':  
1182 - $arr['list'][$key]['dv'] = $facturer[2]['facturer'];  
1183 - break;  
1184 - case '4':  
1185 - $arr['list'][$key]['dv'] = $facturer[3]['facturer'];  
1186 - break;  
1187 - default:  
1188 - $arr['list'][$key]['dv'] = '无';  
1189 - break;  
1190 - }  
1191 - }else{  
1192 - $arr['list'][$key]['dv'] = '无';  
1193 - }  
1194 - //订单接受时间段  
1195 - switch ($value['ddate_solt']) {  
1196 - //'未设置/早市/午市/晚市/夜宵 0/1/2/3/4',  
1197 - case 0:  
1198 - $value['ddate_solt'] = '未设置';  
1199 - break;  
1200 - case 1:  
1201 - $value['ddate_solt'] = '早市';  
1202 - break;  
1203 - case 2:  
1204 - $value['ddate_solt'] = '午市';  
1205 - break;  
1206 - case 3:  
1207 - $value['ddate_solt'] = '晚市';  
1208 - break;  
1209 - case 4:  
1210 - $value['ddate_solt'] = '夜宵';  
1211 - break;  
1212 - default:  
1213 - # code...  
1214 - break;  
1215 - }  
1216 - $arr['list'][$key]['ddate'] = date('Y-m-d H:i:s',$value['ddate']).'['.$value['ddate_solt'].']';  
1217 - $arr['list'][$key]['cdate'] = date('Y-m-d H:i:s',$value['cdate']);  
1218 - $arr['list'][$key]['handle_time'] = $value['handle_time'] ? date('Y-m-d H:i:s',$value['handle_time']) : '';  
1219 - $arr['list'][$key]['rec_date'] = $value['rec_date'] ? date('Y-m-d H:i:s',$value['rec_date']) : '';  
1220 - switch ($value['status']) {  
1221 - case 0:  
1222 - $arr['list'][$key]['sta'] = '待确认';  
1223 - break;  
1224 - case 1:  
1225 - $arr['list'][$key]['sta'] = '已定座';  
1226 - break;  
1227 - case 2:  
1228 - $arr['list'][$key]['sta'] = '到店';  
1229 - break;  
1230 - case 3:  
1231 - $arr['list'][$key]['sta'] = '离店';  
1232 - break;  
1233 - case 4:  
1234 - $arr['list'][$key]['sta'] = '已取消';  
1235 - break;  
1236 - case 5:  
1237 - $arr['list'][$key]['sta'] = '已分配';  
1238 - break;  
1239 - case 6:  
1240 - $arr['list'][$key]['sta'] = '拒单';  
1241 - break;  
1242 - default:  
1243 - # code...  
1244 - break;  
1245 - }  
1246 - switch ($value['sex']) {  
1247 - case 1:  
1248 - $arr['list'][$key]['rname'] = $value['rname'].'先生'.'('.$value['phone'].')';  
1249 - break;  
1250 - case 2:  
1251 - $arr['list'][$key]['rname'] = $value['rname'].'女士'.'('.$value['phone'].')';  
1252 - break;  
1253 - case 3:  
1254 - $arr['list'][$key]['rname'] = $value['rname'].'公司'.'('.$value['phone'].')';  
1255 - break;  
1256 - default:  
1257 - # code...  
1258 - break;  
1259 - }  
1260 -  
1261 - if($value['room_demand']){  
1262 - $arr['list'][$key]['room_demand'] = implode('、',array_column(json_decode($value['room_demand'],true), 'name'));  
1263 - }  
1264 -  
1265 - $arr['list'][$key]['sta'] = $value['is_tele']==1 ? $arr['list'][$key]['sta'] : $arr['list'][$key]['sta'].'无话机';  
1266 -  
1267 - //根据操作人识别操作终端  
1268 - if(isset($template['operator_openid'])){  
1269 - if(strstr($template['operator_openid'],'_',-4)=='tele'){ //话机操作  
1270 - $arr['list'][$key]['operator_openid'] = '电话机';  
1271 - }  
1272 -  
1273 - if(strstr($template['operator_openid'],'_',-4)=='wind'){ //PC操作  
1274 - $arr['list'][$key]['operator_openid'] = 'PC';  
1275 - }  
1276 -  
1277 - if(strstr($template['operator_openid'],'_',-4)=='chat'){ //PC操作  
1278 - $arr['list'][$key]['operator_openid'] = '小程序';  
1279 - }  
1280 - }  
1281 - }  
1282 - foreach ($arr['list'] as $key => $value) {  
1283 - $arr['list'][$key]['tablename'] = '';  
1284 - //如果存了桌子的信息则,直接返回桌子信息,否则去桌位表查  
1285 - if($value['tableinfo']!=NULL){  
1286 - $tableArr = json_decode($value['tableinfo'],true);  
1287 - if(is_array($tableArr)){  
1288 - foreach ($tableArr as $tkey => $tvalue) {  
1289 - $arr['list'][$key]['tablename'] .= $tvalue['name'].'、';  
1290 - }  
1291 - }  
1292 - }  
1293 - /**else{  
1294 - foreach ($value['tid'] as $k => $v) {  
1295 - //$rs[$key]['name'][] = Db::query("SELECT name FROM `xt-member-two-LINE`.xt_dc_seller_table where id = ".$v);  
1296 - }  
1297 - }**/  
1298 - }  
1299 -  
1300 - //excel 导出  
1301 - if($data['export']){  
1302 - return $result = [  
1303 - 'code'=>0,'msg'=>'获取成功!',  
1304 - 'data'=>$arr['list'],  
1305 - 'count'=>$arr['total'],  
1306 - 'rel'=>1  
1307 - ];  
1308 - //加载PHPExcle类库  
1309 - $DOCUMENT_ROOT = str_replace('public','',$_SERVER['DOCUMENT_ROOT']);  
1310 - require_once $DOCUMENT_ROOT.'vendor/Classes/PHPExcel.php';  
1311 - require_once $DOCUMENT_ROOT.'vendor/Classes/PHPExcel/IOFactory.php';  
1312 -  
1313 - //实例化PHPExcel类  
1314 - $objPHPExcel = new \PHPExcel();  
1315 - //激活当前的sheet表  
1316 - $objPHPExcel->setActiveSheetIndex(0);  
1317 - //设置表格头(即excel表格的第一行)  
1318 - $objPHPExcel->setActiveSheetIndex(0)  
1319 - ->setCellValue('A1', '订单编号')  
1320 - ->setCellValue('B1', '所属商家')  
1321 - ->setCellValue('C1', '商家电话')  
1322 - ->setCellValue('D1', '到店时间')  
1323 - ->setCellValue('E1', '包间名称')  
1324 - ->setCellValue('F1', '包间需求')  
1325 - ->setCellValue('G1', '客户信息')  
1326 - ->setCellValue('H1', '备注')  
1327 - ->setCellValue('I1', '下单时间')  
1328 - ->setCellValue('J1', '商家设备')  
1329 - ->setCellValue('K1', '消息送达时间')  
1330 - ->setCellValue('L1', '处理时间')  
1331 - ->setCellValue('M1', '状态');  
1332 - //设置A列水平居中  
1333 - $objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment()  
1334 - ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);  
1335 - //设置单元格宽度  
1336 - //循环刚取出来的数组,将数据逐一添加到excel表格。  
1337 - $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(10);  
1338 - $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setWidth(20);  
1339 - $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20);  
1340 - $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(30);  
1341 -  
1342 - for($i=0;$i<count($arr['list']);$i++){  
1343 - $objPHPExcel->getActiveSheet()->setCellValue('A'.($i+2),$list[$i]['id']);//订单编号  
1344 - $objPHPExcel->getActiveSheet()->setCellValue('B'.($i+2),$list[$i]['sellername']);//所属商家  
1345 - $objPHPExcel->getActiveSheet()->setCellValue('C'.($i+2),$list[$i]['seller_tel']);//商家电话  
1346 - $objPHPExcel->getActiveSheet()->setCellValue('D'.($i+2),$list[$i]['ddate']);//到店时间  
1347 - $objPHPExcel->getActiveSheet()->setCellValue('E'.($i+2),$list[$i]['tablename']);//包间名称  
1348 - $objPHPExcel->getActiveSheet()->setCellValue('F'.($i+2),$list[$i]['room_demand']);//包间需求  
1349 - $objPHPExcel->getActiveSheet()->setCellValue('G'.($i+2),$list[$i]['rname']);//客户信息  
1350 - $objPHPExcel->getActiveSheet()->setCellValue('H'.($i+2),$list[$i]['cusdem']);//备注  
1351 - $objPHPExcel->getActiveSheet()->setCellValue('I'.($i+2),$list[$i]['cdate']);//下单时间  
1352 - $objPHPExcel->getActiveSheet()->setCellValue('J'.($i+2),$list[$i]['dv']);//商家设备  
1353 - $objPHPExcel->getActiveSheet()->setCellValue('K'.($i+2),$list[$i]['rec_date']);//消息送达时间  
1354 - $objPHPExcel->getActiveSheet()->setCellValue('L'.($i+2),$list[$i]['handle_time']);//处理时间  
1355 - $objPHPExcel->getActiveSheet()->setCellValue('M'.($i+2),$list[$i]['sta']);//状态  
1356 - }  
1357 - //设置保存的Excel表格名称  
1358 - $filename = '预定订单数据'.date('ymd',time()).'.xls';  
1359 - //8.设置当前激活的sheet表格名称;  
1360 - $objPHPExcel->getActiveSheet()->setTitle('订单内容');  
1361 - //设置浏览器窗口下载表格  
1362 - header("Content-Type: application/force-download");  
1363 - header("Content-Type: application/octet-stream");  
1364 - header("Content-Type: application/download");  
1365 - header('Content-Disposition:inline;filename="'.$filename.'"');  
1366 - header("Pragma: no-cache");  
1367 - //生成excel文件  
1368 - $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');  
1369 - //下载文件在浏览器窗口  
1370 - $objWriter->save('php://output');  
1371 - exit;  
1372 - }  
1373 - //print_r($arr['list']);die;  
1374 - return $result = [  
1375 - 'code'=>0,'msg'=>'获取成功!',  
1376 - 'data'=>$arr['list'],  
1377 - 'count'=>$arr['total'],  
1378 - 'rel'=>1  
1379 - ];  
1380 - }  
1381 - $this->assign ( 'title','订单管理');  
1382 - return $this->fetch();  
1383 - }  
1384 -  
1385 - /**  
1386 - * 商家详情  
1387 - */  
1388 - public function reservedetail(){  
1389 - $data = Request::except('file');  
1390 - $rs = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_cancel where up_rid = ".$data['rid']." order by cdate desc");  
1391 - if($rs){ 227 + ".$where." order by s.sid".$limit);
  228 + //格式化数据
1392 foreach ($rs as $key => $value) { 229 foreach ($rs as $key => $value) {
1393 - if($this->isjson_str($value['desc'])){  
1394 - $rs[$key]['desc'] = "diff";  
1395 - }  
1396 - switch ($value['action_type']) { 230 + $rs[$key]['create_time'] = date("Y年m月d日",$value['create_time']);
  231 + switch ($value['status']) {
1397 case '1': 232 case '1':
1398 - $rs[$key]['action_type'] = '取消预定'; 233 + $rs[$key]['status_msg'] = '已投放';
1399 break; 234 break;
1400 case '2': 235 case '2':
1401 - $rs[$key]['action_type'] = '修改预定'; 236 + $rs[$key]['status_msg'] = '未投放';
1402 break; 237 break;
1403 case '3': 238 case '3':
1404 - $rs[$key]['action_type'] = '变更客户经理';  
1405 - break;  
1406 - case '4':  
1407 - $rs[$key]['action_type'] = '确认用户到店';  
1408 - break;  
1409 - case '5':  
1410 - $rs[$key]['action_type'] = '分配包间';  
1411 - break;  
1412 - case '6':  
1413 - $rs[$key]['action_type'] = '拒绝接单'; 239 + $rs[$key]['status_msg'] = '停止投放';
1414 break; 240 break;
1415 default: 241 default:
1416 # code... 242 # code...
1417 break; 243 break;
1418 } 244 }
1419 - $rs[$key]['cdate'] = date("Y年m月d日 H时i分",$value['cdate']);  
1420 } 245 }
  246 +
  247 + //获取总条数
  248 + $total = Db::query("SELECT
  249 + s.id
  250 + FROM
  251 + `xt-member-two-LINE`.xt_dc_dz_card_info AS s
  252 + LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS re ON re.sid = s.id
  253 + WHERE
  254 + ".$where."");
  255 + return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$rs,'count'=>count($total),'rel'=>1];
1421 } 256 }
1422 - //订单详情  
1423 - $detail = Db::query("SELECT  
1424 - r.*,  
1425 - s.sellername  
1426 - FROM  
1427 - `xt-member-two-LINE`.xt_dc_reserve AS r  
1428 - LEFT JOIN `xt-member-two-LINE`.xt_seller AS s ON r.sid = s.id  
1429 - WHERE  
1430 - r.id = ".$data['rid']);  
1431 - switch ($detail[0]['channel']) {  
1432 - case 1:  
1433 - $detail[0]['channel'] = '微信小程序';  
1434 - break;  
1435 - case 2:  
1436 - $detail[0]['channel'] = '电话机';  
1437 - break;  
1438 - case 3:  
1439 - $detail[0]['channel'] = '安卓手机客户端';  
1440 - break;  
1441 - case 4:  
1442 - $detail[0]['channel'] = 'C端';  
1443 - break;  
1444 - default:  
1445 - # code...  
1446 - break;  
1447 - }  
1448 - switch ($detail[0]['sex']) {  
1449 - case 1:  
1450 - $detail[0]['sex'] = '先生';  
1451 - break;  
1452 - case 2:  
1453 - $detail[0]['sex'] = '女士';  
1454 - break;  
1455 - case 3:  
1456 - $detail[0]['sex'] = '公司';  
1457 - break;  
1458 - default:  
1459 - # code...  
1460 - break;  
1461 - }  
1462 - $this->assign ( 'html',$detail[0]);  
1463 - $this->assign ( 'rid',$data['rid']);  
1464 - $this->assign ( 'data',$rs);  
1465 - $this->assign ( 'title','订单操作日志详情'); 257 + $this->assign ( 'title','商家卡券');
1466 return $this->fetch(); 258 return $this->fetch();
1467 } 259 }
1468 260
1469 - public function isjson_str($data='',$assoc = false){  
1470 - $data = json_decode($data,$assoc);  
1471 - if(($data&&is_object($data))||(is_array($data)&&!empty($data))){  
1472 - return true;  
1473 - }  
1474 - return false;  
1475 - }  
1476 /** 261 /**
1477 - * 状态设置 262 + * 商家卡券-卡券投放- 停止投放
1478 */ 263 */
1479 - public function setReserveStatus(){  
1480 - 264 + public function cardstop(){
1481 if(Request::isAjax()){ 265 if(Request::isAjax()){
1482 $data = Request::except('file'); 266 $data = Request::except('file');
1483 -  
1484 - $data['cause'] = json_encode(array('uid'=>-1,'uname'=>session('username'),'desc'=>$data['cause']));  
1485 -  
1486 - $list= file_get_contents(ON_LINE.'App.Reserve.SetReserveStatus&rid='.$data['id'].'&status='.$data['status'].'&cause='.$data['cause']);  
1487 -  
1488 - $array = json_decode($list,TRUE);  
1489 - if($array['ret']==200){ 267 + $ups = Db::query("UPDATE `xt-member-two-LINE`.xt_dc_dz_card_info set status = 3 where id = ".$data['id']);
  268 + if(!$ups){
1490 $result['code'] = 1; 269 $result['code'] = 1;
1491 - $result['msg'] = 'SUCCESS!'; 270 + $result['msg'] = '该卡券已停止投放!';
1492 }else{ 271 }else{
1493 $result['code'] = 0; 272 $result['code'] = 0;
1494 - $result['msg'] = '请求错误!'; 273 + $result['msg'] = '请求错误,请联系管理员!';
1495 } 274 }
1496 return $result; 275 return $result;
1497 } 276 }
@@ -1499,175 +278,67 @@ class Card extends Common @@ -1499,175 +278,67 @@ class Card extends Common
1499 } 278 }
1500 279
1501 /** 280 /**
1502 - * 状态设置 281 + * 商家卡券-卡券投放- 投放-弹层
1503 */ 282 */
1504 - public function devicelists(){  
1505 - $facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");  
1506 - $this->assign ( 'facturer',$facturer);  
1507 - if(Request::isAjax()){  
1508 - $data = Request::except('file');  
1509 - $channel = @$data['channel'] ? @$data['channel'] : 1;  
1510 - $manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;  
1511 - 283 + public function cardputin(){
  284 + $id = Request::except('file');
  285 + if(request()->isPost()){
  286 + $data = input('post.');
1512 287
1513 - $page = ($data['page']-1)*$data['limit']; 288 + //商家基本数据
  289 + $end_time = Db::query("SELECT
  290 + end_time
  291 + FROM
  292 + `xt-member-two-LINE`.xt_dc_dz_card_info
  293 + WHERE id=".$data['cid']);
1514 294
1515 - $__Where = ' 1=1'; 295 + $arr = [];
  296 + $time = $data['date'] ? explode(' - ', $data['date']) : '';
  297 + $arr['receive_start_time'] = $time ? strtotime(date($time[0],time())) : '';
  298 + $arr['receive_end_time'] = $time ? strtotime(date($time[1],time())) : '';
  299 + $arr['total_limit'] = $data['total_limit']=='on' ? 1 : 0;
  300 + $arr['total'] = $data['total'] ? intval($data['total']) : 0;
  301 + $arr['receive_condition'] = $data['receive_condition'] ? intval($data['receive_condition']) : 0;
  302 + $arr['order_price'] = $data['order_price'] ? $data['order_price'] : 0;
  303 + $arr['contributor'] = $_SESSION['think']['username'];
  304 + $arr['contributor_time'] = time();
  305 + $arr['status'] = 1;
1516 306
1517 - $__Where .= @$data['key'] ? " and s.sellername like '%".$data['key']."%'" : "";  
1518 307
1519 - switch ($manufacturer) {  
1520 - case '1':  
1521 - $__Where .= ' and sta.type in (0,1)';  
1522 - break;  
1523 - case '-1':  
1524 - $__Where .= ' ';  
1525 - break;  
1526 - default:  
1527 - $__Where .= ' and sta.type = '.$manufacturer;  
1528 - break;  
1529 - }  
1530 -  
1531 - if($channel && $channel!=-1) {  
1532 - $__Where .= ' and rel.type_id='. $channel;  
1533 - }else{  
1534 - $__Where .= ""; 308 + if($end_time[0]['end_time'] < $arr['receive_end_time']){
  309 + $result['code'] = 0;
  310 + $result['msg'] = '领取期限必须在卡券有效期内!';
  311 + return $result;
1535 } 312 }
1536 313
1537 - $total = Db::query("SELECT  
1538 - count(1) as total  
1539 - FROM  
1540 - `xt-member-two-LINE`.xt_dc_dz_seller_app_dv AS sta  
1541 - LEFT JOIN `xt-member-two-LINE`.xt_seller AS s ON sta.sid = s.id  
1542 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS rel ON sta.sid = rel.sid  
1543 - WHERE  
1544 - $__Where");  
1545 - $list = Db::query("SELECT  
1546 - s.sellername,  
1547 - rel.type_id,  
1548 - sta.*  
1549 - FROM  
1550 - `xt-member-two-LINE`.xt_dc_dz_seller_app_dv AS sta  
1551 - LEFT JOIN `xt-member-two-LINE`.xt_seller AS s ON sta.sid = s.id  
1552 - LEFT JOIN `xt-member-two-LINE`.xt_dc_dz_seller_type_rel AS rel ON sta.sid = rel.sid  
1553 - WHERE  
1554 - $__Where  
1555 - ORDER BY  
1556 - sta.sid  
1557 - LIMIT $page,".$data['limit']);  
1558 - foreach ($list as $key => $value) {  
1559 -  
1560 - //$list[$key]['call_jump_page'] = $value['call_jump_page'] == 1 ? "订座页面" : "桌位页面";  
1561 -  
1562 - switch ($value['type']) {  
1563 - case '0':  
1564 - $list[$key]['type'] = $facturer[0]['facturer'];  
1565 - break;  
1566 - case '1':  
1567 - $list[$key]['type'] = $facturer[0]['facturer'];  
1568 - break;  
1569 - case '2':  
1570 - $list[$key]['type'] = $facturer[1]['facturer'];  
1571 - break;  
1572 - case '3':  
1573 - $list[$key]['type'] = $facturer[2]['facturer'];  
1574 - break;  
1575 - case '4':  
1576 - $list[$key]['type'] = $facturer[3]['facturer'];  
1577 - break;  
1578 -  
1579 - default:  
1580 - $list[$key]['type'] = 'error: '.$value['type'];  
1581 - break;  
1582 - }  
1583 - 314 + $sql = "UPDATE `xt-member-two-LINE`.xt_dc_dz_card_info SET ";
  315 + foreach ($arr as $key=>$val){
  316 + $sql .= "".$key."='".$val."',";
1584 } 317 }
1585 - return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$list,'count'=>$total[0]['total'],'rel'=>1];  
1586 - }  
1587 - $this->assign ( 'title','设备列表');  
1588 - return $this->fetch();  
1589 - } 318 + $sql = substr( $sql,0, strlen($sql)-1 );
  319 + $sql .= ' where id = '.$data['cid'];
1590 320
1591 - /**  
1592 - * 商家基础信息配置  
1593 - */  
1594 - public function upcalljumppage(){  
1595 - if(Request::isAjax()){  
1596 - $data = Request::except('file');  
1597 - $list= file_get_contents(ON_LINE.'Android.Device.UpDeviceCallJumpPage&device='.$data['device'].'&field='.'&status='.$data['status']);  
1598 - $array = json_decode($list,TRUE);  
1599 - if($array['ret']==200){ 321 + $ups = Db::query($sql);
  322 + if(!$ups){
1600 $result['code'] = 1; 323 $result['code'] = 1;
1601 - $result['msg'] = 'SUCCESS!'; 324 + $result['msg'] = '已成功投放!';
1602 }else{ 325 }else{
1603 $result['code'] = 0; 326 $result['code'] = 0;
1604 - $result['msg'] = '请求错误!'; 327 + $result['msg'] = '请求错误,请联系管理员!';
1605 } 328 }
1606 return $result; 329 return $result;
1607 } 330 }
1608 - return view();  
1609 - }  
1610 -  
1611 - /*  
1612 - * 商家短信充值查询  
1613 - */  
1614 - public function getsellersmslist(){  
1615 -  
1616 - if(Request::isAjax()){  
1617 - $data = Request::except('file');  
1618 -  
1619 - $time = (isset($data['time']) && !empty($data['time'])) ? explode(' - ',$data['time']) : (strtotime(date("Y-m-d 00:00:00")).'-'.strtotime(date("Y-m-d 23:59:59")));  
1620 -  
1621 - $newtime = is_array($time) ? (strtotime(date($time[0])).'-'.strtotime(date($time[1]))) : $time;  
1622 -  
1623 - $channel = (!isset($data['time'])) ? 1 : $data['channel'];  
1624 -  
1625 - $name = (!isset($data['time'])) ? '' : $data['key'];  
1626 -  
1627 - $url= ON_LINE.'App.Seller.QuerySelllerSmsList&offset='.$data['page'].'&size='.$data['limit'].'&time='.$newtime.'&channel='.$channel.'&name='.$name;  
1628 -  
1629 - $list = $this->curl_get($url);  
1630 -  
1631 - $array = json_decode($list,TRUE);  
1632 -  
1633 - if($array){  
1634 - foreach ($array['data']['list'] as $key => $value) {  
1635 - $array['data']['list'][$key]['bdate'] = date("Y年m月d日 H时i分s秒",$value['bdate']);  
1636 - $array['data']['list'][$key]['paystatus'] = $value['paystatus']==1 ? '成功' : '失败';  
1637 - $array['data']['list'][$key]['channel'] = $value['channel']==NULL ? '小程序' : $value['channel'];  
1638 - $array['data']['list'][$key]['package_name'] = $value['package_name']=='other' ? '其他' : $value['package_name'];  
1639 - }  
1640 - return $result = [  
1641 - 'code'=>0,'msg'=>'获取成功!',  
1642 - 'data'=>$array['data']['list'],  
1643 - 'count'=>$array['data']['total'],  
1644 - 'rel'=>1  
1645 - ];  
1646 - }else{  
1647 - $result['code'] = 0;  
1648 - $result['msg'] = '请求错误!';  
1649 - }  
1650 - return $result;  
1651 - }  
1652 - return view();  
1653 - }  
1654 -  
1655 - /**  
1656 - * post  
1657 - */  
1658 - public function curl_get($url)  
1659 - {  
1660 -  
1661 - $info = curl_init();  
1662 - curl_setopt($info,CURLOPT_RETURNTRANSFER,true);  
1663 - curl_setopt($info,CURLOPT_HEADER,0);  
1664 - curl_setopt($info,CURLOPT_NOBODY,0);  
1665 - curl_setopt($info,CURLOPT_SSL_VERIFYPEER,false);  
1666 - curl_setopt($info,CURLOPT_SSL_VERIFYPEER,false);  
1667 - curl_setopt($info,CURLOPT_SSL_VERIFYHOST,false);  
1668 - curl_setopt($info,CURLOPT_URL,$url);  
1669 - $output = curl_exec($info);  
1670 - curl_close($info);  
1671 - return $output; 331 + //商家基本数据
  332 + $rs = Db::query("SELECT
  333 + id,
  334 + sellername,
  335 + card_title,
  336 + end_time
  337 + FROM
  338 + `xt-member-two-LINE`.xt_dc_dz_card_info
  339 + WHERE id=".$id['id']);
  340 + $this->assign ( 'rs',$rs[0]);
  341 + $this->assign ( 'title','卡券投放');
  342 + return $this->fetch();
1672 } 343 }
1673 } 344 }
@@ -51,11 +51,44 @@ @@ -51,11 +51,44 @@
51 </div> 51 </div>
52 {if $rs.status neq 2} 52 {if $rs.status neq 2}
53 <div class="layui-form-item"> 53 <div class="layui-form-item">
54 - <div class="layui-inline">  
55 - <label class="layui-form-label">领取期限</label>  
56 - <div class="layui-input-inline" style="width: 300px;">  
57 - <input type="text" name="date" id="date" class="layui-input" disabled="disabled" value="{$rs.start_time} - {$rs.end_time}"> 54 + <div class="layui-inline">
  55 + <label class="layui-form-label">领取期限</label>
  56 + <div class="layui-input-inline" style="width: 300px;">
  57 + <input type="text" name="date" id="date" value="{$rs.receive_start_time} 到 {$rs.receive_end_time}" disabled="disabled" class="layui-input">
58 </div> 58 </div>
  59 + <div class="layui-form-mid layui-word-aux">该期间内可以领取</div>
  60 + </div>
  61 + </div>
  62 +
  63 + <div class="layui-form-item">
  64 + <div class="layui-inline">
  65 + <label class="layui-form-label">总数限制</label>
  66 + <div class="layui-input-inline" style="width: 100px;">
  67 + <input type="checkbox" name="total_limit" title="是否限制" {if $rs.total_limit eq 1} checked=""{/if} disabled="disabled" lay-skin="primary">
  68 + </div>
  69 + <ii id="li_total">
  70 + <div class="layui-form-mid layui-word-aux">红包总数达到</div>
  71 + <div class="layui-input-inline" style="width: 100px;">
  72 + <input type="text" name="total" id="total" class="layui-input" value="{$rs.total}" disabled="disabled">
  73 + </div>
  74 + <div class="layui-form-mid layui-word-aux">个时,停止发放</div>
  75 + </ii>
  76 + </div>
  77 + </div>
  78 +
  79 + <div class="layui-form-item">
  80 + <label class="layui-form-label">领取条件</label>
  81 + <div class="layui-input-block">
  82 + <input type="radio" disabled="disabled" name="receive_condition" lay-filter="receive_condition" value="1" title="打开店铺页面时,如果顾客没有该卡券,自动发放" {if $rs.receive_condition eq 1} checked=""{/if}><br>
  83 + <input type="radio" disabled="disabled" name="receive_condition" lay-filter="receive_condition" value="2" title="完成订单支付后,支付订单金额达到:" {if $rs.receive_condition eq 2} checked=""{/if}>
  84 + <input type="text" name="order_price" id="order_price" style="width: 100px;" value="{$rs.order_price}" disabled="disabled" class="layui-input">元时,自动发放
  85 + </div>
  86 + </div>
  87 +
  88 + <div class="layui-form-item">
  89 + <label class="layui-form-label">核销方式</label>
  90 + <div class="layui-input-inline" style="width: 500px;">
  91 + <div class="layui-form-mid layui-word-aux">用户在支付订单时,选择使用该卡券支付后,自动核销</div>
59 </div> 92 </div>
60 </div> 93 </div>
61 {/if} 94 {/if}
  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>{:$title}</legend>
  5 + </fieldset>
  6 + <blockquote class="layui-elem-quote">
  7 + <a href="{:url('card/sellercard')}" class="layui-btn layui-btn-lg">
  8 + <i class="fa fa-file-image-o"></i> 优惠券
  9 + </a>
  10 + <a href="{:url('card/cardput')}" class="layui-btn layui-btn-lg layui-btn-danger">
  11 + <i class="fa fa-file-image-o"></i> 卡券投放
  12 + </a>
  13 + <a href="{:url('card/cardwriteoff')}" class="layui-btn layui-btn-lg">
  14 + <i class="fa fa-file-image-o"></i> 卡券核销
  15 + </a>
  16 + <a href="{:url('card/carddata')}" class="layui-btn layui-btn-lg">
  17 + <i class="fa fa-file-image-o"></i> 数据统计
  18 + </a>
  19 + </blockquote>
  20 +
  21 + <div class="demoTable">
  22 + 商家名称:<div class="layui-inline">
  23 + <input class="layui-input" name="key" id="key" placeholder="{:lang('pleaseEnter')}店铺名称" autocomplete="off">
  24 + </div>
  25 + 商家来源:
  26 + <div class="layui-input-inline layui-form">
  27 + <div class="layui-input-8">
  28 + <select name="class" id="channel" lay-filter="myselect">
  29 + <option value="4">全部</option>
  30 + <option value="1" selected>合作</option>
  31 + <option value="2">推广</option>
  32 + <option value="3">测试</option>
  33 + </select>
  34 + </div>
  35 + </div>
  36 + <button class="layui-btn" id="search" data-type="reload">搜索</button>
  37 + </div>
  38 + <table class="layui-table" id="list" lay-filter="list"></table>
  39 +</div>
  40 +{include file="common/foot"/}
  41 +
  42 +<script type="text/html" id="action">
  43 + {{#if(d.status==1){}}
  44 + <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="stop">停止投放</a>
  45 + {{#} else if(d.status==2) {}} 
  46 + <a class="layui-btn layui-btn-xs" lay-event="putin">投放</a>
  47 + {{#} else {}} 
  48 + 暂无操作
  49 + {{#}}}
  50 +</script>
  51 +
  52 +<script>
  53 + layui.use(['table','form','laydate'], function() {
  54 + var table = layui.table,laydate = layui.laydate,form = layui.form,$ = layui.jquery,layer = layui.layer;
  55 + var tableIn = table.render({
  56 + elem: '#list',
  57 + url: '{:url("cardput")}',
  58 + method: 'post',
  59 + title: '卡券列表',
  60 + cols: [[
  61 + {field: 'id', title: '商家卡券编号',hide:true, fixed: true},
  62 + {field: 'sid', title: '商家编号', fixed: true},
  63 + {field: 'sellername', title: '商家名称'},
  64 + {field: 'card_title', title: '卡券名称'},
  65 + {field: 'price', align: 'center',title: '金额'},
  66 + {field: 'contributor_time', align: 'center', title: '投放日期'},
  67 + {field: 'contributor', align: 'center', title: '投放人'},
  68 + {field: 'status_msg', align: 'center',title: '状态'},
  69 + {align: 'center', width:200,title: '操作', toolbar: '#action'}
  70 + ]]
  71 + ,id: 'cardReload'
  72 + ,page: true
  73 + });
  74 +
  75 + //监听行双击事件
  76 + table.on('rowDouble(list)', function(obj){
  77 + //table.on('row(list)', function(obj){ 双击事件
  78 + //console.log(obj.tr) //得到当前行元素对象
  79 + console.log(obj.data) //得到当前行数据
  80 + layer.open({
  81 + type: 2,
  82 + title: obj.data.sellername,
  83 + shadeClose: true,
  84 + shade: 0.8,
  85 + area: ['90%', '90%'],
  86 + content: '{:url("carddetail")}?id='+obj.data.id //iframe的url
  87 + /*success:function(dom){
  88 + let $iframeDom=$(dom[0]).find("iframe").eq(0).contents();
  89 + $iframeDom.find("#test").html("我是从父级传来的值哟……")
  90 + }*/
  91 + });
  92 + });
  93 +
  94 + //搜索
  95 + $('#search').on('click', function() {
  96 + //关键字
  97 + var key = $('#key').val();
  98 + var channel = $('#channel').val();
  99 + //传参
  100 + tableIn.reload({ page: {page: 1},where: {key: key,channel: channel}});
  101 + });
  102 +
  103 + var $ = layui.$, active = {
  104 + reload: function(){
  105 + var channel = $('#channel');
  106 + var key = $('#key');
  107 + //执行重载
  108 + table.reload('cardReload', {
  109 + page: {
  110 + curr: 1 //重新从第 1 页开始
  111 + }
  112 + ,where: {
  113 + key: {
  114 + id: key.val(),
  115 + channel: channel.val()
  116 + }
  117 + }
  118 + });
  119 + }
  120 + };
  121 +
  122 + //停止投放、投放
  123 + table.on('tool(list)', function(obj){
  124 + var data = obj.data;
  125 + //停止投放
  126 + if(obj.event === 'stop'){
  127 + layer.confirm('确认要停止发放这个红包吗? 停止后,用户将不能在领取这个红包,已经领取的可以在有效期内继续消费。', function(index){
  128 + $.post("{:url('cardstop')}",{id:data.id},function(res){
  129 + if(res.code==1){
  130 + layer.msg(res.msg,{time:1000,icon:1});
  131 + location.reload();
  132 + }else{
  133 + layer.msg(res.msg,{time:1000,icon:2});
  134 + }
  135 + });
  136 + layer.close(index);
  137 + });
  138 + }
  139 + //投放
  140 + if(obj.event === 'putin'){
  141 + layer.open({
  142 + type: 2,
  143 + title: '投放卡券',
  144 + shadeClose: true,
  145 + shade: 0.8,
  146 + area: ['90%', '90%'],
  147 + content: '{:url("cardputin")}?id='+obj.data.id //iframe的url
  148 + /*success:function(dom){
  149 + let $iframeDom=$(dom[0]).find("iframe").eq(0).contents();
  150 + $iframeDom.find("#test").html("我是从父级传来的值哟……")
  151 + }*/
  152 + });
  153 + }
  154 + });
  155 + })
  156 +</script>
  1 +{include file="common/head"/}
  2 +<div class="admin-main layui-anim layui-anim-upbit">
  3 + <title>{:$title}</title>
  4 + <blockquote class="layui-elem-quote">
  5 + <h1> {:$title} </h1>
  6 + </blockquote>
  7 + <form class="layui-form layui-form-pane" action="">
  8 + <input type="hidden" name="cid" value="{$rs.id}">
  9 + <div class="layui-form-item">
  10 + <label class="layui-form-label">商家名称</label>
  11 + <div class="layui-input-block">
  12 + <input type="text" name="title" disabled="disabled" class="layui-input" value="{$rs.sellername}">
  13 + </div>
  14 + </div>
  15 +
  16 + <div class="layui-form-item">
  17 + <label class="layui-form-label">卡券名称</label>
  18 + <div class="layui-input-inline">
  19 + <input type="text" name="username" disabled="disabled" class="layui-input" value="{$rs.card_title}">
  20 + </div>
  21 + </div>
  22 +
  23 + <hr/>
  24 +
  25 + <div class="layui-form-item">
  26 + <div class="layui-inline">
  27 + <label class="layui-form-label">领取期限</label>
  28 + <div class="layui-input-inline" style="width: 300px;">
  29 + <input type="text" name="date" id="date" lay-verify="required" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
  30 + </div>
  31 + <div class="layui-form-mid layui-word-aux">该期间内可以领取</div>
  32 + </div>
  33 + </div>
  34 +
  35 + <div class="layui-form-item">
  36 + <div class="layui-inline">
  37 + <label class="layui-form-label">总数限制</label>
  38 + <div class="layui-input-inline" style="width: 100px;">
  39 + <input type="checkbox" name="total_limit" title="是否限制" lay-filter="total_limit" lay-skin="primary">
  40 + </div>
  41 + <ii id="li_total" style="display:none">
  42 + <div class="layui-form-mid layui-word-aux">红包总数达到</div>
  43 + <div class="layui-input-inline" style="width: 100px;">
  44 + <input type="text" name="total" id="total" class="layui-input">
  45 + </div>
  46 + <div class="layui-form-mid layui-word-aux">个时,停止发放</div>
  47 + </ii>
  48 + </div>
  49 + </div>
  50 +
  51 + <div class="layui-form-item">
  52 + <label class="layui-form-label">领取条件</label>
  53 + <div class="layui-input-block">
  54 + <input type="radio" name="receive_condition" lay-filter="receive_condition" value="1" title="打开店铺页面时,如果顾客没有该卡券,自动发放" checked=""><br>
  55 + <input type="radio" name="receive_condition" lay-filter="receive_condition" value="2" title="完成订单支付后,支付订单金额达到:">
  56 + <input type="text" name="order_price" id="order_price" style="width: 100px;" class="layui-input">元时,自动发放
  57 + </div>
  58 + </div>
  59 +
  60 + <div class="layui-form-item">
  61 + <label class="layui-form-label">核销方式</label>
  62 + <div class="layui-input-inline" style="width: 500px;">
  63 + <div class="layui-form-mid layui-word-aux">用户在支付订单时,选择使用该卡券支付后,自动核销</div>
  64 + </div>
  65 + </div>
  66 +
  67 + <div class="layui-form-item">
  68 + <div class="layui-input-block">
  69 + <button type="button" class="layui-btn" lay-submit="" lay-filter="submit_add_card">确认投放</button>
  70 + <button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
  71 + </div>
  72 + </div>
  73 + </form>
  74 +</div>
  75 +{include file="common/foot"/}
  76 +
  77 +<script>
  78 + layui.use(['table','form','element','laydate'], function() {
  79 + var table = layui.table,laydate = layui.laydate,form = layui.form,$ = layui.jquery,layer = layui.layer,element = layui.element;
  80 +
  81 + //更新该卡券信息
  82 + form.on('submit(submit_add_card)', function (data) {
  83 + var loading = layer.load(1, {shade: [0.1, '#fff']});
  84 + $.post("{:url('cardputin')}", data.field, function (res) {
  85 + layer.close(loading);
  86 + if (res.code == 1) {
  87 + layer.msg(res.msg, {time: 1000, icon: 1}, function () {
  88 + window.parent.location.reload();
  89 + });
  90 + } else {
  91 + layer.msg(res.msg, {time: 1000, icon: 2});
  92 + }
  93 + });
  94 + })
  95 +
  96 + //复选框事件
  97 + form.on('checkbox(total_limit)', function (data) {
  98 + layer.tips((this.checked ? '限制总数' : '不限制总数'), data.othis);
  99 + if(this.checked){
  100 + $("#li_total").show();
  101 + $("#total").attr("lay-verify","required");
  102 + }else{
  103 + $("#li_total").hide();
  104 + $("#total").val('');
  105 + $("#total").attr("lay-verify","");
  106 + }
  107 + });
  108 +
  109 + //单选按钮事件
  110 + form.on('radio(receive_condition)', function(data){
  111 + var msg = data.value==1 ? '自动领取' : "完成支付领取";
  112 + layer.tips((msg), data.othis);
  113 + if(data.value==1){
  114 + $("#order_price").val('');
  115 + $("#order_price").attr("lay-verify","");
  116 + }else{
  117 + $("#order_price").attr("lay-verify","required");
  118 + }
  119 + });
  120 +
  121 + //日期时间范围
  122 + laydate.render({
  123 + elem: '#date'
  124 + ,type: 'datetime'
  125 + ,range: true
  126 + });
  127 + })
  128 +</script>
@@ -4,16 +4,16 @@ @@ -4,16 +4,16 @@
4 <legend>{:$title}</legend> 4 <legend>{:$title}</legend>
5 </fieldset> 5 </fieldset>
6 <blockquote class="layui-elem-quote"> 6 <blockquote class="layui-elem-quote">
7 - <a href="{:url('Seller/sellerList')}" class="layui-btn layui-btn-lg layui-btn-danger"> 7 + <a href="{:url('card/sellercard')}" class="layui-btn layui-btn-lg layui-btn-danger">
8 <i class="fa fa-file-image-o"></i> 优惠券 8 <i class="fa fa-file-image-o"></i> 优惠券
9 </a> 9 </a>
10 - <a href="{:url('Template/uploadFile')}" class="layui-btn layui-btn-lg"> 10 + <a href="{:url('card/cardput')}" class="layui-btn layui-btn-lg">
11 <i class="fa fa-file-image-o"></i> 卡券投放 11 <i class="fa fa-file-image-o"></i> 卡券投放
12 </a> 12 </a>
13 - <a href="{:url('Template/Vegetable')}" class="layui-btn layui-btn-lg"> 13 + <a href="{:url('card/cardwriteoff')}" class="layui-btn layui-btn-lg">
14 <i class="fa fa-file-image-o"></i> 卡券核销 14 <i class="fa fa-file-image-o"></i> 卡券核销
15 </a> 15 </a>
16 - <a href="{:url('Template/Vegetable')}" class="layui-btn layui-btn-lg"> 16 + <a href="{:url('card/carddata')}" class="layui-btn layui-btn-lg">
17 <i class="fa fa-file-image-o"></i> 数据统计 17 <i class="fa fa-file-image-o"></i> 数据统计
18 </a> 18 </a>
19 </blockquote> 19 </blockquote>