Home.php
35.9 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
<?php
use Action\AbstractAction;
use Home\GradeModel;
use Home\OrderModel;
use Plugin\Helpers;
use LibModels\Wap\Home\OrderData;
use Index\UserModel as UserModel;
use Plugin\Pay\weixin\JsApiPay;
use Plugin\Pay\weixin\lib\WxPayUnifiedOrder;
use Plugin\Pay\weixin\lib\WxPayApi;
use Plugin\Pay\weixin\lib\WxPayConfig;
use Plugin\UdpLog;
use Plugin\Encryption;
/**
* 个人中心相关的控制器
*
* @name HomeController
* @package
* @copyright yoho.inc
* @version 1.0 (2015-10-28 16:28:32)
*/
class HomeController extends AbstractAction
{
protected $_uid;
/**
* 通过当前用户审判是否跳到登录
*
* @param boolean $useSession (true:从服务端session中检查, false:从客户端cookie中检查)
* @return void
*/
protected function auditJumpLogin($useSession = true)
{
$uid = $this->getUid($useSession);
if (!$uid) {
$this->go(Helpers::url('/signin.html', array('refer' => Helpers::url($this->server('REQUEST_URI', '/home')))));
}
}
/**
* 个人中心入口
*/
public function indexAction()
{
// 设置网站标题
$this->setTitle('个人中心');
$this->setNavHeader('个人中心', SITE_MAIN . '/?go=1');
$data = array(
'myIndexPage' => true,
'showDownloadApp' => true,
'navHome' => true,
'notice' => UserModel::getNoticeData(),
'pageFooter' => true,
'cartUrl' => Helpers::url('/cart/index/index', null),
'signinUrl' => Helpers::url('/signin.html', array('refer' => Helpers::url('/home'))),
'verifyUrl' => Helpers::url('/activity/student/register')
);
$uid = $this->getUid(true);
// print_r($uid);exit;
if ($uid) {
$data['isLogin'] = true;
$udid = $uid . $this->getUdid();
$data += UserModel::getUserProfileData($uid);
$data += UserModel::getInfoNumData($uid, $udid);
}
$notice = UserModel::getHomeNotice();
if (!empty($notice)) {
$data['notice'] = $notice;
}
$this->_view->display('index', $data);
}
/**
* 为您优选
*/
public function preferenceAction()
{
$result = array();
if ($this->isAjax()) {
// 优选新品数据
$channel = Helpers::getChannelByCookie();
$result = UserModel::getPreferenceData($channel);
}
if (empty($result)) {
echo ' ';
}
else {
$this->_view->display('recommend-content', $result);
}
}
/**
* 用户收藏的商品
*/
public function favoriteAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('我的收藏');
$this->setNavHeader('我的收藏');
$tab = $this->get('tab', '');
$data = array(
'favPage' => true, //加载js
'pageFooter' => true,
'favorite' => true,
'productUrl' => Helpers::url('/product/new'),
'brandUrl' => Helpers::url('/product/new'),
'brandTab' => $tab === 'brand' ? true : false, // 是否为品牌收藏页
);
$this->_view->display('favorite', $data);
}
/**
* 用户收藏的商品数据获取接口
*/
public function favProductAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$page = $this->post('page', 1);
$result = UserModel::getFavProductData($uid, $page, 10);
}
if (empty($result)) {
echo ' ';
}
else if (isset($result['end'])) {
echo 'end';
}
else {
$this->_view->display('favorite_product', $result);
}
}
/**
* 用户收藏的品牌数据获取接口
*/
public function favBrandAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$page = $this->post('page', 1);
$gender = Helpers::getGenderByCookie();
$result = UserModel::getFavBrandData($uid, $gender, $page, 10);
}
if (empty($result)) {
echo ' ';
}
else if (isset($result['end'])) {
echo 'end';
}
else {
$this->_view->display('favorite_brand', $result);
}
}
/**
* 用户收藏的商品-删除
*/
public function favoriteDelAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$favId = $this->post('id', 0);
$result = UserModel::favoriteDelete($uid, $favId);
}
if (empty($result)) {
echo ' ';
}
else {
$this->echoJson($result);
}
}
/**
* 浏览记录页面
*/
public function recordAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('浏览记录');
$this->setNavHeader('浏览记录', true, false);
$this->_view->display('browse-record', array(
'browseRecordPage' => true,
'pageFooter' => true
));
}
/**
* 浏览记录
*/
public function recordContentAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$udid = $uid . $this->getUdid();
$page = $this->get('page', 1);
$result = UserModel::browserRecord($uid, $udid, $page, 100);
}
if (empty($result)) {
echo ' ';
}
else {
$this->_view->display('browse-record-content', $result);
}
}
/**
* 删除浏览记录
*/
public function delRecordAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$skn = $this->get('skn', 0);
$result = UserModel::delRecord($uid, $skn);
}
$this->echoJson($result);
}
/**
* 个人信息
*/
public function mydetailsAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('个人信息');
$this->setNavHeader('个人信息', true, false);
$data = UserModel::getUserProfileData($this->getUid(true));
$data['personalDetailsPage'] = true;
$data['pageFooter'] = true;
$this->_view->display('personal-details', $data);
}
/**
* 有货币
*/
public function mycurrencyAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('有货币');
$this->setNavHeader('有货币', true, false);
$currency = UserModel::getYohoCoinData($this->_uid);
// banenr数据
$currency['banner'] = UserModel::getYohoCoinBanner();
$currency['pageFooter'] = true;
$currency['currencyPage'] = true;
$this->_view->display('currency-new', $currency);
}
/**
* 消息
*/
public function messageAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('我的消息');
$this->setNavHeader('我的消息', true, false);
$messages['pageFooter'] = true;
$messages['messagePage'] = true;
$this->_view->display('message', $messages);
}
/*
* 异步获取我的消息
*/
public function ajaxMessageAction()
{
$result = array();
if ($this->isAjax()) {
$page = $this->post('page', 1);
$uid = $this->getUid(true);
$result = UserModel::getMessageData($uid, $page, 20);
}
if (empty($result)) {
echo ' ';
}
else {
$this->_view->display('message-list', $result);
}
}
/*
* 异步删除我的消息
*/
public function ajaxDelMesAction()
{
$result = array();
if ($this->isAjax()) {
$id = $this->post('id', 0);
$uid = $this->getUid(true);
$result = UserModel::delMessage($uid, $id);
}
$this->echoJson($result);
}
/**
* 消息详情
*/
public function messageDetailAction()
{
$this->setTitle('我的消息');
$this->setNavHeader('我的消息', true, false);
$id = $this->get('id', 0);
$uid = $this->getUid(true);
$data = UserModel::getMessageDetail($uid, $id);
$data['pageFooter'] = true;
$data['messageDetailPage'] = true;
$this->_view->display('message-main', $data);
}
/**
* 我的消息详情中领取生日券
*/
public function pickCouponAction()
{
$result = array('code' => 400, 'message' => '', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
$uid = $this->getUid(true);
$id = $this->post('id', 0);
$result = UserModel::pickBirthCoupon($uid, $id);
}
while (false);
$this->echoJson($result);
}
/**
* 优惠券
*/
public function couponsAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('优惠券');
$this->setNavHeader('优惠券', true, false);
$coupons = array(
'couponsPage' => true,
'pageFooter' => true
);
$this->_view->display('coupons', $coupons);
}
/**
* 异步获取指定状态的优惠券数据
*/
public function couponDataAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$status = $this->post('status', 0);
$page = $this->post('page', 1);
$result = UserModel::getCouponData($uid, $status, $page);
}
if (empty($result)) {
echo ' ';
}
else {
$this->_view->display('coupon_list', $result);
}
}
/**
* 异步获取三级地址数据
*/
public function locationListAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$result['addressList'] = UserModel::getAddressListData($uid);
}
if (empty($result)) {
echo ' ';
}
else {
$this->_view->display('location-list', $result);
}
}
/**
* 地址管理
*/
public function addressAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('地址管理');
$this->setNavHeader('地址管理', Helpers::url('/home'), false);
$uid = $this->_uid;
$address = UserModel::getAddressData($uid);
$this->_view->display('address', array(
'addressPage' => true,
'pageFooter' => true,
'address' => $address,
'showAddBtn' => (count($address) <= 5),
));
}
/**
*
* 地址编辑或添加页面
*/
public function addressActAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$uid = $this->_uid;
$id = $this->get('id', null);
$data = array(
'addressActionPage' => true,
'addressList' => UserModel::getAddressListData($uid)
);
if ($id !== null) { // 编辑地址
// 设置网站标题
$this->setTitle('编辑地址');
$this->setNavHeader('编辑地址', true, false);
$data['id'] = $id;
// 获取特定地址的数据
$data['address'] = UserModel::getAddressDataById($uid, $id);
}
else {
// 设置网站标题
$this->setTitle('添加地址');
$this->setNavHeader('添加地址', true, false);
}
$this->_view->display('address-act', $data);
}
/**
* 修改地址或者添加新地址
*/
public function saveAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$address = $this->post('address', '');
$areaCode = $this->post('area_code', '');
$consignee = $this->post('consignee', '');
$email = $this->post('email', '');
$id = $this->post('id', null);
if ($id) {
$id = Encryption::decrypt($id);
}
$mobile = $this->post('mobile', '');
$zipCode = $this->post('zip_code', '');
$result = UserModel::saveAddressData($uid, $address, $areaCode, $consignee, $email, $id, $mobile, $zipCode);
}
if (empty($result)) {
echo ' ';
}
else {
$this->echoJson($result);
}
}
/**
* 设置默认地址
*/
public function defaultAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$id = $this->post('id', '');
if ($id) {
$id = Encryption::decrypt($id);
}
$result = UserModel::setDefaultAddress($uid, $id);
}
if (empty($result)) {
echo ' ';
}
else {
$this->echoJson($result);
}
}
/**
* 删除地址
*/
public function delAddressAction()
{
$result = array();
if ($this->isAjax()) {
$uid = $this->getUid(true);
$id = $this->post('id', '');
if ($id) {
$id = Encryption::decrypt($id);
}
$result = UserModel::deleteAddress($uid, $id);
}
if (empty($result)) {
echo ' ';
}
else {
$this->echoJson($result);
}
}
/**
* 在线客服
*/
public function onlineServiceAction()
{
// 设置网站标题
$this->setTitle('在线客服');
$this->setNavHeader('在线客服', Helpers::url('/home'), false);
$uid = $this->getUid(false);
$service = Home\OnlineModel::getOnlineServiceInfo();
//$serviceUrl = 'http://chat80.live800.com/live800/chatClient/chatbox.jsp?companyID=493979&configID=123576&jid=9277320930';
// 在线客服
$serviceUrl = 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=';
if ($uid) {
$time = time() . '000';
$info = 'userId=' . $uid . '&name=' . $this->_uname . '&memo=&hashCode=' . md5(strtoupper(rawurlencode($uid . $this->_uname . $time . '1231'))) . '×tamp=' . $time;
$serviceUrl .= rawurlencode($info);
}
$this->_view->display('online-service', array(
'onlineServicePage' => true,
'pageFooter' => true,
'service' => $service,
'serviceUrl' => $serviceUrl,
));
}
/**
* 在线客服-具体详情
*/
public function onlineServiceDetailAction()
{
$cateInfo = $this->get('cateInfo', '');
$cate = explode("_", $cateInfo);
$cateId = isset($cate[0]) ? intval($cate[0]) : 0;
$cateName = isset($cate[1]) ? $cate[1] : '在线客服';
if ($cateId > 0) {
$service = Home\OnlineModel::getOnlineServiceDetail($cateId);
}
$service = array(
'pageFooter' => true,
'service' => $service
);
$this->setTitle('在线客服');
$this->setNavHeader($cateName, true, false);
$this->_view->display('online-service-detail', $service);
}
/**
* 我的逛
*/
public function myGuangAction()
{
$page = $this->get('page', 1);
$uid = $this->getUid(true);
$gender = Helpers::getGenderByCookie();
$channel = Helpers::getChannelByCookie();
$guangInfo = \Home\GuangModel::getMyGuang($uid, $page, $channel, $gender, 10);
$totalPage = $guangInfo['totalPage'];
if ($page == 1) {
$this->setTitle('我收藏的');
$this->setNavHeader('我收藏的', true, '');
$this->_view->display('my-guang', array('myGuangPage' => true, 'myGuang' => array('infos' => $guangInfo), 'pageFooter' => true));
}
else if ($page > 1 && $page <= $totalPage) {
$this->_view->display('my-guang-partial', array('infos' => $guangInfo));
}
else if ($page > 1 && $page > $totalPage) {
echo ' '; //退出循环
}
}
/**
* 意见反馈
*/
public function suggestAction()
{
// 设置网站标题
$this->setTitle('意见反馈');
$this->setNavHeader('意见反馈', true, false);
$udid = $this->getUdid();
$page = $this->get('page', 1);
$limit = $this->get('limit', 30);
$suggest = UserModel::getSuggestData($udid, $page, $limit);
$this->_view->display('suggest', array(
'suggestPage' => true, //加载js
'pageFooter' => true,
'suggest' => true,
'suggestContent' => $suggest
));
}
/**
* 意见反馈-提交表单页面
*/
public function suggestSubAction()
{
// 设置网站标题
$this->setTitle('反馈问题');
$this->setNavHeader('反馈问题', true, false, '提交');
$data = array(
'suggestPage' => true, //加载js
'suggestSub' => true,
'pageFooter' => true
);
$this->_view->display('suggest-sub', $data);
}
/**
* 异步上传图片
*/
public function suggestimgUploadAction()
{
$result = UserModel::saveSuggestImg('fileData');
$this->echoJson($result);
}
/**
* 异步保存意见反馈数据
*/
public function savesuggestAction()
{
if ($this->isAjax()) {
$uid = $this->getUid(true);
$content = $this->post('content', '');
$suggest_type = $this->post('suggest_type', 2);
$image = $this->post('image', null);
$result = UserModel::saveSuggestData($uid, $content, $image, $suggest_type);
$this->echoJson($result);
}
}
/**
* 异步点击靠谱或者不靠谱
*/
public function upAndDownAction()
{
if ($this->isAjax()) {
$uid = $this->getUid(true);
$udid = $this->getUdid();
$suggest_id = $this->post('suggest_id', 0);
$reliable = $this->post('reliable', 2);
$result = UserModel::upAndDown($uid, $udid, $suggest_id, $reliable);
$this->echoJson($result);
}
}
/**
* 会员等级展示页
*/
public function gradeAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
//设置网站seo信息
$this->setTitle('会员等级');
//显示网站导航头部信息
$this->setNavHeader('会员等级', true, false);
$channel = Helpers::getChannelByCookie();
$data = GradeModel::getGrade($channel, $this->_uid);
$data['pageFooter'] = true;
$this->_view->display('vip-grade', $data);
}
/*
* 会员特权查看页
*/
public function preferentialAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
//设置网站seo信息
$this->setTitle('会员等级');
//显示网站导航头部信息
$this->setNavHeader('会员特权详情', true, false);
$channel = Helpers::getChannelByCookie();
$data = GradeModel::getPreferential($channel, $this->_uid);
$data['pageFooter'] = true;
$this->_view->display('privilege', $data);
}
/*
* 我的订单页面,获得nav导航条焦点。并且异步请求订单详情列表页(getOrders)
*
*/
public function ordersAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('我的订单');
$this->setNavHeader('我的订单', Helpers::url('/home'), false);
$order = array();
//获得type值,type:1=>全部,2=>待付款,3=>待发货,4=>待收货,5=>待评论
$type = $this->get('type', 1);
$data = OrderModel::getNavs($type);
if (!empty($data)) {
$order['navs'] = $data;
}
//取消订单原因列表
$resons = OrderData::closeReasons();
$order['cancelReason'] = isset($resons['data']) ? $resons['data'] : '';
//渲染模板
$this->_view->display('order', array(
'order' => $order,
'pageFooter' => true,
'orderPage' => true
));
}
/**
* ajax请求订单页面
*/
public function getOrdersAction()
{
//判断是不是ajax请求
if (!$this->isAjax()) {
echo ' ';
}
//获取基本参数:type 1:全部 2:待付款 3:待发货 4:待收货 5:待评论 7:失败 取消 订单
$type = $this->get('type', 1);
$page = $this->get('page', 1);
//调用模型层getOrder方法获得并处理数据
$uid = $this->getUid(true);
$gender = Helpers::getGenderByCookie();
$channel = Helpers::getChannelByCookie();
$data = OrderModel::getOrder($type, $page, 10, $gender, $channel, $uid);
/* 如果取不到订单数据时,分两种情况:
1、page>1时,echo一个空格字符串到浏览器。
2、page=1时,就给一个随便逛逛的链接。
* */
$order = array();
if (!empty($data)) {
$order['orders'] = $data;
}
else if ($page == 1) {
$order['walkwayUrl'] = Helpers::url('/product/new');
}
else {
echo ' ';
exit();
}
//渲染模板
$this->_view->display('order-content', $order);
}
/**
* 我的订单——再次购买
*/
public function reAddAction()
{
$result = array('code' => 401, 'message' => '商品加入购物车失败', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
//获取相关参数
$uid = $this->getUid(true);
$orderCode = $this->get('orderCode', '');
if (!$uid || !$orderCode) {
$result = array('code' => 400, 'message' => '缺失参数', 'data' => '');
break;
}
$reAddData = OrderData::reAddData($uid, $orderCode);
if(!isset($reAddData['code']) || $reAddData['code'] != 200){
break;
}
$result = array('code' => 200, 'message' => '商品已重新加入购物车', 'data' => $reAddData['data']);
if (!isset($result['code'])) {
break;
}
}
while (false);
$this->echoJson($result);
}
/*
* 我的订单-取消订单
*/
public function cancelOrderAction()
{
//判断是不是ajax请求
if (!$this->isAjax()) {
$this->echoJson(array('code' => 200));
}
//传入orderCode取消订单
$orderCode = $this->get('id'); //订单号
$reason = $this->get('reason', ''); //取消订单原因
$reasonid = $this->get('reasonId', ''); //取消原因id
$gender = Helpers::getGenderByCookie();
$channel = Helpers::getChannelByCookie();
$uid = $this->getUid(true);
//调用取消订单接口,返回订单取消状态
$data = OrderData::cancelOrderData($orderCode, $uid, $gender, $channel, $reason, $reasonid);
//将取消状态返回至浏览器
if (!$data) {
$this->echoJson(array('message' => '取消订单失败'));
}
else if (empty($data['code']) && empty($data['message'])) {
$this->echoJson(array('code' => 200));
}
else {
$this->echoJson($data);
}
}
/*
* 我的订单-删除订单
*/
public function delOrderAction()
{
//判断是不是ajax请求
if (!$this->isAjax()) {
$this->echoJson(array('code' => 200));
}
//传入orderCode删除订单
$orderCode = $this->get('id');
$gender = Helpers::getGenderByCookie();
$channel = Helpers::getChannelByCookie();
$uid = $this->getUid(true);
//调用接口删除订单,并返回订单删除状态
$data = OrderData::deleteOrderData($orderCode, $uid, $gender, $channel);
//将订单删除状态返回至浏览器
if (empty($data['code']) && empty($data['message'])) {
$this->echoJson(array('code' => 200));
}
else {
$this->echoJson($data);
}
}
/**
* 我的订单-查看物流信息
*/
public function logisticAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('物流详情');
$this->setNavHeader('物流详情');
$orderCode = $this->get('order_code');
$data = OrderModel::Logistics($orderCode, $this->_uid);
$data['logisticInfoPage'] = true;
$data['pageFooter'] = true;
$this->_view->display('logistic', $data);
}
/*
* 我的订单-付款跳转页
*/
public function payAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('支付中心');
$this->setNavHeader('支付中心', Helpers::url('/home/orders'), '');
$orderCode = $this->get('order_code');
if (empty($orderCode)) {
$this->error();
}
/* 判断订单信息是否存在 */
$orderDetail = OrderModel::orderDetail($orderCode, $this->_uid, $this->_usession);
if (empty($orderDetail)) {
$this->error();
}
/* 判断订单是否已付款, 已付款跳到订单详情页 */
if (!empty($orderDetail['isPay'])) {
$this->go(Helpers::url('/home/orderdetail', array('order_code' => $orderCode)));
}
$hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false;
if ($hasWxShare) {
$openId = $this->getSession('weixinOpenId' . $orderCode);
if (empty($openId)) {
$tools = new JsApiPay();
$openId = $tools->GetOpenid();
if ($openId) {
$this->setSession('weixinOpenId' . $orderCode, $openId);
}
}
}
$payList = array(
0 => array(
'appIcon' => '',
'payLink' => Helpers::url('/shopping/pay/index', array('order_code' => $orderCode, 'payment_type' => 18)),
'appId' => 'alipay',
'app' => '支付宝支付',
'hint' => '支付宝钱包支付',
'subHint' => '推荐支付宝用户使用'
),
1 => array(
'appIcon' => '',
'payLink' => '',
'appId' => 'weixin',
'app' => '微信支付',
'hint' => '推荐使用',
'subHint' => ''
),
);
$this->_view->display('pay', array(
'payCenterPage' => true,
'payAppInfo' => $payList,
'hasWxShare' => $hasWxShare,
'orderCode' => $orderCode,
'orderTotal' => isset($orderDetail['goodsAmount']) ? $orderDetail['goodsAmount'] : 0,
'orderTotalFormat' => isset($orderDetail['goodsAmount']) ? sprintf("%d", $orderDetail['goodsAmount']) : 0,
'orderCount' => isset($orderDetail['orderCount']) ? $orderDetail['orderCount'] : 0,
'isOldUser' => (isset($_COOKIE['_isOldUser']) && $_COOKIE['_isOldUser'] == '4') ? 'true' : 'false',
'uid' => $this->_uid,
));
}
/**
* 微信支付 API
*/
public function weixinapiAction()
{
do {
if (!$this->isAjax()) {
break;
}
$uid = $this->getUid(true);
if (!$uid) {
break;
}
$orderCode = $this->get('order_code');
if (empty($orderCode)) {
break;
}
/* 判断订单信息不存在 */
$orderDetail = OrderData::viewOrderData($orderCode, $uid, $this->_usession);
if (empty($orderDetail['data'])) {
UdpLog::info('【微信支付下单】订单信息校验','orderCode:'.$orderCode.'uid:'.$uid.'返回:'.json_encode($orderDetail));
break;
}
$totalFee = strval($orderDetail['data']['payment_amount'] * 100);
$openId = $this->getSession('weixinOpenId' . $orderCode);
if (empty($openId)) {
UdpLog::info('【微信支付下单】Session中的weixinOpenId校验','weixinOpenId为空');
break;
}
//统一下单
$tools = new JsApiPay();
$input = new WxPayUnifiedOrder();
$input->SetBody('有货订单号:' . $orderCode);
$input->SetOut_trade_no('YOHOBuy_' . $orderCode); // 商户订单号
$input->SetTotal_fee($totalFee);
$input->SetTime_start(date("YmdHis", (int) $orderDetail['data']['create_time']));
$input->SetTime_expire(date("YmdHis", (int) $orderDetail['data']['create_time'] + 7200));
$input->SetTrade_type("JSAPI");
$input->SetOpenid($openId);
$order = WxPayApi::unifiedOrder($input);
UdpLog::info('【微信支付下单】统一下单时返回结果,','input:'.$input.'返回:'.json_encode($order));
$jsApiParameters = $tools->GetJsApiParameters($order);
UdpLog::info('【微信支付下单】支付参数,','order:'.$order.'uid:'.$uid.'返回:'.$jsApiParameters);
$this->echoJson(array('code' => 200, 'data' => array('jsApiParameters' => json_decode($jsApiParameters))));
}
while (false);
}
// /*
// * 我的订单-确认收货
// */
// private function confirmAction(){
// //
// $gender = Helpers::getGenderByCookie();
// $order_code = $this->get('id');
// $order_code = '';
// $yh_channel = $this->get('yh_channel', 1);
// $data = OrderData::confirmData($gender,$order_code,$yh_channel,$this->_uid);
// $this->echoJson($data);
// }
/**
* 订单详情页
*/
public function orderdetailAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
/* 判断订单号是否传 */
$orderCode = $this->get('order_code');
if (empty($orderCode)) {
$this->error();
}
/* 判断订单信息是否存在 */
$orderDetail = OrderModel::orderDetail($orderCode, $this->_uid, $this->_usession);
if (empty($orderDetail)) {
$this->error();
}
$this->setTitle('订单详情');
$this->setNavHeader('订单详情', true, false);
$openId = $this->get('openId', '');
if (!empty($openId)) {
//微信支付成功,发送支付确认接口
OrderData::payConfirm($orderCode, 22, $this->_uid);
}
$this->_view->display('order-detail', array(
'orderDetailPage' => true,
'invoice' => empty($orderDetail['invoice']) ? array() : $orderDetail['invoice'],
'serviceUrl' => 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=',
'orderDetail' => $orderDetail,
'orderCode' => $orderCode,
'orderTotal' => isset($orderDetail['goodsAmount']) ? $orderDetail['goodsAmount'] : 0,
'orderTotalFormat' => isset($orderDetail['goodsAmount']) ? sprintf("%d", $orderDetail['goodsAmount']) : 0,
'orderCount' => isset($orderDetail['orderCount']) ? intval($orderDetail['orderCount']) : 0,
'isOldUser' => (isset($_COOKIE['_isOldUser']) && $_COOKIE['_isOldUser'] == '4') ? 'true' : 'false',
'uid' => $this->_uid
));
}
/**
* 订单详情页——地址列表
*/
public function addressModifyAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
// 设置网站标题
$this->setTitle('选择地址');
$this->setNavHeader('选择地址');
$uid = $this->_uid;
$address = UserModel::getAddressData($uid);
$orderCode = $this->get('orderCode', '');
$relation = $this->get('relation', '');
//以下为测试数据
$this->_view->display('address_modify', array(
'addressModifyPage' => true,
'pageFooter' => true,
'address' => $address,
'showAddBtn' => (count($address) <= 5),
'orderCode' => $orderCode,
'relation' => $relation
));
}
/**
* 订单详情页地址修改
*/
public function chooseAddressAction()
{
$result = array('code' => 400, 'message' => '', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
//获取相关参数
$order_code = $this->get('orderCode', ''); //订单号
$address_id = $this->get('addressId', ''); //地址id
if (!$order_code || !$address_id) {
$result = array('code' => 400, 'message' => '缺失必填项', 'data' => '');
break;
}
//address_id解密
$address_id = Encryption::decrypt($address_id);
$result = OrderData::updateDeliveryAddress($order_code, $address_id);
if (!isset($result['code'])) {
break;
}
}
while (false);
$this->echoJson($result);
}
/**
* 帮助中心列表页
*/
public function helpAction()
{
$this->setTitle('帮助中心');
$this->setNavHeader('帮助中心', true, false);
$this->_view->display('help', array(
'iHelp' => Home\HelpModel::serviceInfo(),
'pageFooter' => true
));
}
/**
* 帮助中心列表详细信息
*/
public function helpDetailAction()
{
$caption = $this->get('caption', '帮助中心');
$code = $this->get('code', 0);
if (empty($code)) {
$this->error();
}
$this->setTitle($caption);
$this->setNavHeader($caption, true, false);
$this->_view->display('help-detail', array(
'iHelp' => Home\HelpModel::serviceDetail($code),
'pageFooter' => true
));
}
/**
* 有货币详情 新版
*/
public function currencyDetailAction()
{
// 审判跳转登录页
$this->auditJumpLogin();
$this->setTitle('有货币明细');
$this->setNavHeader('有货币明细', true, false);
$data = UserModel::getYohoCoinLists($this->_uid, 0, 20);
$this->_view->display('currency-detail', array(
'money' => $data['money'],
'pageFooter' => true,
'currencyDetailPage' => true,
'currencyDetail' => true,
'currencyDetailPage' => true
));
}
/**
* 有货币详情 AJAX
*/
public function ajaxCurrencyDetailAction()
{
if ($this->isAjax()) {
$uid = $this->getUid();
$page = $this->post('page', 1);
$data = UserModel::getYohoCoinLists($uid, $page, 20);
$this->_view->display('ajax-currency-detail', array(
'currency' => $data['list'],
'pageFooter' => true,
'currencyDetailPage' => true
));
}
else {
echo ' ';
}
}
}