Seller.php
37.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
<?php
namespace app\admin\controller;
use think\Db;
use think\facade\Request;
class Seller extends Common
{
/********************************打印机管理*******************************/
/**
* 商家list
*/
public function sellerList(){
if(Request::isAjax()){
$data = Request::except('file');
$key= input('post.key') ? input('post.key') : "";
$channel = @$key['channel'] ? @$key['channel'] : 1;
$address = @$key['address'] ? @$key['address'] : '';
$prov = @$key['prov'] ? @$key['prov'] : '';
$city = @$key['city'] ? @$key['city'] : '';
$area = @$key['area'] ? @$key['area'] : '';
$limit = '&x='.$data["page"].'&y='.$data["limit"].'&keywords='.@$key['id'].'&channel='.$channel.'&address='.$address.'&prov='.$prov.'&city='.$city.'&area='.$area;
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Seller.GetSellerList'.$limit);
$array = json_decode($list,TRUE);
foreach ($array['data'][0]['data'] as $key => $value) {
$array['data'][0]['data'][$key]['cdate'] = date("Y-m-d H:i:s",$value['cdate']);
if($value['status']==1)
$array['data'][0]['data'][$key]['statusVal'] = "启用";
else
$array['data'][0]['data'][$key]['statusVal'] = "停用";
$c_name = array();
$t_name = array();
//2019-03-05 增加菜系配置、商家类型配置
if(is_array($value['cuisine'])){
foreach ($value['cuisine'] as $k => $v) {
$c_name[] = $v['name'];
}
}
if(is_array($value['type'])){
foreach ($value['type'] as $k => $v) {
$t_name[] = $v['type_name'];
}
}
if(!empty($c_name))
$array['data'][0]['data'][$key]['cuisine'] = implode(',', $c_name);
if(!empty($t_name))
$array['data'][0]['data'][$key]['type'] = implode(',', $t_name);
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data'][0]['data'],'count'=>$array['data'][0]['total'],'rel'=>1];
}
$this->assign ( 'title','商户基本信息维护');
return $this->fetch();
}
/**
* 停用商家
*/
public function configStop(){
if(Request::isAjax()){
$data = Request::except('file');
$data['status'] = $data['status'] ? 0 : 1;
$list= file_get_contents(ON_LINE.'App.Seller.SetStopBySeller&sellerid='.$data['sellerid'].'&status='.$data['status']);
$array = json_decode($list,TRUE);
if($array['ret']==200){
$result['code'] = 1;
$result['msg'] = 'SUCCESS!';
}else{
$result['code'] = 0;
$result['msg'] = '请求错误!';
}
return $result;
}
return view();
}
/**
* 从商家维度统计:订单、短信等情况
*/
public function getStatistics(){
if(Request::isAjax()){
$data = Request::except('file');
$key= input('post.key') ? input('post.key') : "";
$sid = $data['sid'] ? implode(',', $data['sid']) : '';
$sellername = $data['key'] ? $data['key'] : '';
$time = $data['time'] ? explode(' - ', $data['time']) : '';
$stime = $time ? strtotime(date($time[0],time())) : '';
$etime = $time ? strtotime(date($time[1],time())) : '';
$data['time_type'] = $data['time_type'] ? $data['time_type'] : 1;
$data['channel'] = $data['channel'] ? $data['channel'] : 1;
$parame = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$sellername.'&stime='.@$stime.'&etime='.@$etime.'&channel='.@$data['channel'].'&sid='.$sid.'&time_type='.@$data['time_type'];
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Report.GetReserveData'.$parame);
$array = json_decode($list,TRUE);
$new_array = array();
foreach ($array['data'] as $key => $value) {
if(is_array($value)){
$new_array[$key]['id'] = $value['id'];
$new_array[$key]['sellername'] = $value['sellername'];
$new_array[$key]['contacts_total'] = $value['contacts_total'];
$new_array[$key]['inviting'] = $value['inviting'];
$new_array[$key]['reserve_count'] = $value['appReserveCount'] .'/'. $value['AndroidReserveCount'].'/'. $value['CReserveCount'];
$new_array[$key]['reserve_count_sort'] = $value['appReserveCount'] + $value['AndroidReserveCount'] + $value['CReserveCount'];
$new_array[$key]['sms_send_count'] = $value['appSmsCount'] .'/'. $value['AndroidSmsCount'];
$new_array[$key]['sms_send_count_sort'] = $value['appSmsCount'] + $value['AndroidSmsCount'];
$new_array[$key]['table_room_total'] = $value['table_total'] .'/'. $value['room_total'];
$new_array[$key]['address_component'] = $value['address_component']['province'] && $value['address_component']['city'] ? $value['address_component']['province'] .'-'. $value['address_component']['city'] : '无法获取地区,请检查经纬度是否正确!';
}
}
return $result = [
'code'=>0,'msg'=>'获取成功!',
'data'=>$new_array,
'count'=>$array['data']['total'],
'countReserve'=>$array['data']['appReserveCount']+$array['data']['AndroidReserveCount']+$array['data']['CReserveCount'],
'countSms'=>$array['data']['appSmsCount']+$array['data']['AndroidSmsCount'],
'inviteeCount'=>$array['data']['inviteeCount'],
'appReserveCount'=>$array['data']['appReserveCount'],
'AndroidReserveCount'=>$array['data']['AndroidReserveCount'],
'CReserveCount'=>$array['data']['CReserveCount'],
'appSmsCount'=>$array['data']['appSmsCount'],
'AndroidSmsCount'=>$array['data']['AndroidSmsCount'],
'Contacts'=>$array['data']['Contacts'],
'rel'=>1
];
}
$this->assign ( 'title','预定订单统计');
return $this->fetch();
}
/**
* 从设备(电话机)维度统计:订单、短信等情况
*/
public function getEquipment(){
if(Request::isAjax()){
$data = Request::except('file');
$key= input('post.key') ? input('post.key') : "";
$sid = $data['sid'] ? implode(',', $data['sid']) : '';
$sellername = $data['key'] ? $data['key'] : '';
$time = $data['time'] ? explode(' - ', $data['time']) : '';
$stime = $time ? strtotime(date($time[0],time())) : '';
$etime = $time ? strtotime(date($time[1],time())) : '';
$data['time_type'] = $data['time_type'] ? $data['time_type'] : 1;
$data['channel'] = $data['channel'] ? $data['channel'] : 1;
$parame = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$sellername.'&stime='.@$stime.'&etime='.@$etime.'&channel='.@$data['channel'].'&sid='.$sid.'&time_type='.@$data['time_type'];
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Report.GetReserveDataBydev'.$parame);
$array = json_decode($list,TRUE);
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
}
$this->assign ( 'title','设备维度统计预定订单');
return $this->fetch();
}
/**
* 商家菜系、类型配置
*/
public function sellerconfig(){
$data = Request::except('file');
if(Request::isAjax()){
$cuisine = !empty($data['cuisine']) ? implode(',', array_keys($data['cuisine'])) : '';
$type = !empty($data['type']) ? implode(',', array_keys($data['type'])) : '';
$mode = !empty($data['mode']) ? implode(',', array_keys($data['mode'])) : '';
$sms_code = !empty($data['sms_code']) ? $data['sms_code'] : '';
$label = !empty($data['label']) ? implode(',', array_keys($data['label'])) : '';
$brand = !empty($data['brand']) ? implode(',', array_keys($data['brand'])) : '';
$label_1_ = !empty($data['label_1_']) ? implode(',', array_keys($data['label_1_'])) : '';
$label_2_ = !empty($data['label_2_']) ? implode(',', array_keys($data['label_2_'])) : '';
$label_3_ = !empty($data['label_3_']) ? implode(',', array_keys($data['label_3_'])) : '';
if($sms_code)
$res_sms_code= file_get_contents(ON_LINE.'App.SendSMS.SetSellerSmsTemplate&sid='.$data['sellerid'].'&sms_id='.$sms_code);
if($cuisine)
$res_cuisine= file_get_contents(ON_LINE.'App.Seller.SetSellerCuisine&sellerid='.$data['sellerid'].'&cid='.$cuisine);
//$res_cuisine = json_decode($res_cuisine,TRUE);
if($type)
$res_type= file_get_contents(ON_LINE.'App.Seller.SetSellerType&sellerid='.$data['sellerid'].'&typeid='.$type);
//$res_type = json_decode($res_type,TRUE);
if($mode)
$res_mode= file_get_contents(ON_LINE.'App.Seller.setSellerMode&sellerid='.$data['sellerid'].'&modeid='.$mode);
//$res_mode = json_decode($res_mode,TRUE);
if($label)
$res_label= file_get_contents(ON_LINE.'App.Seller.setSellerLabel&sid='.$data['sellerid'].'&field='.$label);
if($brand){
$del=Db::query("DELETE FROM `xt-member-two-LINE`.xt_dc_dz_seller_brand_rel WHERE sid =".$data['sellerid']);
$add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_brand_rel VALUES(".$data['sellerid'].",".$brand.")");
}
if($label_1_){
$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)");
$add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_1_.")");
}
if($label_2_){
$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)");
$add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_2_.")");
}
if($label_3_){
$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)");
$add=Db::query("INSERT INTO `xt-member-two-LINE`.xt_dc_dz_seller_label_c_rel VALUES(".$data['sellerid'].",".$label_3_.")");
}
if(isset($data['edition'])){
$up=Db::query("UPDATE `xt-member-two-LINE`.xt_seller set is_online_reserve = ".$data['edition']." where id = ".$data['sellerid']);
}
if(isset($data['is_tele'])){
$up=Db::query("UPDATE `xt-member-two-LINE`.xt_seller set is_tele = ".$data['is_tele']." where id = ".$data['sellerid']);
}
$result['code'] = 1;
$result['msg'] = "配置成功!";
return $result;
}
//获取商家已有菜系
$cuisine_list= file_get_contents(ON_LINE.'App.Seller.getSellerCuisine&sellerid='.$data['id']);
$cuisine_list = json_decode($cuisine_list,TRUE);
//获取所有菜系
$list= file_get_contents(ON_LINE.'App.Reserve.GetCustomerConfig');
$array = json_decode($list,TRUE);
//组装数据
foreach ($cuisine_list['data'] as $key => $value) {
foreach ($array['data']['cate'] as $k => $v) {
if($value['cid']==$v['id']){
$array['data']['cate'][$k]['checked'] = 1;
}
}
}
$this->assign('list',$array['data']['cate']);//获取所有菜系
//获取商家已有来源
$type_list= file_get_contents(ON_LINE.'App.Seller.GetSellerType&sellerid='.$data['id']);
$type_list = json_decode($type_list,TRUE);
//获取来源
$channel = array(array('id'=>1,'name'=>'合作'),array('id'=>2,'name'=>'推广'),array('id'=>3,'name'=>'测试'));
//组装数据
foreach ($type_list['data'] as $key => $value) {
foreach ($channel as $k => $v) {
if($value['type_id']==$v['id']){
$channel[$k]['checked'] = 1;
}
}
}
$this->assign('channel',$channel);//获取所有来源
//获取商家已有地图显示方式
$mode_list= file_get_contents(ON_LINE.'App.Seller.getSellerMode&sellerid='.$data['id']);
$mode_list = json_decode($mode_list,TRUE);
//获取所有地图显示方式
$mode= array(array('id'=>1,'name'=>'地图上大图标'),array('id'=>2,'name'=>'地图上文字'));
//组装数据
foreach ($mode_list['data'] as $key => $value) {
foreach ($mode as $k => $v) {
if($value['sm_id']==$v['id']){
$mode[$k]['checked'] = 1;
}
}
}
$this->assign('mode',$mode);//获取所有菜系
//获取商家已选短信模板
$template = file_get_contents(ON_LINE.'App.Reserve.SellerInfo&seller_id='.$data['id']);
$template = json_decode($template,TRUE);
//获取商家已有地图显示方式
$template_list = file_get_contents(ON_LINE.'App.SendSMS.GetSmsTemplate');
$template_list = json_decode($template_list,TRUE);
//组装数据
foreach ($template_list['data'] as $key => $value) {
if($value['template_code']==$template['data']['setting']['template_code']){
$template_list['data'][$key]['checked'] = 1;
}
}
$this->assign('template_list',$template_list['data']);//获取短信模板列表
//获取商家拥有哪些标签
$label_list= file_get_contents(ON_LINE.'App.Seller.GetSellerLabel&sid='.$data['id']);
$label_list = json_decode($label_list,TRUE);
$this->assign('label_list',$label_list['data']);
//商家标签
//原生:
//$label_c=Db::query("SELECT * from xt-member-two-LINE.xt_dc_dz_seller_label_c");
$label_c=Db::table("xt-member-two-LINE.xt_dc_dz_seller_label_c")->select();
$label_c_rel=Db::table("xt-member-two-LINE.xt_dc_dz_seller_label_c_rel")->where(array('sid'=>$data['id']))->select();
//组装数据
foreach ($label_c as $key => $value) {
foreach ($label_c_rel as $k => $v) {
if($value['id']==$v['lcid']){
$label_c[$key]['checked'] = 1;
}
}
}
$this->assign('label_c',$label_c);
//商家品牌
$brand=Db::table("xt-member-two-LINE.xt_dc_dz_seller_brand")->select();
$brand_rel=Db::table("xt-member-two-LINE.xt_dc_dz_seller_brand_rel")->where(array('sid'=>$data['id']))->select();
//组装数据
foreach ($brand as $key => $value) {
foreach ($brand_rel as $k => $v) {
if($value['id']==$v['bid']){
$brand[$key]['checked'] = 1;
}
}
}
$this->assign('brand',$brand);
$is_online_reserve=Db::table("xt-member-two-LINE.xt_seller")->where(array('id'=>$data['id']))->select();
//获取商家在线预定版本情况
$this->assign('is_online_reserve',$is_online_reserve[0]['is_online_reserve']);
//是否安装电话机
$this->assign('is_tele',$is_online_reserve[0]['is_tele']);
//商户信息
$this->assign ('data',$data);
$this->assign ( 'title','商户信息配置' );
return $this->fetch();
}
/**
* 商家基础信息配置
*/
public function setsellerconfig(){
if(Request::isAjax()){
$data = Request::except('file');
$data['status'] = $data['status'] ? 0 : 1;
$list= file_get_contents(ON_LINE.'App.Seller.SetSellerConfigByPC&sid='.$data['sellerid'].'&field='.$data['field'].'&value='.$data['value']);
$array = json_decode($list,TRUE);
if($array['ret']==200){
$result['code'] = 1;
$result['msg'] = 'SUCCESS!';
}else{
$result['code'] = 0;
$result['msg'] = '请求错误!';
}
return $result;
}
return view();
}
/**
* 商家详情
*/
public function sellerdetail(){
//print_r(Request::except('file'));die;
$data = Request::except('file');
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Seller.GetSellerById&sellerid='.$data['sid']);
$array = json_decode($list,TRUE);
if($array['data']['data']){
$array['data']['data']['daily'] = json_decode($array['data']['data']['daily'],TRUE);
$array['data']['data']['daily_time'] = json_decode($array['data']['data']['daily_time'],TRUE);
$array['data']['data']['cdate'] = date("Y年m月d日 H时i分s秒",$array['data']['data']['cdate']);
}
//获取短信流水
$sms= file_get_contents(ON_LINE.'App.SendSMS.GetSellerSmsFlowing&sid='.$data['sid']);
$sms_data = json_decode($sms,TRUE);
$sms_data_list = $sms_data['data'] ? $sms_data['data'] : array();
$this->assign ( 'smslist',$sms_data_list);
$this->assign ( 'data',$array['data']['data']);
$this->assign ( 'title','商家详情页面');
return $this->fetch();
}
//商家列表 用于配置商家活动
public function seller_activity_list(){
if(Request::isAjax()){
$data = Request::except('file');
$key= input('post.key') ? input('post.key') : "";
$channel = @$key['channel'] ? @$key['channel'] : 1;
$limit = '&x='.$data["page"].'&y='.$data["limit"].'&keywords='.@$key['id'].'&channel='.$channel;
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Seller.GetSellerListByActivity'.$limit);
$array = json_decode($list,TRUE);
foreach($array['data'][0]['data'] as $key=>$value){
if(!empty($value['activity'])){
foreach ($value['activity'] as $k => $v) {
$str[$key][] = ($k+1).'、'.$v['title'];
}
$array['data'][0]['data'][$key]['activity'] = implode('<br/>', $str[$key]);
//$array['data'][0]['data'][$key]['activity'] = implode('<br/>', array_column($value['activity'], 'title'));
}
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data'][0]['data'],'count'=>$array['data'][0]['total'],'rel'=>1];
}
$this->assign ( 'title','商家活动配置');
return $this->fetch();
}
/**
* 商家活动列表页
*/
public function seller_activity(){
$data = Request::except('file');
//获取商家现有活动
$seller_activity= file_get_contents(ON_LINE.'App.Seller.GetSellerActivity&sid='.$data['id']);
$seller_activity = json_decode($seller_activity,TRUE);
//活动列表
$this->assign('sid',$data['id']);
$this->assign ( 'seller_activity',$seller_activity['data']);
$this->assign ( 'title','商家活动配置页面');
return $this->fetch();
}
//添加活动
public function add_activity(){
$data = Request::except('file');
if(Request::isAjax()){
switch ($data['type']) {
case '1':
if($data['max_num']==0){
$data['title'] = '立减'.$data['min_num'];break;
}else{
$data['title'] = '满'.$data['max_num'].'立减'.$data['min_num'];break;
}
case '2':
$data['title'] = '满赠';
break;
case '3':
if($data['max_num']==0){
$data['title'] = $data['min_num'].'折';break;
}else{
$data['title'] = '满'.$data['max_num'].'立享'.$data['min_num'].'折';break;
}
case '4':
$data['title'] = $data['max_num'].'元代金券';
break;
case '5':
$data['title'] = '会员价';
break;
default:
# code...
break;
}
//字段空值过滤
//添加活动
$res= file_get_contents(ON_LINE.'App.Seller.SetActivity&str='.serialize($data));
$res = json_decode($res,TRUE);
if($data['aid']){
if($res['data']){
$result = ['code'=>1,'msg'=>'修改成功!','rel'=>1];
}else{
$result = ['code'=>0,'msg'=>'修改失败!','rel'=>1];
}
}else{
if($res['data']){
$result = ['code'=>1,'msg'=>'添加成功!','rel'=>1];
}else{
$result = ['code'=>0,'msg'=>'添加失败!','rel'=>1];
}
}
return $result;
}
if($data['id']){
//修改---需要获取对应的数据
$activity= file_get_contents(ON_LINE.'App.Seller.GetSellerActivityById&id='.$data['id']);
$activity = json_decode($activity,TRUE);
$this->assign ('data',$activity['data']);
$this->assign ( 'title','修改活动');
}
$this->assign ( 'hid',$data['sid']);
$this->assign ( 'title','添加活动');
return $this->fetch();
}
//删除活动
public function del_activity(){
$data = Request::except('file');
$res= file_get_contents(ON_LINE.'App.Seller.DelSellerActivity&sid='.$data['sid'].'&aid='.$data['aid']);
$res = json_decode($res,TRUE);
$this->redirect('Seller/seller_activity', ['id' => $data['sid']]);
//return $this->fetch('seller_activity',['id' => $data['sid']]);
}
//商家设备列表
public function device_list(){
//获取类型
$facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
if(Request::isAjax()){
$data = Request::except('file');
$channel = @$data['channel'] ? @$data['channel'] : 1;
$manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;
$limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Device.GetDeviceOnlineStatus'.$limit); //GetSellerDevice
$array = json_decode($list,TRUE);
foreach ($array['data']['list'] as $key => $value) {
switch ($value['type']) {
case '1':
$array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
break;
case '2':
$array['data']['list'][$key]['type'] = $facturer[1]['facturer'];
break;
case '3':
$array['data']['list'][$key]['type'] = $facturer[2]['facturer'];
break;
case '4':
$array['data']['list'][$key]['type'] = $facturer[3]['facturer'];
break;
default:
$array['data']['list'][$key]['type'] = 'error';
break;
}
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
}
$this->assign ( 'facturer',$facturer);
$this->assign ( 'title','商家设备列表');
return $this->fetch();
}
//商家设备列表
public function add_gray_user(){
if(Request::isAjax()){
$data = Request::except('file');
$list= file_get_contents(ON_LINE.'App.Device.SetGrayUser&ids='.serialize($data['id']));
$array = json_decode($list,TRUE);
if($array['ret']==200){
$result['code'] = 1;
$result['msg'] = 'SUCCESS!';
}else{
$result['code'] = 0;
$result['msg'] = '服务器错误,请勿重复将设备号添加到灰度用户!';
}
return $result;
}
return view();
}
//灰度用户列表
public function gray_user_list(){
//获取类型
$facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
$this->assign ( 'facturer',$facturer);
if(Request::isAjax()){
$data = Request::except('file');
$channel = @$data['channel'] ? @$data['channel'] : 1;
$manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;
$limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;
$list= file_get_contents(ON_LINE.'App.Device.GetGrayUserList'.$limit);
$array = json_decode($list,TRUE);
foreach ($array['data']['list'] as $key => $value) {
switch ($value['type']) {
case '1':
$array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
break;
case '2':
$array['data']['list'][$key]['type'] = $facturer[1]['facturer'];
break;
case '3':
$array['data']['list'][$key]['type'] = $facturer[2]['facturer'];
break;
case '4':
$array['data']['list'][$key]['type'] = $facturer[3]['facturer'];
break;
default:
$array['data']['list'][$key]['type'] = 'error';
break;
}
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
}
//获取类型
$facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
$this->assign ( 'facturer',$facturer);
$this->assign ( 'title','灰度用户列表');
return $this->fetch();
}
//删除灰度用户
public function del_gray_user(){
if(Request::isAjax()){
$data = Request::except('file');
$list= file_get_contents(ON_LINE.'App.Device.DelGrayUser&jsstr='.serialize($data['id']));
$array = json_decode($list,TRUE);
if($array['ret']==200){
$result['code'] = 1;
$result['msg'] = 'SUCCESS!';
}else{
$result['code'] = 0;
$result['msg'] = '请刷新页面重新尝试!';
}
return $result;
}
return view();
}
//获取在线设备情况
public function get_device_online_status(){
//获取类型
$facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
if(Request::isAjax()){
$data = Request::except('file');
$channel = @$data['channel'] ? @$data['channel'] : 1;
$manufacturer = @$data['manufacturer'] ? @$data['manufacturer'] : 1;
$limit = '&page='.$data["page"].'&size='.$data["limit"].'&sellername='.@$data['key'].'&channel='.$channel.'&type='.$manufacturer;
$list= file_get_contents(ON_LINE.'App.Device.GetDeviceOnlineStatus'.$limit);
$array = json_decode($list,TRUE);
foreach ($array['data']['list'] as $key => $value) {
switch ($value['type']) {
case '1':
$array['data']['list'][$key]['type'] = $facturer[0]['facturer'];
break;
case '2':
$array['data']['list'][$key]['type'] = $facturer[1]['facturer'];
break;
case '3':
$array['data']['list'][$key]['type'] = $facturer[2]['facturer'];
break;
case '4':
$array['data']['list'][$key]['type'] = $facturer[3]['facturer'];
break;
default:
$array['data']['list'][$key]['type'] = 'error';
break;
}
}
return $result = ['code'=>0,'msg'=>'获取成功!','data'=>$array['data']['list'],'count'=>$array['data']['total'],'rel'=>1];
}
$this->assign ( 'facturer',$facturer);
$this->assign ( 'title','商家话机在线设备列表');
return $this->fetch();
}
/**
* 从商家维度统计:订单、短信等情况
*/
public function GetReserveList(){
//获取类型
$facturer = Db::query("SELECT * FROM `xt-member-two-LINE`.xt_dc_dz_facturer");
if(Request::isAjax()){
$data = Request::except('file');
$key= input('post.key') ? input('post.key') : "";
$nokey= input('post.nokey') ? input('post.nokey') : "";
$sellername = $data['key'] ? $data['key'] : ''; //商家名称
$id = $data['nokey'] ? $data['nokey'] : ''; //订单ID
$time = $data['time'] ? explode(' - ', $data['time']) : '';
$stime = $time ? strtotime(date($time[0],time())) : strtotime(date('Y-m-d 00:00:00',time()));
$etime = $time ? strtotime(date($time[1],time())) : strtotime(date('Y-m-d 23:59:59',time()));
$dtime = $data['dtime'] ? explode(' - ', $data['dtime']) : '';
$sdtime = $dtime ? strtotime(date($dtime[0],time())) : '';
$edtime = $dtime ? strtotime(date($dtime[1],time())) : '';
$data['status'] = $data['status'] ? $data['status'] : 2;
$data['channel'] = $data['channel'] ? $data['channel'] : 1;
$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;
//获取运营人员列表
$list= file_get_contents(ON_LINE.'App.Customer.GetReserveList'.$parame);
$array = json_decode($list,TRUE);
$new_array = array();
foreach ($array['data']['list'] as $key => $value) {
//有无设备
if($value['is_tele']==1){
switch ($value['type']) {
case '1':
$array['data']['list'][$key]['dv'] = $facturer[0]['facturer'];
break;
case '2':
$array['data']['list'][$key]['dv'] = $facturer[1]['facturer'];
break;
case '3':
$array['data']['list'][$key]['dv'] = $facturer[2]['facturer'];
break;
case '4':
$array['data']['list'][$key]['dv'] = $facturer[3]['facturer'];
break;
default:
$array['data']['list'][$key]['dv'] = '无';
break;
}
}else{
$array['data']['list'][$key]['dv'] = '无';
}
//订单接受时间段
switch ($value['ddate_solt']) {
//'未设置/早市/午市/晚市/夜宵 0/1/2/3/4',
case 0:
$value['ddate_solt'] = '未设置';
break;
case 1:
$value['ddate_solt'] = '早市';
break;
case 2:
$value['ddate_solt'] = '午市';
break;
case 3:
$value['ddate_solt'] = '晚市';
break;
case 4:
$value['ddate_solt'] = '夜宵';
break;
default:
# code...
break;
}
$array['data']['list'][$key]['ddate'] = date('Y-m-d H:i:s',$value['ddate']).'['.$value['ddate_solt'].']';
$array['data']['list'][$key]['cdate'] = date('Y-m-d H:i:s',$value['cdate']);
$array['data']['list'][$key]['handle_time'] = date('Y-m-d H:i:s',$value['handle_time']);
switch ($value['status']) {
case 0:
$array['data']['list'][$key]['sta'] = '待确认';
break;
case 1:
$array['data']['list'][$key]['sta'] = '已定座';
break;
case 2:
$array['data']['list'][$key]['sta'] = '到店';
break;
case 3:
$array['data']['list'][$key]['sta'] = '离店';
break;
case 4:
$array['data']['list'][$key]['sta'] = '已取消';
break;
case 5:
$array['data']['list'][$key]['sta'] = '已分配';
break;
case 6:
$array['data']['list'][$key]['sta'] = '拒单';
break;
default:
# code...
break;
}
switch ($value['sex']) {
case 1:
$array['data']['list'][$key]['rname'] = $value['rname'].'先生'.'('.$value['phone'].')';
break;
case 2:
$array['data']['list'][$key]['rname'] = $value['rname'].'女士'.'('.$value['phone'].')';
break;
case 3:
$array['data']['list'][$key]['rname'] = $value['rname'].'公司'.'('.$value['phone'].')';
break;
default:
# code...
break;
}
if($value['room_demand']){
$array['data']['list'][$key]['room_demand'] = implode(',',array_column(json_decode($value['room_demand'],true), 'name'));
}
$array['data']['list'][$key]['sta'] = $value['is_tele']==1 ? $array['data']['list'][$key]['sta'] : $array['data']['list'][$key]['sta'].'无话机';
//根据操作人识别操作终端
if(isset($template['operator_openid'])){
if(strstr($template['operator_openid'],'_',-4)=='tele'){ //话机操作
$array['data']['list'][$key]['operator_openid'] = '电话机';
}
if(strstr($template['operator_openid'],'_',-4)=='wind'){ //PC操作
$array['data']['list'][$key]['operator_openid'] = 'PC';
}
if(strstr($template['operator_openid'],'_',-4)=='chat'){ //PC操作
$array['data']['list'][$key]['operator_openid'] = '小程序';
}
}
}
//print_r($array['data']['list']);die;
return $result = [
'code'=>0,'msg'=>'获取成功!',
'data'=>$array['data']['list'],
'count'=>$array['data']['total'],
'rel'=>1
];
}
$this->assign ( 'title','C端预定订单管理');
return $this->fetch();
}
/**
* 状态设置
*/
public function setReserveStatus(){
if(Request::isAjax()){
$data = Request::except('file');
$data['cause'] = json_encode(array('uid'=>-1,'uname'=>session('username'),'desc'=>$data['cause']));
$list= file_get_contents(ON_LINE.'App.Reserve.SetReserveStatus&rid='.$data['id'].'&status='.$data['status'].'&cause='.$data['cause']);
$array = json_decode($list,TRUE);
if($array['ret']==200){
$result['code'] = 1;
$result['msg'] = 'SUCCESS!';
}else{
$result['code'] = 0;
$result['msg'] = '请求错误!';
}
return $result;
}
return view();
}
}