System.php
58.2 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
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
<?php
/**
* tpshop
* ============================================================================
* 版权所有 2015-2027 深圳搜豹网络科技有限公司,并保留所有权利。
* 网站地址: http://www.tp-shop.cn
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
* 不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* Author: 当燃
* Date: 2015-10-09
*/
namespace app\admin\controller;
use app\admin\logic\GoodsLogic;
use SebastianBergmann\Environment\Runtime;
use think\db;
use think\Validate;
use think\Page;
class System extends Base
{
/*
* 配置入口
*/
public function index()
{
$this->initEditor();
/*配置列表*/
$inc_type = I('get.inc_type', 'shop_info');
$this->assign('inc_type', $inc_type);
$qclurl = QCLOUD_IMGURL;
$this->assign('qclurl', $qclurl);
/*-缓存--*/
$config = tpCache($inc_type, getAdmStoId());
switch ($inc_type)
{
case "basic"://基本设置
//是否启用客服
$where=time().'<end_time and store_id='.getAdmStoId();
$kers=M('storage_recharge_detail')->where($where)->order('end_time')->find();
$isopenkefu=0;
if($kers) $isopenkefu=1;
$this->assign('isopenkefu', $isopenkefu);
$inv_coupon = M('coupon')->where("type = 3 and store_id=" . getAdmStoId())->select(); //邀请类型的优惠券
$coupon = M('coupon')->where("type = 2 and store_id=" . getAdmStoId())->select(); //注册类型的优惠券
$this->assign('reginfo_coupon', $coupon);
$this->assign('inv_coupon', $inv_coupon);
break;
case "shopping"://购物设置
$feemail=M('area_feemail')->where('store_id='.getAdmStoId())->order('id desc')->select();
$this->assign('feemail',$feemail);
$province = M('region')->where(array('parent_id' => 0))->select();
$city = M('region')->where(array('parent_id' => $config['province']))->select();
$area = M('region')->where(array('parent_id' => $config['city']))->select();
$this->assign('province', $province);
$this->assign('city', $city);
$this->assign('area', $area);
//
$is_ylpapp = tpCache('shop_info.is_ylpapp', getAdmStoId());
if (isset($is_ylpapp))
{
$this->assign('is_ylpapp', $is_ylpapp);
}
else {
$storeinfo = M("store")->where("store_id", getAdmStoId()) ->field("is_ylpapp")->find();
$this->assign('is_ylpapp', $storeinfo['is_ylpapp']);
}
//
if ($config['point_rate'])
{
$point_rate=json_decode($config['point_rate'],true);
}
$this->assign('point_rate', $point_rate);//当前配置项
if ($config['quan_rate'])
{
$quan_rate=json_decode($config['quan_rate'],true);
}
$this->assign('quanlist', $quan_rate);//当前配置项
break;
case "distribut"://分销设置
$distr_goods_id = $config['condition_goods_id'];
$gname = "";
if ($distr_goods_id) {
$rs = M('goods')->where('goods_id', $distr_goods_id)->field('goods_name')->find();
$gname = $rs['goods_name'];
$this->assign('condition_goods_name', $gname);
}
//分销是否过期
$isbuy=0;
$is_out=M("store_module_endtime")
->where('store_id',getAdmStoId())
->where('type',2)->find();
$all=M('store_distribut')->where('store_id',getAdmStoId())->find();
$allnum=$all['distribut_num'];
if($is_out){
//----体验是无限时间---
if($is_out['is_sy']){
$yy=M('distri_price')->where('type',0)->where('money',0)->find();
$allnum=$yy['user_num'];
if(empty($all)){
$ud['distribut_num']=$allnum;
$ud['store_id']=getAdmStoId();
M('store_distribut')->save($ud);
}else{
$ud['distribut_num']=$allnum;
M('store_distribut')->where('store_id',getAdmStoId())->save($ud);
$count=M("users")->where('store_id',getAdmStoId())->where('is_distribut',1)->count();
if($count>=$allnum){
$this->redirect(U('admin/System/not_distribut',array('out'=>0))); //过期
}
}
}else{
if($is_out['end_time']>time()) {
$isbuy=1;
$this->assign('end_time', $is_out['end_time']);
}else{
$this->redirect(U('admin/System/not_distribut',array('out'=>1))); //过期
}
}
}else{
$this->redirect(U('admin/System/not_distribut',array('out'=>2))); //过期
}
$disnum=M('users')->where('store_id',getAdmStoId())->where('is_distribut',1)->count();
$this->assign('allnum', $allnum);
$this->assign('disnum', $disnum);
$this->assign('isbuy', $isbuy);
break;
case "cardsetup":
$storeinfo = tpCache('shop_info', getAdmStoId());
$sto_erpid = $storeinfo['ERPId'];
$all0 = Db::name('storage_recharge')
->where("type", 8)
->where("recharge_state", 1)
->where('store_id', getAdmStoId())
->order("id desc")
->find();
$all = Db::name('store_config')->where('store_id', getAdmStoId())->find();
$allnum = $all['dj_num'];
$rs_count = getApiData_java("/api/erp/vip/mem/card/count", $sto_erpid, null, 1, 1);
if ($rs_count) {
$rs_count = json_decode($rs_count, true);
if ($rs_count['code'] == 0) {
$count = $rs_count['data']['SumTotal'];
}
}
$is_out = M("store_module_endtime")
->where('store_id', getAdmStoId())
->where('type', 3)->find();
if ($is_out) {
//---如果是试用的话---
if($is_out['is_sy']){
$yy = M('dj_price')->where('type', 0)->where('money', 0)->find();
$all0['buy_num'] = $allnum = $yy['user_num'];
if (empty($all)) {
$ud['dj_num'] = $allnum;
$ud['store_id'] = getAdmStoId();
M('store_config')->save($ud);
} else {
$ud['dj_num'] = $allnum;
M('store_distribut')->where('store_id', getAdmStoId())->save($ud);
}
}else{
if ($is_out['end_time'] > time()) {
$this->assign('end_time', $is_out['end_time']);
} else {
$this->error("plus卡功能已过期,请及时续费!",U('admin/index/welcome'));
}
}
} else {
$this->error("未购买plus卡功能!",U('admin/index/welcome'));
}
//等级卡列表
$plusinfo = getApiData_java_p("/api/erp/vip/mem/bership/list", $sto_erpid, null, 1, 10, null, "GET");
if ($plusinfo) {
$plusinfo = json_decode($plusinfo, true);
$this->assign('plusinfo', $plusinfo['data']);
}
$this->assign('allnum', $allnum);
$this->assign('djnum', $count);
$this->assign('all0', $all0);
break;
case "water"://水印默认选项
if (empty($config)) {
$config['mark_type'] = 'text';
}
break;
default:
break;
}
/*---商家是否开启等级卡 --*/
if (getERPId()) { //有ERP
$tk = M("store_config")->where("store_id", getAdmStoId())
->field("dj_num")->find();
if ($tk['dj_num'] > 0) {
$iscard = 1;
}
}
if ($inc_type=="basic" || $inc_type=="cardsetup") {
//会员中心工具及服务
$usertool = M("user_tool")->order('ordid asc,id asc')->select();
//后台是否开启了初始化
$isBool = 0;
if (getERPId()) {//判断是否有ERP商家
$init_data = getApiData_java_p("/api/erp/grade/vip/init/get", getERPId(), null, 1, 10, null, "GET");
if ($init_data) {
$init_data = json_decode($init_data, true);
if ($init_data['code'] === 0 && $init_data['data']) {
$isBool = $init_data['data']['isBool'];
$this->assign('isBool', $init_data['data']['isBool']);
}
}
}
$switch_list = tpCache('basic.switch_list', getAdmStoId());
//等级卡
$rank_switch =0;
$switch_list_decode=json_decode($switch_list, true);
if ($switch_list_decode)
{
if ($switch_list_decode['rank_switch']) {
$rank_switch = $switch_list_decode['rank_switch'];
}
}
$vipcard = 0;
if ($rank_switch == 2)//默认商城(商家开启等级卡)
{
$vipcard = 1;
}
$getdistribut_switch = tpCache('distribut.switch', getAdmStoId());
//过滤工具要显示的条件
if ($usertool) {
foreach ($usertool as $k => $v) {
//--判断分销---
if (strpos($v['url'], 'Distribut') !== false && $getdistribut_switch != 1) {
continue;
}
//--判断等级卡--
if (strpos($v['url'], 'cardinfo') !== false && $vipcard != 1) {
continue;
}
//我的权益
if (strpos($v['url'], 'gorw_up') !== false && !$isBool) {
continue;
}
//我的权益(旧)
if (strpos($v['url'], 'vipqy') !== false && $isBool) {
continue;
}
$usertool_new[] = $v;
}
$this->assign('usertool', $usertool_new);
}
}
$this->assign('erpid', getERPId());
$this->assign('config', $config);//当前配置项
$this->assign('isopencard',$iscard);//判断当前商家是否开通等级卡
return $this->fetch($inc_type, getAdmStoId());
}
/*
* 新增修改配置
*/
public function handle()
{
ClearALLCache();
delFile(TEMP_PATH . "/" . getAdmStoId());
$param = I('post.');
$inc_type = $param['inc_type'];
mlog($inc_type . ":" . json_encode($param), 'system/' . getAdmStoId());
/*邀请规则*/
if ($inc_type == "basic") {
$invitation_rate = array(
'inv_jf' => $param['inv_jf'],
'inv_coupon' => $param['inv_coupon_id'],
'inv_cz' => $param['inv_cz'],
);
$param['invitation_rate'] = json_encode($invitation_rate);
$reg_default = array(
'reg_def_ty' => $param['reg_def_ty'],
'jf' => $param['jf'],
'coupon' => $param['coupon_id'],
'reg_cz' => $param['reg_cz'],
);
$getjfcz=0;
$getdhwz=0;
$getyckcz=0;
if ($param['jfcz'])
{
$getjfcz=1;
}
if ($param['dhwz'])
{
$getdhwz=1;
}
if ($param['yckcz'])
{
$getyckcz=1;
}
$getispt_goods=-1;
if ($param['ispt_goods'])
{
$getispt_goods=0;
}
$is_tx_wx=0;
if ($param['is_tx_wx'])
{
$is_tx_wx=1;
}
$getis_brithday=0;
if ($param['is_brithday'])
{
$getis_brithday=1;
}
$is_flash_return=0;
if ($param['is_flash_return'])
{
$is_flash_return=1;
}
$if_fast_reg=0;
if ($param['is_fast_reg'])
{
$is_fast_reg=1;
}
$is_close_quan=0;
if ($param['is_close_quan'])
{
$is_close_quan=1;
}
$is_newchoosestore=0;
if ($param['is_newchoosestore'])
{
$is_newchoosestore=1;
}
$is_closecoupon=0;
if ($param['is_closecoupon'])
{
$is_closecoupon=1;
}
$is_regstores=0;
if ($param['is_regstores'])
{
$is_regstores=1;
}
$is_newsgoodstype = 0;
if ($param['is_newsgoodstype']) {
$is_newsgoodstype = 1;
}
$is_closetxbank = 0;
if ($param['is_closetxbank']) {
$is_closetxbank = 1;
}
$is_newsales_rules = 0;
if ($param['is_newsales_rules']) {
$is_newsales_rules = 1;
}
$switch = tpCache('shopping.switch_list',getAdmStoId());//获取开关json
$switch_list = json_decode($switch,true);//获取开关列表
$switch_list['jfcz_switch']=$getjfcz;
$switch_list['dhwz_switch']=$getdhwz;
$switch_list['yckcz_switch']=$getyckcz;
$switch_list['ispt_goods']=$getispt_goods;
$switch_list['is_tx_wx']=$is_tx_wx;
$switch_list['is_brithday']=$getis_brithday;
$switch_list['is_flash_return']=$is_flash_return;
$switch_list['is_fast_reg']=$is_fast_reg;
$switch_list['is_close_quan']=$is_close_quan;
$switch_list['is_newchoosestore']=$is_newchoosestore;
$switch_list['is_closecoupon']=$is_closecoupon;
$switch_list['is_regstores']=$is_regstores;
$switch_list['is_newsgoodstype'] = $is_newsgoodstype;
$switch_list['usertool'] = json_encode($param['usertool']);
$switch_list['is_closetxbank'] = $is_closetxbank;
$switch_list['is_newsales_rules'] = $is_newsales_rules;
$switch_list['user_label_set'] = $param['user_label_set'];
$switch_list['user_label_val'] = $param['user_label_val'];
$switch_list['user_label_type'] = $param['user_label_type'];
unset($param['jfcz']);
unset($param['dhwz']);
unset($param['yckcz']);
unset($param['ispt_goods']);
unset($param['is_tx_wx']);
unset($param['is_brithday']);
unset($param['is_flash_return']);
unset($param['is_fast_reg']);
unset($param['is_close_quan']);
unset($param['is_newchoosestore']);
unset($param['is_closecoupon']);
unset($param['is_regstores']);
unset($param['is_newsgoodstype']);
unset($param['usertool']);
unset($param['is_closetxbank']);
unset($param['is_newsales_rules']);
unset($param['user_label_set']);
unset($param['user_label_val']);
unset($param['user_label_type']);
$param['switch_list'] = json_encode($switch_list);
$param['reg_default'] = json_encode($reg_default);
$reg_info = array(
'name' => (int)$param['name_v'],
'name_val_type' => (int)$param['name_val_type'],
'name_state' => (int)$param['name'],
'birthday' => (int)$param['birthday_v'],
'birthday_type' => (int)$param['birthday_type'],
'birthday_state' => (int)$param['birthday'],
'idcard' => (int)$param['idcard_v'],
'idcard_type' => (int)$param['idcard_type'],
'idcard_state' => (int)$param['idcard'],
'address' => (int)$param['address_v'],
'address_type' => (int)$param['address_type'],
'address_state' => (int)$param['address'],
'pick' => (int)$param['pick_v'],
'pick_type' => (int)$param['pick_type'],
'pick_state' => (int)$param['pick'],
'sex' => (int)$param['sex'],
'sex_state_type' => (int)$param['sex_state_type'],
'sex_state' => (int)$param['sex_state'],
'introducer' => (int)$param['introducer'],
'introducer_type' => (int)$param['introducer_type'],
'introducer_state' => (int)$param['introducer_state'],
'reginfo_coupon' => $param['reginfo_coupon'],
);
$param['reg_info'] = json_encode($reg_info);
if ($param['categoryset1']) {
$param['categoryset'] .= "," . $param['categoryset1'];
}
if ($param['categoryset2']) {
$param['categoryset'] .= "," . $param['categoryset2'];
}
if ($param['categoryset3']) {
$param['categoryset'] .= "," . $param['categoryset3'];
}
$param['categoryset'] .= ",";
unset($param['categoryset1']);
unset($param['categoryset2']);
unset($param['categoryset3']);
}
if ($inc_type == 'shop_info') {
upload_ylp_log('A01商城信息/确认提交');
}
if ($inc_type == 'basic') {
upload_ylp_log('A02基本设置/确认提交');
}
if ($inc_type == 'shopping') {
$switch = tpCache('shopping.switch_list',getAdmStoId());//获取开关json
$switch_list = json_decode($switch,true);//获取开关列表
// $switch_list['rank_switch'] = $param['rank_switch'];
// unset($param['is_rank']);
$param['mzprice_list']['mz_time'] = time();
$param['switch_list'] = json_encode($switch_list);
$param['mzprice_list'] = json_encode($param['mzprice_list']);
$pjlist['is_autopj']=$param['is_autopj'];
$pjlist['auto_pjday']=$param['auto_pjday'];
$pjlist['auto_pjremark']=$param['auto_pjremark'];
$param['autopj_list'] = json_encode($pjlist);
if ($param['ylpapp_list1']) {
$param['ylpapp_list'] .= "," . $param['ylpapp_list1'];
}
if ($param['ylpapp_list2']) {
$param['ylpapp_list'] .= "," . $param['ylpapp_list2'];
}
if ($param['ylpapp_list3']) {
$param['ylpapp_list'] .= "," . $param['ylpapp_list3'];
}
if ($param['ylpapp_list']) {
$param['ylpapp_list'] .= ",";
}
else{
$param['ylpapp_list']="";
}
unset($param['ylpapp_list1']);
unset($param['ylpapp_list2']);
unset($param['ylpapp_list3']);
$point_rate['money']=$param['point_rate_money'];
$point_rate['integral']=$param['point_rate_integral'];
$param['point_rate']=json_encode($point_rate);
unset($param['point_rate_money']);
unset($param['point_rate_integral']);
$param['quan_rate']=json_encode($param['quanlist']);
unset($param['quanlist']);
//自动评价
upload_ylp_log('A03购物流程/确认提交');
}
if ($inc_type == 'sms') {
$sms_send_type = array(
'type' => (int)$param['type'],
'time_out' => (int)$param['time_out'],
'is_verifycode' => (int)$param['is_verifycode'],
);
$param['sms_send_type'] = json_encode($sms_send_type);
unset($param['type']);
unset($param['time_out']);
upload_ylp_log('A04短信设置/确认提交');
}
if ($inc_type == 'water') {
upload_ylp_log('A05水印设置/确认提交');
}
if ($inc_type == 'distribut') {
upload_ylp_log('A06分销设置/确认提交');
}
if ($inc_type == 'cardsetup') {
$fir_yaoqing_no = $param['fir_yaoqing_no'];
if ($fir_yaoqing_no) {
$rss = M("users")->where('mobile', $fir_yaoqing_no)->where('store_id', getAdmStoId())
->field('user_id,erpvipid,store_id')
->find();
if (empty($rss))
$this->error("初始邀请人必须是线上会员", U('System/index', array('inc_type' => $inc_type)));
//---读取等级卡项目---
$tk = tpCache('shop_info', $rss['store_id']);
$sto_erpid = $tk['ERPId'];
// $rs=getApiData("wxd.mem.bershipcard.list.get",$tk['api_token'],null,null,null,null,'CardCode desc');//等级卡项
//$api = "/api/erp/vip/mem/card/renew";
$api = "/api/erp/vip/mem/bership/list";
$rs = getApiData_java_p($api, $sto_erpid, null, 1, 10, null, "GET");
$arrlist = json_decode($rs, true)['data'];
if ($arrlist) {
$v = $arrlist[0];
$v['CardFee'] = number_format($v['CardFee'], 2, ".", "");
$arrlist = $v;
} else {
$this->error("商家未设置等级卡项目", U('System/index', array('inc_type' => $inc_type)));
}
mlog('等级卡,会员id::' . $rss['user_id'], 'recharge/' . $rss['store_id']);
$vipid = $rss['erpvipid'];
$data1 = array(
'VIPId' => $vipid,//会员ID
'CardId' => $arrlist['CardId'],//等级卡ID
'CardFee' => $arrlist['CardFee'],//等级卡金额
'PayTypeId' => '初始邀请人',
'PayNo' => $tk['ERPId'] . "0001",//
);
$data1['Recommon'] = "";//邀请码
$data1['ServiceMan'] = "";//营业员
// $mrs=getApiData("wxd.mem.registration.card.add",$tk['api_token'],$data1);
$api = "/api/erp/vip/mem/card/register";
$mrs = getApiData_java_p($api, $sto_erpid, $data1, 1, 10, null, "POST");
mlog('购买:' . json_encode($data1, true) . ' 返回值:' . $mrs, 'recharge_1/' . getAdmStoId());
$mrs = json_decode($mrs, true);
//计算有效期
$yxq = strtotime("+" . $arrlist['ExpiryDate'] . " day");
$updateuser['card_expiredate'] = date('Y-m-d H:i:s', $yxq);
$updateuser['card_field'] = strtolower($arrlist["Newcorrprice"]);
M('users')->where('user_id', $rss['user_id'])->save($updateuser);//更新会员信息表
}
$switch = tpCache('shopping.switch_list', getAdmStoId());//获取开关json
$switch_list = json_decode($switch, true);//获取开关列表
//$switch_list['rank_switch'] = 2;//$param['rank_switch'];
$switch_list['rank_switch'] = $param['rank_switch'] == null ? 0 : $param['rank_switch'];
$switch_list['isyaoqingma'] = $param['isyaoqingma'] == null ? 0 : $param['isyaoqingma'];
$switch_list['is_staffno'] = $param['is_staffno'] == null ? 0 : $param['is_staffno'];
//$switch_list['rank_close'] = $param['rank_close'];
unset($param['is_rank']);
unset($param['isyaoqingma']);
unset($param['is_staffno']);
unset($param['rank_close']);
$param['switch_list'] = json_encode($switch_list);
}
//unset($param['__hash__']);
unset($param['inc_type']);
$arr1 = tpCache($inc_type, getAdmStoId(), $param);
ClearALLCache();
delFile(TEMP_PATH . "/" . getAdmStoId());
// upload_ylp_log('保存商城信息');
if ($arr1 == null) {
$this->success("操作成功", U('System/index', array('inc_type' => $inc_type)));
exit;
} else {
if ($arr1['code'] == false) {
$this->error($arr1['str'], U('System/index', array('inc_type' => $inc_type)));
}
$this->success("操作成功", U('System/index', array('inc_type' => $inc_type)));
exit;
}
}
/**
* 自定义导航
*/
public function navigationList()
{
$model = M("Navigation");
$navigationList = $model->order("id desc")->select();
$this->assign('navigationList', $navigationList);
return $this->fetch('navigationList', getAdmStoId());
}
/**
* 添加修改编辑 前台导航
*/
public function addEditNav()
{
$model = D("Navigation");
if (IS_POST) {
if (I('id')) {
// upload_ylp_log('编辑前台导航');
$model->update(I('post.'));
} else {
// upload_ylp_log('添加前台导航');
$model->add(I('post.'));
}
$this->success("操作成功!!!", U('Admin/System/navigationList'));
exit;
}
// 点击过来编辑时
$id = I('id', 0);
$navigation = DB::name('navigation')->where('id', $id)->find();
// 系统菜单
$GoodsLogic = new GoodsLogic();
$cat_list = $GoodsLogic->goods_cat_list();
$select_option = array();
foreach ($cat_list AS $key => $value) {
$strpad_count = $value['level'] * 4;
$select_val = U("/Home/Goods/goodsList", array('id' => $key));
$select_option[$select_val] = str_pad('', $strpad_count, "-", STR_PAD_LEFT) . $value['name'];
}
$system_nav = array(
'http://www.tp-shop.cn' => 'tpshop官网',
'http://www.99soubao.com' => '搜豹公司',
'/index.php?m=Home&c=Index&a=promoteList' => '限时抢购',
'/index.php?m=Home&c=Activity&a=group_list' => '团购',
'/index.php?m=Home&c=Goods&a=integralMall' => '积分商城',
);
$system_nav = array_merge($system_nav, $select_option);
$this->assign('system_nav', $system_nav);
$this->assign('navigation', $navigation);
return $this->fetch('_navigation', getAdmStoId());
}
/**
* 删除前台 自定义 导航
*/
public function delNav()
{
// 删除导航
M('Navigation')->where("id", I('id'))->delete();
// upload_ylp_log('删除前台导航');
$this->success("操作成功!!!", U('Admin/System/navigationList'));
}
public function refreshMenu()
{
$pmenu = $arr = array();
$rs = M('system_module')->where('level>1 AND visible=1')->order('mod_id ASC')->select();
foreach ($rs as $row) {
if ($row['level'] == 2) {
$pmenu[$row['mod_id']] = $row['title'];//父菜单
}
}
foreach ($rs as $val) {
if ($row['level'] == 2) {
$arr[$val['mod_id']] = $val['title'];
}
if ($row['level'] == 3) {
$arr[$val['mod_id']] = $pmenu[$val['parent_id']] . '/' . $val['title'];
}
}
return $arr;
}
/**
* 清空系统缓存
*/
public function cleanCache()
{
if (IS_POST) {
// in_array('cache',$_POST['clear']) && delFile('./Application/Runtime/Cache');// 模板缓存
// in_array('data',$_POST['clear']) && delFile('./Application/Runtime/Data');// 项目数据
// in_array('logs',$_POST['clear']) && delFile('./Application/Runtime/Logs');// logs日志
// in_array('temp',$_POST['clear']) && delFile('./Application/Runtime/Temp');// 临时数据
// in_array('cacheAll',$_POST['clear']) && delFile('./Application/Runtime');// 清除所有
// //in_array('goods_thumb',$_POST['clear']) && delFile('./public/upload/goods/thumb'); // 删除缩略图
//
// // 删除静态文件
// $html_arr = glob("./Application/Runtime/Html/*.html");
// foreach ($html_arr as $key => $val)
// {
//
// in_array('index',$_POST['clear']) && strstr($val,'Home_Index_index.html') && unlink($val); // 首页
// in_array('goodsList',$_POST['clear']) && strstr($val,'Home_Goods_goodsList') && unlink($val); // 列表页
// in_array('channel',$_POST['clear']) && strstr($val,'Home_Channel_index') && unlink($val); // 频道页
//
// in_array('articleList',$_POST['clear']) && strstr($val,'Index_Article_articleList') && unlink($val); // 文章列表页
// in_array('detail',$_POST['clear']) && strstr($val,'Index_Article_detail') && unlink($val); // 文章详情
// in_array('articleList',$_POST['clear']) && strstr($val,'Doc_Index_index_') && unlink($val); // 文章列表页
// in_array('detail',$_POST['clear']) && strstr($val,'Doc_Index_article_') && unlink($val); // 文章详情
//
// // 详情页
// if(in_array('goodsInfo',$_POST['clear']))
// {
// if(strstr($val,'Home_Goods_goodsInfo') || strstr($val,'Home_Goods_ajaxComment') || strstr($val,'Home_Goods_ajax_consult'))
// unlink($val);
// }
// }
// $this->error("操作完成!!!");
// exit;
}
//delFile(RUNTIME_PATH);
ClearALLCache();
delFile(TEMP_PATH . "/" . getAdmStoId());
upload_ylp_log('A10清除缓存/确认提交');
$this->success("操作完成!!!", U("admin/index/welcome"));
exit();
return $this->fetch('', getAdmStoId());
}
/**
* 清空静态商品页面缓存
*/
public function ClearGoodsHtml()
{
$goods_id = I('goods_id');
// upload_ylp_log('清空静态商品页面缓存');
if (unlink("./Application/Runtime/Html/Home_Goods_goodsInfo_{$goods_id}.html")) {
// 删除静态文件
$html_arr = glob("./Application/Runtime/Html/Home_Goods*.html");
foreach ($html_arr as $key => $val) {
strstr($val, "Home_Goods_ajax_consult_{$goods_id}") && unlink($val); // 商品咨询缓存
strstr($val, "Home_Goods_ajaxComment_{$goods_id}") && unlink($val); // 商品评论缓存
}
$json_arr = array('status' => 1, 'msg' => '清除成功', 'result' => '');
} else {
$json_arr = array('status' => -1, 'msg' => '未能清除缓存', 'result' => '');
}
$json_str = json_encode($json_arr);
exit($json_str);
}
/**
* 商品静态页面缓存清理
*/
public function ClearGoodsThumb()
{
// upload_ylp_log('商品静态页面缓存清理');
$goods_id = I('goods_id');
delFile(UPLOAD_PATH . "goods/thumb/" . $goods_id); // 删除缩略图
$json_arr = array('status' => 1, 'msg' => '清除成功,请清除对应的静态页面', 'result' => '');
$json_str = json_encode($json_arr);
exit($json_str);
}
/**
* 清空 文章静态页面缓存
*/
public function ClearAritcleHtml()
{
// upload_ylp_log('清空文章静态页面缓存');
$article_id = I('article_id');
unlink("./Application/Runtime/Html/Index_Article_detail_{$article_id}.html"); // 清除文章静态缓存
unlink("./Application/Runtime/Html/Doc_Index_article_{$article_id}_api.html"); // 清除文章静态缓存
unlink("./Application/Runtime/Html/Doc_Index_article_{$article_id}_phper.html"); // 清除文章静态缓存
unlink("./Application/Runtime/Html/Doc_Index_article_{$article_id}_android.html"); // 清除文章静态缓存
unlink("./Application/Runtime/Html/Doc_Index_article_{$article_id}_ios.html"); // 清除文章静态缓存
$json_arr = array('status' => 1, 'msg' => '操作完成', 'result' => '');
$json_str = json_encode($json_arr);
exit($json_str);
}
//发送测试邮件
public function send_email()
{
$param = I('post.');
// upload_ylp_log('发送测试邮件');
tpCache($param['inc_type'], $param);
if (send_email($param['test_eamil'], '后台测试', '测试发送验证码:' . mt_rand(1000, 9999))) {
exit(json_encode(1));
} else {
exit(json_encode(0));
}
}
/**
* 管理员登录后 处理相关操作
*/
public function login_task()
{
$getstoid = getAdmStoId();
/*** 随机清空购物车的垃圾数据*/
$time = time() - 3600; // 删除购物车数据 1小时以前的
M("Cart")->where(" store_id=" . $getstoid . " and user_id = 0 and add_time < $time")->delete();
$today_time = time();
// // 发货后满多少天自动收货确认
// $auto_confirm_date = tpCache('shopping.auto_confirm_date', $getstoid);
// $auto_confirm_date = $auto_confirm_date * (60 * 60 * 24); // 7天的时间戳
// $order_id_arr = M('order')->where("store_id=" . $getstoid . " and order_status = 1 and shipping_status = 1 and ($today_time - shipping_time) > $auto_confirm_date")->getField('order_id', true);
// foreach ($order_id_arr as $k => $v) {
// confirm_order($v);
// }
//
// // 多少天后自动分销记录自动分成
// $switch = tpCache('distribut.switch', $getstoid);
// if ($switch == 1 && file_exists(APP_PATH . 'common/logic/DistributLogic.php')) {
// $distributLogic = new \app\common\logic\DistributLogic();
// $distributLogic->auto_confirm($getstoid); // 自动确认分成
// }
//
// //清除不是当天未付款的订单
// //清除不是当天未付款的订单
// $delTempOrder1 = M('order')
// ->where('pay_status=0 and order_status=0 and is_zsorder=0')
// ->where(" store_id=" . $getstoid . " and from_unixtime(add_time)<date_add(NOW(), interval -1 day) ")
// ->field("user_id,user_money,coupon_no,store_id,order_id,is_zsorder,pt_prom_id,pt_listno,is_pt_tz,gift_receive_id")
// ->select();
// $delTempOrder2 = M('order')
// ->where('pt_status=0 and order_status=0 and is_zsorder>1')
// ->where(" store_id=" . $getstoid . " and from_unixtime(add_time)<date_add(NOW(), interval -1 day) ")
// ->field("user_id,user_money,coupon_no,store_id,order_id,is_zsorder,pt_prom_id,pt_listno,is_pt_tz,gift_receive_id")
// ->select();
//
// $delTempOrder=array_merge($delTempOrder1,$delTempOrder2);
//
// foreach ($delTempOrder as $k => $v) {
// $ur= M('order')->where(array('order_id' => $v['order_id']))
// ->where('order_status<>3')
// ->save(['order_status' => 3]);
// if($ur) {
// $user_id = $v['user_id'];
// // mlog($v['order_id'],"temporder");
// // M('ordr_goods')->where(' order_id=')
// if ($v['user_money'] > 0) {
// //解冻余额
// $rs = M('Users')->where("user_id", $v['user_id'])
// ->where('frozen_money>=' . $v['user_money'])->find();
// if ($rs)
// M('Users')->where("user_id", $v['user_id'])->setDec('frozen_money', $v['user_money']);
// }
//
// /*---优惠券冻结---*/
// $quanno = $v['coupon_no'];
// if (!empty($quanno)) {
// $dada = ['CashRepNo' => $quanno, 'user_id' => $user_id];
// //冻结优惠券
// M('frozen_quan')->where($dada)->delete();
// }
//
//
// //$redis = new \Redis();
// //$redis->connect(redisip, 6379);
// $redis=get_redis_handle();
//
// $stoid= $v['store_id'];
// $hh = M('order_goods')->where('order_id', $v['order_id'])
// ->where('prom_type',1)->where('store_id',$stoid)
// ->field('order_id,goods_num,prom_id,order_sn,rec_id')->select();
// if($hh) {
// $odarr0 = get_arr_column($hh, 'order_id');
// //增加队列
// foreach ($hh as $kk => $vv) {
// //$name0 ='ms'.$vv['prom_id'] . '-' . $stoid;
// $name0=get_redis_name($vv['prom_id'],1,$stoid);
//
// //不重复退回redis
// if(!doublefind($redis,$name0,$vv['rec_id'])) {
// for ($i = 0; $i < $vv['goods_num']; $i++) {
// $redis->lPush($name0, $vv['rec_id'] . '_' . $i);
// }
// $jsda['num'] = $vv['goods_num'];
// $jsda['order_sn'] = $vv['order_sn'];
// $jsda['type'] = 1; //1是5分钟自动补回
// mlog(json_encode($jsda), 'flash_log/' . $stoid . '/' . $vv['prom_id']);
// }
// }
// }
//
// $hh2 = M('order_goods')->where('order_id', $v['order_id'])
// ->where('prom_type',2)->where('store_id',$stoid)
// ->field('order_id,goods_num,prom_id,order_sn,rec_id')->select();
// if($hh2){
// $odarr0 = get_arr_column($hh, 'order_id');
// //增加队列
// foreach ($hh2 as $k => $v) {
// //$name_g ='grb'.$v['prom_id'] . '-' . $stoid;
// $name_g = get_redis_name($v['prom_id'],2 ,$stoid);
//
// //不重复退回redis
// if(!doublefind($redis,$name_g,"2".$v['rec_id'])) {
// for ($i = 0; $i < $v['goods_num']; $i++) {
// $redis->lPush($name_g, "2".$v['rec_id'] . '_' . $i);
// }
//
// $jsda['num'] = $v['goods_num'];
// $jsda['order_sn'] = $v['order_sn'];
// $jsda['type'] = 1; //1是5分钟自动补回
// mlog(json_encode($jsda), 'group_buy_log/' . $stoid . '/' . $v['prom_id']);
// }
// }
// }
//
// if ($v['is_zsorder'] == 3) {
// //$name2 = 'pind' . $v['pt_prom_id'] . '-' . $v['pt_listno'] . $stoid;
// $name2=get_redis_name($v['pt_prom_id'],6,$stoid);
//
// if (!doublefind($redis, $name2, $v['order_id'])) {
// $redis->lPush($name2, $v['order_id'] . '_0');
// }
// //$len = $redis->lLen($name2);
// //如果这个团,全部补回,那这个单就没有意思了,要delete掉
// //$teamnum = M('teamlist')->field('ct_num')
// // ->where('id', $v['pt_prom_id'])->find();
//
// //当取消的单是本人开的团,那么这个团要取消掉
// if ($v['is_pt_tz']==1) {
// //$redis->delete($name2);
// del_redis($redis,$name2);
// //要取消这个团
// $da['state'] = 1;
// $map['team_id'] = $v['pt_prom_id'];
// $map['listno'] = $v['pt_listno'];
// $map['store_id'] = $stoid;
//
// mlog("取消订单:".$v['pt_listno'].'-'.$v['order_id'],"login_task/".$stoid);
// M('teamgroup')->where($map)->save($da);
// }
// }
//
// //补回购买的数量
// $hh = M('order_goods')->where('order_id', $v['order_id'])
// ->where('prom_type',6)->where('store_id',$stoid)
// ->field('order_id,goods_num,prom_id,rec_id')->select();
// if($hh) {
// //增加队列
// foreach ($hh as $kq => $vq) {
// //$name0 ='pind'.$vq['prom_id'] . '-' . $stoid;
// $name0 =get_redis_name($vq['prom_id'] ,6,$stoid);
// if(!doublefind($redis,$name0,$vq['rec_id'])) {
// for ($i = 0; $i < $vq['goods_num']; $i++) {
// $redis->lPush($name0, $vq['rec_id'] . "_" . $i);
//
// $jsdaa['num'] = $vq['goods_num'];
// $jsdaa['order_sn'] = $vq['order_sn'];
// $jsdaa['type'] = 1; //1是5分钟自动补回
// mlog(json_encode($jsdaa), 'pt_log/' . $stoid . '/' . $vq['prom_id']."_6");
// }
// }
// }
// }
//
// if (!empty($v['gift_receive_id'])) {
// //M('gift_receive')->where(['id' => ['in', $order['gift_receive_id']]])->delete();//去掉赠品领用记录
// $org=M("order_goods")->where('order_id',$v['order_id'])
// ->where('is_gift',1)->where('store_id',$stoid)
// ->field('rec_id,gift_id,goods_num,prom_id')->select();
//
// if($org){
// foreach($org as $ko=>$vo){
// //从表上删除记录,主表做标记,赠品被取消,同时补回活动的库存
// //M('order_goods')->where('rec_id',$vo['rec_id'])->delete();
// M("order")->where('order_id',$v['order_id'])->where('store_id',$stoid)
// ->save(['is_del_gift'=>1]);
// M("gift")->where('store_id',$stoid)
// ->where('id',$vo['gift_id'])
// ->setInc('goods_num',$vo['goods_num']);
// M('gift_receive')->where(["orderGoods_id"=>$vo['rec_id'],'user_id'=>$v['user_id']])->delete();
// }
//
// }
// }
// }
// }
//访问计时任务
//httpRequest(curHostURL().'/index.php/timer/index/timeset/stoid/'.$getstoid);
//httpRequest(curHostURL().'/index.php/timer/index/time_minutes/stoid/'.$getstoid);
}
function ajax_get_action()
{
$control = I('controller');
$advContrl = get_class_methods("app\\admin\\controller\\" . str_replace('.php', '', $control));
//dump($advContrl);
$baseContrl = get_class_methods('app\admin\controller\Base');
$diffArray = array_diff($advContrl, $baseContrl);
$html = '';
foreach ($diffArray as $val) {
$html .= "<option value='" . $val . "'>" . $val . "</option>";
}
exit($html);
}
function right_list()
{
$group = array('system' => '系统设置', 'content' => '内容管理', 'goods' => '商品中心', 'member' => '会员中心',
'order' => '订单中心', 'marketing' => '营销推广', 'tools' => '插件工具', 'count' => '统计报表'
);
$right_list = M('system_menu')->select();
$this->assign('right_list', $right_list);
$this->assign('group', $group);
return $this->fetch('', getAdmStoId());
}
public function edit_right()
{
if (IS_POST) {
$data = I('post.');
$data['right'] = implode(',', $data['right']);
if (!empty($data['id'])) {
// upload_ylp_log('修改权限');
M('system_menu')->where(array('id' => $data['id']))->save($data);
} else {
if (M('system_menu')->where(array('name' => $data['name']))->count() > 0) {
$this->error('该权限名称已添加,请检查', U('System/right_list'));
}
unset($data['id']);
// upload_ylp_log('新增权限');
M('system_menu')->add($data);
}
$this->success('操作成功', U('System/right_list'));
exit;
}
$id = I('id');
if ($id) {
$info = M('system_menu')->where(array('id' => $id))->find();
$info['right'] = explode(',', $info['right']);
$this->assign('info', $info);
}
$group = array('system' => '系统设置', 'content' => '内容管理', 'goods' => '商品中心', 'member' => '会员中心',
'order' => '订单中心', 'marketing' => '营销推广', 'tools' => '插件工具', 'count' => '统计报表'
);
$planPath = APP_PATH . 'Admin/Controller';
$planList = array();
$dirRes = opendir($planPath);
while ($dir = readdir($dirRes)) {
if (!in_array($dir, array('.', '..', '.svn'))) {
$planList[] = basename($dir, '.class.php');
}
}
$this->assign('planList', $planList);
$this->assign('group', $group);
return $this->fetch('', getAdmStoId());
}
public function right_del()
{
$id = I('del_id');
if (is_array($id)) {
$id = implode(',', $id);
}
if (!empty($id)) {
// upload_ylp_log('删除权限');
$r = M('system_menu')->where("id in ($id)")->delete();
if ($r) {
respose(1);
} else {
respose('删除失败');
}
} else {
respose('参数有误');
}
}
private function initEditor()
{
$this->assign("URL_upload", U('Admin/Ueditor/imageUp', array('savepath' => 'wechat')));
$this->assign("URL_fileUp", U('Admin/Ueditor/fileUp', array('savepath' => 'wechat')));
$this->assign("URL_scrawlUp", U('Admin/Ueditor/scrawlUp', array('savepath' => 'wechat')));
$this->assign("URL_getRemoteImage", U('Admin/Ueditor/getRemoteImage', array('savepath' => 'wechat')));
$this->assign("URL_imageManager", U('Admin/Ueditor/imageManager', array('savepath' => 'wechat')));
$this->assign("URL_imageUp", U('Admin/Ueditor/imageUp', array('savepath' => 'wechat')));
$this->assign("URL_getMovie", U('Admin/Ueditor/getMovie', array('savepath' => 'wechat')));
$this->assign("URL_Home", "");
}
/*--设置分销商注册邀请奖励--*/
public function setjiangli()
{
$is_ajax = I('is_ajax');
$data = I('post.');
/*
{"first_money":5,"second_money":3,"third_money":1}
*/
if ($is_ajax == 1) {
ClearALLCache();
delFile(TEMP_PATH . "/" . getAdmStoId());
$jdata['first_money'] = $data['first_money'];
$jdata['second_money'] = $data['second_money'];
$jdata['third_money'] = $data['third_money'];
$da = ['is_invitation_rate' => $data['is_invitation_rate'],
'invitation_ratelist' => json_encode($jdata)];
$rs0 = M('store_distribut')->where("store_id", getAdmStoId())->field('Id')->find();
$rs=null;
if($rs0){
$rs = M('store_distribut')->where("store_id", getAdmStoId())->save($da);
}else{
$da["store_id"]=getAdmStoId();
$rs = M('store_distribut')->save($da);
}
if ($rs !== false) {
$newData = M('store_distribut')->where("store_id", getAdmStoId())->find();
F("distribut" . "_" . getAdmStoId(), $newData, TEMP_PATH);
return json(['code' => 1, 'msg' => '设置成功']);
} else {
return json(['code' => -1, 'msg' => '设置值未改变或失败']);
}
}
/*--dis--*/
$dis = tpCache('distribut', getAdmStoId());
$json = json_decode($dis['invitation_ratelist'], true);
$config = [];
if ($json) {
$config = $json;
}else{
$dis['is_invitation_rate']=1;
}
$this->assign("distribut", $dis);
$this->assign("config", $config);
return $this->fetch('', getAdmStoId());
}
//选择商品
public function search_goods()
{
$GoodsLogic = new GoodsLogic;
$brandList = $GoodsLogic->getSortBrands();
$this->assign('brandList', $brandList);
$categoryList = $GoodsLogic->getSortCategory();
$this->assign('categoryList', $categoryList);
$goods_id = I('goods_id');
$price = I('price');
$t=time();
$where = "is_on_sale = 1 and store_count>0 and on_time<".$t." and (down_time>".$t." or down_time=0 or down_time='' or down_time is null)";
if (!empty($goods_id)) {
$where .= " and goods_id not in ($goods_id) ";
}
if (!empty($price)) {
$where .= " and market_price >= " . $price;
}
I('intro') && $where = "$where and " . I('intro') . " = 1";
if (I('cat_id')) {
$this->assign('cat_id', I('cat_id'));
$grandson_ids = getCatGrandson(I('cat_id'));
$where = " $where and cat_id in(" . implode(',', $grandson_ids) . ") "; // 初始化搜索条件
}
if (I('brand_id')) {
$this->assign('brand_id', I('brand_id'));
$where = "$where and brand_id = " . I('brand_id');
}
if (!empty($_REQUEST['keywords'])) {
$kw = I('keywords');
$kword = urldecode(urldecode($kw));
$this->assign('keywords', $kword);
$where = "$where and (goods_sn like '%" . $kword . "%' or goods_name like '%" . $kword . "%' or keywords like '%" . $kword . "%' or sku = '" . $kw . "')";
}
$getAdmStoId = getAdmStoId();
$where .= " and store_id=" . $getAdmStoId;
$count = M('goods')->where($where)->count();
$Page = new Page($count, 10);
$goodsList = M('goods')->where($where)->order('goods_id DESC')->limit($Page->firstRow . ',' . $Page->listRows)->select();
$show = $Page->show();//分页显示输出
$this->assign('page', $show);//赋值分页输出
$this->assign('goodsList', $goodsList);
$this->assign('pager', $Page);//赋值分页输出
$tpl = I('get.tpl', 'select_goods');
// upload_ylp_log('搜索商品');
return $this->fetch($tpl, getAdmStoId());
}
public function not_distribut(){
$is_out=I('out');
$this -> assign('is_out',$is_out);
$ucount=M('users')->where("store_id",getAdmStoId())->where('is_distribut',1)->count();
$this->assign('ucount',$ucount);
$yy=M("storage_recharge")->where("store_id",getAdmStoId())->where('recharge_state',1)
->where("distri_price_id>0")->field('distri_price_id')->select();
$aarr = M("distri_price")->order('type desc,money desc')->select();
$barr = null;
if($yy) {
/*---
$idarr = get_arr_column($yy, 'distri_price_id');
$aarr0 = M("distri_price")->order('type desc,money desc')->where('id', 'in', $idarr)->find();
foreach ($aarr as $k => $v) {
if($v['id']!=$aarr0['id']){
$barr[]=$v;
}else{
break;
}
}---*/
foreach ($aarr as $k => $v) {
if($v['user_num']>$ucount && $v['type']==0){
if($v['money']<=0)
break;
else{}
$barr[]=$v;
}else{
if($v['type']==1)
$barr[]=$v;
else
break;
}
}
}else{
$barr=$aarr;
}
if($barr){
$this -> assign('price_arr',array_reverse($barr));
}
return $this->fetch("", getAdmStoId());
}
//更新等级卡信息
public function updateCardInfo()
{
$getcardid = I('cardid');
$getcardimg = I('cardimg');
$getcardcolor = I('cardcolor');
if (empty($getcardid) || empty($getcardimg) || empty($getcardcolor)) {
return json(['code' => -1, 'msg' => '参数不能为空']);
}
$accdb = tpCache("shop_info.ERPId", getAdmStoId());
$wdata['CardId'] = $getcardid;
$wdata['CardColor'] = $getcardcolor;
$wdata['CardImg'] = $getcardimg;
$rs = getApiData_java_p('/api/erp/vip/mem/bership/update', $accdb, $wdata, 1, 10, null, "PUT");
return json_decode($rs, true);
}
//plus会员推荐码
public function plusqrcode()
{
$pagenum = 20;//每页显示多少条
if ((int)I('pagenum/s') > 0) {
$pagenum = I('pagenum/s');
}
$p = I('p', 1);
$keyword = I('keyword');//手机号码
$where = " a.StoreId=" . getAdmStoId();
if ($keyword) {
$where .= " and (a.StaffNo like '%$keyword%' or a.StaffMobile like '%$keyword%')";
}
$qdrecord = M('plus_qrcode');
$count = $qdrecord->alias('a')
->where($where)->count();
$Page = $pager = new Page($count, $pagenum);// 实例化分页类 传入总记录数和每页显示的记录数
$res = $qdrecord->alias('a')
->where($where)
->limit($Page->firstRow . ',' . $Page->listRows)
->order('a.AddTime desc')
->select();// 查询满足要求的总记录数
$show = $Page->show();
$this->assign('page', $show);
$this->assign('pager', $pager);
$this->assign('total', $count);
$this->assign('info', $res);
$this->assign('urlhttp', curHostURL());
$this->assign('getadmstoid', getAdmStoId());
return $this->fetch('', getAdmStoId());
}
//创建plus会员推荐码
public function create_plusqrcode()
{
$qrcodeno = I('qrcodeno');
if (empty($qrcodeno)) {
return json(['code' => -1, 'msg' => '营业员编号不能为空']);
}
$getadmstoid = getAdmStoId();
$qrcodeinfo = M('plus_qrcode')->where(array("StoreId"=>$getadmstoid,'StaffNo'=>$qrcodeno))->find();
if ($qrcodeinfo)
{
return json(['code' => -1, 'msg' => '生成失败,该营业员已存在!']);
}
$accdb = tpCache("shop_info.ERPId", $getadmstoid);
$wdata['KeyWord'] = $qrcodeno;
$rs = getApiData_java_p('/api/erp/vip/mem/referee/staff/check', $accdb, $wdata, 1, 10, null, "POST");
if (empty($rs)) {
return json(['code' => -1, 'msg' => '生成失败,不是营业员!']);
}
$rs = json_decode($rs, true);
if ($rs['code']!=0)
{
return json(['code' => -1, 'msg' => $rs['msg']]);
}
$getstaffname = $rs['data']['pageData'][0]['StaffName'];
$getstaffmobile = $rs['data']['pageData'][0]['Tel'];
$userinfo = M('users')->where(array('store_id' => $getadmstoid, 'mobile' => $getstaffmobile,'erpvipid'=>array('neq','')))->find();
if (empty($userinfo)) {
return json(['code' => -1, 'msg' => '生成失败,该营业员绑定手机未注册!']);
}
$wdata1['VIPId'] = urlencode($userinfo['erpvipid']);
$rs = getApiData_java_p('/api/erp/vip/mem/list', $accdb, $wdata1, 1, 10, null, "GET");
if (empty($rs)) {
return json(['code' => -1, 'msg' => '生成失败,未获取到plus会员!']);
}
$rs = json_decode($rs, true);
//if ($rs['code']!=0 || empty($rs['GradeCardID']))
if ($rs['code']!=0 || empty($rs['data'][0]['GradeCardID']))
{
return json(['code' => -1,'msg' => '生成失败,该手机不是plus会员!']);
}
$getuserid = $userinfo['user_id'];
$adddata['StoreId'] = $getadmstoid;
$adddata['StaffNo'] = $qrcodeno;
$adddata['StaffName'] = $getstaffname;
$adddata['StaffMobile'] = $getstaffmobile;
$adddata['AddTime'] = time();
$adddata['UserId'] = $getuserid;
$saveinfo = M('plus_qrcode')->add($adddata);
if (empty($saveinfo)) {
return json(['code' => -1, 'msg' => '生成失败,请重试!']);
}
return json(['code' => 0, 'msg' => '生成成功!']);
}
//创建plus会员推荐码
public function delplusqrcode()
{
$getid = I('id/d', 0);
if (empty($getid)) {
$this->error('删除失败,参数有误!', U('System/plusqrcode'));
exit();
}
$info = M('plus_qrcode')->where(array('StoreId' => getAdmStoId(), 'Id' => $getid))->find();
if (empty($info)) {
$this->error('删除失败,找不到该信息!', U('System/plusqrcode'));
exit();
}
if ($info['InvitationNum']) {
$this->error('删除失败,该二维码已邀请人数!', U('System/plusqrcode'));
exit();
}
M('plus_qrcode')->where(array('StoreId' => getAdmStoId(), 'Id' => $getid))->delete();
$this->success("删除成功!!!", U('System/plusqrcode'));
exit();
}
}