Browse Source

Merge branch 'dev-sxb-back-01' into dev-sxb-notify-01

# Conflicts:
#	app/common/dao/store/order/StoreOrderDao.php
#	app/common/repositories/store/order/StoreGroupOrderRepository.php
#	app/common/repositories/store/order/StoreOrderProductRepository.php
#	app/common/repositories/store/order/StoreOrderRepository.php
sunxbiao 6 months ago
parent
commit
f274f4c05a
94 changed files with 5421 additions and 527 deletions
  1. 684 0
      app/abc.json
  2. 1 1
      app/command/PensionTasks.php
  3. 656 0
      app/command/WiwibaoProductSync.php
  4. 21 0
      app/common/dao/backup/BackupStoreOrderDao.php
  5. 74 0
      app/common/dao/backup/BackupUserChangeDao.php
  6. 25 0
      app/common/dao/backup/BackupUserDao.php
  7. 41 0
      app/common/dao/dividend/DividendLogDao.php
  8. 15 0
      app/common/dao/douhuomall/DouhuomallChangeLogDao.php
  9. 14 0
      app/common/dao/gzc/GzcLogDao.php
  10. 6 1
      app/common/dao/merchant/order/OrderMerchantDao.php
  11. 35 0
      app/common/dao/shared/SharedProsperityRecommendConfigDao.php
  12. 41 0
      app/common/dao/shared/SharedProsperityUserDao.php
  13. 34 1
      app/common/dao/store/order/StoreOrderDao.php
  14. 13 0
      app/common/dao/store/order/StoreOrderProductDao.php
  15. 15 0
      app/common/dao/store/product/ProductAttrValueChangeLogDao.php
  16. 63 1
      app/common/dao/user/UserBillDao.php
  17. 22 0
      app/common/dao/user/UserDao.php
  18. 27 0
      app/common/dao/user/UserOrderKillOrRecoverRecordsDao.php
  19. 27 1
      app/common/dao/user/UserPvLogDao.php
  20. 17 1
      app/common/dao/user/UserSignGongxianDao.php
  21. 79 1
      app/common/dao/user/UserSignScoreDao.php
  22. 27 1
      app/common/dao/user/UserSignVrDao.php
  23. 45 0
      app/common/dao/util/TableOpsDao.php
  24. 2 1
      app/common/enum/CommonEnum.php
  25. 21 0
      app/common/enum/dividend/DividendLogEnum.php
  26. 13 0
      app/common/enum/douhuomall/DouhuomallChangeLogEnum.php
  27. 15 0
      app/common/enum/douhuomall/DouhuomallEnum.php
  28. 5 0
      app/common/enum/store/ProductEnum.php
  29. 1 1
      app/common/middleware/AdminTokenMiddleware.php
  30. 16 0
      app/common/model/backup/BackupStoreOrder.php
  31. 17 0
      app/common/model/backup/BackupUser.php
  32. 17 0
      app/common/model/backup/BackupUserChange.php
  33. 19 0
      app/common/model/dividend/DividendLog.php
  34. 19 0
      app/common/model/douhuomall/DouhuomallChangeLog.php
  35. 18 0
      app/common/model/shared/SharedProsperityRecommendConfig.php
  36. 18 0
      app/common/model/shared/SharedProsperityUser.php
  37. 19 0
      app/common/model/store/product/ProductAttrValueChangeLog.php
  38. 19 0
      app/common/model/user/UserOrderKillOrRecoverRecords.php
  39. 19 0
      app/common/model/user/UserOrderKillRecord.php
  40. 5 0
      app/common/repositories/agreement/AgreementRepository.php
  41. 64 0
      app/common/repositories/dividend/DividendLogRepository.php
  42. 39 0
      app/common/repositories/douhuomall/DouhuomallChangeLogRepository.php
  43. 97 55
      app/common/repositories/finance/FinanceRepository.php
  44. 11 11
      app/common/repositories/merchant/order/OrderMerchantRepository.php
  45. 49 0
      app/common/repositories/shared/SharedProsperityRecommendConfigRepository.php
  46. 118 0
      app/common/repositories/shared/SharedProsperityUserRepository.php
  47. 13 0
      app/common/repositories/store/order/StoreOrderProductRepository.php
  48. 322 34
      app/common/repositories/store/order/StoreOrderRepository.php
  49. 39 0
      app/common/repositories/store/product/ProductAttrValueChangeLogRepository.php
  50. 1 1
      app/common/repositories/store/product/ProductAttrValueRepository.php
  51. 21 8
      app/common/repositories/store/product/ProductRepository.php
  52. 6 6
      app/common/repositories/system/merchant/MerchantRepository.php
  53. 8 5
      app/common/repositories/user/UserRepository.php
  54. 7 1
      app/controller/admin/agreement/Agreement.php
  55. 121 0
      app/controller/admin/order/MerchantOfflineOrder.php
  56. 15 221
      app/controller/admin/order/Order.php
  57. 22 0
      app/controller/admin/system/sharedProsperity/SharedProsperityRecommend.php
  58. 50 7
      app/controller/api/Auth.php
  59. 6 2
      app/controller/api/Common.php
  60. 1 1
      app/controller/api/Notify.php
  61. 11 13
      app/controller/api/douhuomall/Take.php
  62. 1 1
      app/controller/api/store/merchant/Merchant.php
  63. 294 5
      app/controller/api/store/merchant/TaskPartnerProfits.php
  64. 6 44
      app/controller/api/store/merchant/Taskorderguquan.php
  65. 4 1
      app/controller/api/store/merchant/Taskordervr.php
  66. 237 36
      app/controller/api/store/product/DaTaoKe.php
  67. 5 3
      app/controller/api/store/product/Jd.php
  68. 2 2
      app/controller/api/store/product/Other.php
  69. 25 25
      app/controller/api/store/product/TaoKe.php
  70. 9 7
      app/controller/api/store/product/Vip.php
  71. 1 0
      app/controller/api/store/service/Huafei.php
  72. 7 7
      app/controller/api/user/User.php
  73. 7 1
      app/controller/merchant/gong/Goods.php
  74. 3 2
      app/controller/merchant/store/product/Product.php
  75. 344 0
      app/entity/data/dividend/DividendLogEntity.php
  76. 110 0
      app/entity/data/douhuomall/DouhuomallChangeLogEntity.php
  77. 158 0
      app/entity/data/shared/SharedProsperityRecommendConfigEntity.php
  78. 180 0
      app/entity/data/shared/SharedProsperityUserEntity.php
  79. 180 0
      app/entity/data/store/StoreProductAttrValueChangeLogEntity.php
  80. 1 1
      app/event.php
  81. 3 1
      app/middleware.php
  82. 509 0
      app/middleware/SecurityMiddleware.php
  83. 3 3
      app/traits/GongApiRequest.php
  84. 13 10
      app/traits/GzcApiRequest.php
  85. 40 0
      app/utils/TimeUtil.php
  86. 1 0
      config/console.php
  87. 6 0
      config/middleware.php
  88. 19 3
      crmeb/listens/AutoCancelGroupOrderListen.php
  89. 6 0
      route/admin.php
  90. 1 0
      route/api.php
  91. BIN
      uploads/def/20220104/112183.jpg
  92. BIN
      uploads/def/20220104/462618.jpg
  93. BIN
      uploads/def/20220104/505882.jpg
  94. BIN
      uploads/def/20220104/952252.jpg

+ 684 - 0
app/abc.json

@@ -0,0 +1,684 @@
1
+[
2
+  {
3
+    "id": "d35bddfd-ebbb-4f3a-a82a-d1f47601d4cf",
4
+    "data": {
5
+      "logoSrc": "",
6
+      "backSrc": "",
7
+      "isShowName": "1",
8
+      "isShowSearch": "2",
9
+      "mainPage": {
10
+        "defColor": "#F6F6F6",
11
+        "imageUrl": [],
12
+        "name": "标题",
13
+        "type": "纯色",
14
+        "imgUrl": "/diy/nav/bg1.png",
15
+        "diytemplate": "user_center"
16
+      },
17
+      "name": "用户中心",
18
+      "positionChoose": "1"
19
+    },
20
+    "computedStyle": {
21
+      "mode": 1,
22
+      "style": 1,
23
+      "titleSwitch": true,
24
+      "titleMode": 1,
25
+      "imageUrl": [],
26
+      "position": 1,
27
+      "searchSwitch": true,
28
+      "searchBgColor": "",
29
+      "defaultForm": {
30
+        "defColor": "transparer"
31
+      },
32
+      "titleDistance": {
33
+        "fontSize": 16,
34
+        "height": 30,
35
+        "width": 57,
36
+        "marginLeft": 20
37
+      },
38
+      "statusBar": "1",
39
+      "searchMarPad": {
40
+        "marginLeft": 20,
41
+        "paddingLeft": 14
42
+      }
43
+    },
44
+    "permission": [
45
+      {
46
+        "name": "member",
47
+        "title": "用户权重",
48
+        "list": [
49
+          {
50
+            "checked": true,
51
+            "level": 0,
52
+            "name": "普通用户"
53
+          }
54
+        ]
55
+      }
56
+    ],
57
+    "funcListItem": {
58
+      "type": "nav",
59
+      "title": "顶部导航",
60
+      "is_top": 1
61
+    },
62
+    "isShow": true,
63
+    "is_show_permission": false,
64
+    "is_drag": false,
65
+    "disabled": true
66
+  },
67
+  {
68
+    "id": "8a74d150-9243-43b5-9df6-ff7f5a3b83ba",
69
+    "data": {
70
+      "contentList2": [
71
+        "balance",
72
+        "score",
73
+        "coupon",
74
+        "secondary_card"
75
+      ],
76
+      "currencyStyle": 1
77
+    },
78
+    "computedStyle": {
79
+      "styleMode": 1,
80
+      "contentList1": [
81
+        0,
82
+        1,
83
+        2,
84
+        3
85
+      ],
86
+      "containBgColor": "",
87
+      "cardBgType": 1,
88
+      "cardShadowColor": "",
89
+      "iconColor": "#333333",
90
+      "iconBgColor": "#000000",
91
+      "tabSelectColor": "#F54B4A",
92
+      "tabSelectImg": "",
93
+      "nameColor": "#333333",
94
+      "memBgColor": "#000000",
95
+      "memColor": "#ffffff",
96
+      "assetColor": "#ffffff",
97
+      "compMarginTop": 10,
98
+      "compMarginBot": 0,
99
+      "compMarginLR": 16,
100
+      "compRadiusTop": 10,
101
+      "compRadiusBot": 10,
102
+      "imgIndex": 1,
103
+      "cardStyle": [
104
+        "pattern",
105
+        "cradient"
106
+      ]
107
+    },
108
+    "permission": [
109
+      {
110
+        "name": "member",
111
+        "title": "用户权重",
112
+        "list": [
113
+          {
114
+            "checked": true,
115
+            "level": 0,
116
+            "name": "普通用户"
117
+          }
118
+        ]
119
+      }
120
+    ],
121
+    "funcListItem": {
122
+      "id": 16,
123
+      "type": "member-info",
124
+      "title": "用户信息",
125
+      "group": "member",
126
+      "img": "",
127
+      "count": 1,
128
+      "is_top": 2,
129
+      "permission": "{\"is_drag\":\"false\",\"is_up\":\"false\",\"id_down\":\"false\",\"is_copy\":\"false\"}"
130
+    },
131
+    "isShow": true,
132
+    "is_show_permission": true,
133
+    "visible": false
134
+  },
135
+  {
136
+    "id": "2c2e1e97-f3e3-4288-8625-fdc820c4bd67",
137
+    "data": {
138
+      "iconList": [
139
+        {
140
+          "title": "待付款",
141
+          "img": "/diy/icon-set/order-1.png",
142
+          "btnText": "待付款",
143
+          "link_params": {
144
+            "title": "待付款订单",
145
+            "open_type": "page",
146
+            "navigate": "navigateTo",
147
+            "route": "/plugins/pages/order/list?tabIndex=1",
148
+            "params": {
149
+              "id": 6,
150
+              "name": "",
151
+              "title": "待付款订单",
152
+              "cat_id": 5,
153
+              "open_type": "page",
154
+              "route": "/plugins/pages/order/list?tabIndex=1",
155
+              "remark": ""
156
+            }
157
+          }
158
+        },
159
+        {
160
+          "title": "待发货",
161
+          "img": "/diy/icon-set/order-2.png",
162
+          "btnText": "待发货",
163
+          "link_params": {
164
+            "title": "待发货订单",
165
+            "open_type": "page",
166
+            "navigate": "navigateTo",
167
+            "route": "/plugins/pages/order/list?tabIndex=2",
168
+            "params": {
169
+              "id": 7,
170
+              "name": "",
171
+              "title": "待发货订单",
172
+              "cat_id": 5,
173
+              "open_type": "page",
174
+              "route": "/plugins/pages/order/list?tabIndex=2",
175
+              "remark": ""
176
+            }
177
+          }
178
+        },
179
+        {
180
+          "title": "待收货",
181
+          "img": "/diy/icon-set/order-3.png",
182
+          "btnText": "待收货",
183
+          "link_params": {
184
+            "title": "待收货订单",
185
+            "open_type": "page",
186
+            "navigate": "navigateTo",
187
+            "route": "/plugins/pages/order/list?tabIndex=3",
188
+            "params": {
189
+              "id": 8,
190
+              "name": "",
191
+              "title": "待收货订单",
192
+              "cat_id": 5,
193
+              "open_type": "page",
194
+              "route": "/plugins/pages/order/list?tabIndex=3",
195
+              "remark": ""
196
+            }
197
+          }
198
+        },
199
+        {
200
+          "title": "待评价",
201
+          "img": "/diy/icon-set/order-4.png",
202
+          "btnText": "待评价",
203
+          "link_params": {
204
+            "title": "待评价",
205
+            "open_type": "page",
206
+            "navigate": "navigateTo",
207
+            "route": "/plugins/pages/order/list?tabIndex=4",
208
+            "params": {
209
+              "id": 9,
210
+              "name": "",
211
+              "title": "待评价",
212
+              "cat_id": 5,
213
+              "open_type": "page",
214
+              "route": "/plugins/pages/order/list?tabIndex=4",
215
+              "remark": ""
216
+            }
217
+          }
218
+        },
219
+        {
220
+          "title": "退换货",
221
+          "img": "/diy/icon-set/order-5.png",
222
+          "btnText": "退换货",
223
+          "link_params": {
224
+            "title": "售后",
225
+            "open_type": "page",
226
+            "navigate": "navigateTo",
227
+            "route": "/plugins/pages/refund/list",
228
+            "params": {
229
+              "id": 10,
230
+              "name": "",
231
+              "title": "售后",
232
+              "cat_id": 5,
233
+              "open_type": "page",
234
+              "route": "/plugins/pages/refund/list",
235
+              "remark": ""
236
+            }
237
+          }
238
+        }
239
+      ],
240
+      "colorInfos": [
241
+        {
242
+          "name": "底部背景",
243
+          "color": "",
244
+          "showAlpha": false,
245
+          "value": "transparent"
246
+        },
247
+        {
248
+          "name": "标题背景",
249
+          "color": "",
250
+          "showAlpha": false,
251
+          "value": "transparent"
252
+        },
253
+        {
254
+          "name": "内容背景",
255
+          "color": "#fff",
256
+          "showAlpha": false,
257
+          "value": "#fff"
258
+        },
259
+        {
260
+          "name": "我的订单",
261
+          "color": "#333",
262
+          "showAlpha": false,
263
+          "value": "#333"
264
+        },
265
+        {
266
+          "name": "全部订单",
267
+          "color": "#666",
268
+          "showAlpha": false,
269
+          "value": "#666"
270
+        },
271
+        {
272
+          "name": "按钮颜色",
273
+          "color": "#666",
274
+          "showAlpha": false,
275
+          "value": "#666"
276
+        }
277
+      ]
278
+    },
279
+    "computedStyle": {
280
+      "searchIpts": {
281
+        "marginTop": "0px",
282
+        "marginBottom": "0px",
283
+        "marginLeft": "16px",
284
+        "marginRight": "16px",
285
+        "border-top-left-radius": "10px",
286
+        "border-top-right-radius": "10px",
287
+        "border-bottom-right-radius": "10px",
288
+        "border-bottom-left-radius": "10px"
289
+      },
290
+      "conRadiusSets": {
291
+        "border-top-left-radius": "10px",
292
+        "border-top-right-radius": "10px"
293
+      }
294
+    },
295
+    "permission": [
296
+      {
297
+        "name": "member",
298
+        "title": "用户权重",
299
+        "list": [
300
+          {
301
+            "checked": true,
302
+            "level": 0,
303
+            "name": "普通用户"
304
+          }
305
+        ]
306
+      }
307
+    ],
308
+    "funcListItem": {
309
+      "id": 17,
310
+      "type": "order-icon-group",
311
+      "title": "订单图标组",
312
+      "group": "member",
313
+      "img": "",
314
+      "count": 1,
315
+      "is_top": 0,
316
+      "permission": "{\"is_drag\":\"true\",\"is_up\":\"true\",\"id_down\":\"true\",\"is_copy\":\"true\"}",
317
+      "source": ""
318
+    },
319
+    "isShow": true,
320
+    "is_show_permission": true,
321
+    "visible": false
322
+  },
323
+  {
324
+    "id": "22d5bb77-6c9e-4603-8afe-7d317e7ec487",
325
+    "data": {
326
+      "iconList": [
327
+        {
328
+          "img": "/diy/icon-set/promotion.png",
329
+          "btnText": "推广中心",
330
+          "link_params": {
331
+            "title": "推广中心",
332
+            "open_type": "page",
333
+            "navigate": "navigateTo",
334
+            "route": "/plugins/public/promotion/index",
335
+            "params": {
336
+              "id": 44,
337
+              "name": "",
338
+              "title": "推广中心",
339
+              "cat_id": 6,
340
+              "open_type": "page",
341
+              "route": "/plugins/public/promotion/index",
342
+              "remark": ""
343
+            }
344
+          }
345
+        },
346
+        {
347
+          "img": "/diy/icon-set/cart.png",
348
+          "btnText": "购物车",
349
+          "link_params": {
350
+            "title": "购物车",
351
+            "open_type": "page",
352
+            "navigate": "navigateTo",
353
+            "route": "/pages/cart/index",
354
+            "params": {
355
+              "id": 4,
356
+              "name": "",
357
+              "title": "购物车",
358
+              "cat_id": 4,
359
+              "open_type": "page",
360
+              "route": "/pages/cart/index",
361
+              "remark": ""
362
+            }
363
+          }
364
+        },
365
+        {
366
+          "img": "/diy/icon-set/collect.png",
367
+          "btnText": "我的收藏",
368
+          "link_params": {
369
+            "title": "我的收藏",
370
+            "open_type": "page",
371
+            "navigate": "navigateTo",
372
+            "route": "/plugins/pages/center/keep",
373
+            "params": {
374
+              "id": 12,
375
+              "name": "",
376
+              "title": "我的收藏",
377
+              "cat_id": 6,
378
+              "open_type": "page",
379
+              "route": "/plugins/pages/center/keep",
380
+              "remark": ""
381
+            }
382
+          }
383
+        },
384
+        {
385
+          "img": "/diy/icon-set/address.png",
386
+          "btnText": "收货地址",
387
+          "link_params": {
388
+            "title": "收货地址",
389
+            "open_type": "page",
390
+            "navigate": "navigateTo",
391
+            "route": "/plugins/pages/settings/address",
392
+            "params": {
393
+              "id": 19,
394
+              "name": "",
395
+              "title": "收货地址",
396
+              "cat_id": 6,
397
+              "open_type": "page",
398
+              "route": "/plugins/pages/settings/address",
399
+              "remark": ""
400
+            }
401
+          }
402
+        },
403
+        {
404
+          "img": "resources/img/decorate/user_fun_chat.png",
405
+          "icon": "el-icon-setting",
406
+          "is_show_tag": false,
407
+          "tags": "热门",
408
+          "tagsBgColor": "#f83287",
409
+          "tagsTextColor": "#ffffff",
410
+          "btnText": "小店入驻",
411
+          "link_params": {
412
+            "title": "小店入驻",
413
+            "open_type": "page",
414
+            "navigate": "navigateTo",
415
+            "route": "/customDesigns/Happiness/shopEnter",
416
+            "params": {
417
+              "id": 522,
418
+              "addons_name": "Happiness",
419
+              "title": "小店入驻",
420
+              "route": "/customDesigns/Happiness/shopEnter",
421
+              "params": null,
422
+              "open_type": "page"
423
+            }
424
+          }
425
+        },
426
+        {
427
+          "img": "resources/img/decorate/user_fun_chat.png",
428
+          "icon": "el-icon-setting",
429
+          "is_show_tag": false,
430
+          "tags": "热门",
431
+          "tagsBgColor": "#f83287",
432
+          "tagsTextColor": "#ffffff",
433
+          "btnText": "推广收益",
434
+          "link_params": {
435
+            "title": "推广收益",
436
+            "open_type": "page",
437
+            "navigate": "navigateTo",
438
+            "route": "/customDesigns/Happiness/earningsShare?type=command",
439
+            "params": {
440
+              "id": 520,
441
+              "addons_name": "Happiness",
442
+              "title": "推广收益",
443
+              "route": "/customDesigns/Happiness/earningsShare?type=command",
444
+              "params": null,
445
+              "open_type": "page"
446
+            }
447
+          }
448
+        },
449
+        {
450
+          "img": "resources/img/decorate/user_fun_chat.png",
451
+          "icon": "el-icon-setting",
452
+          "is_show_tag": false,
453
+          "tags": "热门",
454
+          "tagsBgColor": "#f83287",
455
+          "tagsTextColor": "#ffffff",
456
+          "btnText": "代理收益",
457
+          "link_params": {
458
+            "title": "代理收益",
459
+            "open_type": "page",
460
+            "navigate": "navigateTo",
461
+            "route": "/customDesigns/Happiness/earningsShare?type=agent",
462
+            "params": {
463
+              "id": 517,
464
+              "addons_name": "Happiness",
465
+              "title": "代理收益",
466
+              "route": "/customDesigns/Happiness/earningsShare?type=agent",
467
+              "params": null,
468
+              "open_type": "page"
469
+            }
470
+          }
471
+        },
472
+        {
473
+          "img": "resources/img/decorate/user_fun_chat.png",
474
+          "icon": "el-icon-setting",
475
+          "is_show_tag": false,
476
+          "tags": "热门",
477
+          "tagsBgColor": "#f83287",
478
+          "tagsTextColor": "#ffffff",
479
+          "btnText": "分享收益",
480
+          "link_params": {
481
+            "title": "分享收益",
482
+            "open_type": "page",
483
+            "navigate": "navigateTo",
484
+            "route": "/customDesigns/Happiness/earningsShare?type=share",
485
+            "params": {
486
+              "id": 518,
487
+              "addons_name": "Happiness",
488
+              "title": "分享收益",
489
+              "route": "/customDesigns/Happiness/earningsShare?type=share",
490
+              "params": null,
491
+              "open_type": "page"
492
+            }
493
+          }
494
+        },
495
+        {
496
+          "img": "resources/img/decorate/user_fun_chat.png",
497
+          "icon": "el-icon-setting",
498
+          "is_show_tag": false,
499
+          "tags": "热门",
500
+          "tagsBgColor": "#f83287",
501
+          "tagsTextColor": "#ffffff",
502
+          "btnText": "锁定收益",
503
+          "link_params": {
504
+            "title": "锁定收益",
505
+            "open_type": "page",
506
+            "navigate": "navigateTo",
507
+            "route": "/customDesigns/Happiness/earningsShare?type=lock",
508
+            "params": {
509
+              "id": 519,
510
+              "addons_name": "Happiness",
511
+              "title": "锁定收益",
512
+              "route": "/customDesigns/Happiness/earningsShare?type=lock",
513
+              "params": null,
514
+              "open_type": "page"
515
+            }
516
+          }
517
+        },
518
+        {
519
+          "img": "resources/img/decorate/user_fun_chat.png",
520
+          "icon": "el-icon-setting",
521
+          "is_show_tag": false,
522
+          "tags": "热门",
523
+          "tagsBgColor": "#f83287",
524
+          "tagsTextColor": "#ffffff",
525
+          "btnText": "实名认证",
526
+          "link_params": {
527
+            "title": "养老金实名",
528
+            "open_type": "page",
529
+            "navigate": "navigateTo",
530
+            "route": "/customDesigns/Happiness/real",
531
+            "params": {
532
+              "id": 871,
533
+              "addons_name": "Happiness",
534
+              "title": "养老金实名",
535
+              "route": "/customDesigns/Happiness/real",
536
+              "params": null,
537
+              "open_type": "page"
538
+            }
539
+          }
540
+        },
541
+        {
542
+          "img": "/diy/icon-set/store-clerk.png",
543
+          "icon": "el-icon-setting",
544
+          "is_show_tag": false,
545
+          "tags": "热门",
546
+          "tagsBgColor": "#f83287",
547
+          "tagsTextColor": "#ffffff",
548
+          "btnText": "核销入口",
549
+          "link_params": {
550
+            "title": "订单核销",
551
+            "open_type": "page",
552
+            "navigate": "navigateTo",
553
+            "route": "/plugins2/Store/writeoff/index",
554
+            "params": {
555
+              "id": 720,
556
+              "addons_name": "Happiness",
557
+              "title": "订单核销",
558
+              "route": "/plugins2/Store/writeoff/index",
559
+              "params": null,
560
+              "open_type": "page"
561
+            }
562
+          }
563
+        },
564
+        {
565
+          "img": "resources/img/decorate/user_fun_chat.png",
566
+          "icon": "el-icon-setting",
567
+          "is_show_tag": false,
568
+          "tags": "热门",
569
+          "tagsBgColor": "#f83287",
570
+          "tagsTextColor": "#ffffff",
571
+          "btnText": "养老金",
572
+          "link_params": {
573
+            "title": "养老金",
574
+            "open_type": "page",
575
+            "navigate": "navigateTo",
576
+            "route": "/customDesigns/Happiness/pension",
577
+            "params": {
578
+              "id": 640,
579
+              "addons_name": "Happiness",
580
+              "title": "养老金",
581
+              "route": "/customDesigns/Happiness/pension",
582
+              "params": null,
583
+              "open_type": "page"
584
+            }
585
+          }
586
+        },
587
+        {
588
+          "img": "/diy/icon-set/mobile-device.png",
589
+          "icon": "el-icon-setting",
590
+          "is_show_tag": false,
591
+          "tags": "热门",
592
+          "tagsBgColor": "#f83287",
593
+          "tagsTextColor": "#ffffff",
594
+          "btnText": "门店移动端",
595
+          "link_params": {
596
+            "title": "O2O门店移动端",
597
+            "open_type": "page",
598
+            "navigate": "navigateTo",
599
+            "route": "/plugins2/Store/admin/store",
600
+            "params": {
601
+              "id": 940,
602
+              "addons_name": "Store",
603
+              "title": "O2O门店移动端",
604
+              "route": "/plugins2/Store/admin/store",
605
+              "params": null,
606
+              "open_type": "page"
607
+            }
608
+          }
609
+        }
610
+      ],
611
+      "colorInfos": [
612
+        {
613
+          "name": "底部背景",
614
+          "color": "",
615
+          "showAlpha": false,
616
+          "value": "transparent"
617
+        },
618
+        {
619
+          "name": "标题背景",
620
+          "color": "",
621
+          "showAlpha": false,
622
+          "value": "transparent"
623
+        },
624
+        {
625
+          "name": "内容背景",
626
+          "color": "#fff",
627
+          "showAlpha": false,
628
+          "value": "#fff"
629
+        },
630
+        {
631
+          "name": "标题颜色",
632
+          "color": "#333",
633
+          "showAlpha": false,
634
+          "value": "#333"
635
+        },
636
+        {
637
+          "name": "按钮颜色",
638
+          "color": "#333",
639
+          "showAlpha": false,
640
+          "value": "#333"
641
+        }
642
+      ]
643
+    },
644
+    "computedStyle": {
645
+      "conRadiusSets": {
646
+        "border-top-left-radius": "10px",
647
+        "border-top-right-radius": "10px"
648
+      },
649
+      "searchIpts": {
650
+        "marginTop": "0px",
651
+        "marginBottom": "0px",
652
+        "marginLeft": "16px",
653
+        "marginRight": "16px"
654
+      }
655
+    },
656
+    "permission": [
657
+      {
658
+        "name": "member",
659
+        "title": "用户权重",
660
+        "list": [
661
+          {
662
+            "checked": true,
663
+            "level": 0,
664
+            "name": "普通用户"
665
+          }
666
+        ]
667
+      }
668
+    ],
669
+    "funcListItem": {
670
+      "id": 18,
671
+      "type": "commonly-icon-group",
672
+      "title": "常用图标组",
673
+      "group": "member",
674
+      "img": "",
675
+      "count": 3,
676
+      "is_top": 0,
677
+      "permission": "{\"is_drag\":\"true\",\"is_up\":\"true\",\"id_down\":\"true\",\"is_copy\":\"true\"}",
678
+      "source": ""
679
+    },
680
+    "isShow": true,
681
+    "is_show_permission": true,
682
+    "visible": false
683
+  }
684
+]

+ 1 - 1
app/command/PensionTasks.php

@@ -53,7 +53,7 @@ class PensionTasks extends Command
53 53
 //            $this->doOnlineOrderGzc($timeLimit = 30);
54 54
 //            $this->doOnlineHuuafeiOrderGzc($timeLimit = 30);
55 55
             $this->onlineOrderNew($timeLimit = 30);
56
-            $this->huafeiOrderNew($timeLimit = 30);
56
+            $this->huafeiOrderNew($timeLimit = 0);
57 57
             $this->pddOrderNew($timeLimit = 30);
58 58
             $this->jdOrderNew($timeLimit = 30);
59 59
             $this->suOrderNew($timeLimit = 30);

+ 656 - 0
app/command/WiwibaoProductSync.php

@@ -0,0 +1,656 @@
1
+<?php
2
+declare (strict_types=1);
3
+
4
+namespace app\command;
5
+
6
+use app\common\enum\CommonEnum;
7
+use app\common\enum\store\ProductEnum;
8
+use app\common\repositories\douhuomall\DouhuomallChangeLogRepository;
9
+use app\common\repositories\store\product\ProductRepository;
10
+use app\entity\data\douhuomall\DouhuomallChangeLogEntity;
11
+use app\traits\GongApiRequest;
12
+use think\console\Command;
13
+use think\console\Input;
14
+use think\console\Output;
15
+use think\db\exception\DbException;
16
+use think\facade\Db;
17
+use think\facade\Log;
18
+
19
+class WiwibaoProductSync extends Command
20
+{
21
+
22
+    use GongApiRequest;
23
+
24
+    // 配置参数
25
+    protected $config = [
26
+        'page_size' => 100,      // 每页拉取数量
27
+        'max_pages' => 0,       // 最大页数限制
28
+        'price_change_rate' => 0.0, // 价格变动比率阈值(10%)
29
+        'mer_id' => CommonEnum::DESIGN_MERCHANT_ID['WonderfulLiving']['code']
30
+    ];
31
+
32
+    protected function configure()
33
+    {
34
+        // 指令配置
35
+        $this->setName('wiwibaoproductsync')
36
+            ->setDescription('the wiwibaoproductsync command');
37
+    }
38
+
39
+    protected function execute(Input $input, Output $output)
40
+    {
41
+        $output->writeln('定时任务执行中...');
42
+
43
+        $this->syncGoodsFromGong();
44
+
45
+        $output->writeln('定时任务执行完成');
46
+    }
47
+
48
+    /**
49
+     * 同步微唯宝商品数据(主方法)
50
+     */
51
+    public function syncGoodsFromGong()
52
+    {
53
+        try {
54
+            set_time_limit(0);
55
+
56
+            // 1. 批量拉取所有商品数据
57
+            $allProducts = $this->fetchAllProducts();
58
+
59
+            if (empty($allProducts)) {
60
+                Log::info('未拉取到任何商品数据');
61
+                return 'success';
62
+            }
63
+
64
+            // 2. 获取本地所有SPU ID
65
+            $douhuomallDataMap = [];
66
+            $douhuomallDataList = Db::name('douhuomall')
67
+                ->select()
68
+                ->toArray();
69
+            if (!empty($douhuomallDataList)) {
70
+                $douhuomallDataMap = array_column($douhuomallDataList, null, 'spu_id');
71
+
72
+            }
73
+            $syncedSpuIds = [];
74
+
75
+            // 3. 批量处理商品数据
76
+            foreach ($allProducts as $product) {
77
+                try {
78
+                    $spuId = $this->processSingleProduct($product, $douhuomallDataMap[$product['goods_id']] ?? []);
79
+                    if ($spuId) {
80
+                        $syncedSpuIds[] = $spuId;
81
+                    }
82
+                } catch (\Exception $e) {
83
+                    $this->logError("处理商品 {$product['goods_id']} 失败: ", $e);
84
+                    continue;
85
+                }
86
+            }
87
+
88
+            // 4. 处理需要下架的商品(本地有但第三方已下架)
89
+            $this->handleOfflineProducts($syncedSpuIds, $douhuomallDataMap);
90
+
91
+            return 'success';
92
+
93
+        } catch (\Exception $e) {
94
+            $this->logError('商品同步失败', $e);
95
+            return 'error';
96
+        }
97
+    }
98
+
99
+    /**
100
+     * 批量拉取所有商品数据
101
+     */
102
+    protected function fetchAllProducts()
103
+    {
104
+        $allData = [];
105
+
106
+        // 第一页
107
+        $firstPageData = GongApiRequest::get_goods_list(1, $this->config['page_size']);
108
+        if (empty($firstPageData['list'])) {
109
+            return [];
110
+        }
111
+
112
+        $allData = $firstPageData['list'];
113
+        $totalPages = $firstPageData['pages'] ?? 1;
114
+        if (!empty($this->config['max_pages'])) {
115
+            $totalPages = min($totalPages, $this->config['max_pages']);
116
+        }
117
+
118
+        // 并行获取剩余页面
119
+        for ($page = 2; $page <= $totalPages; $page++) {
120
+            $pageData = GongApiRequest::get_goods_list($page, $this->config['page_size']);
121
+            if (!empty($pageData['list'])) {
122
+                $allData = array_merge($allData, $pageData['list']);
123
+            }
124
+        }
125
+
126
+        return $allData;
127
+    }
128
+
129
+    /**
130
+     * 处理单个商品
131
+     */
132
+    protected function processSingleProduct($productData, $douhuomallData)
133
+    {
134
+        $goodsId = $productData['goods_id'];
135
+
136
+        // 1. 获取商品详情
137
+        $goodsInfo = GongApiRequest::get_goods_info($goodsId);
138
+        if (!$goodsInfo) {
139
+            return null;
140
+        }
141
+
142
+        // 2. 处理SKU信息
143
+        if (empty($goodsInfo['sku_list'])) {
144
+            return null;
145
+        }
146
+        $skuInfo = [];
147
+        foreach ($goodsInfo['sku_list'] as $sku) {
148
+            if (empty($sku['plat_price'])) {
149
+                continue;
150
+            }
151
+            $processedSku = [
152
+                'sku_id' => $sku['sku_id'] ?? 0,
153
+                'plat_price' => $sku['plat_price'],
154
+                'img_url' => $sku['main_img'],
155
+                'retail_price' => $sku['retail_price'] ?? 0,
156
+                'cost_price' => $this->calculateCostPrice($sku['plat_price']),
157
+                'market_price' => $this->calculateMarketPrice($sku['plat_price']),
158
+                'profit' => $this->calculateProfit($sku['plat_price']),
159
+                'mer_profit' => $this->calculateMerProfit($sku['plat_price']),
160
+                'yanglaojin' => '0.00',
161
+                'main_img' => $sku['main_img'] ?? '',
162
+                'attribute_json' => !empty($sku['attr']) ? $sku['attr'] : [['val' => '默认', 'name' => '默认']]
163
+            ];
164
+            $skuInfo[] = array_merge($sku, $processedSku);
165
+        }
166
+
167
+        // 4. 构建保存数据
168
+        $imageData = [
169
+            'cover_url' => $goodsInfo['main_img'] ?? '',
170
+            'detail_images' => $goodsInfo['detail_img'] ?? [],
171
+            'detail_img_list' => $goodsInfo['detail_img'] ?? [] // 为了兼容以前写的代码,建议保留这个数据项,之前用的是detail_img_list字段,但我感觉他们意义一样
172
+        ];
173
+
174
+        // 构建详情HTML
175
+        $detailHtml = $this->buildDetailHtml($imageData['detail_images']);
176
+
177
+        $saveData = [
178
+            'spu_id' => $goodsInfo['goods_id'],
179
+            'skuId_info' => $skuInfo,
180
+            'sys_id' => '112',
181
+            'goods_id' => $goodsInfo['goods_id'],
182
+            'spuId_info' => array_merge(
183
+                $goodsInfo,
184
+                [
185
+                    'cover_url' => $imageData['cover_url'],
186
+                    'detail' => $detailHtml,
187
+                    'detail_img_list' => $imageData['detail_img_list']
188
+                ]
189
+            ),
190
+            'sku_id' => $skuInfo[0]['sku_id'] ?? 0,
191
+            'status' => $goodsInfo['status'] ?? 0,
192
+            'cate_ids' => $goodsInfo['cate_ids'] ?? '',
193
+            'title' => $goodsInfo['spu_name'] ?? '',
194
+            'cxb_cate_id' => 0,
195
+            'third_update_time' => $goodsInfo['update_time'] ?? ''
196
+        ];
197
+
198
+        // 5. 保存到本地(使用原有的add方法逻辑)
199
+        try {
200
+            $spuId = $this->addToDouhuomall($saveData, $douhuomallData);
201
+        } catch (DbException $e) {
202
+            return 0;
203
+        }
204
+
205
+        return $spuId;
206
+    }
207
+
208
+    /**
209
+     * 构建详情HTML
210
+     */
211
+    protected function buildDetailHtml($detailImages): string
212
+    {
213
+        if (empty($detailImages)) {
214
+            return '';
215
+        }
216
+
217
+        $detailHtml = '';
218
+        foreach ((array)$detailImages as $imgUrl) {
219
+            $detailHtml .= "<img src='{$imgUrl}' referrerpolicy='no-referrer' />";
220
+        }
221
+
222
+        return $detailHtml;
223
+    }
224
+
225
+    /**
226
+     * @param $data
227
+     * @param $findData
228
+     * @return mixed
229
+     * @throws DbException
230
+     */
231
+    protected function addToDouhuomall($data, $findData)
232
+    {
233
+        try {
234
+            // 对SKU按成本价排序,获取最低成本价的SKU
235
+            $skuInfo = $this->arrSort($data['skuId_info'], 'cost_price', SORT_ASC);
236
+
237
+            // 计算价格字段
238
+            $data['cost_price'] = $skuInfo[0]['cost_price'] ?? 0;
239
+            $data['market_price'] = $skuInfo[0]['market_price'] ?? 0;
240
+            $data['ot_price'] = $skuInfo[0]['retail_price'] ?? 0;
241
+            $data['mer_profit'] = $skuInfo[0]['mer_profit'] ?? 0;
242
+            $data['pension'] = $skuInfo[0]['yanglaojin'] ?? 0;
243
+            $data['profit'] = (empty($data['cost_price']) || empty($data['market_price']))
244
+                ? 0
245
+                : bcdiv((string)$data['market_price'], (string)$data['cost_price'], 2);
246
+
247
+            $now = date('Y-m-d H:i:s');
248
+
249
+            if (empty($findData)) {
250
+                // 新增
251
+                $insertData = [
252
+                    'spu_id' => $data['spu_id'],
253
+                    'skuId_info' => json_encode($data['skuId_info'], JSON_UNESCAPED_UNICODE),
254
+                    'sys_id' => $data['sys_id'],
255
+                    'goods_id' => $data['goods_id'],
256
+                    'spuId_info' => json_encode($data['spuId_info'], JSON_UNESCAPED_UNICODE),
257
+                    'create_time' => $now,
258
+                    'update_time' => $now,
259
+                    'sku_id' => $data['sku_id'],
260
+                    'status' => $data['status'],
261
+                    'cate_ids' => $data['cate_ids'],
262
+                    'title' => $data['title'],
263
+                    'cost_price' => $data['cost_price'],
264
+                    'market_price' => $data['market_price'],
265
+                    'ot_price' => $data['ot_price'],
266
+                    'profit' => $data['profit'],
267
+                    'mer_profit' => $data['mer_profit'],
268
+                    'pension' => $data['pension'],
269
+                    'cxb_cate_id' => $data['cxb_cate_id'],
270
+                    'third_update_time' => $data['third_update_time']
271
+                ];
272
+                Db::name('douhuomall')->insert($insertData);
273
+
274
+                // 创建完商品后立马上架
275
+                $this->insert_product($data['spu_id'], $this->config['mer_id']);
276
+
277
+            } else {
278
+                // 更新
279
+                if (empty($findData['third_update_time']) || strtotime($data['third_update_time']) > strtotime($findData['third_update_time'])) {
280
+                    $updateData = [
281
+                        'status' => $data['status'],
282
+                        'update_time' => $now,
283
+                        'cost_price' => $data['cost_price'],
284
+                        'market_price' => $data['market_price'],
285
+                        'ot_price' => $data['ot_price'],
286
+                        'mer_profit' => $data['mer_profit'],
287
+                        'pension' => $data['pension'],
288
+                        'profit' => $data['profit'],
289
+                        'skuId_info' => json_encode($data['skuId_info'], JSON_UNESCAPED_UNICODE),
290
+                        'spuId_info' => json_encode($data['spuId_info'], JSON_UNESCAPED_UNICODE),
291
+                        'title' => $data['title'],
292
+                        'cate_ids' => $data['cate_ids'],
293
+                        'cxb_cate_id' => $data['cxb_cate_id'],
294
+                        'third_update_time' => $data['third_update_time']
295
+                    ];
296
+                    Db::name('douhuomall')
297
+                        ->where('spu_id', $findData['spu_id'])
298
+                        ->update($updateData);
299
+
300
+                    $productList = Db::name('store_product')
301
+                        ->where('spu_id', $findData['spu_id'])
302
+                        // ->where('is_show', ProductEnum::IS_SHOW['Yes']['code'])
303
+                        ->where('is_del', ProductEnum::IS_DEL['No']['code'])
304
+                        // ->where('status', '<>', ProductEnum::STATUS['Withdrawn']['code'])
305
+                        ->select()
306
+                        ->toArray();
307
+                    $productIdList = array_column($productList, 'product_id');
308
+
309
+                    // 将绑定的商品进行下架
310
+                    Db::name('store_product')
311
+                        ->whereIn('product_id', $productIdList)
312
+                        ->update([
313
+                            // 'is_show' => ProductEnum::IS_SHOW['No']['code'],
314
+                            'is_del' => ProductEnum::IS_DEL['Yes']['code'],
315
+                            // 'status' => ProductEnum::STATUS['Withdrawn']['code'],
316
+                            // 'is_status' => ProductEnum::IS_STATUS['Automatic']['code']
317
+                        ]);
318
+
319
+                    /** @var DouhuomallChangeLogEntity $douhuomallChangeLogEntity */
320
+                    $douhuomallChangeLogEntity = DouhuomallChangeLogEntity::newInstance();
321
+                    $douhuomallChangeLogEntity->setSpuId($findData['spu_id'])
322
+                        ->setDataJson($findData)
323
+                        ->setEffectProductJson($productIdList)
324
+                        ->setCreateTime(date('Y-m-d H:i:s'));
325
+                    /** @var DouhuomallChangeLogRepository $douhuomallChangeLogRepository */
326
+                    $douhuomallChangeLogRepository = app()->make(DouhuomallChangeLogRepository::class);
327
+                    $douhuomallChangeLogRepository->createByEntity($douhuomallChangeLogEntity);
328
+
329
+                    // 将商品重新上架
330
+                    // 创建完商品后立马上架
331
+                    $this->insert_product($data['spu_id'], $this->config['mer_id']);
332
+                }
333
+            }
334
+
335
+            return $data['spu_id'];
336
+
337
+        } catch (\Exception $e) {
338
+            $this->logError('保存商品到douhuomall失败: ', $e);
339
+            throw $e;
340
+        }
341
+    }
342
+
343
+    /**
344
+     * 恢复商品上架状态
345
+     */
346
+    protected function restoreProduct($spuId)
347
+    {
348
+        Db::name('store_product')
349
+            ->where('spu_id', $spuId)
350
+            ->update([
351
+                'is_show' => ProductEnum::IS_SHOW['Yes']['code'],
352
+                'status' => ProductEnum::STATUS['Approved']['code']
353
+            ]);
354
+
355
+        Log::info("恢复商品上架(恢复到仓库中)状态: spu_id={$spuId}");
356
+    }
357
+
358
+    /**
359
+     * 处理需要下架的商品(第三方已下架)
360
+     */
361
+    protected function handleOfflineProducts($syncedSpuIds, $douhuomallDataMap)
362
+    {
363
+        $localSpuIds = array_keys($douhuomallDataMap);
364
+        $offlineSpuIds = array_diff($localSpuIds, $syncedSpuIds);
365
+
366
+        if (empty($offlineSpuIds)) {
367
+            return;
368
+        }
369
+
370
+        $productList = Db::name('store_product')
371
+            ->whereIn('spu_id', $offlineSpuIds)
372
+            // ->where('is_show', ProductEnum::IS_SHOW['Yes']['code'])
373
+            ->where('is_del', ProductEnum::IS_DEL['No']['code'])
374
+            // ->where('status', '<>', ProductEnum::STATUS['Withdrawn']['code'])
375
+            ->field('product_id, spu_id, is_show, is_del, status')
376
+            ->select()
377
+            ->toArray();
378
+        if (empty($productList)) {
379
+            return;
380
+        }
381
+        $productIdList = [];
382
+        $spuIdMap = [];
383
+        foreach ($productList as $item) {
384
+            $productIdList[] = $item['product_id'];
385
+            $spuIdMap[$item['spu_id']][] = $item['product_id'];
386
+        }
387
+
388
+        // 将绑定的商品进行下架
389
+        Db::name('store_product')
390
+            ->whereIn('product_id', $productIdList)
391
+            ->update([
392
+                // 'is_show' => ProductEnum::IS_SHOW['No']['code'],
393
+                'is_del' => ProductEnum::IS_DEL['Yes']['code'],
394
+                // 'status' => ProductEnum::STATUS['Withdrawn']['code'],
395
+                // 'is_status' => ProductEnum::IS_STATUS['Automatic']['code']
396
+            ]);
397
+        foreach ($spuIdMap as $spuId => $productIdListGroupBySpuId) {
398
+            /** @var DouhuomallChangeLogEntity $douhuomallChangeLogEntity */
399
+            $douhuomallChangeLogEntity = DouhuomallChangeLogEntity::newInstance();
400
+            $douhuomallChangeLogEntity->setSpuId($spuId)
401
+                ->setDataJson($douhuomallDataMap[$spuId])
402
+                ->setEffectProductJson($productIdListGroupBySpuId)
403
+                ->setCreateTime(date('Y-m-d H:i:s'));
404
+            /** @var DouhuomallChangeLogRepository $douhuomallChangeLogRepository */
405
+            $douhuomallChangeLogRepository = app()->make(DouhuomallChangeLogRepository::class);
406
+            $douhuomallChangeLogRepository->createByEntity($douhuomallChangeLogEntity);
407
+        }
408
+
409
+        // foreach ($offlineSpuIds as $spuId) {
410
+        //     $this->offlineProductBySpuId($spuId, 'third_party_offline');
411
+        // }
412
+
413
+        Log::info("下架第三方已下架商品" . json_encode(['count' => count($offlineSpuIds), 'spu_ids' => $offlineSpuIds]));
414
+    }
415
+
416
+    /**
417
+     * 数组排序(从原有add方法中提取)
418
+     */
419
+    protected function arrSort($array, $keys, $sort = SORT_DESC)
420
+    {
421
+        $keysValue = [];
422
+        foreach ($array as $k => $v) {
423
+            $keysValue[$k] = $v[$keys] ?? 0;
424
+        }
425
+        array_multisort($keysValue, $sort, $array);
426
+        return $array;
427
+    }
428
+
429
+    /**
430
+     * 计算成本价
431
+     */
432
+    protected function calculateCostPrice($platPrice)
433
+    {
434
+        return bcadd((string)$platPrice, bcmul((string)$platPrice, '0.03', 4), 2);
435
+    }
436
+
437
+    /**
438
+     * 计算市场价
439
+     */
440
+    protected function calculateMarketPrice($platPrice)
441
+    {
442
+        $costPrice = $this->calculateCostPrice($platPrice);
443
+        return bcadd($costPrice, bcmul($costPrice, '0.2', 4), 2);
444
+    }
445
+
446
+    /**
447
+     * 计算利润率
448
+     */
449
+    protected function calculateProfit($platPrice)
450
+    {
451
+        $costPrice = $this->calculateCostPrice($platPrice);
452
+        $marketPrice = $this->calculateMarketPrice($platPrice);
453
+        return bcdiv($marketPrice, $costPrice, 2);
454
+    }
455
+
456
+    /**
457
+     * 计算毛利
458
+     */
459
+    protected function calculateMerProfit($platPrice)
460
+    {
461
+        $costPrice = $this->calculateCostPrice($platPrice);
462
+        $marketPrice = $this->calculateMarketPrice($platPrice);
463
+        return bcsub($marketPrice, $costPrice, 2);
464
+    }
465
+
466
+    /**
467
+     * 记录错误
468
+     */
469
+    protected function logError($message, \Exception $e)
470
+    {
471
+        $errorInfo = [
472
+            'message' => $message,
473
+            'error_message' => $e->getMessage(),
474
+            'error_file' => $e->getFile(),
475
+            'error_line' => $e->getLine(),
476
+            'error_code' => $e->getCode(),
477
+            'exception_class' => get_class($e),
478
+            'trace' => $e->getTraceAsString()
479
+        ];
480
+        Log::error($message);
481
+
482
+        Log::error($message . json_encode($errorInfo, JSON_UNESCAPED_UNICODE));
483
+
484
+        Db::name('log')->insert([
485
+            'data' => json_encode($errorInfo, JSON_UNESCAPED_UNICODE),
486
+            'time' => date('Y-m-d H:i:s')
487
+        ]);
488
+    }
489
+
490
+    // 借用 app\controller\merchant\gong\Goods.php 控制器内方法
491
+
492
+    /**
493
+     * 将 微唯宝商品 选品(加入) 到系统内部商户商品表
494
+     * @param $spu_id
495
+     * @param $mer_id
496
+     * @return bool
497
+     */
498
+    public function insert_product($spu_id, $mer_id)
499
+    {
500
+        try {
501
+            // 1、获取商品信息
502
+            $data = Db::name('douhuomall')->where('spu_id', $spu_id)->find();
503
+
504
+            // 2、是否为多规格
505
+            $sku_data = json_decode($data['skuId_info'], true);
506
+            $spec_type = count($sku_data);
507
+            if ($spec_type > 1) {
508
+                $spec_type = 1;
509
+            } else {
510
+                $spec_type = 0;
511
+            }
512
+
513
+            // 3、商品主图
514
+            $spuId_info = json_decode($data['spuId_info'], true);
515
+            $slider_image = $spuId_info['detail_img_list'] ?? '';
516
+            $image = $spuId_info['cover_url'] ?? '';
517
+            if (empty($slider_image)) {
518
+                $slider_image = $image;
519
+            } else if (is_string($slider_image)) {
520
+                $slider_image = implode(',', json_decode($slider_image, true));
521
+            } else if (is_array($slider_image)) {
522
+                $slider_image = implode(',', $slider_image);
523
+            }
524
+            $yanglaojin_scale = (!empty($data['pension']) && !empty($data['market_price'])) ? bcdiv($data['pension'], $data['market_price'], 2) : 0;
525
+
526
+            // 4、商品入库数据
527
+            $product_insert_data = [
528
+                'mer_id' => $mer_id,
529
+                'image' => $image,
530
+                'slider_image' => $slider_image,
531
+                'store_name' => $data['title'],
532
+                'store_info' => 1,
533
+                'keyword' => mb_substr($data['title'], 0, 3),
534
+                'is_show' => 1,
535
+                'status' => 1,
536
+                'cate_id' => $data['cate_ids'],
537
+                'unit_name' => '个',
538
+                'price' => $data['market_price'],
539
+                'cost' => $data['cost_price'],
540
+                'ot_price' => $data['ot_price'],
541
+                'stock' => '1000',
542
+                'spec_type' => $spec_type,
543
+                'extension_type' => 1,
544
+                'mer_status' => 1,
545
+                'is_used' => 1,
546
+                'old_product_id' => $data['id'],
547
+                'volunteer' => 0,
548
+                'type' => 1,
549
+                'pension' => '0.00',
550
+                'commission' => 5,
551
+                'spu_id' => $data['spu_id'],
552
+                'temp_id' => 105,
553
+                'plate_mer_profit' => $data['mer_profit'],
554
+                'concession_pri' => $data['mer_profit'],
555
+                'yanglaojin_scale' => $yanglaojin_scale
556
+            ];
557
+            $insert_id = Db::name('store_product')->insertGetId($product_insert_data);
558
+
559
+            // 5、更新商品详情表
560
+            $detail = $spuId_info['detail'];
561
+            if (!is_null(json_decode($detail))) {
562
+                $detail_list = json_decode($detail);
563
+                $detail = '';
564
+                foreach ($detail_list as $value) {
565
+                    $detail .= '<img src="' . $value . '"></img>';
566
+                }
567
+            }
568
+            Db::name('store_product_content')->insert(['content' => $detail, 'product_id' => $insert_id]);
569
+
570
+            // 6、
571
+            $this->insert_sku($insert_id, $sku_data);
572
+            return true;
573
+        } catch (\Exception $e) {
574
+            $this->logError($spu_id . "加入选品失败:", $e);
575
+            return false;
576
+        }
577
+    }
578
+
579
+    // 借用 app\controller\merchant\gong\Goods.php 控制器内方法
580
+    public function insert_sku($id, $data)
581
+    {
582
+        // 1、获取 所有SKU的 规格属性值
583
+        $sku_attr_data = array_column($data, 'attribute_json');
584
+        $name = '';
585
+
586
+        // 2、写入 商品属性表
587
+        /** @var ProductRepository $ProductRepository */
588
+        $ProductRepository = app()->make(ProductRepository::class);
589
+        if (empty($sku_attr_data[0][0])) {
590
+            // 写入商品属性表
591
+            Db::name('store_product_attr')->insert(['product_id' => $id, 'attr_name' => '规格', 'attr_values' => $name]);
592
+            $key = '';
593
+            $num = 1;
594
+            // 写入 SKU 商品属性值表
595
+            foreach ($data as $k => $v) {
596
+                Db::name('store_product_attr_value')->insert([
597
+                    'product_id' => $id,
598
+                    'detail' => json_encode(['规格' => $key]),
599
+                    'sku' => $key,
600
+                    'image' => $v['img_url'],
601
+                    'cost' => $v['cost_price'],
602
+                    'ot_price' => $v['retail_price'],
603
+                    'price' => $v['market_price'],
604
+                    'unique' => $ProductRepository->setUnique($id, $v['sku_id'], 0),
605
+                    'stock' => 100,
606
+                    'cost_price' => $v['cost_price'],
607
+                    'extension_one' => 5,
608
+                    'gong_sku_id' => $v['sku_id'],
609
+                    'gong_mer_profit' => $v['mer_profit'],
610
+                    'gong_pension' => $v['yanglaojin'],
611
+                    'gong_market_price' => $v['market_price'],
612
+                    'plate_mer_profit' => $v['mer_profit']
613
+                ]);
614
+                $key = '';
615
+                $num++;
616
+            }
617
+        } else {
618
+            foreach ($sku_attr_data as $kk => $vv) {
619
+                foreach ($vv as $k1 => $v1) {
620
+                    $name .= $v1['val'];
621
+                }
622
+                $name .= '-!-';
623
+            }
624
+            $name = rtrim($name, '-!-');
625
+            Db::name('store_product_attr')->insert(['product_id' => $id, 'attr_name' => '规格', 'attr_values' => $name]);
626
+            $key = '';
627
+            $num = 1;
628
+            foreach ($data as $k => $v) {
629
+                foreach ($v['attribute_json'] as $k2 => $v2) {
630
+                    $key .= $v2['val'];
631
+                }
632
+
633
+                Db::name('store_product_attr_value')->insert([
634
+                    'product_id' => $id,
635
+                    'detail' => json_encode(['规格' => $key]),
636
+                    'sku' => $key,
637
+                    'image' => $v['img_url'],
638
+                    'cost' => $v['cost_price'],
639
+                    'ot_price' => $v['retail_price'],
640
+                    'price' => $v['market_price'],
641
+                    'unique' => $ProductRepository->setUnique((int)$id, $v['sku_id'], 0),
642
+                    'stock' => 100,
643
+                    'cost_price' => $v['cost_price'],
644
+                    'extension_one' => 5,
645
+                    'gong_sku_id' => $v['sku_id'],
646
+                    'gong_mer_profit' => $v['mer_profit'],
647
+                    'gong_pension' => $v['yanglaojin'],
648
+                    'gong_market_price' => $v['market_price'],
649
+                    'plate_mer_profit' => $v['mer_profit']
650
+                ]);
651
+                $key = '';
652
+                $num++;
653
+            }
654
+        }
655
+    }
656
+}

+ 21 - 0
app/common/dao/backup/BackupStoreOrderDao.php

@@ -0,0 +1,21 @@
1
+<?php
2
+
3
+namespace app\common\dao\backup;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\backup\BackupStoreOrder;
7
+
8
+class BackupStoreOrderDao extends BaseDao
9
+{
10
+    protected function getModel(): string
11
+    {
12
+        return BackupStoreOrder::class;
13
+    }
14
+    /**
15
+     * 获取撤回订单列表
16
+     */
17
+    public function getKillOrderList($limit)
18
+    {
19
+        return $this->getModel()::getDB()->paginate($limit)->toArray();
20
+    }
21
+}

+ 74 - 0
app/common/dao/backup/BackupUserChangeDao.php

@@ -0,0 +1,74 @@
1
+<?php
2
+
3
+namespace app\common\dao\backup;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\backup\BackupUserChange;
7
+
8
+class BackupUserChangeDao extends BaseDao
9
+{
10
+    protected function getModel(): string
11
+    {
12
+        return BackupUserChange::class;
13
+    }
14
+
15
+    /**
16
+     * @param array $dataList
17
+     * @return array批量更新
18
+     */
19
+    public function saveAll(array $dataList): array
20
+    {
21
+        try {
22
+            return $this->getModel()->getInstance()->allowField(array_keys(reset($dataList)))->saveAll($dataList)->toArray();
23
+        } catch (\Exception $e) {
24
+            return [];
25
+        }
26
+    }
27
+    /**
28
+     * 根据 order_id 获取用户本人变更数据(user=1)
29
+     */
30
+    public function getUserOneChangeFromOrderId($orderId)
31
+    {
32
+        return $this::getModel()::getDB()
33
+            ->where('order_id', '=', $orderId)
34
+            ->where('user', '=', 1)
35
+            ->field('pv, vr, score, contribute, annuity, uid')
36
+            ->find();
37
+    }
38
+
39
+    /**
40
+     * 根据 order_id 获取一级推荐人变更数据(user=2)
41
+     */
42
+    public function getUserTwoChangeFromOrderId($orderId)
43
+    {
44
+        return $this::getModel()::getDB()
45
+            ->where('order_id', '=', $orderId)
46
+            ->where('user', '=', 2)
47
+            ->field('brokerage_price, score, per_contribute, annuity, uid')
48
+            ->find();
49
+    }
50
+
51
+    /**
52
+     * 根据 order_id 获取第二推荐人佣金变更数据(user=3)
53
+     */
54
+    public function getUserThreeChangeFromOrderId($orderId)
55
+    {
56
+        return $this::getModel()::getDB()
57
+            ->where('order_id', '=', $orderId)
58
+            ->where('user', '=', 3)
59
+            ->field('brokerage_price, uid')
60
+            ->find();
61
+    }
62
+
63
+    /**
64
+     * 根据 order_id 获取扫码推荐人积分变更数据(user=4)
65
+     */
66
+    public function getUserFourChangeFromOrderId($orderId)
67
+    {
68
+        return $this::getModel()::getDB()
69
+            ->where('order_id', '=', $orderId)
70
+            ->where('user', '=', 4)
71
+            ->field('score, uid')
72
+            ->find();
73
+    }
74
+}

+ 25 - 0
app/common/dao/backup/BackupUserDao.php

@@ -0,0 +1,25 @@
1
+<?php
2
+
3
+
4
+namespace app\common\dao\backup;
5
+use app\common\dao\BaseDao;
6
+use app\common\model\BaseModel;
7
+use app\common\model\backup\BackupUser;
8
+
9
+class BackupUserDao extends BaseDao
10
+{
11
+    protected function getModel(): string
12
+    {
13
+        return BackupUser::class;
14
+    }
15
+
16
+    /**
17
+     * 备份删除的用户表数据
18
+     * @param array $spreadUser
19
+     * @return int
20
+     */
21
+    public function saveDelData(array $spreadUser)
22
+    {
23
+        return $this->getModel()::getDB()->insert($spreadUser);
24
+    }
25
+}

+ 41 - 0
app/common/dao/dividend/DividendLogDao.php

@@ -0,0 +1,41 @@
1
+<?php
2
+
3
+namespace app\common\dao\dividend;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\dividend\DividendLog;
7
+use app\entity\data\dividend\DividendLogEntity;
8
+
9
+class DividendLogDao extends BaseDao
10
+{
11
+
12
+    protected function getModel(): string
13
+    {
14
+        return DividendLog::class;
15
+    }
16
+
17
+    /**
18
+     * @param array $idList
19
+     * @return DividendLogEntity[]
20
+     */
21
+    public function getDividendLogEntityListByIdList(array $idList): array
22
+    {
23
+        $entityList = [];
24
+        try {
25
+            /** @var DividendLog $model */
26
+            $model = $this->getModel();
27
+            $dataRes = $model::getDB()
28
+                ->whereIn('id', $idList)
29
+                ->select()
30
+                ->toArray();
31
+            if (!empty($dataRes)) {
32
+                $entityList = array_map(function ($data) {
33
+                    return DividendLogEntity::newInstance($data);
34
+                }, $dataRes);
35
+            }
36
+        } catch (\Exception $e) {
37
+
38
+        }
39
+        return $entityList;
40
+    }
41
+}

+ 15 - 0
app/common/dao/douhuomall/DouhuomallChangeLogDao.php

@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+namespace app\common\dao\douhuomall;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\douhuomall\DouhuomallChangeLog;
7
+
8
+class DouhuomallChangeLogDao extends BaseDao
9
+{
10
+
11
+    protected function getModel(): string
12
+    {
13
+        return DouhuomallChangeLog::class;
14
+    }
15
+}

+ 14 - 0
app/common/dao/gzc/GzcLogDao.php

@@ -11,4 +11,18 @@ class GzcLogDao extends BaseDao
11 11
     {
12 12
         return GzcLog::class;
13 13
     }
14
+    /**
15
+     * 公证处推送记录失效
16
+     */
17
+    public function loseGzcLog($orderId)
18
+    {
19
+        return $this->getModel()::getDB()->where('link_id',$orderId)->update(['gzc' => 0,'success' => 0]);
20
+    }
21
+    /**
22
+     * 恢复正常
23
+     */
24
+    public function recoverGzcLogs($orderId)
25
+    {
26
+        return $this->getModel()::getDB()->where('link_id',$orderId)->update(['gzc' => 1,'success' => 1]);
27
+    }
14 28
 }

+ 6 - 1
app/common/dao/merchant/order/OrderMerchantDao.php

@@ -62,7 +62,12 @@ class OrderMerchantDao extends BaseDao
62 62
     public function merchantSearch($merId, array $where, $sysDel = 0)
63 63
     {
64 64
         return OrderMerchant::getDB()
65
-            ->where('mer_id', $merId)
65
+            ->when($merId, function ($query, $merId) {
66
+                $query->where('mer_id', $merId);
67
+            })
68
+            ->when(!$merId && isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use ($where) {
69
+                $query->where('mer_id', $where['mer_id']);
70
+            })
66 71
             ->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
67 72
                 getModelTime($query, $where['date']);
68 73
             })

+ 35 - 0
app/common/dao/shared/SharedProsperityRecommendConfigDao.php

@@ -0,0 +1,35 @@
1
+<?php
2
+
3
+namespace app\common\dao\shared;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\shared\SharedProsperityRecommendConfig;
7
+
8
+class SharedProsperityRecommendConfigDao extends BaseDao
9
+{
10
+
11
+    protected function getModel(): string
12
+    {
13
+        return SharedProsperityRecommendConfig::class;
14
+    }
15
+
16
+    /**
17
+     * @return array
18
+     * @author 史晨
19
+     * @date 2026/2/5 14:43
20
+     * 获取推荐配置
21
+     */
22
+    public function getConfigList(): array
23
+    {
24
+        $entityList = [];
25
+        try {
26
+            /** @var SharedProsperityRecommendConfig $model */
27
+            $model = $this->getModel();
28
+            return $model::getDB()
29
+                ->select()
30
+                ->toArray();
31
+        } catch (\Exception $e) {
32
+        }
33
+        return $entityList;
34
+    }
35
+}

+ 41 - 0
app/common/dao/shared/SharedProsperityUserDao.php

@@ -0,0 +1,41 @@
1
+<?php
2
+
3
+namespace app\common\dao\shared;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\shared\SharedProsperityUser;
7
+use app\entity\data\shared\SharedProsperityUserEntity;
8
+
9
+class SharedProsperityUserDao extends BaseDao
10
+{
11
+
12
+    protected function getModel(): string
13
+    {
14
+        return SharedProsperityUser::class;
15
+    }
16
+
17
+    /**
18
+     * @param array $userIdList
19
+     * @return SharedProsperityUserEntity[]
20
+     */
21
+    public function getSharedProsperityUserEntityListByUserIdList(array $userIdList): array
22
+    {
23
+        $entityList = [];
24
+        try {
25
+            /** @var SharedProsperityUser $model */
26
+            $model = $this->getModel();
27
+            $dataRes = $model::getDB()
28
+                ->whereIn('user_id', $userIdList)
29
+                ->select()
30
+                ->toArray();
31
+            if (!empty($dataRes)) {
32
+                $entityList = array_map(function ($data) {
33
+                    return SharedProsperityUserEntity::newInstance($data);
34
+                }, $dataRes);
35
+            }
36
+        } catch (\Exception $e) {
37
+
38
+        }
39
+        return $entityList;
40
+    }
41
+}

+ 34 - 1
app/common/dao/store/order/StoreOrderDao.php

@@ -16,6 +16,7 @@ use app\common\enum\store\StoreOrderEnum;
16 16
 use app\common\model\BaseModel;
17 17
 use app\common\model\store\order\StoreOrder;
18 18
 use app\common\model\user\User;
19
+use app\common\repositories\store\order\StoreOrderProductRepository;
19 20
 use app\common\repositories\user\UserRepository;
20 21
 use app\entity\CommonEntity;
21 22
 use app\entity\data\store\StoreOrderEntity;
@@ -112,10 +113,14 @@ class StoreOrderDao extends BaseDao
112 113
             })
113 114
             ->when(isset($where['keywords']) && $where['keywords'] !== '', function ($query) use ($where) {
114 115
                 $query->where(function ($query) use ($where) {
116
+                    /** @var StoreOrderProductRepository $storeOrderProductRepository */
117
+                    $storeOrderProductRepository = app()->make(StoreOrderProductRepository::class);
118
+                    $orderIdList = $storeOrderProductRepository->getOrderIdListByKeyword($where['keywords']);
115 119
                     $query->where('real_name', 'like', "%" . $where['keywords'] . "%")
116 120
                         ->whereOr('user_phone', 'like', "%{$where['keywords']}%")
117 121
                         ->whereOr('order_sn', 'like', '%' . $where['keywords'] . '%')
118
-                        ->whereOr('verify_code', 'like', '%' . $where['keywords'] . '%');
122
+                        ->whereOr('verify_code', 'like', '%' . $where['keywords'] . '%')
123
+                        ->whereOr('order_id', 'in', $orderIdList);
119 124
                 });
120 125
             })
121 126
             ->when(isset($where['reconciliation_type']) && $where['reconciliation_type'] !== '', function ($query) use ($where) {
@@ -698,4 +703,32 @@ class StoreOrderDao extends BaseDao
698 703
                 'settlement_time' => date('Y-m-d H:i:s')
699 704
             ]);
700 705
     }
706
+
707
+    /**
708
+     * 红积分订单查询(订单ID列表)
709
+     * @param int $merId
710
+     * @param array $orderIdList
711
+     * @return array
712
+     */
713
+    public function getRedNumOrders(int $merId, array $orderIdList): array
714
+    {
715
+        try {
716
+            return StoreOrder::getDB()
717
+                ->alias('o')
718
+                ->join('user_bill u', 'u.order_sn=o.order_sn')
719
+                ->where('o.paid', 1)
720
+                ->where('o.is_red_ylj', 0)
721
+                ->where('o.mer_id', $merId)
722
+                ->where('u.commission_type', 5)
723
+                ->where('u.gzc', 3)
724
+                ->where('u.status', 0)
725
+                ->whereIn('o.pay_type', [0, 5])
726
+                ->whereIn('o.order_id', $orderIdList)
727
+                ->field('o.order_id,o.order_sn,u.number,u.mark')
728
+                ->select()
729
+                ->toArray();
730
+        } catch (\Exception $e) {
731
+            return [];
732
+        }
733
+    }
701 734
 }

+ 13 - 0
app/common/dao/store/order/StoreOrderProductDao.php

@@ -143,4 +143,17 @@ class StoreOrderProductDao extends BaseDao
143 143
                 $query->where('B.mer_id', $merId);
144 144
             })->where('B.paid', 1)->group('B.mer_id')->limit($limit)->order('total DESC')->select();
145 145
     }
146
+
147
+    /**
148
+     * @param $keyword
149
+     * @return array
150
+     */
151
+    public function getOrderIdListByKeyword($keyword): array
152
+    {
153
+        /** @var StoreOrderProduct $model */
154
+        $model = $this->getModel();
155
+        return $model::getDB()
156
+            ->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(cart_info, '$.product.store_name')) LIKE ?", ["%{$keyword}%"])
157
+            ->column('order_id');
158
+    }
146 159
 }

+ 15 - 0
app/common/dao/store/product/ProductAttrValueChangeLogDao.php

@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+namespace app\common\dao\store\product;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\store\product\ProductAttrValueChangeLog as model;
7
+
8
+class ProductAttrValueChangeLogDao extends BaseDao
9
+{
10
+
11
+    protected function getModel(): string
12
+    {
13
+        return model::class;
14
+    }
15
+}

+ 63 - 1
app/common/dao/user/UserBillDao.php

@@ -254,4 +254,66 @@ class UserBillDao extends BaseDao
254 254
             return [];
255 255
         }
256 256
     }
257
-}
257
+    /**
258
+     * 根据order_id与uid查找养老金值(link_id,status=1, pm=1)
259
+     */
260
+    public function getYanglaoFromUidOrderId($orderId, $uid)
261
+    {
262
+        try {
263
+            return $this::getModel()::getDB()
264
+                ->where('link_id', '=', $orderId)
265
+                ->where('status', '=', 1)
266
+                ->where('pm', '=', 1)
267
+                ->where('uid', '=', $uid)
268
+                ->value('number');
269
+        } catch (\Exception $e) {
270
+            return [];
271
+        }
272
+    }
273
+    /**
274
+     * 根据order_id与uid查找佣金(commission_type=5)
275
+     */
276
+    public function getYljFromCommissionTypeUidOrderId($orderId, $uid)
277
+    {
278
+        try {
279
+            return $this::getModel()::getDB()
280
+                ->where('link_id', '=', $orderId)
281
+                ->where('commission_type', '=', 5)
282
+                ->where('uid', '=', $uid)
283
+                ->value('number');
284
+        } catch (\Exception $e) {
285
+            return [];
286
+        }
287
+    }
288
+    /**
289
+     * 根据order_id与uid查找佣金(commission_type=3)
290
+     */
291
+    public function getYongjinFromCommissionTypeUidOrderId($orderId, $uid)
292
+    {
293
+        try {
294
+            return $this::getModel()::getDB()
295
+                ->where('link_id', '=', $orderId)
296
+                ->where('commission_type', '=', 3)
297
+                ->where('uid', '=', $uid)
298
+                ->value('number');
299
+        } catch (\Exception $e) {
300
+            return [];
301
+        }
302
+    }
303
+    /**
304
+     * 根据order_id查找第二推荐佣金uid(commission_type=3,排除当前用户和一级推荐人)
305
+     */
306
+    public function getYongjinTwoUidFromOrderId($orderId, $uid, $spreadUid)
307
+    {
308
+        try {
309
+            $value = $this::getModel()::getDB()
310
+                ->where('link_id', '=', $orderId)
311
+                ->where('commission_type', '=', 3)
312
+                ->whereNotIn('uid', [$uid, $spreadUid])
313
+                ->value('uid');
314
+            return $value ?: 0;
315
+        } catch (\Exception $e) {
316
+            return 0;
317
+        }
318
+    }
319
+}

+ 22 - 0
app/common/dao/user/UserDao.php

@@ -456,4 +456,26 @@ class UserDao extends BaseDao
456 456
     {
457 457
         return $this::getModel()::getDB()->where('level_id', '=', $userId)->column('uid');
458 458
     }
459
+    /**
460
+     * 通过uid获取spreadUid
461
+     */
462
+    public function getSpreadUidFromUid($uid)
463
+    {
464
+        try {
465
+        return $this::getModel()::getDB()->where('uid', '=', $uid)->value('spread_uid');
466
+        } catch (\Exception $e) {
467
+        return [];
468
+        }
469
+    }
470
+    /**
471
+     * 根据spread查找用户信息
472
+     */
473
+    public function getSpreadUserFromUid($spreadUid)
474
+    {
475
+        try {
476
+            return $this::getModel()::getDB()->where('uid', '=', $spreadUid)->find();
477
+        } catch (\Exception $e) {
478
+            return [];
479
+        }
480
+    }
459 481
 }

+ 27 - 0
app/common/dao/user/UserOrderKillOrRecoverRecordsDao.php

@@ -0,0 +1,27 @@
1
+<?php
2
+
3
+namespace app\common\dao\user;
4
+
5
+use app\common\dao\BaseDao;
6
+use app\common\model\user\UserOrderKillOrRecoverRecords;
7
+
8
+class UserOrderKillOrRecoverRecordsDao extends BaseDao
9
+{
10
+    protected function getModel(): string
11
+    {
12
+        return UserOrderKillOrRecoverRecords::class;
13
+    }
14
+
15
+    /**
16
+     * 插入撤销或恢复订单记录
17
+     */
18
+    public function insertKillOrRecoverRecord(array $data)
19
+    {
20
+        try {
21
+            return $this->getModel()::getDB()->insert($data);
22
+        } catch (\Exception $e) {
23
+            return false;
24
+        }
25
+    }
26
+}
27
+

+ 27 - 1
app/common/dao/user/UserPvLogDao.php

@@ -86,4 +86,30 @@ class UserPvLogDao extends BaseDao
86 86
             return [];
87 87
         }
88 88
     }
89
-}
89
+    /**
90
+     * 根据order_id和status查找pv值
91
+     */
92
+    public function getPVFromStatusOrderId($orderId)
93
+    {
94
+        try {
95
+            return $this::getModel()::getDB()->where('order_id', '=', $orderId)->where('status','=',1)->value('pv');
96
+        } catch (\Exception $e) {
97
+            return [];
98
+        }
99
+    }
100
+    /**
101
+     * 根据order_id获取pv值(用于备份用户变更记录)
102
+     */
103
+    public function getPvForBackupFromOrderId($orderId)
104
+    {
105
+        try {
106
+            $value = $this::getModel()::getDB()
107
+                ->where('order_id', '=', $orderId)
108
+                ->where('status', '=', 1)
109
+                ->value('pv');
110
+            return $value ?: 0;
111
+        } catch (\Exception $e) {
112
+            return 0;
113
+        }
114
+    }
115
+}

+ 17 - 1
app/common/dao/user/UserSignGongxianDao.php

@@ -86,4 +86,20 @@ class UserSignGongxianDao extends BaseDao
86 86
             return [];
87 87
         }
88 88
     }
89
-}
89
+    /**
90
+     * 根据order_id与uid查找贡献值(status=1, type=1)
91
+     */
92
+    public function getGongxianFromUidOrderId($orderId, $uid)
93
+    {
94
+        try {
95
+            return $this::getModel()::getDB()
96
+                ->where('order_id', '=', $orderId)
97
+                ->where('status', '=', 1)
98
+                ->where('type', '=', 1)
99
+                ->where('uid', '=', $uid)
100
+                ->value('number');
101
+        } catch (\Exception $e) {
102
+            return [];
103
+        }
104
+    }
105
+}

+ 79 - 1
app/common/dao/user/UserSignScoreDao.php

@@ -87,4 +87,82 @@ class UserSignScoreDao extends BaseDao
87 87
             return [];
88 88
         }
89 89
     }
90
-}
90
+    /**
91
+     * 根据order_id与uid查找奖励积分值(status=1, source_type=3, pm=1)
92
+     */
93
+    public function getRewardScoreFromUidOrderId($orderId, $uid)
94
+    {
95
+        try {
96
+            return $this::getModel()::getDB()
97
+                ->where('order_id', '=', $orderId)
98
+                ->where('status', '=', 1)
99
+                ->where('source_type', '=', 3)
100
+                ->where('uid', '=', $uid)
101
+                ->where('pm', '=', 1)
102
+                ->value('reward_socre');
103
+        } catch (\Exception $e) {
104
+            return [];
105
+        }
106
+    }
107
+    /**
108
+     * 根据order_id与uid查找支付积分值(status=1, pm=2)
109
+     */
110
+    public function getPayScoreFromUidOrderId($orderId, $uid)
111
+    {
112
+        try {
113
+            return $this::getModel()::getDB()
114
+                ->where('order_id', '=', $orderId)
115
+                ->where('status', '=', 1)
116
+                ->where('uid', '=', $uid)
117
+                ->where('pm', '=', 2)
118
+                ->value('reward_socre');
119
+        } catch (\Exception $e) {
120
+            return [];
121
+        }
122
+    }
123
+    /**
124
+     * 根据order_id与uid查找奖励积分值(status=1)
125
+     */
126
+    public function getRewardScoreFromStatusUidOrderId($orderId, $uid)
127
+    {
128
+        try {
129
+            return $this::getModel()::getDB()
130
+                ->where('order_id', '=', $orderId)
131
+                ->where('uid', '=', $uid)
132
+                ->where('status', '=', 1)
133
+                ->value('reward_socre');
134
+        } catch (\Exception $e) {
135
+            return [];
136
+        }
137
+    }
138
+    /**
139
+     * 根据order_id查找扫码推荐人uid(mark like '%扫码%', status=1)
140
+     */
141
+    public function getUidFromMarkLikeStatusOrderId($orderId)
142
+    {
143
+        try {
144
+            return $this::getModel()::getDB()
145
+                ->where('order_id', '=', $orderId)
146
+                ->whereLike('mark', '%扫码%')
147
+                ->where('status', '=', 1)
148
+                ->value('uid');
149
+        } catch (\Exception $e) {
150
+            return [];
151
+        }
152
+    }
153
+    /**
154
+     * 根据上面getUidFromMarkLikeStatusOrderId方法查处的Uid来确定score
155
+     */
156
+    public function getScoreFromUidOrderId($orderId, $smSpreadUid)
157
+    {
158
+        try {
159
+            return $this::getModel()::getDB()
160
+                ->where('order_id', '=', $orderId)
161
+                ->where('uid', '=', $smSpreadUid)
162
+                ->where('status', '=', 1)
163
+                ->value('reward_socre');
164
+        } catch (\Exception $e) {
165
+            return [];
166
+        }
167
+    }
168
+}

+ 27 - 1
app/common/dao/user/UserSignVrDao.php

@@ -56,4 +56,30 @@ class UserSignVrDao extends BaseDao
56 56
             return [];
57 57
         }
58 58
     }
59
-}
59
+    /**
60
+     * 根据订单id和type类型查找vr
61
+     */
62
+    public function getVrFromTypeOrderId($orderId)
63
+    {
64
+        try {
65
+            return $this::getModel()::getDB()->where('order_id', '=', $orderId)->where('type','=',2)->value('number');
66
+        } catch (\Exception $e){
67
+            return [];
68
+        }
69
+    }
70
+    /**
71
+     * 根据order_id获取vr值(用于备份用户变更记录)
72
+     */
73
+    public function getVrForBackupFromOrderId($orderId)
74
+    {
75
+        try {
76
+            $value = $this::getModel()::getDB()
77
+                ->where('order_id', '=', $orderId)
78
+                ->where('type', '=', 2)
79
+                ->value('number');
80
+            return $value ?: 0;
81
+        } catch (\Exception $e) {
82
+            return 0;
83
+        }
84
+    }
85
+}

+ 45 - 0
app/common/dao/util/TableOpsDao.php

@@ -0,0 +1,45 @@
1
+<?php
2
+
3
+namespace app\common\dao\util;
4
+
5
+use think\facade\Db;
6
+
7
+class TableOpsDao
8
+{
9
+    public function backupAndDeleteBatch(array $ops): void
10
+    {
11
+        foreach ($ops as [$table, $where]) {
12
+        $this->backupAndDelete($table, $where);
13
+        }
14
+    }
15
+    public function backupAndDelete(string $table, array $where): void
16
+    {
17
+        $rows = Db::name($table)->where($where)->select()->toArray();
18
+        if ($rows) {
19
+            Db::name('backup_' . $table)->insertAll($rows);
20
+            Db::name($table)->where($where)->delete();
21
+        }
22
+    }
23
+
24
+    public function restore(string $table, array $where): void
25
+    {
26
+        $backupTable = 'backup_' . $table;
27
+        $rows = Db::name($backupTable)->where($where)->select()->toArray();
28
+        if ($rows) {
29
+            foreach ($rows as &$row) {
30
+                if (isset($row['del_time'])) unset($row['del_time']);
31
+            }
32
+            unset($row);
33
+            Db::name($table)->insertAll($rows);
34
+            Db::name($backupTable)->where($where)->delete();
35
+        }
36
+    }
37
+
38
+    public function restoreBatch(array $ops): void
39
+    {
40
+        foreach ($ops as [$table, $where]) {
41
+            $this->restore($table, $where);
42
+        }
43
+    }
44
+}
45
+

+ 2 - 1
app/common/enum/CommonEnum.php

@@ -51,7 +51,8 @@ class CommonEnum
51 51
         'PARTNER_DIVIDEND' => ['code' => 11, 'name' => '合伙人分红'],
52 52
         'JOINT_CREATOR_DIVIDEND' => ['code' => 12, 'name' => '联创分红'],
53 53
         'EQUITY_DIVIDEND' => ['code' => 13, 'name' => '股权分红'],
54
-        'SHARE_EARNINGS' => ['code' => 20, 'name' => '分享收益']
54
+        'SHARE_EARNINGS' => ['code' => 20, 'name' => '分享收益'],
55
+        'COMMISSION_RECORD_V1.0' => ['code' => 21, 'name' => '1.0佣金记录'],
55 56
     ];
56 57
 
57 58
     const USER_GROUP = [

+ 21 - 0
app/common/enum/dividend/DividendLogEnum.php

@@ -0,0 +1,21 @@
1
+<?php
2
+
3
+namespace app\common\enum\dividend;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class DividendLogEnum extends CommonEnum
8
+{
9
+    // 1-合伙人分红;2-联创分红;3-股权分红;4-佣金补贴
10
+    const TYPE = [
11
+        'PartnerProfit' => ['code' => 1, 'name' => '合伙人分红'],
12
+        'CoFounderProfit' => ['code' => 2, 'name' => '联创分红'],
13
+        'EquityDividend' => ['code' => 3, 'name' => '股权分红'],
14
+        'CommissionSubsidy' => ['code' => 4, 'name' => '佣金补贴']
15
+    ];
16
+
17
+    const IS_TEST = [
18
+        'No' => ['code' => 0, 'name' => '否'],
19
+        'Yes' => ['code' => 1, 'name' => '是']
20
+    ];
21
+}

+ 13 - 0
app/common/enum/douhuomall/DouhuomallChangeLogEnum.php

@@ -0,0 +1,13 @@
1
+<?php
2
+
3
+namespace app\common\enum\douhuomall;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class DouhuomallChangeLogEnum extends CommonEnum
8
+{
9
+    const TYPE = [
10
+        'Adjust' => ['code' => 1, 'name' => '调价'],
11
+        'Delete' => ['code' => 2, 'name' => '删除']
12
+    ];
13
+}

+ 15 - 0
app/common/enum/douhuomall/DouhuomallEnum.php

@@ -0,0 +1,15 @@
1
+<?php
2
+
3
+namespace app\common\enum\douhuomall;
4
+
5
+use app\common\enum\CommonEnum;
6
+
7
+class DouhuomallEnum extends CommonEnum
8
+{
9
+    // 微唯宝文档中说明:"status": 1,//商品状态(0=下架,1=上架,3=删除)
10
+    const STATUS = [
11
+        'Down' => ['code' => 0, 'name' => '下架'],
12
+        'Up' => ['code' => 1, 'name' => '上架'],
13
+        'Delete' => ['code' => 3, 'name' => '删除'],
14
+    ];
15
+}

+ 5 - 0
app/common/enum/store/ProductEnum.php

@@ -36,4 +36,9 @@ class ProductEnum extends CommonEnum
36 36
         'No' => ['code' => 0, 'name' => '否'],
37 37
         'Yes' => ['code' => 1, 'name' => '是']
38 38
     ];
39
+
40
+    const IS_STATUS = [
41
+        'Automatic' => ['code' => 0, 'name' => '系统自动操作'],
42
+        'Triggered' => ['code' => 1, 'name' => '人为触发操作']
43
+    ];
39 44
 }

+ 1 - 1
app/common/middleware/AdminTokenMiddleware.php

@@ -32,7 +32,7 @@ class AdminTokenMiddleware extends BaseMiddleware
32 32
      */
33 33
     public function before(Request $request)
34 34
     {
35
-        \think\facade\Log::info('Midd_ko=>'.\GuzzleHttp\json_encode($request));
35
+        // \think\facade\Log::info('Midd_ko=>'.\GuzzleHttp\json_encode($request));
36 36
         $force = $this->getArg(0, true);
37 37
         try {
38 38
             $token = trim($request->header('X-Token'));

+ 16 - 0
app/common/model/backup/BackupStoreOrder.php

@@ -0,0 +1,16 @@
1
+<?php
2
+
3
+namespace app\common\model\backup;
4
+use app\common\model\BaseModel;
5
+
6
+class BackupStoreOrder extends BaseModel
7
+{
8
+    public static function tablePk(): ?string
9
+    {
10
+        return 'order_id';
11
+    }
12
+    public static function tableName(): string
13
+    {
14
+        return 'backup_store_order';
15
+    }
16
+}

+ 17 - 0
app/common/model/backup/BackupUser.php

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace app\common\model\backup;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class BackupUser extends BaseModel
8
+{
9
+    public static function tablePk(): string
10
+    {
11
+        return 'uid';
12
+    }
13
+    public static function tableName(): string
14
+    {
15
+        return 'backup_user';
16
+    }
17
+}

+ 17 - 0
app/common/model/backup/BackupUserChange.php

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace app\common\model\backup;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class BackupUserChange extends BaseModel
8
+{
9
+    public static function tablePk(): ?string
10
+    {
11
+        return 'id';
12
+    }
13
+    public static function tableName(): string
14
+    {
15
+        return 'backup_user_change';
16
+    }
17
+}

+ 19 - 0
app/common/model/dividend/DividendLog.php

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\dividend;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class DividendLog extends BaseModel
8
+{
9
+
10
+    public static function tablePk(): string
11
+    {
12
+        return 'id';
13
+    }
14
+
15
+    public static function tableName(): string
16
+    {
17
+        return 'dividend_logs';
18
+    }
19
+}

+ 19 - 0
app/common/model/douhuomall/DouhuomallChangeLog.php

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\douhuomall;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class DouhuomallChangeLog extends BaseModel
8
+{
9
+
10
+    public static function tablePk(): string
11
+    {
12
+        return '';
13
+    }
14
+
15
+    public static function tableName(): string
16
+    {
17
+        return 'douhuomall_change_logs';
18
+    }
19
+}

+ 18 - 0
app/common/model/shared/SharedProsperityRecommendConfig.php

@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+namespace app\common\model\shared;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class SharedProsperityRecommendConfig extends BaseModel
8
+{
9
+    public static function tablePk(): ?string
10
+    {
11
+        return 'id';
12
+    }
13
+
14
+    public static function tableName(): string
15
+    {
16
+        return 'shared_prosperity_recommend_config';
17
+    }
18
+}

+ 18 - 0
app/common/model/shared/SharedProsperityUser.php

@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+namespace app\common\model\shared;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class SharedProsperityUser extends BaseModel
8
+{
9
+    public static function tablePk(): ?string
10
+    {
11
+        return 'id';
12
+    }
13
+
14
+    public static function tableName(): string
15
+    {
16
+        return 'shared_prosperity_user';
17
+    }
18
+}

+ 19 - 0
app/common/model/store/product/ProductAttrValueChangeLog.php

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\store\product;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class ProductAttrValueChangeLog extends BaseModel
8
+{
9
+
10
+    public static function tablePk(): string
11
+    {
12
+        return '';
13
+    }
14
+
15
+    public static function tableName(): string
16
+    {
17
+        return 'store_product_attr_value_change_logs';
18
+    }
19
+}

+ 19 - 0
app/common/model/user/UserOrderKillOrRecoverRecords.php

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserOrderKillOrRecoverRecords extends BaseModel
8
+{
9
+    public static function tablePk(): ?string//hajimi
10
+    {
11
+        return 'id';
12
+    }
13
+
14
+    public static function tableName(): string
15
+    {
16
+        return 'user_order_kill_or_recover_records';
17
+    }
18
+}
19
+

+ 19 - 0
app/common/model/user/UserOrderKillRecord.php

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+namespace app\common\model\user;
4
+
5
+use app\common\model\BaseModel;
6
+
7
+class UserOrderKillRecord extends BaseModel
8
+{
9
+    public static function tablePk(): ?string//hajimi
10
+    {
11
+        return 'id';
12
+    }
13
+
14
+    public static function tableName(): string
15
+    {
16
+        return 'user_order_kill_records';
17
+    }
18
+}
19
+

+ 5 - 0
app/common/repositories/agreement/AgreementRepository.php

@@ -23,6 +23,11 @@ class AgreementRepository extends BaseRepository
23 23
         return Db::name("user_agreement")->where(['agreement_id'=>$id])->find();
24 24
     }
25 25
 
26
+    /*详情*/
27
+    public function getDetailContent($id){
28
+        return Db::name("user_agreement")->where(['agreement_id' => $id])->find()['content'] ?? '';
29
+    }
30
+
26 31
     /*修改*/
27 32
     public function updateData($id,$data){
28 33
         return Db::name("user_agreement")

+ 64 - 0
app/common/repositories/dividend/DividendLogRepository.php

@@ -0,0 +1,64 @@
1
+<?php
2
+
3
+namespace app\common\repositories\dividend;
4
+
5
+use app\common\dao\dividend\DividendLogDao;
6
+use app\common\repositories\BaseRepository;
7
+use app\entity\data\dividend\DividendLogEntity;
8
+
9
+class DividendLogRepository extends BaseRepository
10
+{
11
+
12
+    protected $dao;
13
+
14
+    /**
15
+     * DividendLogRepository constructor.
16
+     * @param DividendLogDao $dao
17
+     */
18
+    public function __construct(DividendLogDao $dao)
19
+    {
20
+        $this->dao = $dao;
21
+    }
22
+
23
+    /**
24
+     * @param int $id
25
+     * @return DividendLogEntity
26
+     */
27
+    public function getDividendLogEntityById(int $id): DividendLogEntity
28
+    {
29
+        $entityList = $this->getDividendLogEntityListByIdList([$id]);
30
+        $entity = array_shift($entityList);
31
+        if ($entity instanceof DividendLogEntity) {
32
+            return $entity;
33
+        } else {
34
+            /** @var DividendLogEntity */
35
+            return DividendLogEntity::newInstance();
36
+        }
37
+    }
38
+
39
+    /**
40
+     * @param array $idList
41
+     * @return DividendLogEntity[]
42
+     */
43
+    public function getDividendLogEntityListByIdList(array $idList): array
44
+    {
45
+        return $this->dao->getDividendLogEntityListByIdList($idList);
46
+    }
47
+
48
+    public function create($data)
49
+    {
50
+        return $this->dao->create($data);
51
+    }
52
+
53
+    /**
54
+     * @param DividendLogEntity $dividendLogEntity
55
+     * @return DividendLogEntity
56
+     */
57
+    public function createByEntity(DividendLogEntity $dividendLogEntity): DividendLogEntity
58
+    {
59
+        $result = $this->create($dividendLogEntity->toUnderlineArray())->toArray();
60
+        /** @var DividendLogEntity $entity */
61
+        $entity = DividendLogEntity::newInstance($result);
62
+        return $entity;
63
+    }
64
+}

+ 39 - 0
app/common/repositories/douhuomall/DouhuomallChangeLogRepository.php

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+namespace app\common\repositories\douhuomall;
4
+
5
+use app\common\dao\douhuomall\DouhuomallChangeLogDao;
6
+use app\common\repositories\BaseRepository;
7
+use app\entity\data\douhuomall\DouhuomallChangeLogEntity;
8
+
9
+class DouhuomallChangeLogRepository extends BaseRepository
10
+{
11
+
12
+    protected $dao;
13
+
14
+    /**
15
+     * DouhuomallChangeLogRepository constructor.
16
+     * @param DouhuomallChangeLogDao $dao
17
+     */
18
+    public function __construct(DouhuomallChangeLogDao $dao)
19
+    {
20
+        $this->dao = $dao;
21
+    }
22
+
23
+    public function create($data)
24
+    {
25
+        return $this->dao->create($data);
26
+    }
27
+
28
+    /**
29
+     * @param DouhuomallChangeLogEntity $douhuomallChangeLogEntity
30
+     * @return DouhuomallChangeLogEntity
31
+     */
32
+    public function createByEntity(DouhuomallChangeLogEntity $douhuomallChangeLogEntity): DouhuomallChangeLogEntity
33
+    {
34
+        $result = $this->create($douhuomallChangeLogEntity->toUnderlineArray())->toArray();
35
+        /** @var DouhuomallChangeLogEntity $entity */
36
+        $entity = DouhuomallChangeLogEntity::newInstance($result);
37
+        return $entity;
38
+    }
39
+}

+ 97 - 55
app/common/repositories/finance/FinanceRepository.php

@@ -1041,6 +1041,7 @@ class FinanceRepository extends BaseRepository
1041 1041
         $query = Db::name('user_bill')
1042 1042
             ->alias('ub')
1043 1043
             ->leftJoin('user u', 'u.uid=ub.uid')
1044
+            ->where('u.test_user', '<>', 1)
1044 1045
             ->when($mer_id, function ($query) use ($mer_id) {
1045 1046
                 $query->where('ub.mer_id', $mer_id);
1046 1047
             })
@@ -1049,7 +1050,7 @@ class FinanceRepository extends BaseRepository
1049 1050
                 $query->where('ub.commission_type', 5);
1050 1051
             }, function ($query) use ($params) {
1051 1052
                 // 非养老金
1052
-                $query->whereIn('ub.commission_type', [3, 16, 14, 10, 12, 20, 15, 7, 19]);
1053
+                $query->whereIn('ub.commission_type', [3, 7, 8, 10, 11, 12, 13, 20, 21]);
1053 1054
             })
1054 1055
             ->when(isset($params['uid']) && $params['uid'] != '', function ($query) use ($params) {
1055 1056
                 $query->where('ub.uid', $params['uid']);
@@ -1075,6 +1076,8 @@ class FinanceRepository extends BaseRepository
1075 1076
         //导出数据
1076 1077
         $is_excel = request()->param('is_excel', 0);
1077 1078
         if($is_excel == 1){
1079
+            ini_set('memory_limit', '-1');
1080
+            set_time_limit(0);
1078 1081
             $date['list'] = $this->date_where($query, $where['date'], 'ub.create_time')
1079 1082
             ->field('ub.bill_id,ub.title,ub.number,ub.mark,ub.take_time,ub.commission_type,u.uid,u.phone,u.nickname,u.user_group,ub.order_sn,ub.take_time,ub.status,ub.create_time')
1080 1083
             ->order('ub.bill_id', 'desc')
@@ -1201,20 +1204,28 @@ class FinanceRepository extends BaseRepository
1201 1204
                 return $item;
1202 1205
             });
1203 1206
         $data['count'] = $query->count();
1207
+        //应用时间筛选条件
1208
+        $query1 = $this->date_where($query1, $where['date'], 'ub.create_time');
1204 1209
         $statistics = $query1->field('sum(ub.number) money,ub.commission_type')->group('ub.commission_type')->select()->toArray();
1205 1210
         $statistics = array_column($statistics, 'money', 'commission_type');
1206
-
1211
+        //应用时间筛选条件
1212
+        $query3 = $this->date_where($query3, $where['date'], 'ub.create_time');
1207 1213
         $statistics_tow = $query3->field('sum(ub.number) money,ub.status')->group('ub.status')->select()->toArray();
1208 1214
         $statistics_tow = array_column($statistics_tow, 'money', 'status');
1209
-
1210 1215
         //佣金类型 1代理费 2 消费佣金 3直推奖√ 4辖区佣金\r\n5 养老金√ 6 广告费 7 跨店奖励√ 8平台奖励 9渠道商\r\n10 推荐创客收益√ 11分红奖金√ 12区县代区域收益√ 13消费循环佣金  14-推荐代理收益√ 15邀请小区团长升级√ 16大V经理分享奖√ 17创客合伙人√ 18积分奖励√ 19创客补贴√' 20省级代理区域收益√
1211 1216
         $data['statistics']['commission'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim(array_sum($statistics)), 'name' => '佣金奖励总额'];
1212 1217
         $data['statistics']['commission'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($statistics_tow[1] ?? 0), 'name' => '已结算佣金'];
1213 1218
         $data['statistics']['commission'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($statistics_tow[0] ?? 0), 'name' => '未结算佣金'];
1214 1219
         $data['statistics']['commission'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($statistics_tow[-1] ?? 0), 'name' => '已失效佣金'];
1215
-        $transition_vr = Db::name('user_transition_vr')->where('type', 1)->sum('number');
1220
+        //应用时间筛选条件
1221
+        $transition_vr_query = Db::name('user_transition_vr')->where('type', 1);
1222
+        $transition_vr_query = $this->date_where($transition_vr_query, $where['date'], 'create_time', '-', 2);//type为2时,才能根据时间戳来筛选数据。默认是处理Y-m-d H:i:s字符串
1223
+        $transition_vr = $transition_vr_query->sum('number');
1216 1224
         $data['statistics']['commission'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($transition_vr), 'name' => '佣金转VR'];
1217
-        $user_extra_money = Db::name('user_extract')->where('status', 1)->sum('extract_price');
1225
+        //应用时间筛选条件
1226
+        $user_extra_money_query = Db::name('user_extract')->where('status', 1);
1227
+        $user_extra_money_query = $this->date_where($user_extra_money_query, $where['date'], 'create_time');
1228
+        $user_extra_money = $user_extra_money_query->sum('extract_price');
1218 1229
         $data['statistics']['commission'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($user_extra_money), 'name' => '已提现佣金'];
1219 1230
         $data['statistics'][] = ['className' => 'el-icon-s-goods', 'count' => set_price_rtrim($user_extra_money), 'name' => '已提现金额'];
1220 1231
 
@@ -1835,49 +1846,34 @@ class FinanceRepository extends BaseRepository
1835 1846
      */
1836 1847
     public function vr_list($mer_id = 0)
1837 1848
     {
1838
-        $page = input('page');
1839
-        $limit = input('limit');
1849
+        $page = input('page', 1);
1850
+        $limit = input('limit', 20);
1840 1851
         $where = request()->params(['date']);
1841
-        $params = request()->params(['type', 'uid', 'pm', 'phone','status']);
1852
+        $params = request()->params(['type', 'uid', 'pm', 'phone', 'status']);
1842 1853
 
1843
-        $date = [];
1844
-        //商户ID
1854
+        // 1. 基础查询构建
1845 1855
         $query = Db::name('user_sign_vr')
1846
-        ->alias('uss')
1847
-        ->leftJoin('user u', 'u.uid=uss.uid')
1848
-        ->leftJoin('store_order o', 'o.order_id=uss.order_id')
1849
-        ->when(isset($params['uid']) && $params['uid'] != '', function ($query) use ($params) {
1850
-            $query->where('uss.uid', $params['uid']);
1851
-        })
1852
-        // ->when(isset($params['pm']) && $params['pm'] != '', function ($query) use ($params) {
1853
-        //     $query->where('uss.pm', $params['pm']);
1854
-        // })
1855
-        // ->when(isset($params['status']) && $params['status'] != '', function ($query) use ($params) {
1856
-        //     $query->where('uss.status', $params['status']);
1857
-        // })
1858
-        ->when(isset($params['phone']) && $params['phone'] != '', function ($query) use ($params) {
1859
-            $query->whereLike('u.phone', '%' . $params['phone'] . '%');
1860
-        })
1861
-        ->when(isset($params['type']) && $params['type'] != '', function ($query) use ($params) {
1862
-            $query->where('type', $params['type']);
1863
-        });
1864
-        $query1 = clone $query;
1865
-        $query2 = clone $query;
1866
-        $query3 = clone $query;
1867
-        $query4 = clone $query;
1868
-        $query5 = clone $query;
1869
-        $query6 = clone $query;
1870
-        $query7 = clone $query;
1871
-        $query8 = clone $query;
1872
-        $query9 = clone $query;
1856
+            ->alias('uss')
1857
+            ->leftJoin('user u', 'u.uid = uss.uid')
1858
+            ->leftJoin('store_order o', 'o.order_id = uss.order_id')
1859
+            ->where('u.test_user','<>','1')
1860
+            ->when(isset($params['uid']) && $params['uid'] != '', function ($query) use ($params) {
1861
+                $query->where('uss.uid', $params['uid']);
1862
+            })
1863
+            ->when(isset($params['phone']) && $params['phone'] != '', function ($query) use ($params) {
1864
+                $query->whereLike('u.phone', '%' . $params['phone'] . '%');
1865
+            })
1866
+            ->when(isset($params['type']) && $params['type'] != '', function ($query) use ($params) {
1867
+                $query->where('uss.type', $params['type']);
1868
+            });
1873 1869
 
1874 1870
         //导出数据
1875 1871
         $is_excel = request()->param('is_excel', 0);
1876 1872
         if($is_excel == 1){
1877 1873
             $date['list'] = $this->date_where($query, $where['date'], 'uss.addtime', '-', 2)
1878
-            ->field('uss.id,uss.addtime,u.nickname,u.phone,uss.number,o.order_sn,uss.type,uss.mark,u.score')
1879
-            ->order('uss.id', 'desc')
1880
-            ->select();
1874
+                ->field('uss.id,uss.addtime,u.nickname,u.phone,uss.number,o.order_sn,uss.type,uss.mark,u.score')
1875
+                ->order('uss.id', 'desc')
1876
+                ->select();
1881 1877
             $arr = [];
1882 1878
             foreach ($date['list'] as $k=>$item){
1883 1879
                 switch ($item['type']) {
@@ -1903,32 +1899,78 @@ class FinanceRepository extends BaseRepository
1903 1899
             ], $arr, 'VR统计');
1904 1900
         }
1905 1901
 
1906
-        $date['list'] = $this->date_where($query, $where['date'], 'uss.addtime', '-', 2)
1907
-            ->field('uss.id,uss.addtime,u.nickname,u.phone,uss.number,o.order_sn,uss.type,uss.mark,u.score')
1902
+        // 4. 分页查询
1903
+        $date['list'] = $query->field([
1904
+            'uss.id',
1905
+            'uss.addtime',
1906
+            'u.nickname',
1907
+            'u.phone',
1908
+            'uss.number',
1909
+            'o.order_sn',
1910
+            'uss.type',
1911
+            'uss.mark',
1912
+            'u.score'
1913
+        ])
1908 1914
             ->page($page, $limit)
1909 1915
             ->order('uss.id', 'desc')
1910 1916
             ->select()
1911 1917
             ->each(function ($item) {
1912
-                $item['mark'] = $item['mark'];
1913 1918
                 $item['addtime'] = date('Y-m-d H:i:s', $item['addtime']);
1914 1919
                 return $item;
1915 1920
             });
1921
+
1922
+        // 5. 统计信息提取到单独方法
1916 1923
         $date['count'] = $query->count();
1917
-        $date['statistics']['all'] = decimal2($query1->sum('number'));
1918
-        // $date['statistics']['clear'] = decimal2($query2->where('uss.type', 1)->sum('number'));
1919
-        $date['statistics']['nclear'] = decimal2($query3->where('uss.type', 2)->sum('number'));
1920
-
1921
-        //按照备注内容分类统计vr
1922
-        $date['statistics']['transfervr'] = decimal2($query4->whereLike('uss.mark', '%消耗VR%')->sum('number'));
1923
-        $date['statistics']['acquirevr'] = decimal2($query5->whereLike('uss.mark', '%到账VR%')->sum('number'));
1924
-        $date['statistics']['transitionvr'] = decimal2($query6->whereLike('uss.mark', '%佣金转VR%')->sum('number'));
1925
-        $date['statistics']['jcshqvr'] = decimal2($query7->whereLike('uss.mark', '%购买精彩%')->sum('number'));
1926
-        $date['statistics']['hyzqvr'] = decimal2($query8->whereLike('uss.mark', '%购买会员%')->sum('number'));
1927
-        $date['statistics']['allbuyvr'] = decimal2($query9->whereLike('uss.mark', '%购买%')->sum('number'));
1928
- 
1924
+        $date['statistics'] = $this->getVrStatistics($query);
1925
+
1929 1926
         return $date;
1930 1927
     }
1931 1928
 
1929
+    /**
1930
+     * 获取VR统计信息
1931
+     */
1932
+    private function getVrStatistics($query)
1933
+    {
1934
+        $statistics = [];
1935
+        $conditions = [
1936
+            'all' => [],
1937
+            'nclear' => ['uss.type' => 2],
1938
+            'transfervr' => function ($subQuery) {
1939
+                $subQuery->where('uss.type', '=', 2)
1940
+                    ->where(function ($q) {
1941
+                        $q->where('uss.mark', 'like', '%消耗%')
1942
+                            ->whereOr('uss.mark', 'like', '%管理员调整vr%');
1943
+                    });
1944
+            },
1945
+            'acquirevr' => function ($subQuery) {
1946
+                $subQuery->where('uss.type', '=', 1)
1947
+                    ->where(function ($q) {
1948
+                        $q->where('uss.mark', 'like', '%到账%')
1949
+                            ->whereOr('uss.mark', 'like', '%管理员调整vr%');
1950
+                    });
1951
+            },
1952
+            'transitionvr' => [['uss.mark', 'like', '%佣金转VR%']],
1953
+            'jcshqvr' => [['uss.mark', 'like', '%购买精彩%']],
1954
+            'hyzqvr' => [['uss.mark', 'like', '%购买会员%']],
1955
+            'allbuyvr' => [['uss.mark', 'like', '%购买%']],
1956
+        ];
1957
+
1958
+        foreach ($conditions as $key => $condition) {
1959
+            $subQuery = clone $query;
1960
+            if (is_callable($condition)) {
1961
+                // 如果是闭包函数,直接调用
1962
+                $condition($subQuery);
1963
+            } elseif (!empty($condition)) {
1964
+                // 如果是数组条件,使用where
1965
+                $subQuery->where($condition);
1966
+            }
1967
+            $statistics[$key] = decimal2($subQuery->sum('uss.number'));
1968
+        }
1969
+
1970
+        return $statistics;
1971
+    }
1972
+
1973
+
1932 1974
 
1933 1975
 
1934 1976
 

+ 11 - 11
app/common/repositories/merchant/order/OrderMerchantRepository.php

@@ -154,7 +154,7 @@ class OrderMerchantRepository extends BaseRepository
154 154
      */
155 155
     public function getMerchantListAdmin($merId, array $where, $page, $limit)
156 156
     {
157
-//        $merId=Db::name('merchant')->where('uid',$uid)->value('mer_id');
157
+        //        $merId=Db::name('merchant')->where('uid',$uid)->value('mer_id');
158 158
         $query = $this->dao->merchantSearch($merId, $where);
159 159
         $query1 = $this->dao->merchantSearch($merId, $where);
160 160
         $statistics = $query1->field('sum(money) money,sum(available) available,sum(swipe_fee) swipe_fee')
@@ -162,21 +162,20 @@ class OrderMerchantRepository extends BaseRepository
162 162
             ->where('paid', 1)
163 163
             ->whereNull('refund_time')
164 164
             ->find();
165
-
166 165
         $count = $query->count();
167 166
         $list = $query->with(['merchant', 'merchant' => function ($query) {
168 167
             return $query->field('mer_id,mer_name,mer_avatar');
169 168
         }])->page($page, $limit)->select()->each(function ($item) {
170 169
             $item->actual = bcsub($item->money, ($item->available + $item->swipe_fee), 2);
171
-//            switch($item->trade_type) {
172
-//                case 'ALI':
173
-//                    $item->broadcast = '支付宝收款'.$item->actual.'元';
174
-//                    break;
175
-//                case 'WX':
176
-//                    $item->broadcast = '微信收款'.$item->actual.'元';
177
-//                    break;
178
-//                default:break;
179
-//            }
170
+            //            switch($item->trade_type) {
171
+            //                case 'ALI':
172
+            //                    $item->broadcast = '支付宝收款'.$item->actual.'元';
173
+            //                    break;
174
+            //                case 'WX':
175
+            //                    $item->broadcast = '微信收款'.$item->actual.'元';
176
+            //                    break;
177
+            //                default:break;
178
+            //            }
180 179
             //语音内容
181 180
             $broadcast = systemConfig('broadcast');
182 181
             $item->broadcast = strtr($broadcast, ['{money}' => $item->actual]);
@@ -251,6 +250,7 @@ class OrderMerchantRepository extends BaseRepository
251 250
                 $base_commission = merchantConfig(0, 'extension_one_rate');
252 251
             }
253 252
             if($params['mer_id'] == 3425) $base_commission = 0;
253
+            if($params['mer_id'] == 3447) $base_commission = 0;
254 254
             $merchant_data = Db::name('merchant')->where('mer_id', $params['mer_id'])->find();
255 255
             $is_dacang = 0;
256 256
             $avaiable = 0;

+ 49 - 0
app/common/repositories/shared/SharedProsperityRecommendConfigRepository.php

@@ -0,0 +1,49 @@
1
+<?php
2
+
3
+namespace app\common\repositories\shared;
4
+
5
+use app\common\dao\shared\SharedProsperityRecommendConfigDao;
6
+use app\common\repositories\BaseRepository;
7
+use app\entity\data\shared\SharedProsperityRecommendConfigEntity;
8
+
9
+class SharedProsperityRecommendConfigRepository extends BaseRepository
10
+{
11
+
12
+    protected $dao;
13
+
14
+    /**
15
+     * SharedProsperityUserRepository constructor.
16
+     * @param SharedProsperityRecommendConfigDao $dao
17
+     */
18
+    public function __construct(SharedProsperityRecommendConfigDao $dao)
19
+    {
20
+        $this->dao = $dao;
21
+    }
22
+
23
+    public function create($data)
24
+    {
25
+        return $this->dao->create($data);
26
+    }
27
+
28
+    /**
29
+     * @param SharedProsperityRecommendConfigEntity $sharedProsperityRecommendConfigEntity
30
+     * @return SharedProsperityRecommendConfigEntity
31
+     */
32
+    public function createByEntity(SharedProsperityRecommendConfigEntity $sharedProsperityRecommendConfigEntity): SharedProsperityRecommendConfigEntity
33
+    {
34
+        $result = $this->create($sharedProsperityRecommendConfigEntity->toUnderlineArray())->toArray();
35
+        /** @var SharedProsperityRecommendConfigEntity $entity */
36
+        $entity = SharedProsperityRecommendConfigEntity::newInstance($result);
37
+        return $entity;
38
+    }
39
+
40
+    /**
41
+     * @return array
42
+     * @author 史晨
43
+     * @date 2026/2/5 14:12
44
+     */
45
+    public function getList(): array
46
+    {
47
+        return $this->dao->getConfigList();
48
+    }
49
+}

+ 118 - 0
app/common/repositories/shared/SharedProsperityUserRepository.php

@@ -0,0 +1,118 @@
1
+<?php
2
+
3
+namespace app\common\repositories\shared;
4
+
5
+use app\common\dao\shared\SharedProsperityUserDao;
6
+use app\common\repositories\BaseRepository;
7
+use app\entity\data\shared\SharedProsperityUserEntity;
8
+use think\db\exception\DbException;
9
+
10
+class SharedProsperityUserRepository extends BaseRepository
11
+{
12
+
13
+    protected $dao;
14
+
15
+    /**
16
+     * SharedProsperityUserRepository constructor.
17
+     * @param SharedProsperityUserDao $dao
18
+     */
19
+    public function __construct(SharedProsperityUserDao $dao)
20
+    {
21
+        $this->dao = $dao;
22
+    }
23
+
24
+    /**
25
+     * @param int $userId
26
+     * @return SharedProsperityUserEntity
27
+     */
28
+    public function getSharedProsperityUserEntityByUserId(int $userId): SharedProsperityUserEntity
29
+    {
30
+        $entityList = $this->getSharedProsperityUserEntityListByUserIdList([$userId]);
31
+        $entity = array_shift($entityList);
32
+        if ($entity instanceof SharedProsperityUserEntity) {
33
+            return $entity;
34
+        } else {
35
+            /** @var SharedProsperityUserEntity */
36
+            return SharedProsperityUserEntity::newInstance();
37
+        }
38
+    }
39
+
40
+    /**
41
+     * @param array $userIdList
42
+     * @return SharedProsperityUserEntity[]
43
+     */
44
+    public function getSharedProsperityUserEntityListByUserIdList(array $userIdList): array
45
+    {
46
+        return $this->dao->getSharedProsperityUserEntityListByUserIdList($userIdList);
47
+    }
48
+
49
+    public function create($data)
50
+    {
51
+        return $this->dao->create($data);
52
+    }
53
+
54
+    /**
55
+     * @param SharedProsperityUserEntity $sharedProsperityUserEntity
56
+     * @return SharedProsperityUserEntity
57
+     */
58
+    public function createByEntity(SharedProsperityUserEntity $sharedProsperityUserEntity): SharedProsperityUserEntity
59
+    {
60
+        $result = $this->create($sharedProsperityUserEntity->toUnderlineArray())->toArray();
61
+        /** @var SharedProsperityUserEntity $entity */
62
+        $entity = SharedProsperityUserEntity::newInstance($result);
63
+        return $entity;
64
+    }
65
+
66
+    /**
67
+     * @param $id
68
+     * @param $data
69
+     * @return int
70
+     */
71
+    public function update($id, $data): int
72
+    {
73
+        try {
74
+            return $this->dao->update($id, $data);
75
+        } catch (DbException $e) {
76
+            return 0;
77
+        }
78
+    }
79
+
80
+    /**
81
+     * @param SharedProsperityUserEntity $sharedProsperityUserEntity
82
+     * @return SharedProsperityUserEntity
83
+     */
84
+    public function updateByEntity(SharedProsperityUserEntity $sharedProsperityUserEntity): SharedProsperityUserEntity
85
+    {
86
+        if (empty($sharedProsperityUserEntity->getId())) {
87
+            return SharedProsperityUserEntity::newInstance();
88
+        }
89
+        $result = $this->update($sharedProsperityUserEntity->getId(), $sharedProsperityUserEntity->toUnderlineArray());
90
+        if ($result > 0) {
91
+            return $this->getSharedProsperityUserEntityByUserId($sharedProsperityUserEntity->getUserId());
92
+        }
93
+        return SharedProsperityUserEntity::newInstance();
94
+    }
95
+
96
+    /**
97
+     * 绑定 上级
98
+     * @param int $userId
99
+     * @param int $parentId
100
+     * @return bool
101
+     */
102
+    public function bindParentId(int $userId, int $parentId): bool
103
+    {
104
+        $sharedProsperityUserEntity = $this->getSharedProsperityUserEntityByUserId($userId);
105
+        if (empty($sharedProsperityUserEntity->getUserId())) {
106
+            return false;
107
+        }
108
+        $sharedProsperityUserEntityByParentId = $this->getSharedProsperityUserEntityByUserId($parentId);
109
+        if (empty($sharedProsperityUserEntityByParentId->getUserId())) {
110
+            return false;
111
+        }
112
+        $sharedProsperityUserEntity = $this->updateByEntity($sharedProsperityUserEntity->setParentId($sharedProsperityUserEntityByParentId->getUserId()));
113
+        if (empty($sharedProsperityUserEntity->getId())) {
114
+            return false;
115
+        }
116
+        return true;
117
+    }
118
+}

+ 13 - 0
app/common/repositories/store/order/StoreOrderProductRepository.php

@@ -64,4 +64,17 @@ class StoreOrderProductRepository extends BaseRepository
64 64
         }
65 65
         return $this->insertAll($dataList);
66 66
     }
67
+
68
+    /**
69
+     * 根据关键字 获取订单ID列表
70
+     * @param $keyword
71
+     * @return array
72
+     * @throws \think\db\exception\DataNotFoundException
73
+     * @throws \think\db\exception\DbException
74
+     * @throws \think\db\exception\ModelNotFoundException
75
+     */
76
+    public function getOrderIdListByKeyword($keyword): array
77
+    {
78
+        return $this->dao->getOrderIdListByKeyword($keyword);
79
+    }
67 80
 }

+ 322 - 34
app/common/repositories/store/order/StoreOrderRepository.php

@@ -11,10 +11,25 @@
11 11
 namespace app\common\repositories\store\order;
12 12
 
13 13
 
14
+use app\common\dao\gzc\GzcLogDao;
14 15
 use app\common\dao\store\order\StoreOrderDao;
16
+use app\common\dao\user\UserDao;
17
+use app\common\dao\user\UserPvLogDao;
18
+use app\common\dao\user\UserSignVrDao;
19
+use app\common\dao\user\UserSignScoreDao;
20
+use app\common\dao\user\UserSignGongxianDao;
21
+use app\common\dao\user\UserBillDao;
22
+use app\common\dao\user\UserOrderKillOrRecoverRecordsDao;
23
+use app\common\dao\backup\BackupUserDao;
24
+use app\common\dao\backup\BackupUserChangeDao;
25
+use app\common\dao\util\TableOpsDao;
26
+use app\common\dao\backup\BackupStoreOrderDao;
15 27
 use app\common\enum\CommonEnum;
16 28
 use app\common\enum\merchant\MerchantEnum;
17 29
 use app\common\enum\shipping\ShippingTemplateEnum;
30
+use app\common\enum\store\CartEnum;
31
+use app\common\enum\store\ProductEnum;
32
+use app\common\enum\store\StoreGroupOrderEnum;
18 33
 use app\common\enum\store\StoreOrderEnum;
19 34
 use app\common\enum\user\UserBillEnum;
20 35
 use app\common\enum\user\UserEnum;
@@ -30,9 +45,15 @@ use app\common\model\store\order\StoreGroupOrder;
30 45
 use app\common\model\store\order\StoreOrder;
31 46
 use app\common\model\store\order\StoreRefundOrder;
32 47
 use app\common\model\user\User;
48
+use app\common\model\user\UserCertification;
49
+use app\common\model\user\UserRich;
33 50
 use app\common\repositories\merchant\order\OrderGzcRepository;
34 51
 use app\common\repositories\merchant\order\OrderMerchantRepository;
35 52
 use app\common\repositories\BaseRepository;
53
+use app\common\repositories\product\ProductSeckillRepository;
54
+use app\common\repositories\product\ShareRepository;
55
+use app\common\repositories\store\coupon\StoreCouponProductRepository;
56
+use app\common\repositories\store\coupon\StoreCouponRepository;
36 57
 use app\common\repositories\store\coupon\StoreCouponUserRepository;
37 58
 use app\common\repositories\store\MerchantTakeRepository;
38 59
 use app\common\repositories\store\product\ProductAttrValueRepository;
@@ -45,8 +66,10 @@ use app\common\repositories\store\shipping\ShippingTemplateUndeliveRepository;
45 66
 use app\common\repositories\store\StoreSeckillActiveRepository;
46 67
 use app\common\repositories\system\attachment\AttachmentRepository;
47 68
 use app\common\repositories\system\merchant\FinancialRecordRepository;
69
+use app\common\repositories\system\merchant\MerchantCategoryRepository;
48 70
 use app\common\repositories\system\merchant\MerchantContributionRepository;
49 71
 use app\common\repositories\system\merchant\MerchantRepository;
72
+use app\common\repositories\merchant\MerchantRepository as m;
50 73
 use app\common\repositories\user\UserAddressRepository;
51 74
 use app\common\repositories\user\UserBillRepository;
52 75
 use app\common\repositories\user\UserPvLogRepository;
@@ -62,20 +85,31 @@ use app\common\repositories\user\UserThirdRepository;
62 85
 use app\common\repositories\wechat\RoutineQrcodeRepository;
63 86
 use app\common\repositories\wechat\WechatUserRepository;
64 87
 use app\controller\api\user\Volunteer;
88
+use app\entity\data\merchant\MerchantEntity;
89
+use app\entity\data\product\ProductSeckillEntity;
90
+use app\entity\data\product\ShareEntity;
91
+use app\entity\data\store\CartEntity;
65 92
 use app\entity\data\store\StoreProductAttrValueEntity;
66 93
 use app\entity\data\store\StoreProductEntity;
94
+use app\entity\data\store\StoreGroupOrderEntity;
67 95
 use app\entity\data\store\StoreOrderEntity;
96
+use app\entity\data\user\UserAddressEntity;
97
+use app\entity\data\user\UserBillEntity;
68 98
 use app\entity\data\user\UserEntity;
69 99
 use app\entity\monomer\store\FzonePayTypeEntity;
70 100
 use app\entity\request\api\store\order\CalculatePostageRequestEntity;
101
+use app\entity\request\api\store\order\StoreOrderCreateRequestEntity;
71 102
 use app\model\common\JdOrderModel;
72 103
 use app\model\common\TbOrderModel;
73 104
 use app\traits\GongApiRequest;
74 105
 use app\traits\HuiPay;
75 106
 use app\traits\ShouxinyiApiRequest;
107
+use app\utils\ArrayUtil;
108
+use Carbon\Carbon;
76 109
 use crmeb\jobs\PayGiveCouponJob;
77 110
 use crmeb\jobs\SendSmsJob;
78 111
 use crmeb\jobs\SendTemplateMessageJob;
112
+use crmeb\services\AliYunSmsService;
79 113
 use crmeb\services\ExpressService;
80 114
 use crmeb\services\MiniProgramService;
81 115
 use crmeb\services\QrcodeService;
@@ -98,6 +132,7 @@ use think\facade\Route;
98 132
 use Alipay\AopClient;
99 133
 use Alipay\request\AlipayTradeAppPayRequest;
100 134
 use Lakala\src\LakalaBoss;
135
+use vipapis\dvd\DvdAreaSalesService_healthCheck_args;
101 136
 use function Couchbase\basicEncoderV1;
102 137
 
103 138
 /**
@@ -4078,39 +4113,39 @@ class StoreOrderRepository extends BaseRepository
4078 4113
             Db::name('log')->insert(['data' => '订单号:' . $order_sn . '付款额度较低或 商家、平台设置的返佣比例较低,养老金低于0.01无法入库 特此记录!']);
4079 4114
         }
4080 4115
 
4081
-        // 消费者
4082
-        $userinfo = Db::name("user")->where('uid', $order["uid"])->find();
4083
-        // 直推用户
4084
-        $directThrustUserinfo = User::where('uid', $userinfo["spread_uid"])->find();
4085
-        if (!empty($directThrustUserinfo)) {
4086
-            // 直推养老金
4087
-            $directThrustEstimateannuity = bcmul($order['total_price'], $sanfangfenpei['direct_thrust_ratio'], 2);
4088
-            if ($directThrustEstimateannuity >= 0.01) {
4089
-                $this->add_bill(
4090
-                    '养老金', $directThrustEstimateannuity, $directThrustUserinfo["uid"], "复购-直接推广者获得养老金" . $directThrustEstimateannuity,
4091
-                    5, $order_sn, $order_id, $order["mer_id"], 0, 0, $order["type_shop"]
4092
-                );
4093
-            } else {
4094
-                Db::name('log')->insert(['data' => '订单号:' . $order_sn . '付款额度较低或 商家、平台设置的返佣比例较低,养老金低于0.01无法入库 特此记录!']);
4095
-            }
4096
-        }
4097
-
4098
-        // 间推用户
4099
-        if ($directThrustUserinfo && !empty($directThrustUserinfo["spread_uid"])) {
4100
-            $indirectThrustUserinfo = User::where('uid', $directThrustUserinfo["spread_uid"])->find();
4101
-            if (!empty($indirectThrustUserinfo)) {
4102
-                // 间推养老金
4103
-                $indirectThrustEstimateannuity = bcmul($order['total_price'], $sanfangfenpei['indirect_thrust_ratio'], 2);
4104
-                if ($indirectThrustEstimateannuity >= 0.01) {
4105
-                    $this->add_bill(
4106
-                        '养老金', $indirectThrustEstimateannuity, $indirectThrustUserinfo["uid"], "复购-间接推广者获得养老金" . $indirectThrustEstimateannuity,
4107
-                        5, $order_sn, $order_id, $order["mer_id"], 0, 0, $order["type_shop"]
4108
-                    );
4109
-                } else {
4110
-                    Db::name('log')->insert(['data' => '订单号:' . $order_sn . '付款额度较低或 商家、平台设置的返佣比例较低,养老金低于0.01无法入库 特此记录!']);
4111
-                }
4112
-            }
4113
-        }
4116
+        // // 消费者
4117
+        // $userinfo = Db::name("user")->where('uid', $order["uid"])->find();
4118
+        // // 直推用户
4119
+        // $directThrustUserinfo = User::where('uid', $userinfo["spread_uid"])->find();
4120
+        // if (!empty($directThrustUserinfo)) {
4121
+        //     // 直推养老金
4122
+        //     $directThrustEstimateannuity = bcmul($order['total_price'], $sanfangfenpei['direct_thrust_ratio'], 2);
4123
+        //     if ($directThrustEstimateannuity >= 0.01) {
4124
+        //         $this->add_bill(
4125
+        //             '养老金', $directThrustEstimateannuity, $directThrustUserinfo["uid"], "复购-直接推广者获得养老金" . $directThrustEstimateannuity,
4126
+        //             5, $order_sn, $order_id, $order["mer_id"], 0, 0, $order["type_shop"]
4127
+        //         );
4128
+        //     } else {
4129
+        //         Db::name('log')->insert(['data' => '订单号:' . $order_sn . '付款额度较低或 商家、平台设置的返佣比例较低,养老金低于0.01无法入库 特此记录!']);
4130
+        //     }
4131
+        // }
4132
+        //
4133
+        // // 间推用户
4134
+        // if ($directThrustUserinfo && !empty($directThrustUserinfo["spread_uid"])) {
4135
+        //     $indirectThrustUserinfo = User::where('uid', $directThrustUserinfo["spread_uid"])->find();
4136
+        //     if (!empty($indirectThrustUserinfo)) {
4137
+        //         // 间推养老金
4138
+        //         $indirectThrustEstimateannuity = bcmul($order['total_price'], $sanfangfenpei['indirect_thrust_ratio'], 2);
4139
+        //         if ($indirectThrustEstimateannuity >= 0.01) {
4140
+        //             $this->add_bill(
4141
+        //                 '养老金', $indirectThrustEstimateannuity, $indirectThrustUserinfo["uid"], "复购-间接推广者获得养老金" . $indirectThrustEstimateannuity,
4142
+        //                 5, $order_sn, $order_id, $order["mer_id"], 0, 0, $order["type_shop"]
4143
+        //             );
4144
+        //         } else {
4145
+        //             Db::name('log')->insert(['data' => '订单号:' . $order_sn . '付款额度较低或 商家、平台设置的返佣比例较低,养老金低于0.01无法入库 特此记录!']);
4146
+        //         }
4147
+        //     }
4148
+        // }
4114 4149
     }
4115 4150
 
4116 4151
     public function yugu_rebate($order)
@@ -5041,6 +5076,16 @@ class StoreOrderRepository extends BaseRepository
5041 5076
     {
5042 5077
         $where['paid'] = 1;
5043 5078
         $query = $this->dao->search($where, null);
5079
+        $kw = trim($where['product_keywords'] ?? '');//从where取出去除空格
5080
+        if ($kw !== '') {
5081
+            $ids =Db::name('store_order_product')
5082
+                ->whereRaw("JSON_UNQUOTE(JSON_EXTRACT(cart_info, '$.product.store_name')) LIKE ?", ["%{$kw}%"])
5083
+                ->column('order_id');
5084
+            if (empty($ids)) {
5085
+                return ['count' => 0, 'list' => []];
5086
+            }
5087
+            $query->whereIn('order_id', $ids);
5088
+        }
5044 5089
         $count = $query->count();
5045 5090
         $list = $query->with([
5046 5091
             'orderProduct', 'merchant' => function ($query) {
@@ -6842,7 +6887,7 @@ class StoreOrderRepository extends BaseRepository
6842 6887
         try {
6843 6888
             $order = Db::name('store_order')->where('status', 0)->where('pay_type', '>', 0)->where('douhuomall', 1)->where('douhuomall_status', 9)->select();
6844 6889
             if ($order) {
6845
-                log::info("传参数据333========");
6890
+                // log::info("传参数据333========");
6846 6891
                 $gong = app()->make(ProductAttrValueRepository::class);
6847 6892
                 $order = $order->toArray();
6848 6893
                 foreach ($order as $key => $value) {
@@ -12194,3 +12239,246 @@ class StoreOrderRepository extends BaseRepository
12194 12239
         }
12195 12240
     }
12196 12241
 }
12242
+    public function useKillOrderRewards($groupOrderId, $orderId, $uid,$adminId)
12243
+    {
12244
+        if (empty($orderId) || empty($groupOrderId) || empty($uid)) {
12245
+            return false;
12246
+        }
12247
+        /** @var UserDao $userDao */
12248
+        $userDao = app()->make(UserDao::class);
12249
+        /** @var UserPvLogDao $userPvLogDao */
12250
+        $userPvLogDao = app()->make(UserPvLogDao::class);
12251
+        /** @var UserSignVrDao $userSignVrDao */
12252
+        $userSignVrDao = app()->make(UserSignVrDao::class);
12253
+        /** @var UserSignScoreDao $userSignScoreDao */
12254
+        $userSignScoreDao = app()->make(UserSignScoreDao::class);
12255
+        /** @var UserSignGongxianDao $userSignGongxianDao */
12256
+        $userSignGongxianDao = app()->make(UserSignGongxianDao::class);
12257
+        /** @var UserBillDao $userBillDao */
12258
+        $userBillDao = app()->make(UserBillDao::class);
12259
+        /** @var GzcLogDao $gzcLogDao */
12260
+        $gzcLogDao = app()->make(GzcLogDao::class);
12261
+        /** @var BackupUserDao $backupUserDao */
12262
+        $backupUserDao = app()->make(BackupUserDao::class);
12263
+        /** @var BackupUserChangeDao $backupUserChangeDao */
12264
+        $backupUserChangeDao = app()->make(BackupUserChangeDao::class);
12265
+        /** @var TableOpsDao $tableOpsDao */
12266
+        $tableOpsDao = app()->make(TableOpsDao::class);
12267
+        /** @var UserOrderKillOrRecoverRecordsDao $userOrderKillOrRecoverRecordsDao */
12268
+        $userOrderKillOrRecoverRecordsDao = app()->make(UserOrderKillOrRecoverRecordsDao::class);
12269
+
12270
+        try {
12271
+            Db::startTrans();
12272
+            //查找是否有推荐人
12273
+            $spreadUid = $userDao->getSpreadUidFromUid($uid);
12274
+            //取出pv
12275
+            $pv = $userPvLogDao->getPVFromStatusOrderId($orderId);
12276
+            //取出 vr
12277
+            $payVr = $userSignVrDao->getVrFromTypeOrderId($orderId);
12278
+            //取出购买赠送积分 / 支出积分
12279
+            $score = $userSignScoreDao->getRewardScoreFromUidOrderId($orderId, $uid);
12280
+            $payScore = $userSignScoreDao->getPayScoreFromUidOrderId($orderId, $uid);
12281
+            // 贡献值
12282
+            $gongXian = $userSignGongxianDao->getGongxianFromUidOrderId($orderId, $uid);
12283
+            // 养老金
12284
+            $yangLaoJin = $userBillDao->getYanglaoFromUidOrderId($orderId, $uid);
12285
+            if ($spreadUid) {
12286
+                $spreadScore = $userSignScoreDao->getRewardScoreFromStatusUidOrderId($orderId, $spreadUid);//积分
12287
+                $spreadGongXian = $userSignGongxianDao->getGongxianFromUidOrderId($orderId, $spreadUid);//贡献
12288
+                $spreadYlj = $userBillDao->getYljFromCommissionTypeUidOrderId($orderId, $spreadUid);//养老金
12289
+                $spreadYongJin = $userBillDao->getYongjinFromCommissionTypeUidOrderId($orderId, $spreadUid);//佣金
12290
+//                $spreadUser = $userDao->getSpreadUserFromUid($spreadUid);//找到推荐人的user表数据
12291
+//                $backupUserDao->saveDelData($spreadUser);//备份原始的user大概是没必要的,user更新数据都靠具体数目加减操作
12292
+                $userUpdateList = [//减去各奖励数目
12293
+                    'id' => $uid,
12294
+                    'score' => Db::raw("score - {$spreadScore}"),
12295
+                    'per_contribute' => Db::raw("per_contribute - {$spreadGongXian}"),
12296
+                    'brokerage_price' => Db::raw("brokerage_price - {$spreadYongJin}"),
12297
+                    'annuity' => Db::raw("annuity - {$spreadYlj}"),
12298
+                ];
12299
+                $userDao->saveAll($userUpdateList);//执行
12300
+                $saveSpreadUserChangeList = [//将奖励数目进行备份
12301
+                    'uid' => $spreadUid,
12302
+                    'order_id' => $orderId,
12303
+                    'score' => $spreadScore ?: 0,
12304
+                    'per_contribute' => $spreadGongXian ?: 0,
12305
+                    'brokerage_price' => $spreadYongJin ?: 0,
12306
+                    'user' => 2,
12307
+                ];
12308
+                $backupUserChangeDao->saveAll($saveSpreadUserChangeList);
12309
+            }
12310
+            $smSpreadUid = $userSignScoreDao->getUidFromMarkLikeStatusOrderId($orderId);//查找扫码消费的uid
12311
+            $smSpreadScore = $userSignScoreDao->getScoreFromUidOrderId($orderId,$smSpreadUid);//扫码消费积分
12312
+            $spreadYongJinTwoUid = $userBillDao->getYongjinTwoUidFromOrderId($orderId, $uid, $spreadUid);//第二推荐
12313
+            $spreadYongJinTwo = $userBillDao->getYongjinFromCommissionTypeUidOrderId($orderId, $spreadYongJinTwoUid);//第二推荐佣金
12314
+            $useScore = $payScore - $score;//将花费的积分减去购买获得的积分
12315
+//            $user = Db::name('user')->where('uid', $uid)->find();
12316
+//            Db::name('backup_user')->insert($user);//用户信息备份,大概也是不需要
12317
+            $updateUserOrderAwardList = [//吧奖励和花费撤回
12318
+                'uid' => $uid,
12319
+                'pv' => Db::raw("pv - {$pv}"),
12320
+                'vr' => Db::raw("vr + {$payVr}"),
12321
+                'score' => Db::raw("score + {$useScore}"),
12322
+                'contribute' => Db::raw("contribute - {$gongXian}"),
12323
+                'annuity' => Db::raw("annuity - {$yangLaoJin}"),
12324
+            ];
12325
+            $userDao->saveAll($updateUserOrderAwardList);
12326
+            $saveUserChangeList = [
12327
+                'uid' => $uid,
12328
+                'order_id' => $orderId,
12329
+                'pv' => $pv ?: 0,
12330
+                'vr' => $payVr ?: 0,
12331
+                'score' => $useScore ?: 0,
12332
+                'contribute' => $gongXian ?: 0,
12333
+                'annuity' => $yangLaoJin ?: 0,
12334
+                'user' => 1,
12335
+            ];
12336
+            $backupUserChangeDao->saveAll($saveUserChangeList);
12337
+            if ($spreadYongJinTwoUid) {
12338
+                $updateSpreadUserTwoList = [
12339
+                    'uid' => $spreadYongJinTwoUid,
12340
+                    'brokerage_price' => $spreadYongJinTwo
12341
+                ];
12342
+                $userDao->saveAll($updateSpreadUserTwoList);
12343
+                $saveSpreadUserTwoChangeList = [
12344
+                    'uid' => $spreadYongJinTwoUid,
12345
+                    'order_id' => $orderId,
12346
+                    'brokerage_price' => $spreadYongJinTwo ?: 0,
12347
+                    'user' => 3,
12348
+                ];
12349
+                $backupUserChangeDao->saveAll($saveSpreadUserTwoChangeList);
12350
+            }
12351
+            if ($smSpreadUid) {
12352
+                $updateSpreadSMUserList = [
12353
+                    'uid' => $smSpreadUid,
12354
+                    'score' => $smSpreadScore
12355
+                ];
12356
+                $userDao->saveAll($updateSpreadSMUserList);
12357
+                $saveSpreadSMUserChangeList = [
12358
+                    'uid' => $smSpreadUid,
12359
+                    'order_id' => $orderId,
12360
+                    'score' => $smSpreadScore ?: 0,
12361
+                    'user' => 4,
12362
+                ];
12363
+                $backupUserChangeDao->saveAll($saveSpreadSMUserChangeList);
12364
+            }
12365
+            $ops = [
12366
+                ['store_order', ['group_order_id' => $groupOrderId]],
12367
+                ['store_group_order', ['group_order_id' => $groupOrderId]],
12368
+                ['user_pv_log', ['order_id' => $orderId]],
12369
+                ['user_sign_vr', ['order_id' => $orderId]],
12370
+                ['user_sign_score', ['order_id' => $orderId]],
12371
+                ['user_sign_gongxian', ['order_id' => $orderId]],
12372
+                ['user_bill', ['link_id' => $orderId]],
12373
+                ['gzc_logs', ['link_id' => $orderId]],
12374
+            ];
12375
+            $tableOpsDao->backupAndDeleteBatch($ops);//备份数据以及删除源数据
12376
+            $gzcLogDao->loseGzcLog($orderId);//公证处设置失效
12377
+            Db::commit();
12378
+        } catch (\Exception $e) {
12379
+            Db::rollback();
12380
+            return false;
12381
+        }
12382
+        $userOrderKillOrRecoverRecordsDao->insertKillOrRecoverRecord([
12383
+            'operation_id' => $adminId,
12384
+            'uid' => $uid,
12385
+            'order_id' => $orderId,
12386
+            'mark' => '后台管理员撤销订单记录',
12387
+        ]);
12388
+        return true;
12389
+    }
12390
+    public function getKillOrderList()
12391
+    {
12392
+        /**@var BackupStoreOrderDao $backupStoreOrderDao*/
12393
+        $backupStoreOrderDao = app()->make(BackupStoreOrderDao::class);
12394
+        $backupStoreOrderDao->getKillOrderList(20);
12395
+    }
12396
+    public function recoverOrderByAdmin($groupOrderId, $orderId)
12397
+    {
12398
+        if (empty($orderId) || empty($groupOrderId)) {
12399
+            return false;
12400
+        }
12401
+        /** @var TableOpsDao $tableOpsDao */
12402
+        $tableOpsDao = app()->make(TableOpsDao::class);
12403
+        /** @var GzcLogDao $gzcLogDao */
12404
+        $gzcLogDao = app()->make(GzcLogDao::class);
12405
+        /** @var UserOrderKillOrRecoverRecordsDao $userOrderKillOrRecoverRecordsDao */
12406
+        $userOrderKillOrRecoverRecordsDao = app()->make(UserOrderKillOrRecoverRecordsDao::class);
12407
+
12408
+        try {
12409
+            /** @var easterOrder $model */
12410
+            Db::startTrans();
12411
+            $restoreOps = [
12412
+                ['store_order', ['group_order_id' => $groupOrderId]],
12413
+                ['store_group_order', ['group_order_id' => $groupOrderId]],
12414
+                ['user_pv_log', ['order_id' => $orderId]],
12415
+                ['user_sign_vr', ['order_id' => $orderId]],
12416
+                ['user_sign_score', ['order_id' => $orderId]],
12417
+                ['user_sign_gongxian', ['order_id' => $orderId]],
12418
+                ['user_bill', ['link_id' => $orderId]],
12419
+                ['gzc_logs', ['link_id' => $orderId]],
12420
+            ];
12421
+            $tableOpsDao->restoreBatch($restoreOps);
12422
+            $this->easterUserAward(['order_id' => $orderId]);
12423
+            $gzcLogDao->recoverGzcLogs($orderId);//公证处设置有效
12424
+            Db::commit();
12425
+        } catch (\Exception $e) {
12426
+            Db::rollback();
12427
+            return false;
12428
+        }
12429
+        $userOrderKillOrRecoverRecordsDao->insertKillOrRecoverRecord([
12430
+            'operation_id' => null,
12431
+            'uid' => null,
12432
+            'order_id' => $orderId,
12433
+            'mark' => '后台管理员恢复订单记录',
12434
+        ]);
12435
+        return true;
12436
+    }
12437
+    public function easterUserAward(array $where): void
12438
+    {
12439
+        /** @var BackupUserChangeDao $backupUserChangeDao */
12440
+        $backupUserChangeDao = app()->make(BackupUserChangeDao::class);
12441
+        /** @var UserDao $userDao */
12442
+        $userDao = app()->make(UserDao::class);
12443
+
12444
+        $orderId = $where['order_id'];
12445
+        $row1 = $backupUserChangeDao->getUserOneChangeFromOrderId($orderId);
12446
+        if (!empty($row1)) {
12447
+            $userDao->saveAll([
12448
+            'uid' => $row1['uid'],
12449
+            'pv' => Db::raw("pv + {$row1['pv']}"),
12450
+            'vr' => Db::raw("vr - {$row1['vr']}"),
12451
+            'score' => Db::raw("score - {$row1['score']}"),
12452
+            'contribute' => Db::raw("contribute + {$row1['contribute']}"),
12453
+            'annuity' => Db::raw("annuity + {$row1['annuity']}"),
12454
+            ]);
12455
+        }
12456
+        $row2 = $backupUserChangeDao->getUserTwoChangeFromOrderId($orderId);
12457
+        if (!empty($row2)) {
12458
+            $userDao->saveAll([
12459
+                'uid' => $row2['uid'],
12460
+                'score' => Db::raw("score + {$row2['score']}"),
12461
+                'contribute' => Db::raw("contribute + {$row2['per_contribute']}"),
12462
+                'annuity' => Db::raw("annuity + {$row2['annuity']}"),
12463
+                'brokerage_price' => Db::raw("brokerage_price + {$row2['brokerage_price']}"),
12464
+                'per_contribute' => Db::raw("per_contribute + {$row2['per_contribute']}"),
12465
+            ]);
12466
+        }
12467
+        $row3 = $backupUserChangeDao->getUserThreeChangeFromOrderId($orderId);
12468
+        if (!empty($row3)) {
12469
+            $userDao->saveAll([
12470
+                'uid' => $row3['uid'],
12471
+                'brokerage_price' => Db::raw("brokerage_price + {$row3['brokerage_price']}"),
12472
+            ]);
12473
+        }
12474
+        $row4 = $backupUserChangeDao->getUserFourChangeFromOrderId($orderId);
12475
+        if (!empty($row4)) {
12476
+            $userDao->saveAll([
12477
+                'uid' => $row4['uid'],
12478
+                'score' => Db::raw("score + {$row4['score']}")
12479
+            ]);
12480
+        }
12481
+    }
12482
+}
12483
+
12484
+

+ 39 - 0
app/common/repositories/store/product/ProductAttrValueChangeLogRepository.php

@@ -0,0 +1,39 @@
1
+<?php
2
+
3
+namespace app\common\repositories\store\product;
4
+
5
+use app\common\repositories\BaseRepository;
6
+use app\common\dao\store\product\ProductAttrValueChangeLogDao;
7
+use app\entity\data\store\StoreProductAttrValueChangeLogEntity;
8
+
9
+class ProductAttrValueChangeLogRepository extends BaseRepository
10
+{
11
+
12
+    protected $dao;
13
+
14
+    /**
15
+     * ProductAttrValueChangeLogRepository constructor.
16
+     * @param ProductAttrValueChangeLogDao $dao
17
+     */
18
+    public function __construct(ProductAttrValueChangeLogDao $dao)
19
+    {
20
+        $this->dao = $dao;
21
+    }
22
+
23
+    public function create($data)
24
+    {
25
+        return $this->dao->create($data);
26
+    }
27
+
28
+    /**
29
+     * @param StoreProductAttrValueChangeLogEntity $storeProductAttrValueChangeLogEntity
30
+     * @return StoreProductAttrValueChangeLogEntity
31
+     */
32
+    public function createByEntity(StoreProductAttrValueChangeLogEntity $storeProductAttrValueChangeLogEntity): StoreProductAttrValueChangeLogEntity
33
+    {
34
+        $result = $this->create($storeProductAttrValueChangeLogEntity->toUnderlineArray())->toArray();
35
+        /** @var StoreProductAttrValueChangeLogEntity $entity */
36
+        $entity = StoreProductAttrValueChangeLogEntity::newInstance($result);
37
+        return $entity;
38
+    }
39
+}

+ 1 - 1
app/common/repositories/store/product/ProductAttrValueRepository.php

@@ -112,7 +112,7 @@ class ProductAttrValueRepository extends BaseRepository
112 112
         $address_id = '809';
113 113
         if($address_code_list){
114 114
             $address_id = explode(',',$address_code_list);
115
-            log::info($address_id);
115
+            // log::info($address_id);
116 116
             $address_id = end($address_id);
117 117
         }
118 118
         $sku = [[

+ 21 - 8
app/common/repositories/store/product/ProductRepository.php

@@ -23,6 +23,7 @@ use app\common\repositories\user\UserVisitRepository;
23 23
 use app\common\repositories\wechat\RoutineQrcodeRepository;
24 24
 use app\common\repositories\wechat\WechatQrcodeRepository;
25 25
 use app\controller\merchant\gong\Goods;
26
+use app\entity\data\store\StoreProductAttrValueChangeLogEntity;
26 27
 use app\entity\data\store\StoreProductEntity;
27 28
 use app\traits\ShouxinyiApiRequest;
28 29
 use crmeb\exceptions\ApiException;
@@ -859,7 +860,7 @@ class ProductRepository extends BaseRepository
859 860
 
860 861
         //搜索记录
861 862
         if ($userInfo && isset($where['keyword']) && !empty($where['keyword'])){
862
-            log::info("======sousuojilu====");
863
+            // log::info("======sousuojilu====");
863 864
             app()->make(UserVisitRepository::class)->searchProduct($userInfo['uid'], $where['keyword']);
864 865
         }
865 866
 
@@ -1949,23 +1950,23 @@ class ProductRepository extends BaseRepository
1949 1950
                 $base_commission= floatval(systemConfig('extension_tao_rate'));
1950 1951
                 $logs['extension_tao_rate'] = $base_commission;
1951 1952
                 //返佣总额 返利总额=(交易金额-手续费)*返利比例
1952
-                log::info("计算养老金 good_id: {$good_id},yanglao : $yanglao");
1953
+                // log::info("计算养老金 good_id: {$good_id},yanglao : $yanglao");
1953 1954
                 $yanglao=bcmul($yanglao-$souxufees,$base_commission/100,3);
1954
-                log::info("计算养老金 good_id: {$good_id},yanglao-$souxufees 保留三位$yanglao");
1955
+                // log::info("计算养老金 good_id: {$good_id},yanglao-$souxufees 保留三位$yanglao");
1955 1956
             }
1956 1957
             $yanglao = $yanglao * $yanglaojin_admin /100  ;//养老金比例
1957
-            log::info("计算养老金 good_id: {$good_id},yanglao : $yanglao");
1958
+            // log::info("计算养老金 good_id: {$good_id},yanglao : $yanglao");
1958 1959
 
1959 1960
             $yanglao= decimal2($yanglao);// 取两位小数 后面舍去
1960 1961
         }
1961 1962
 
1962
-        log::info(json_encode($logs));
1963
-        log::info("计算养老金 good_id: {$good_id},price{$total_price},yanglao:{$yanglao}");
1963
+        // log::info(json_encode($logs));
1964
+        // log::info("计算养老金 good_id: {$good_id},price{$total_price},yanglao:{$yanglao}");
1964 1965
 
1965 1966
         return set_price_rtrim($yanglao);
1966 1967
     }
1967 1968
 
1968
-    public function editPrice($product_id, $skuArr, $type = 1)
1969
+    public function editPrice($product_id, $skuArr, $type = 1, $operatorId = 0)
1969 1970
     {
1970 1971
         if (empty($skuArr))
1971 1972
             throw new ApiException('参数错误');
@@ -1977,6 +1978,8 @@ class ProductRepository extends BaseRepository
1977 1978
                 ->select()->toArray();
1978 1979
             $attrInfo = array_column($attrInfo, null, 'gong_sku_id');
1979 1980
             $updateData = [];
1981
+            /** @var ProductAttrValueChangeLogRepository $productAttrValueChangeLogRepository */
1982
+            $productAttrValueChangeLogRepository = app()->make(ProductAttrValueChangeLogRepository::class);
1980 1983
             // 组装数据
1981 1984
             foreach ($skuArr as $key => $value) {
1982 1985
                 if (isset($attrInfo[$value['sku_id']])) {
@@ -1995,7 +1998,17 @@ class ProductRepository extends BaseRepository
1995 1998
                             throw new ApiException('销售价格填写不正确');
1996 1999
                         }
1997 2000
                     }
1998
-
2001
+                    /** @var StoreProductAttrValueChangeLogEntity $storeProductAttrValueChangeLogEntity */
2002
+                    $storeProductAttrValueChangeLogEntity = StoreProductAttrValueChangeLogEntity::newInstance();
2003
+                    $storeProductAttrValueChangeLogEntity->setProductId($product_id)
2004
+                        ->setSkuId($value['sku_id'])
2005
+                        ->setCost($attrInfo[$value['sku_id']]['cost'])
2006
+                        ->setOtPrice($attrInfo[$value['sku_id']]['ot_price'])
2007
+                        ->setPrice($attrInfo[$value['sku_id']]['price'])
2008
+                        ->setPlateMerProfit($attrInfo[$value['sku_id']]['plate_mer_profit'])
2009
+                        ->setOperatorId($operatorId)
2010
+                        ->setCreateTime(date('Y-m-d H:i:s'));
2011
+                    $productAttrValueChangeLogRepository->createByEntity($storeProductAttrValueChangeLogEntity);
1999 2012
                     $updateData[] = [
2000 2013
                         'gong_sku_id'      => $value['sku_id'],
2001 2014
                         'price'            => $value['edit_price'],

+ 6 - 6
app/common/repositories/system/merchant/MerchantRepository.php

@@ -416,11 +416,11 @@ class MerchantRepository extends BaseRepository
416 416
      */
417 417
     public function productList($merId, $where, $page, $limit, $userInfo,$type439=false,$is_commercetrade = 0)
418 418
     {
419
-        log::info("========j进入prodctList");
420
-        log::info($merId);
421
-        log::info( $where);
422
-        log::info($userInfo);
423
-        log::info($type439);
419
+        // log::info("========j进入prodctList");
420
+        // log::info($merId);
421
+        // log::info( $where);
422
+        // log::info($userInfo);
423
+        // log::info($type439);
424 424
         $list=app()->make(ProductRepository::class)->getApiSearch($merId, $where, $page, $limit, $userInfo,$type439);
425 425
 
426 426
         $arr=[];
@@ -429,7 +429,7 @@ class MerchantRepository extends BaseRepository
429 429
             $productMerId = $v['mer_id'] ?? 0;
430 430
 //            $v['special_merchant']= merchantConfig($v['mer_id'], 'special_merchant');
431 431
 
432
-            log::info("==========yang= {$k['yanglao']} ");
432
+            // log::info("==========yang= {$k['yanglao']} ");
433 433
 
434 434
             $v['yanglao']='';
435 435
             $v['pv']='';

+ 8 - 5
app/common/repositories/user/UserRepository.php

@@ -1101,6 +1101,7 @@ class UserRepository extends BaseRepository
1101 1101
                 // 直推佣金
1102 1102
                 case 3:
1103 1103
                     $commission_type = 3;
1104
+                    break;
1104 1105
                 // 锁客收益
1105 1106
                 case 6:
1106 1107
                     $commission_type = 7;
@@ -4622,11 +4623,13 @@ class UserRepository extends BaseRepository
4622 4623
      * @return void
4623 4624
      */
4624 4625
     public function sproductkeywordHistory($uid, $keyword, $type){
4625
-        Db::name('third_history')->insert([
4626
-            'uid' => $uid,
4627
-            'keyword' => $keyword,
4628
-            'type' => $type,
4629
-        ]);
4626
+        if (!empty($keyword)) {
4627
+            Db::name('third_history')->insert([
4628
+                'uid' => $uid,
4629
+                'keyword' => $keyword,
4630
+                'type' => $type,
4631
+            ]);
4632
+        }
4630 4633
     }
4631 4634
 
4632 4635
 

+ 7 - 1
app/controller/admin/agreement/Agreement.php

@@ -42,5 +42,11 @@ class Agreement extends BaseController
42 42
         return app("json")->success($this->repository->updateData($id,$data));
43 43
     }
44 44
 
45
-
45
+    /*详情*/
46
+    public function  detailContent($id){
47
+        if ($id != 13) {
48
+            return '';
49
+        }
50
+        return $this->repository->getDetailContent($id);
51
+    }
46 52
 }

+ 121 - 0
app/controller/admin/order/MerchantOfflineOrder.php

@@ -0,0 +1,121 @@
1
+<?php
2
+
3
+namespace app\controller\admin\order;
4
+use app\common\repositories\merchant\order\OrderMerchantRepository;
5
+use crmeb\basic\BaseController;
6
+use crmeb\services\SpreadsheetExcelService;
7
+use think\App;
8
+
9
+class MerchantOfflineOrder extends BaseController
10
+{
11
+    /**
12
+     * @var OrderMerchantRepository
13
+     */
14
+    protected $repository;
15
+
16
+    /**
17
+     * @var int
18
+     */
19
+    protected $merId;
20
+
21
+    /**
22
+     * MerchantIntention constructor.
23
+     * @param App $app
24
+     * @param OrderMerchantRepository $repository
25
+     */
26
+    public function __construct(App $app, OrderMerchantRepository $repository)
27
+    {
28
+        parent::__construct($app);
29
+        $this->repository = $repository;
30
+        $this->merId = 0;
31
+    }
32
+    /**
33
+     * @return mixed
34
+     * 展示线下订单
35
+     */
36
+    public function lst()
37
+    {
38
+        [$page, $limit] = $this->getPage();
39
+        $where = $this->request->params(['keyword', 'date', 'status', 'mer_id']);
40
+        $is_excel = $this->request->param('is_excel', 0);
41
+        $data = $this->repository->getMerchantListAdmin($this->merId, $where, $page, $limit);
42
+        $list = $data['list'];
43
+        if($is_excel){
44
+            $arr = [];
45
+            foreach ($list as $item) {
46
+                switch ($item['status']) {
47
+                    case 0:
48
+                        $status = '待支付';
49
+                        break;
50
+                    case 1:
51
+                        $status = '已支付';
52
+                        break;
53
+                    case 2:
54
+                        $status = '申请退款';
55
+                        break;
56
+                    case 3:
57
+                        $status = '退款完成';
58
+                        break;
59
+                    case 5:
60
+                        $status = '已失效';
61
+                        break;
62
+                    default:
63
+                        $status = '未知';
64
+                        break;
65
+                }
66
+                $arr[] = [
67
+                    $item['id'],
68
+                    $item['mer_id'],
69
+                    $item['merchant']['mer_name'] ?? '',
70
+                    $item['uid'],
71
+                    $item['money'],
72
+                    $item['available'],
73
+                    $item['service_money'],
74
+                    $item['pension'],
75
+                    $item['swipe_fee'],
76
+                    $item['mer_money'],
77
+                    $item['mer_fanyong'],
78
+                    $item['actual'],
79
+                    $status,
80
+                    $item['create_time'],
81
+                    $item['out_trade_no']
82
+                ];
83
+            }
84
+            $header = [
85
+                'ID', '商户ID', '商户名称', '用户ID',
86
+                '充值金额', '可分佣总额', '服务商返利', '养老金', '刷卡手续费', '商户金额', '商户返佣', '实到金额',
87
+                '状态', '时间', '订单号'
88
+            ];
89
+            return app('json')->success($this->getStatisticsExcel($header, $arr, '线下订单'));
90
+        }
91
+        return app('json')->success($data);
92
+    }
93
+
94
+    public function getStatisticsExcel($header,$arr,$title)
95
+    {
96
+        $filename = $title.'_'.date('YmdHis').'_'.rand(10000,99999);
97
+        $name = $filename;
98
+        $info = '生成时间:' . date('Y-m-d H:i:s',time());
99
+        $suffix='xlsx';
100
+        $path='offline_order';
101
+        unset($_instance);
102
+
103
+        $_instance = SpreadsheetExcelService::instance_xin();
104
+
105
+        $_path =$_instance
106
+            ->createOrActive()
107
+            ->setExcelHeader($header)
108
+            ->setExcelTile($title, $name, $info)
109
+            ->setExcelContent($arr)
110
+            ->excelSave($filename, $suffix, $path);
111
+
112
+        $domain = request()->domain();
113
+        $data= [
114
+            'name' => $filename.'.'.$suffix,
115
+            'status' => 1,
116
+            'path' => $domain.'/'.$_path
117
+        ];
118
+
119
+        return $data;
120
+    }
121
+}

+ 15 - 221
app/controller/admin/order/Order.php

@@ -33,8 +33,10 @@ class Order extends BaseController
33 33
     {
34 34
         [$page, $limit] = $this->getPage();
35 35
         $where = $this->request->params(['date','order_sn','order_type','keywords','username']);
36
+        $productKeywords = $this->request->param('product_keywords');//商品关键字
36 37
         $where['reconciliation_type'] = $this->request->param('status', 1);
37 38
         $where['mer_id'] = $id;
39
+        $where['product_keywords'] = $productKeywords;
38 40
         return app('json')->success($this->repository->adminGetList($where, $page, $limit));
39 41
     }
40 42
 
@@ -339,145 +341,26 @@ class Order extends BaseController
339 341
         $group_order_id = request()->param('group_order_id');
340 342
         $order_id = request()->param('order_id');
341 343
         $uid = request()->param('uid');
344
+        $adminId = $this->request->adminId();
342 345
         if (empty($order_id) || empty($group_order_id) || empty($uid)) {
343 346
             return app('json')->fail('参数缺失');
344 347
         }
345
-        try {
346
-            Db::startTrans();
347
-            //查找是否有推荐人
348
-            $spreadUid = Db::name('user')->where('uid', $uid)->value('spread_uid');
349
-            //取出pv
350
-            $pv = $this->getValue('user_pv_log', [['order_id', '=', $order_id], ['status', '=', 1],], 'pv');
351
-            //取出 vr
352
-            $payVr = $this->getValue('user_sign_vr', [['order_id', '=', $order_id], ['type', '=', 2],], 'number');
353
-            //取出购买赠送积分 / 支出积分
354
-            $score = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['source_type', '=', 3], ['uid', '=', $uid], ['pm', '=', 1],], 'reward_socre');
355
-            $payScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 2], ['uid', '=', $uid],], 'reward_socre');
356
-            // 贡献值
357
-            $gongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $uid],], 'number');
358
-            // 养老金
359
-            $yangLaoJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 1], ['uid', '=', $uid],], 'number');
360
-            if($spreadUid){  //如果有推荐人就执行
361
-                $spreadScore = 0;
362
-                $spreadGongXian = 0;
363
-                $spreadYlj = 0;
364
-                $spreadYongJin = 0;
365
-                $spreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid', '=', $spreadUid], ['status', '=', 1],], 'reward_socre');
366
-                $spreadGongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $spreadUid],], 'number');
367
-                $spreadYlj = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 5], ['uid', '=', $spreadUid],], 'number'); //推荐获得养老金
368
-                $spreadYongJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '=', $spreadUid],], 'number');  //推荐获得佣金
369
-                $spreadUser = Db::name('user')->where('uid', $spreadUid)->find();
370
-                Db::name('backup_user')->insert($spreadUser);  //插入备份表
371
-                Db::name('user')->where('uid', $spreadUid)   //更新数据
372
-                    ->update([
373
-                        'score' => Db::raw("score - {$spreadScore}"),
374
-                        'per_contribute' => Db::raw("per_contribute - {$spreadGongXian}"),
375
-                        'brokerage_price' => Db::raw("brokerage_price - {$spreadYongJin}"),
376
-                        'annuity' => Db::raw("annuity - {$spreadYlj}"),
377
-                    ]);
378
-                $userhjm1 =[
379
-                    'uid' => $spreadUid,
380
-                    'order_id' => $order_id,
381
-                    'score' => $spreadScore??0,
382
-                    'per_contribute' => $spreadGongXian??0,
383
-                    'brokerage_price' => $spreadYongJin??0,
384
-                    'user' => 2,
385
-                ];
386
-                Db::name('backup_user_change')->insert($userhjm1);   //插入更新数据记录表
387
-            }
388
-            //扫吗消费
389
-            $smSpreadUid = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['mark','like','%扫码%'], ['status', '=', 1],], 'uid');
390
-            $smSpreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid','=',$smSpreadUid], ['status', '=', 1],], 'reward_socre');
391
-            //第二推荐
392
-            $spreadYongJinTwoUid = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', 'not in', [$uid, $spreadUid]],], 'uid');
393
-            $spreadYongJinTwo = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '=', $spreadYongJinTwoUid],], 'number');
394
-            //更新购买用户的user表
395
-            $uscore = $payScore - $score;
396
-            $user = Db::name('user')->where('uid', $uid)->find();
397
-            Db::name('backup_user')->insert($user);
398
-            Db::name('user')->where('uid', $uid)
399
-                ->update([
400
-                    'pv'         => Db::raw("pv - {$pv}"),
401
-                    'vr'         => Db::raw("vr + {$payVr}"),
402
-                    'score'      => Db::raw("score + {$uscore}"),
403
-                    'contribute' => Db::raw("contribute - {$gongXian}"),
404
-                    'annuity'    => Db::raw("annuity - {$yangLaoJin}"),
405
-                ]);
406
-            $userhjm =[
407
-                'uid' => $uid,
408
-                'order_id' => $order_id,
409
-                'pv' => $pv??0,
410
-                'vr' => $payVr??0,
411
-                'score' => $uscore??0,
412
-                'contribute' => $gongXian??0,
413
-                'annuity' => $yangLaoJin??0,
414
-                'user' => 1,
415
-            ];
416
-            Db::name('backup_user_change')->insert($userhjm);//具体修改插入对应表
417
-            //第二推荐
418
-            if($spreadYongJinTwoUid) {
419
-                $spreadUserTwo = Db::name('user')->where('uid', $spreadYongJinTwoUid)->find();
420
-                Db::name('backup_user')->insert($spreadUserTwo);
421
-                Db::name('user')->where('uid', $spreadYongJinTwoUid)->dec('brokerage_price', $spreadYongJinTwo)->update();
422
-                $userhjm2 =[
423
-                    'uid' => $spreadYongJinTwoUid,
424
-                    'order_id' => $order_id,
425
-                    'brokerage_price' => $spreadYongJinTwo??0,
426
-                    'user' => 3,
427
-                ];
428
-                Db::name('backup_user_change')->insert($userhjm2);
429
-            }//扫码消费
430
-            if($smSpreadUid){
431
-                $smUserTwo = Db::name('user')->where('uid', $smSpreadUid)->find();
432
-                Db::name('backup_user')->insert($smUserTwo);
433
-                Db::name('user')->where('uid', $smSpreadUid)->dec('score', $smSpreadScore)->update();
434
-                $userhjm3 =[
435
-                    'uid' => $smSpreadUid,
436
-                    'order_id' => $order_id,
437
-                    'score' => $smSpreadScore??0,
438
-                    'user' => 4,
439
-                ];
440
-                Db::name('backup_user_change')->insert($userhjm3);
441
-            }
442
-            // 删除订单相关表p;
443
-            $this->backupAndDelete('store_order', ['group_order_id' => $group_order_id]);
444
-            $this->backupAndDelete('store_group_order', ['group_order_id' => $group_order_id]);
445
-            $this->backupAndDelete('user_pv_log', ['order_id' => $order_id]);
446
-            $this->backupAndDelete('user_sign_vr', ['order_id' => $order_id]);
447
-            $this->backupAndDelete('user_sign_score', ['order_id' => $order_id]);
448
-            $this->backupAndDelete('user_sign_gongxian', ['order_id' => $order_id]);
449
-            $this->backupAndDelete('user_bill', ['link_id' => $order_id]);
450
-            $this->backupAndDelete('gzc_logs', ['link_id' => $order_id]);
451
-            Db::commit();
452
-        } catch (\Exception $e) {
453
-            Db::rollback();
454
-            return app('json')->fail('操作失败'. $e->getMessage());
348
+        if (!in_array($adminId, [1,28,29])) {//超级管理员,财务,老总
349
+            return app('json')->fail('后台权限不足');
455 350
         }
456
-        return app('json')->success('操作成功');
457
-    }
458
-
459
-    private function backupAndDelete($table, array $where)//备份并删除
460
-    {
461
-        $backupTable = 'backup_' . $table;
462
-        $rows = Db::name($table)->where($where)->select()->toArray();
463
-        if ($rows) {
464
-            Db::name($backupTable)->insertAll($rows);
465
-            Db::name($table)->where($where)->delete();
351
+        $ok = $this->repository->useKillOrderRewards($group_order_id, $order_id, $uid,$adminId);
352
+        if (!$ok) {
353
+            return app('json')->fail('操作失败');
466 354
         }
355
+        return app('json')->success('操作成功');
467 356
     }
468
-    private function getValue($table, array $where, string $field, $default = 0)//查找
469
-    {
470
-        $value = Db::name($table)->where($where)->value($field);
471
-        return $value ?? $default;
472
-    }
473
-
474 357
     /**
475 358
      * 展示撤回订单列表,恢复订单
476 359
      */
477 360
     public function killOrderLst()  //撤回订单的列表
478 361
     {
479
-        $query = Db::name('backup_store_order')->paginate(20)->toArray();
480
-        return app('json')->success($query, '获取成功');
362
+        $list = $this->repository->getKillOrderList();
363
+        return app('json')->success($list, '获取成功');
481 364
     }
482 365
     public function easterKillOrder(){   //恢复订单
483 366
         $group_order_id = request()->param('group_order_id');
@@ -485,99 +368,10 @@ class Order extends BaseController
485 368
         if (empty($order_id) || empty($group_order_id)) {
486 369
             return app('json')->fail('参数缺失');
487 370
         }
488
-        try {
489
-            Db::startTrans();
490
-            // 恢复订单相关表
491
-            $this->easterOrder('store_order', ['group_order_id' => $group_order_id]);
492
-            $this->easterOrder('store_group_order', ['group_order_id' => $group_order_id]);
493
-            // 恢复 pv
494
-            $this->easterOrder('user_pv_log', ['order_id' => $order_id]);
495
-            // 恢复 vr
496
-            $this->easterOrder('user_sign_vr', ['order_id' => $order_id]);
497
-            // 恢复 积分
498
-            $this->easterOrder('user_sign_score', ['order_id' => $order_id]);
499
-            // 恢复 贡献值
500
-            $this->easterOrder('user_sign_gongxian', ['order_id' => $order_id]);
501
-            // 恢复 佣金/养老金等
502
-            $this->easterOrder('user_bill', ['link_id' => $order_id]);
503
-            // 恢复 公证处
504
-            $this->easterOrder('gzc_logs', ['link_id' => $order_id]);
505
-            //恢复用户奖励
506
-            $this->easterUserAward(['order_id' => $order_id]);
507
-            Db::commit();
508
-        } catch (\Exception $e) {
509
-            Db::rollback();
510
-            return app('json')->fail('撤回失败: '.$e->getMessage());
511
-        }
512
-        return app('json')->success('撤回成功');
513
-    }
514
-    private function easterOrder($table, array $where)  //恢复表数据
515
-    {
516
-        $backupTable = 'backup_' . $table;
517
-        $rows = Db::name($backupTable)->where($where)->select()->toArray();
518
-
519
-        if ($rows) {
520
-            foreach ($rows as &$row) {
521
-                if (isset($row['del_time'])) unset($row['del_time']);
522
-            }
523
-            unset($row);
524
-            Db::name($table)->insertAll($rows);
525
-            Db::name($backupTable)->where($where)->delete();
526
-        }
527
-    }
528
-    private function easterUserAward(array $where){  //恢复奖励
529
-        $row = Db::name('backup_user_change')->where($where)->where('user', 1)->field('pv, vr, score, contribute, annuity,uid')->find();
530
-        $uid = $row['uid'];
531
-        $pv   = $row['pv'];
532
-        $vr   = $row['vr'];
533
-        $score= $row['score'];
534
-        $contribute = $row['contribute'];
535
-        $annuity = $row['annuity'];
536
-        Db::name('user') //更新订单用户
537
-            ->where('uid', $uid)
538
-            ->update([
539
-                'pv'         => Db::raw("pv + {$pv}"),
540
-                'vr'         => Db::raw("vr - {$vr}"),
541
-                'score'      => Db::raw("score - {$score}"),
542
-                'contribute' => Db::raw("contribute + {$contribute}"),
543
-                'annuity'    => Db::raw("annuity + {$annuity}"),
544
-            ]);
545
-        $row2 = Db::name('backup_user_change')->where($where)->where('user', 2)->field('brokerage_price, score, per_contribute, annuity,uid')->find();
546
-        if ($row2) {
547
-            $spreadUid = $row2['uid'];
548
-            $spreadScore = $row2['score'];
549
-            $per_contribute = $row2['per_contribute'];
550
-            $spreadAnnuity = $row2['annuity'];
551
-            $spreadYongJin = $row2['brokerage_price'];
552
-            Db::name('user')     //更新推荐人
553
-            ->where('uid', $spreadUid)
554
-                ->update([
555
-                    'score' => Db::raw("score + {$spreadScore}"),
556
-                    'contribute' => Db::raw("contribute + {$per_contribute}"),
557
-                    'annuity' => Db::raw("annuity + {$spreadAnnuity}"),
558
-                    'brokerage_price' => Db::raw("brokerage_price + {$spreadYongJin}"),
559
-                    'per_contribute'=> Db::raw("per_contribute + {$per_contribute}"),
560
-                ]);
561
-        }
562
-        $row3 = Db::name('backup_user_change')->where($where)->where('user', 3)->field('brokerage_price,uid')->find();
563
-        if ($row3) {
564
-            $spreadUidTwo = $row3['uid']; //第二推荐人
565
-            $spreadYongJin2 = $row3['brokerage_price'];
566
-            Db::name('user')
567
-                ->where('uid', $spreadUidTwo)
568
-                ->update([
569
-                    'brokerage_price' => Db::raw("brokerage_price + {$spreadYongJin2}"),
570
-                ]);
571
-        }
572
-        $row4 = Db::name('backup_user_change')->where($where)->where('user', 4)->field('score,uid')->find();
573
-        if ($row4) {
574
-            $spreadUidThree = $row4['uid'];   //扫码
575
-            $spreadScore3 = $row4['score'];
576
-            Db::name('user')
577
-                ->where('uid', $spreadUidThree)
578
-                ->update([
579
-                    'score' => Db::raw("score + {$spreadScore3}"),
580
-                ]);
371
+        $ok = $this->repository->recoverOrderByAdmin($group_order_id, $order_id);
372
+        if (!$ok) {
373
+            return app('json')->fail('操作失败');
581 374
         }
375
+        return app('json')->success('操作成功');
582 376
     }
583 377
 }

+ 22 - 0
app/controller/admin/system/sharedProsperity/SharedProsperityRecommend.php

@@ -0,0 +1,22 @@
1
+<?php
2
+
3
+namespace app\controller\admin\system\sharedProsperity;
4
+
5
+use app\common\repositories\shared\SharedProsperityRecommendConfigRepository;
6
+
7
+class SharedProsperityRecommend
8
+{
9
+    /**
10
+     * @return mixed
11
+     * @author 史晨
12
+     * @date 2026/2/5 14:28
13
+     * 获取推荐奖励配置
14
+     */
15
+    public function list()
16
+    {
17
+        /** @var SharedProsperityRecommendConfigRepository $repository */
18
+        $repository = app()->make(SharedProsperityRecommendConfigRepository::class);
19
+        $list = $repository->getList();
20
+        return app('json')->success($list);
21
+    }
22
+}

+ 50 - 7
app/controller/api/Auth.php

@@ -17,6 +17,8 @@ use app\common\model\user\User;
17 17
 use app\common\model\user\UserCertification;
18 18
 use app\common\repositories\merchant\order\OrderGzcRepository;
19 19
 use app\common\repositories\merchant\order\OrderMerchantRepository;
20
+use app\common\repositories\product\ShareRepository;
21
+use app\common\repositories\shared\SharedProsperityUserRepository;
20 22
 use app\common\repositories\store\order\StoreGroupOrderRepository;
21 23
 use app\common\repositories\store\order\StoreOrderRepository;
22 24
 use app\common\repositories\store\order\StoreOrderStatusRepository;
@@ -27,6 +29,7 @@ use app\common\repositories\wechat\RoutineQrcodeRepository;
27 29
 use app\common\repositories\wechat\WechatUserRepository;
28 30
 use app\controller\api\user\Volunteer;
29 31
 use app\controller\api\util\Signature;
32
+use app\entity\data\shared\SharedProsperityUserEntity;
30 33
 use app\models\routine\RoutineQrcode;
31 34
 use app\traits\GongApiRequest;
32 35
 use app\traits\GzcApiRequest;
@@ -53,6 +56,7 @@ use think\db\exception\ModelNotFoundException;
53 56
 use think\Env;
54 57
 use think\Exception;
55 58
 use think\exception\HttpResponseException;
59
+use think\exception\ValidateException;
56 60
 use think\facade\Cache;
57 61
 use think\facade\Db;
58 62
 use think\facade\Log;
@@ -502,13 +506,25 @@ class Auth extends BaseController
502 506
         // $repository->insterUser(16328, 14395);
503 507
 
504 508
         // return "=====";
505
-        $data = $this->request->params(['phone', 'sms_code', 'spread', 'password',"spread_phone","type","mer_id"]);
509
+        $data = $this->request->params(['phone', 'sms_code', 'spread', 'password',"spread_phone","type","mer_id", 'share_id']);
510
+        // $lockKey = 'lock:register:' . $data['phone'];
511
+        // $redis = \think\facade\Cache::store('redis')->handler();
512
+        // $acquired = $redis->set($lockKey, 1, ['nx', 'ex' => 15]);
513
+        // if (!$acquired) {
514
+        //     return app('json')->fail('正在注册,请稍后');
515
+        // }
516
+        $redisHandler = Cache::store('redis')->handler();
517
+        $isSet = $redisHandler->set('register' . '-' . $data['phone'], 1, ['nx', 'ex' => 30]);
518
+        if (!$isSet) {
519
+            return app('json')->fail('请勿重复下单');
520
+        }
521
+        try {
506 522
         $type=$data['type']??'';
507 523
         unset($data['type']);
508 524
         $validate->sceneSmslogin()->check($data);
509 525
 
510 526
         $domain = $this->request->domain();
511
-        if($data['sms_code'] == '6865' && strpos($domain, 'test.hebeiyhc.com') !== false) {
527
+        if($data['sms_code'] == '9658' && strpos($domain, 'test.hebeiyhc.com') !== false) {
512 528
             // 域名中包含 "test.hebeiyhc.com'" 字符串
513 529
         }else if (!$this->checkSmsCode($data['phone'], $data['sms_code']) ){
514 530
             return app('json')->fail('验证码不正确');
@@ -519,6 +535,17 @@ class Auth extends BaseController
519 535
         $user = $repository->accountByUser($data['phone']);
520 536
         if ($user)
521 537
             return app('json')->fail('手机号已存在');
538
+
539
+            if (!empty($data['share_id'])) {
540
+                /** @var ShareRepository $shareRepository */
541
+                $shareRepository = app()->make(ShareRepository::class);
542
+                $shareEntity = $shareRepository->getShareEntityByShareId($data['share_id']);
543
+                if (empty($shareEntity->getId())) {
544
+                    throw new ValidateException('无效的分享信息');
545
+                }
546
+                $data['spread'] = $shareEntity->getUid();
547
+            }
548
+
522 549
         if ($data["spread_phone"]){
523 550
             $spread_user = $repository->accountByUser($data['spread_phone']);
524 551
             if ($spread_user ){
@@ -529,6 +556,18 @@ class Auth extends BaseController
529 556
         }
530 557
         // Log::info($data);
531 558
         $user = $repository->registr($data['phone'], $data['password'],'APP',"","",1,$data['spread']);
559
+
560
+            // 注意创建完用户后 需要立马创建 共富体系 用户数据
561
+            /** @var SharedProsperityUserRepository $sharedProsperityUserRepository */
562
+            $sharedProsperityUserRepository = app()->make(SharedProsperityUserRepository::class);
563
+            $sharedProsperityUserEntity = $sharedProsperityUserRepository->createByEntity(
564
+                SharedProsperityUserEntity::newInstance()
565
+                    ->setUserId($user->uid)
566
+            );
567
+            if (!empty($data['spread']) && !empty($sharedProsperityUserEntity->getUserId())) {
568
+                $sharedProsperityUserRepository->bindParentId((int)$sharedProsperityUserEntity->getUserId(), (int)$data['spread']);
569
+            }
570
+
532 571
         // $repository->registr($data['phone'], $data['password'],'APP',$data['spread']);
533 572
         $repository->addagent($user);
534 573
         $user = $repository->mainUser($user);
@@ -574,6 +613,10 @@ class Auth extends BaseController
574 613
         $repository->createUserOperatingRecord($user->uid, 1, 1, '用户同意用户协议记录');
575 614
         return app('json')->success($result);
576 615
 
616
+        } finally {
617
+            // $redis->del($lockKey);
618
+        }
619
+
577 620
     }
578 621
 
579 622
     /**
@@ -1446,6 +1489,7 @@ class Auth extends BaseController
1446 1489
                 if (!$data['code'])
1447 1490
                     return app('json')->make(402, '操作过于频繁,请稍后重试~');
1448 1491
             }
1492
+            Cache::set($sms_num_key, $num + 1, 300);
1449 1493
         }
1450 1494
         $sms_key = 'api.auth.sms.' . $data['phone'];
1451 1495
         $sms_code = str_pad(random_int(1, 9999), 4, 0, STR_PAD_LEFT);
@@ -1458,11 +1502,10 @@ class Auth extends BaseController
1458 1502
             return app('json')->fail('操作过于频繁,请稍后重试~');
1459 1503
         }
1460 1504
 
1461
-        log::info("sms_key==={$sms_key}" );
1462
-        log::info("sms_code==={$sms_code}" );
1463
-        log::info("sms_time==={$sms_time}" );
1505
+        // log::info("sms_key==={$sms_key}" );
1506
+        // log::info("sms_code==={$sms_code}" );
1507
+        // log::info("sms_time==={$sms_time}" );
1464 1508
         Cache::set($sms_key, $sms_code,$sms_time * 60);
1465
-        Cache::set($sms_num_key, $num + 1, 300);
1466 1509
         //'短信发送成功'
1467 1510
         return app('json')->success('短信发送成功');
1468 1511
     }
@@ -1572,7 +1615,7 @@ class Auth extends BaseController
1572 1615
         // $domain = $this->request->domain();
1573 1616
 
1574 1617
         //如果手机验证码错误并且验证码不是6865,进入查验团队验证码环节
1575
-        if (!$this->checkSmsCode($data['phone'], $data['sms_code']) && $data['sms_code'] !== '6865') {
1618
+        if (!$this->checkSmsCode($data['phone'], $data['sms_code']) && $data['sms_code'] !== '9658') {
1576 1619
             $uid= Db::name('user')->where("phone", $data["phone"])->value('uid');//通过输入的手机号查询用户的uid
1577 1620
             if($uid){
1578 1621
                 $allTeams = Db::name('user_zero_line')->field('team_uid,custom_code')->select()->toArray();//去user_zero_line表查询团队team_uid和团队自定义的验证码

+ 6 - 2
app/controller/api/Common.php

@@ -393,9 +393,13 @@ class Common extends BaseController
393 393
         //安卓
394 394
         if ($data['type'] == 1) {
395 395
             $config = systemConfig(['about_edition_android', 'about_link_android', 'update_content','Android_forced_update']);
396
-            if ($data['about'] != $config['about_edition_android']) {
396
+
397
+            $version = str_replace('.', '', $data['about']);
398
+            $sysVersion = str_replace('.', '', $config['about_edition_android']);
399
+
400
+            if ($version < $sysVersion) {
397 401
                 return app('json')->success($config);
398
-            } else {
402
+            }else{
399 403
                 return app('json')->fail('已是最新版本');
400 404
             }
401 405
         }

File diff suppressed because it is too large
+ 1 - 1
app/controller/api/Notify.php


+ 11 - 13
app/controller/api/douhuomall/Take.php

@@ -24,19 +24,14 @@ class Take
24 24
 
25 25
             // 2、循环拉取 商品 数据
26 26
             $allData = [];
27
-            $page = 1;
28
-            $limit = 100;
29
-            $hasNextPage = true; // 是否有下一页的标志
30
-            while ($hasNextPage) {
31
-                $data = GongApiRequest::get_goods_list($page, $limit);
32
-                if (!$data) {
33
-                    break; // 如果请求失败,停止循环
34
-                }
27
+            $data = GongApiRequest::get_goods_list(1, 100);
28
+            if (!empty($data)) {
35 29
                 $allData = array_merge($allData, $data['list']); // 数据在list键下
36
-                if (!count($data['list']) || count($data['list']) < $limit) {
37
-                    $hasNextPage = false; // 如果没有更多页面,停止循环
38
-                } else {
39
-                    $page++; // 增加页码数
30
+                for ($page = $data['pages'] ?? 1; $page >= 2; $page--) {
31
+                    $pageData = GongApiRequest::get_goods_list($page, 100);
32
+                    if ($pageData && !empty($pageData['list'])) {
33
+                        $allData = array_merge($allData, $pageData['list']); // 数据在list键下
34
+                    }
40 35
                 }
41 36
             }
42 37
 
@@ -72,6 +67,9 @@ class Take
72 67
                 //sku信息处理
73 68
                 $skuInfo = $goodsInfo['sku_list'];
74 69
                 foreach ($skuInfo as $k => $v) {
70
+                    if (empty($v['plat_price'])) {
71
+                        continue;
72
+                    }
75 73
                     $skuInfo[$k]['img_url'] = $this->seveImg($value['goods_id'], $v['main_img'], $targetDir);//规格图片
76 74
                     $skuInfo[$k]['cost_price'] = bcadd($v['plat_price'], bcmul($v['plat_price'], 0.03, 2), 2);//成本价格 原来进价的基础上加百分之3
77 75
                     $skuInfo[$k]['market_price'] = bcadd($skuInfo[$k]['cost_price'], bcmul($skuInfo[$k]['cost_price'], 0.2, 2), 2);//销售价格  售价在成本价格的基础上加百分20
@@ -150,7 +148,7 @@ class Take
150 148
             'slider_image' => $slider_image,
151 149
         ];
152 150
         Db::name('store_product')->where('product_id', $product_id)->update($product_insert_data);
153
-        echo '更新产品图片数据成功' . json_encode($product_insert_data);
151
+        // echo '更新产品图片数据成功' . json_encode($product_insert_data);
154 152
         $detail = $spuId_info['detail'];
155 153
         if (!is_null(json_decode($detail))) {
156 154
             $detail_list = json_decode($detail);

+ 1 - 1
app/controller/api/store/merchant/Merchant.php

@@ -133,7 +133,7 @@ class Merchant extends BaseController
133 133
         $where['is_used'] = 1;
134 134
         $where['product_type'] = 0;
135 135
         $where['is_hide'] = 0;
136
-        log::info("====={$params['mer_cate_id']}===");
136
+        // log::info("====={$params['mer_cate_id']}===");
137 137
         if($params['mer_cate_id']){
138 138
             $where['cate_id'] = $params['mer_cate_id'];
139 139
         }

+ 294 - 5
app/controller/api/store/merchant/TaskPartnerProfits.php

@@ -4,7 +4,15 @@
4 4
 namespace app\controller\api\store\merchant;
5 5
 
6 6
 
7
+use app\common\enum\CommonEnum;
8
+use app\common\enum\dividend\DividendLogEnum;
9
+use app\common\repositories\dividend\DividendLogRepository;
10
+use app\entity\data\dividend\DividendLogEntity;
11
+use think\db\exception\DataNotFoundException;
12
+use think\db\exception\DbException;
13
+use think\db\exception\ModelNotFoundException;
7 14
 use think\facade\Db;
15
+use think\facade\Log;
8 16
 use think\Request;
9 17
 
10 18
 class TaskPartnerProfits
@@ -77,6 +85,113 @@ class TaskPartnerProfits
77 85
         return $totalPv;
78 86
     }
79 87
 
88
+    /**
89
+     * 获取周期内 所有 有效的下单人ID列表
90
+     * @param $startTime
91
+     * @param $endTime
92
+     * @param array $removeUserIdList
93
+     * @return array
94
+     */
95
+    public function getOrderUidListByTime($startTime, $endTime, array $removeUserIdList = []): array
96
+    {
97
+        $orderUidMap = [];
98
+        try {
99
+            // 本地订单
100
+            $storeOrder = Db::name("store_order")
101
+                ->where('mer_id', '<>', CommonEnum::DESIGN_MERCHANT_ID['Repurchase']['code'])
102
+                ->whereNotIn('uid', $removeUserIdList)
103
+                ->whereIn('status', [0, 1, 2, 3])
104
+                ->whereBetween("pay_time", [$startTime, $endTime])
105
+                ->whereNotNull("pay_time") // 排除 pay_time 为 NULL 的订单
106
+                ->field('mer_id, status, pay_time, total_price, uid, order_id, order_sn')
107
+                ->select()
108
+                ->toArray();
109
+            foreach ($storeOrder as $order) {
110
+                $orderUidMap[$order['uid']][] = ['orderTable' => 'store_order', 'orderId' => $order['order_id'], 'orderSn' => $order['order_sn']];
111
+            }
112
+            // $storeOrderUidList = array_column($storeOrder, 'uid');
113
+            // $uidList = array_merge($uidList, $storeOrderUidList);
114
+
115
+            // 话费订单 order_huafei
116
+            $orderHuafei = Db::name("order_huafei")
117
+                ->whereNotIn('uid', $removeUserIdList)
118
+                ->where('status', '<>', 0) // 只要不是待支付的 即算是有效活跃度
119
+                ->whereBetween("finish_time", [$startTime, $endTime])
120
+                ->field('order_huafei_id, uid, status, finish_time, amount_price, order_sn')
121
+                ->select()
122
+                ->toArray();
123
+            foreach ($orderHuafei as $order) {
124
+                $orderUidMap[$order['uid']][] = ['orderTable' => 'order_huafei', 'orderId' => $order['order_huafei_id'], 'orderSn' => $order['order_sn']];
125
+            }
126
+            // $orderHuafeiUidList = array_column($orderHuafei, 'uid');
127
+            // $uidList = array_merge($uidList, $orderHuafeiUidList);
128
+
129
+            // 三方订单
130
+            // 京东
131
+            $orderJd = Db::name("order_jd")
132
+                ->whereNotIn('uid', $removeUserIdList)
133
+                ->where('status', '<>', 15) // 只要不是待支付的 即算是有效活跃度
134
+                ->whereBetween("create_time", [$startTime, $endTime])
135
+                ->field('order_jd_id, uid, status, create_time, price, order_sn')
136
+                ->select()
137
+                ->toArray();
138
+            foreach ($orderJd as $order) {
139
+                $orderUidMap[$order['uid']][] = ['orderTable' => 'order_jd', 'orderId' => $order['order_jd_id'], 'orderSn' => $order['order_sn']];
140
+            }
141
+            // $orderJdUidList = array_column($orderJd, 'uid');
142
+            // $uidList = array_merge($uidList, $orderJdUidList);
143
+            // 淘宝
144
+            $orderTb = Db::name("order_tb")
145
+                ->whereNotIn('uid', $removeUserIdList)
146
+                // ->where('status', '<>', 15) // 只要不是待支付的 即算是有效活跃度 不能明确状态信息
147
+                ->whereBetween("create_time", [$startTime, $endTime])
148
+                ->field('order_tb_id, uid, tk_status, create_time, pay_price, order_sn')
149
+                ->select()
150
+                ->toArray();
151
+            foreach ($orderTb as $order) {
152
+                $orderUidMap[$order['uid']][] = ['orderTable' => 'order_tb', 'orderId' => $order['order_tb_id'], 'orderSn' => $order['order_sn']];
153
+            }
154
+            // $orderTbUidList = array_column($orderTb, 'uid');
155
+            // $uidList = array_merge($uidList, $orderTbUidList);
156
+            // 拼多多
157
+            $orderPdd = Db::name("order_pdd")
158
+                ->whereNotIn('uid', $removeUserIdList)
159
+                ->where('pin_order_status', '<>', -1) // 只要不是待支付的 即算是有效活跃度 不能明确状态信息
160
+                ->whereBetween("group_time", [strtotime($startTime), strtotime($endTime)])
161
+                ->field('order_pdd_id, uid, pin_order_status, create_time, pay_money, order_sn')
162
+                ->select()
163
+                ->toArray();
164
+            foreach ($orderPdd as $order) {
165
+                $orderUidMap[$order['uid']][] = ['orderTable' => 'order_pdd', 'orderId' => $order['order_pdd_id'], 'orderSn' => $order['order_sn']];
166
+            }
167
+            // $orderPddUidList = array_column($orderPdd, 'uid');
168
+            // $uidList = array_merge($uidList, $orderPddUidList);
169
+            // 唯品会
170
+            $orderVip = Db::name("order_vip")
171
+                ->whereNotIn('uid', $removeUserIdList)
172
+                ->where('status', '<>', 0) // 只要不是待支付的 即算是有效活跃度 不能明确状态信息
173
+                ->whereBetween("order_time", [strtotime($startTime), strtotime($endTime)])
174
+                ->field('order_vip_id, uid, status, order_time, pay_money, order_sn')
175
+                ->select()
176
+                ->toArray();
177
+            foreach ($orderVip as $order) {
178
+                $orderUidMap[$order['uid']][] = ['orderTable' => 'order_vip', 'orderId' => $order['order_vip_id'], 'orderSn' => $order['order_sn']];
179
+            }
180
+            // $orderVipUidList = array_column($orderVip, 'uid');
181
+            // $uidList = array_merge($uidList, $orderVipUidList);
182
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
183
+            Log::error('分红-获取下单用户列表失败:' . json_encode([
184
+                    'error_message' => $e->getMessage(),
185
+                    'error_file' => $e->getFile(),
186
+                    'error_line' => $e->getLine(),
187
+                    'error_code' => $e->getCode(),
188
+                    'exception_class' => get_class($e),
189
+                    'trace' => $e->getTraceAsString()
190
+                ], JSON_UNESCAPED_UNICODE));
191
+        }
192
+        return $orderUidMap;
193
+    }
194
+
80 195
     public function getRedEnvelopeByTime($startTime, $endTime, $removeUserIdList = [])
81 196
     {
82 197
         // 查询指定时间区间内的所有订单,并排除 pay_time 为 NULL 的订单
@@ -121,6 +236,7 @@ class TaskPartnerProfits
121 236
 
122 237
         $startTime = $request->param('startTime', null);
123 238
         $endTime = $request->param('endTime', null);
239
+        $remark = $request->param('remark', '');
124 240
         $isTest = $request->param('isTest', 1);
125 241
         $maxAllocationAmount = $request->param('maxAllocationAmount', null);
126 242
 
@@ -149,7 +265,7 @@ class TaskPartnerProfits
149 265
             try {
150 266
                 $spread_user_list = Db::query($sql);
151 267
             } catch (\Exception $exception) {
152
-                return json($exception->getMessage());
268
+                return app('json')->fail($exception->getMessage());
153 269
             }
154 270
             $removeUserIdList = array_merge(explode(",", trim($spread_user_list[0]['uids'], '$,')), $removeUserIdList);
155 271
         }
@@ -172,7 +288,7 @@ class TaskPartnerProfits
172 288
         }
173 289
 
174 290
         if ($weekRecord <= 0) {
175
-            return json('无效分红金额');
291
+            return app('json')->fail('无效分红金额');
176 292
         }
177 293
 
178 294
 
@@ -184,6 +300,19 @@ class TaskPartnerProfits
184 300
             ->select()
185 301
             ->toArray();//星级等级
186 302
 
303
+        // 组装日志信息
304
+        /** @var DividendLogEntity $dividendLogEntity */
305
+        $dividendLogEntity = DividendLogEntity::newInstance();
306
+        $dividendLogEntity->setType(DividendLogEnum::TYPE['PartnerProfit']['code'])
307
+            ->setStartTime($startTime)
308
+            ->setEndTime($endTime)
309
+            ->setPerformance($performance)
310
+            ->setAbatement(json_encode([['code' => 'redEnvelope', 'name' => '红包', 'reason' => '发放的红包金额,需要从赚取的业绩中扣除', 'number' => $redEnvelope]]))
311
+            ->setAllocated($weekRecord)
312
+            ->setRule(json_encode($starList))
313
+            ->setIsTest($isTest)
314
+            ->setRemark($remark);
315
+
187 316
         // 2、循环星级信息 并分组归类
188 317
         $salesArr = array_column($starList, null, 'title');
189 318
 
@@ -251,6 +380,10 @@ class TaskPartnerProfits
251 380
             //周总业绩(8400) * 合伙人级别的分佣比例(15%) = 可分红的佣金(1260)
252 381
             //            $salesArr[$key]['fs_money_nums'] = round($weekRecord * $value['profit_rate'], 2);
253 382
             $salesArr[$key]['fs_money_nums'] = floor(($weekRecord * ($value['profit_rate'] / 100)) * 100) / 100;
383
+
384
+            // 日志表 记录应分配金额
385
+            $dividendLogEntity->setExpected(bcadd($dividendLogEntity->getExpected() ?: '0.00', $salesArr[$key]['fs_money_nums'], 2));
386
+
254 387
             //可分红的业绩(分为两半,各50%,一部分是分给双联盟比例,一部分是小业绩比例)
255 388
             //把本周的业绩(8400) * 合伙人级别的分佣比例(15%) * 0.5 = 630(可分红佣金的 50%)
256 389
             //            $salesArr[$key]['fs_money'] = round($salesArr[$key]['fs_money_nums'] / 2, 2);
@@ -298,6 +431,11 @@ class TaskPartnerProfits
298 431
             }
299 432
         }
300 433
 
434
+        // 6、记录日志
435
+        // 获取周期内所有符合条件的订单
436
+        $orderUidMap = $this->getOrderUidListByTime($startTime, $endTime, $removeUserIdList);
437
+        $feeUids = array_keys($orderUidMap);
438
+
301 439
         // 7、执行分红
302 440
         $testRecord = [];
303 441
         foreach ($salesArr as $key => $value) {
@@ -349,16 +487,31 @@ class TaskPartnerProfits
349 487
                 //                    $testRecord['fg_fushu'][] = ['uid' => $v, 'num' => floor($allAward * 0.1 * 100) / 100, 'exist' => $user_sign_fugou_uid_list[$v]['number'] ?? 0.00, 'fg' => $fg_10];
350 488
                 //                }
351 489
 
490
+                if (!in_array($v, $feeUids)) {
491
+                    $feeWaiverUids = $dividendLogEntity->getFeeWaiverUids() ?: [];
492
+                    $feeWaiverUids[] = [
493
+                        'uid' => $v,
494
+                        'remark' => '周期内未完成订单任务'
495
+                    ];
496
+                    $dividendLogEntity->setFeeWaiverUids($feeWaiverUids);
497
+                    continue;
498
+                }
499
+                $dividendLogEntity->setArrivalPoint(bcadd($dividendLogEntity->getArrivalPoint() ?: '0.00', $allAward, 2));
500
+                $arrivalInfo = $dividendLogEntity->getArrivalInfo() ?: [];
501
+                $arrivalInfo[$v]['allAward'] = $allAward;
502
+                $arrivalInfo[$v]['orderInfo'] = $orderUidMap[$v];
503
+                $dividendLogEntity->setArrivalInfo($arrivalInfo);
504
+
352 505
                 if ($isTest == 0) {
353 506
                     $userdatassss = db::name("old_user_jbp")->where("id", $v)->find();
354 507
                     $datas_log = [
355 508
                         'note' => "名称:" . $userdatassss['nick_name'] . " 用户:" . $v . " 双联盟总业绩:" . $maxValueAll . " 我的双区业绩:" . $myBill . " 小区总业绩:" . $userPvSmallNum . " 我的业绩小的:" . $myMixMoney . "  可分红佣金:" . $amount . "  可分红总佣金:" . $fsMoneyNums . "  小区业绩可分红:" . $myMixMoney . " 双区业绩可分红:" . $myWeightMoney . " 实际分得:" . $yj_90,
356 509
                         'create_time' => date('Y-m-d H:i:s')
357 510
                     ];
358
-                    $con_data = Db::name('test_log')->insert($datas_log);   //数据存到2.0数据表中
511
+                    Db::name('test_log')->insert($datas_log);   //数据存到2.0数据表中
359 512
 
360 513
                     # code...
361
-                    $res = Db::name("user")->where("uid", $v)->inc("total_amount_old", $yj_90)->save();
514
+                    Db::name("user")->where("uid", $v)->inc("total_amount_old", $yj_90)->save();
362 515
 
363 516
                     Db::name("user")->where("uid", $v)->inc("amount_old", $yj_90)->save();//不用冻结金额和提现额度来限制佣金发放
364 517
                     Db::name("user")->where("uid", $v)->inc("brokerage_price", $yj_90)->save();
@@ -411,7 +564,13 @@ class TaskPartnerProfits
411 564
             }
412 565
             $salesArr['cs'] = $testRecord;
413 566
         }
414
-        return json($salesArr);
567
+        $dividendLogEntity->setResult(json_encode($salesArr, JSON_UNESCAPED_UNICODE));
568
+
569
+        /** @var DividendLogRepository $dividendLogRepository */
570
+        $dividendLogRepository = app()->make(DividendLogRepository::class);
571
+        $dividendLogRepository->createByEntity($dividendLogEntity);
572
+
573
+        return app('json')->success($salesArr);
415 574
     }
416 575
 
417 576
     /**
@@ -854,4 +1013,134 @@ class TaskPartnerProfits
854 1013
 
855 1014
         Db::name('user_sign_fugou')->insert($bill);
856 1015
     }
1016
+
1017
+    /**
1018
+     * 补发分红
1019
+     * @param Request $request
1020
+     * @return mixed
1021
+     */
1022
+    public function resendUnissued(Request $request)
1023
+    {
1024
+        $dividendLogId = $request->param('dividendLogId', 0);
1025
+        if (empty($dividendLogId)) {
1026
+            return app('json')->fail('无效记录ID');
1027
+        }
1028
+        /** @var DividendLogRepository $dividendLogRepository */
1029
+        $dividendLogRepository = app()->make(DividendLogRepository::class);
1030
+        $dividendLogEntity = $dividendLogRepository->getDividendLogEntityById($dividendLogId);
1031
+        if (empty($dividendLogEntity->getId())) {
1032
+            return app('json')->fail('无效记录');
1033
+        }
1034
+
1035
+        $dividendLogEntityByResend = DividendLogEntity::newInstance()
1036
+            ->setType($dividendLogEntity->getType())
1037
+            ->setStartTime($dividendLogEntity->getStartTime())
1038
+            ->setEndTime($dividendLogEntity->getEndTime())
1039
+            ->setPerformance($dividendLogEntity->getPerformance())
1040
+            ->setAbatement($dividendLogEntity->getAbatement())
1041
+            ->setAllocated($dividendLogEntity->getAllocated())
1042
+            ->setRule($dividendLogEntity->getRule())
1043
+            ->setExpected(bcsub($dividendLogEntity->getExpected(), $dividendLogEntity->getArrivalPoint(), 2))
1044
+            ->setFeeWaiverUids([])
1045
+            ->setResult($dividendLogEntity->getResult())
1046
+            ->setIsTest(DividendLogEnum::IS_TEST['No']['code'])
1047
+            ->setReissueId($dividendLogEntity->getId())
1048
+            ->setRemark('补发合伙人分佣未发放部分');
1049
+
1050
+        $startTime = $dividendLogEntity->getStartTime();
1051
+        $endTime = $dividendLogEntity->getEndTime();
1052
+        $performance = $dividendLogEntity->getPerformance();
1053
+        $weekRecord = $dividendLogEntity->getAllocated();
1054
+        $feeWaiverUids = $dividendLogEntity->getFeeWaiverUids();
1055
+        $feeWaiverUids = array_column($feeWaiverUids, 'uid');
1056
+        $redEnvelope = 0.00;
1057
+        if (!empty($dividendLogEntity->getAbatement())) {
1058
+            $abatement = json_decode($dividendLogEntity->getAbatement(), true);
1059
+            if (is_array($abatement)) {
1060
+                foreach ($abatement as $item) {
1061
+                    if ($item['code'] == 'redEnvelope') {
1062
+                        $redEnvelope = $item['number'] ?? 0.00;
1063
+                    }
1064
+                }
1065
+            }
1066
+        }
1067
+
1068
+        $salesArr = $dividendLogEntity->getResult();
1069
+        $salesArr = is_array($salesArr) ?: json_decode($salesArr, true);
1070
+        foreach ($salesArr as $key => $value) {
1071
+            if (empty($value)) {
1072
+                continue;
1073
+            }
1074
+            if (count($value['dividerPeoplePv']) <= 0) {
1075
+                continue;
1076
+            }
1077
+            $fsMoneyNums = $value['fs_money_nums'];//中级合伙人级别,可分红的总佣金
1078
+            $maxValueAll = $value['maxValueAll'];//当前级别合伙人下面所有的双联盟业绩
1079
+            $sumOfOthersAll = $value['sumOfOthersAll'];//当前级别合伙人下面所有的小区(业绩小的部分)总业绩
1080
+
1081
+            //每人分红金额
1082
+            foreach ($value['dividerPeoplePv'] as $uid => $item) {
1083
+
1084
+
1085
+                $allAward = bcadd($item['myWeightMoney'], $item['myMixMoney'], 2);
1086
+                //90%给佣金,10给复购金
1087
+                $yj_90 = floor($allAward * 0.9 * 100) / 100;
1088
+                $fg_10 = floor($allAward * 0.1 * 100) / 100;
1089
+
1090
+                if (!in_array($uid, $feeWaiverUids)) {
1091
+                    // $feeWaiverUids = $dividendLogEntity->getFeeWaiverUids() ?: [];
1092
+                    // $feeWaiverUids[] = [
1093
+                    //     'uid' => $uid,
1094
+                    //     'remark' => '此次发放为补发,只发放上次未发放人员数据'
1095
+                    // ];
1096
+                    // $dividendLogEntity->setFeeWaiverUids($feeWaiverUids);
1097
+                    continue;
1098
+                }
1099
+                $dividendLogEntityByResend->setArrivalPoint(bcadd($dividendLogEntityByResend->getArrivalPoint() ?: '0.00', $allAward, 2));
1100
+                $arrivalInfo = $dividendLogEntityByResend->getArrivalInfo() ?: [];
1101
+                $arrivalInfo[$uid]['allAward'] = $allAward;
1102
+                $arrivalInfo[$uid]['orderInfo'] = [];
1103
+                $dividendLogEntityByResend->setArrivalInfo($arrivalInfo);
1104
+
1105
+
1106
+                # code...
1107
+                Db::name("user")->where("uid", $uid)->inc("total_amount_old", $yj_90)->save();
1108
+                Db::name("user")->where("uid", $uid)->inc("amount_old", $yj_90)->save();//不用冻结金额和提现额度来限制佣金发放
1109
+                Db::name("user")->where("uid", $uid)->inc("brokerage_price", $yj_90)->save();
1110
+                Db::name("user")->where("uid", $uid)->inc("fugou", $fg_10)->save();
1111
+
1112
+                $this->change_user_log($uid, 'amount_old', 1, $yj_90, "member_award", "星级分红入账" . "-" . $value['title']);//释放佣金
1113
+
1114
+                // 入账记录
1115
+                $week_data = [];
1116
+                $week_data['user_id'] = $uid;
1117
+                $week_data['user_group'] = $value['user_group'];
1118
+                $week_data['start_time'] = $startTime;
1119
+                $week_data['end_time'] = $endTime;
1120
+                $week_data['performance'] = $performance;
1121
+                $week_data['red_envelope'] = $redEnvelope;
1122
+                $week_data['reality_performance'] = $weekRecord;
1123
+                $week_data['dividend_ratio'] = $value['profit_rate'];
1124
+                $week_data['dividend'] = $fsMoneyNums;
1125
+                $week_data['performance_part'] = $item['sumOfOthers'] ?? '0.00';
1126
+                $week_data['performance_part_all'] = $sumOfOthersAll;
1127
+                $week_data['part_money'] = $item['myMixMoney'];
1128
+                $week_data['performance_total'] = bcadd($item['maxValue'] ?? '0.00', $item['sumOfOthers'] ?? '0.00', 2);
1129
+                $week_data['performance_total_all'] = ($maxValueAll + $sumOfOthersAll);
1130
+                $week_data['total_money'] = $item['myWeightMoney'];
1131
+                $week_data['brokerage'] = $yj_90;
1132
+                $week_data['fugou'] = $fg_10;
1133
+                $week_data['radio'] = 2;
1134
+                $week_data['create_time'] = date('Y-m-d H:i:s');
1135
+                Db::name("partner_profit_records")->insert($week_data);
1136
+
1137
+                $this->bill_user_log111111($uid, "合伙人分佣", $yj_90, "合伙人分佣明细入账(补发)", 11);//联创分佣明细2.0系统
1138
+                $this->fugou_user_log($uid, $fg_10, 16, 1, 1);//复购金明细入账
1139
+            }
1140
+        }
1141
+        /** @var DividendLogRepository $dividendLogRepository */
1142
+        $dividendLogRepository = app()->make(DividendLogRepository::class);
1143
+        $dividendLogRepository->createByEntity($dividendLogEntityByResend);
1144
+        return app('json')->success($salesArr);
1145
+    }
857 1146
 }

+ 6 - 44
app/controller/api/store/merchant/Taskorderguquan.php

@@ -18,52 +18,14 @@ class Taskorderguquan
18 18
     {
19 19
 
20 20
         /**
21
-        * 补贴下面人员
22
-         * 13231658486周行体300
23
-         * 13333069689魏   新300
24
-         * 13959100621周金花200
25
-         * 13701061395李素红200
26
-         * 17501006833邢艳丽100
27
-         * 15631982690魏震洪100
28
-         * 18603401312黄金花50
29
-         * 13521438652徐立苹200
30
-         * 15832971815孟晓玮100
31
-         * 15810064711 王   玲 100
32
-         * 13932925303会强100
33
-         * 13601071082隋彩云100
34
-         * 13601179856陈瑞元50
35
-         * 13161909228刘银霞100
36
-         * 18760167163刘春梅20
37
-         * 13215917919李小秋20
38
-         * 15532683963李玉芝50
39
-         * 13381085923王建军50
40
-         * 13231658486周军市场补贴400
41
-         * 13331043787张吉良65
42
-         * 15332507711 张传莲 50
43
-         * 18715313601大饼200
21
+         * 业绩25000分配
22
+         * 补贴下面人员
23
+         * 13331043787张吉良55
24
+         *
25
+         * 其余部分做分红
44 26
          */
45 27
         $data = [
46
-            '13231658486' => 700,
47
-            '13333069689' => 300,
48
-            '13959100621' => 200,
49
-            '13701061395' => 200,
50
-            '17501006833' => 100,
51
-            '15631982690' => 100,
52
-            '18603401312' => 50,
53
-            '13521438652' => 200,
54
-            '15832971815' => 100,
55
-            '15810064711' => 100,
56
-            '13932925303' => 100,
57
-            '13601071082' => 100,
58
-            '13601179856' => 50,
59
-            '13161909228' => 100,
60
-            '18760167163' => 20,
61
-            '13215917919' => 20,
62
-            '15532683963' => 50,
63
-            '13381085923' => 50,
64
-            '13331043787' => 65,
65
-            '15332507711' => 50,
66
-            '18715313601' => 200
28
+            '13331043787' => 55
67 29
         ];
68 30
 
69 31
         $result = Db::name("user")

+ 4 - 1
app/controller/api/store/merchant/Taskordervr.php

@@ -47,6 +47,9 @@ class Taskordervr extends BaseController
47 47
     //接收VR和收款人信息
48 48
     public function lst4()
49 49
     {
50
+        if (strtotime('2026-01-29 00:00:00') < time()) {
51
+            return json(['code'=>400,'msg'=>'该功能已关闭!']);
52
+        }
50 53
 
51 54
         // return json(['code'=>400,'msg'=>'获取失败!']);
52 55
         $phone = input("post.phone");
@@ -117,7 +120,7 @@ class Taskordervr extends BaseController
117 120
             $user_res_log = Db::name("user_sign_vr")->insert( $log_data);
118 121
 
119 122
             //收款账号
120
-            $jieshouuser_res = Db::name("user")->where("account",$phone)->update(['vr'=>$user_data['vr'] + $vr]);
123
+            $jieshouuser_res = Db::name("user")->where("uid",$user_data['uid'])->update(['vr'=>$user_data['vr'] + $vr]);
121 124
 
122 125
             if( $jieshouuser_res){
123 126
 

+ 237 - 36
app/controller/api/store/product/DaTaoKe.php

@@ -13,9 +13,11 @@ use app\common\repositories\store\product\ProductRepository;
13 13
 use app\common\repositories\user\UserThirdRepository;
14 14
 use app\model\common\TbOrderModel;
15 15
 use app\model\common\UserThirdModel;
16
+use app\utils\TimeUtil;
16 17
 use http\Exception;
17 18
 use think\facade\Db;
18 19
 use think\facade\Log;
20
+use think\Request;
19 21
 use function GuzzleHttp\Promise\iter_for;
20 22
 
21 23
 /**
@@ -24,9 +26,12 @@ use function GuzzleHttp\Promise\iter_for;
24 26
  */
25 27
 class DaTaoKe
26 28
 {
27
-    public static $appKey = '6002a6fd58162';
28
-    public static $appSecret = '0e4f0cdf9b1a58d763bcb956b56578da';
29
-    public static $pid = 'mm_1411990095_2149000369_111007900247';//推广位ID
29
+    // public static $appKey = '6002a6fd58162';
30
+    // public static $appSecret = '0e4f0cdf9b1a58d763bcb956b56578da';
31
+    // public static $pid = 'mm_1411990095_2149000369_111007900247';//推广位ID
32
+    public static $appKey = '691e84c785246';
33
+    public static $appSecret = '6b701ad73c7cc4c2de56a4afcb876af2';
34
+    public static $pid = 'mm_9436146813_3362200454_116174700455';//推广位ID
30 35
 
31 36
     //大淘客生产签名方法
32 37
     public static function makeSign($data, $appSecret)
@@ -212,48 +217,236 @@ class DaTaoKe
212 217
 
213 218
 
214 219
     //订单查询接口(20分钟一个时间段)
215
-    public function getOrder()
220
+    public function getOrder(Request $request)
216 221
     {
222
+        // // 立即返回响应,断开客户端连接
223
+        // header('Content-Length: 0');
224
+        // header('Connection: close');
225
+        // ob_end_clean();
226
+        // ob_start();
227
+        // echo 'Request accepted'; // 可选的初始响应
228
+        //
229
+        // // 获取内容长度并发送头部
230
+        // header('Content-Length: ' . ob_get_length());
231
+        // ob_end_flush();
232
+        // flush();
233
+        //
234
+        // // 如果是FastCGI,还需要额外的刷新
235
+        // if (function_exists('fastcgi_finish_request')) {
236
+        //     fastcgi_finish_request();
237
+        // }
238
+
239
+        // 从这里开始,客户端已经断开,脚本可以长时间运行
240
+        ignore_user_abort(true); // 忽略用户中断
241
+        set_time_limit(0); // 取消时间限制
242
+        $scene = $request->get('scene', 1);
243
+
217 244
         try {
218
-            $startTime = date("Y-m-d H:i:00", strtotime("-50 minutes"));
219
-            $endTime = date("Y-m-d H:i:00");
220 245
             $url = 'https://openapi.dataoke.com/api/tb-service/get-order-details';
221
-            $queryTypes = [1, 2, 3];//1:按照订单淘客创建时间查询,2:按照订单淘客付款时间查询,3:按照订单淘客结算时间查询
222 246
             $orders = [];
223
-            foreach ($queryTypes as $queryType) {
224
-                $queryData = [
225
-                    'appKey' => self::$appKey,
226
-                    'version' => 'v1.0.0',
227
-                    'queryType' => $queryType,
228
-                    'pageSize' => 80,
229
-                    'startTime' => $startTime,
230
-                    'endTime' => $endTime,
231
-                    //1:常规订单,2:渠道订单,3:会员运营订单 默认为1
232
-                    'orderScene' => 2,
233
-                ];
234
-                $queryData['sign'] = self::makeSign($queryData, self::$appSecret);
235
-                $fullUrl = "{$url}?" . http_build_query($queryData);
236
-                $response = self::sendCurl($fullUrl);
237
-                $isError = $response['data']['error_response'] ?? '';
238
-                if ($isError) {//查询订单出错
239
-                    return app('json')->fail("拉取淘宝客订单出错", $response);
240
-                }
241
-                $responseOrders = $response['data']['results']['publisher_order_dto'] ?? [];
242
-                if ($responseOrders) {
243
-                    $orders = array_merge($orders, $responseOrders);
244
-                }
247
+
248
+            // 场景1:实时同步最近20分钟内有更新的订单
249
+            $recentOrders = $this->queryRecentOrders($url);
250
+            $orders = array_merge($orders, $recentOrders);
251
+
252
+            // 场景2:分批次查询历史订单(避免时间范围过大) 平时只需要开场景1 场景二主要目的是 指定时间内(比如10天内) 有漏掉的订单,可以开启执行一次;注意执行一次后再给关闭,防止资源浪费
253
+            if ($scene == 2) {
254
+                $refundOrders = $this->queryOrdersByBatch($url);
255
+                $orders = array_merge($orders, $refundOrders);
245 256
             }
257
+
246 258
             if ($orders) {
247
-                //格式化拉取到的订单列表
248
-                $formatLists = self::formatOrderList($orders);
249
-                //创建/更新淘宝订单
259
+                // 去重处理
260
+                $uniqueOrders = $this->removeDuplicateOrders($orders);
261
+
262
+                // 格式化拉取到的订单列表
263
+                $formatLists = self::formatOrderList($uniqueOrders);
264
+                // 创建/更新淘宝订单
250 265
                 self::operateOrder($formatLists);
266
+
267
+                Log::info("订单处理完成". json_encode([
268
+                    '总订单数' => count($orders),
269
+                    '去重后订单数' => count($uniqueOrders),
270
+                    '处理时间' => date('Y-m-d H:i:s')
271
+                ], JSON_UNESCAPED_UNICODE));
272
+            } else {
273
+                Log::info("未获取到新订单");
251 274
             }
275
+
252 276
             return app('json')->success("拉取并处理淘宝客订单成功");
277
+
253 278
         } catch (\Throwable $throwable) {
254
-            return app('json')->fail("拉取并处理淘宝客订单出错{$throwable->getMessage()}");
279
+            Log::error("拉取订单异常". json_encode([
280
+                '错误信息' => $throwable->getMessage(),
281
+                '堆栈' => $throwable->getTraceAsString()
282
+            ], JSON_UNESCAPED_UNICODE));
283
+            return app('json')->fail("拉取并处理淘宝客订单出错: {$throwable->getMessage()}");
284
+        }
285
+
286
+        // try {
287
+        //     $startTime = date("Y-m-d H:i:00", strtotime("-50 minutes"));
288
+        //     $endTime = date("Y-m-d H:i:00");
289
+        //     $url = 'https://openapi.dataoke.com/api/tb-service/get-order-details';
290
+        //     $queryTypes = [1, 2, 3];//1:按照订单淘客创建时间查询,2:按照订单淘客付款时间查询,3:按照订单淘客结算时间查询
291
+        //     $orders = [];
292
+        //     foreach ($queryTypes as $queryType) {
293
+        //         $queryData = [
294
+        //             'appKey' => self::$appKey,
295
+        //             'version' => 'v1.0.0',
296
+        //             'queryType' => $queryType,
297
+        //             'pageSize' => 100,
298
+        //             'startTime' => $startTime,
299
+        //             'endTime' => $endTime,
300
+        //             //1:常规订单,2:渠道订单,3:会员运营订单 默认为1
301
+        //             'orderScene' => 2,
302
+        //             'tkStatus' => 3
303
+        //         ];
304
+        //         $queryData['sign'] = self::makeSign($queryData, self::$appSecret);
305
+        //         $fullUrl = "{$url}?" . http_build_query($queryData);
306
+        //         $response = self::sendCurl($fullUrl);
307
+        //         $isError = $response['data']['error_response'] ?? '';
308
+        //         if ($isError) {//查询订单出错
309
+        //             return app('json')->fail("拉取淘宝客订单出错", $response);
310
+        //         }
311
+        //         $responseOrders = $response['data']['results']['publisher_order_dto'] ?? [];
312
+        //         if ($responseOrders) {
313
+        //             $orders = array_merge($orders, $responseOrders);
314
+        //         }
315
+        //     }
316
+        //     if ($orders) {
317
+        //         //格式化拉取到的订单列表
318
+        //         $formatLists = self::formatOrderList($orders);
319
+        //         //创建/更新淘宝订单
320
+        //         self::operateOrder($formatLists);
321
+        //     }
322
+        //     return app('json')->success("拉取并处理淘宝客订单成功");
323
+        // } catch (\Throwable $throwable) {
324
+        //     return app('json')->fail("拉取并处理淘宝客订单出错{$throwable->getMessage()}");
325
+        // }
326
+
327
+    }
328
+
329
+    /**
330
+     * 查询最近20分钟内有更新的订单
331
+     */
332
+    private function queryRecentOrders($url)
333
+    {
334
+        $endTime = date("Y-m-d H:i:00");
335
+        $startTime = date("Y-m-d H:i:00", strtotime("-20 minutes"));
336
+
337
+        $queryData = [
338
+            'appKey' => self::$appKey,
339
+            'version' => 'v1.0.0',
340
+            'queryType' => 4, // 按照订单更新时间查询
341
+            'pageSize' => 100,
342
+            'startTime' => $startTime,
343
+            'endTime' => $endTime,
344
+            'orderScene' => 2,
345
+        ];
346
+
347
+        $queryData['sign'] = self::makeSign($queryData, self::$appSecret);
348
+        $fullUrl = "{$url}?" . http_build_query($queryData);
349
+
350
+        Log::info("查询最近订单". json_encode(['时间范围' => "{$startTime} 至 {$endTime}"], JSON_UNESCAPED_UNICODE));
351
+
352
+        $response = self::sendCurl($fullUrl);
353
+        $isError = $response['data']['error_response'] ?? '';
354
+
355
+        if ($isError) {
356
+            Log::error("查询最近订单错误". json_encode(['错误' => $isError], JSON_UNESCAPED_UNICODE));
357
+            return [];
358
+        }
359
+
360
+        return $response['data']['results']['publisher_order_dto'] ?? [];
361
+    }
362
+
363
+    /**
364
+     * 分批查询退款订单
365
+     */
366
+    private function queryOrdersByBatch($url): array
367
+    {
368
+        $allRefundOrders = [];
369
+
370
+        // 定义查询的时间段 大促期间 只能查20分钟的
371
+        $batchIntervals = TimeUtil::generateTimeIntervals(
372
+            date("Y-m-d H:i:00", strtotime("-10 days")), // 开始时间:10天前
373
+            date("Y-m-d H:i:00"),   // 结束时间 当前
374
+            20
375
+        );
376
+
377
+        foreach ($batchIntervals as $interval) {
378
+            $orders = $this->queryOrdersInInterval($url, $interval['start'], $interval['end']);
379
+            $allRefundOrders = array_merge($allRefundOrders, $orders);
380
+
381
+            // 添加延迟,避免请求过于频繁
382
+            usleep(500000); // 注意 这是微妙
383
+        }
384
+
385
+        Log::info("分批查询退款订单完成". json_encode([
386
+            '时间段数量' => count($batchIntervals),
387
+            '退款订单数' => count($allRefundOrders)
388
+        ], JSON_UNESCAPED_UNICODE));
389
+
390
+        return $allRefundOrders;
391
+    }
392
+
393
+    /**
394
+     * 在指定时间区间内查询退款订单
395
+     */
396
+    private function queryOrdersInInterval($url, $startTime, $endTime)
397
+    {
398
+        $queryData = [
399
+            'appKey' => self::$appKey,
400
+            'version' => 'v1.0.0',
401
+            'queryType' => 2, // 按照 付款时间查询
402
+            'pageSize' => 100,
403
+            'startTime' => $startTime,
404
+            'endTime' => $endTime,
405
+            'orderScene' => 2,
406
+            // 'tkStatus' => 13
407
+        ];
408
+
409
+        $queryData['sign'] = self::makeSign($queryData, self::$appSecret);
410
+        $fullUrl = "{$url}?" . http_build_query($queryData);
411
+
412
+        Log::debug("查询订单时间段". json_encode([
413
+            '开始时间' => $startTime,
414
+            '结束时间' => $endTime,
415
+            '时间差(分钟)' => round((strtotime($endTime) - strtotime($startTime)) / 60, 2)
416
+        ], JSON_UNESCAPED_UNICODE));
417
+
418
+        $response = self::sendCurl($fullUrl);
419
+        Log::debug("查询结果". json_encode($response, JSON_UNESCAPED_UNICODE));
420
+        $isError = $response['data']['error_response'] ?? '';
421
+
422
+        if ($isError) {
423
+            Log::warning("查询订单出错". json_encode([
424
+                '时间段' => "{$startTime} 至 {$endTime}",
425
+                '错误' => $isError
426
+            ], JSON_UNESCAPED_UNICODE));
427
+            return [];
428
+        }
429
+
430
+        return $response['data']['results']['publisher_order_dto'] ?? [];
431
+    }
432
+
433
+    /**
434
+     * 订单去重
435
+     */
436
+    private function removeDuplicateOrders($orders): array
437
+    {
438
+        $uniqueOrders = [];
439
+        $orderIds = [];
440
+
441
+        foreach ($orders as $order) {
442
+            $orderId = $order['trade_parent_id'] ?? '';
443
+            if ($orderId && !in_array($orderId, $orderIds)) {
444
+                $uniqueOrders[] = $order;
445
+                $orderIds[] = $orderId;
446
+            }
255 447
         }
256 448
 
449
+        return $uniqueOrders;
257 450
     }
258 451
 
259 452
     //订单查询接口(20分钟一个时间段)
@@ -365,15 +558,16 @@ class DaTaoKe
365 558
     //处理淘宝客订单
366 559
     public static function operateOrder($formatLists)
367 560
     {
561
+        /** @var UserThirdRepository $orderThird */
368 562
         $orderThird = app()->make(UserThirdRepository::class);
369 563
         foreach ($formatLists as $k => $order) {
370
-            log::info("=++++==taobaoorder=====+++");
564
+            // log::info("=++++==taobaoorder=====+++");
371 565
 
372 566
             if (empty($order)) continue;
373 567
             //判断数据库有无此订单
374 568
             $localOrder = TbOrderModel::getInstance()->getOne(['order_sn' => $order['order_sn']]);
375
-            log::info("localOrder========");
376
-            log::info($localOrder);
569
+            // log::info("localOrder========");
570
+            // log::info($localOrder);
377 571
             if (empty($localOrder)) {
378 572
                 //订单写入数据库,bill_end_time再格式化订单的时候已经加入,所以写入订单的时候就不需要在计算了
379 573
                 $localOrder = TbOrderModel::create($order);
@@ -395,6 +589,13 @@ class DaTaoKe
395 589
                     $localOrder['order_sn'],
396 590
                     5
397 591
                 );
592
+                if($order['tk_status'] == 13){
593
+                    //修改积分和贡献,yanglaojin值记录
594
+                    $orderThird->updateJilu(
595
+                        $localOrder['uid'],
596
+                        $localOrder['order_tb_id'],
597
+                        5);
598
+                }
398 599
             } else {
399 600
                 if($localOrder['tk_status']!=$order['tk_status']) {
400 601
                     log::info("=============更新订单");

+ 5 - 3
app/controller/api/store/product/Jd.php

@@ -115,7 +115,7 @@ class Jd extends BaseController
115 115
         if (empty($apiName)) {
116 116
             return false;
117 117
         }
118
-        log::info("url京东111");
118
+        // log::info("url京东111");
119 119
         //公共请求参数
120 120
         $requestParams = [
121 121
             'method'            => $apiName,
@@ -130,8 +130,8 @@ class Jd extends BaseController
130 130
         $sign = $this->paramSign($orderData);
131 131
         $requestParams['sign'] = $sign;
132 132
         $res = $this->apiSign($requestParams);
133
-        log::info("url京东end");
134
-        log::info($res);
133
+        // log::info("url京东end");
134
+        // log::info($res);
135 135
         return $res;
136 136
     }
137 137
 
@@ -216,7 +216,9 @@ class Jd extends BaseController
216 216
             ];
217 217
             $goods_obj = $goods_obj->whereIn('cid', $oldToNewMapping[$_cid]);
218 218
         }
219
+        $salt = (int)(time() / 100);
219 220
         $list = $goods_obj->page($page, $limit)
221
+            ->orderRaw("RAND({$salt})")
220 222
             ->select()->toArray();
221 223
 
222 224
         $formatList = [];

+ 2 - 2
app/controller/api/store/product/Other.php

@@ -522,8 +522,8 @@ class Other extends BaseController
522 522
                         $value['bill_end_time'] = $billEndTime ? date('Y-m-d H:i:s', $billEndTime) : '';
523 523
                         //'0平台未结算1已结算2失效
524 524
                         $value['status_name'] = $this->statusName[$value['status']];
525
-                        if (strpos($value['goods_img'], 'http') === false){
526
-                            $value['goods_img'] = "http:".$value['goods_img'];
525
+                        if (strpos($tb_list['goods_img'], 'http') === false){
526
+                            $value['goods_img'] = "http:".$tb_list['goods_img'];
527 527
                         }
528 528
                         $value['yanglao'] = $yanglao;
529 529
                         $value = array_merge($value,$tb_list);

+ 25 - 25
app/controller/api/store/product/TaoKe.php

@@ -184,7 +184,7 @@ class TaoKe extends BaseController
184 184
 
185 185
         $params['cat_id'] = $cat_id;
186 186
 
187
-        Log::info($params);
187
+        // Log::info($params);
188 188
 
189 189
         $apiName = 'pdd.ddk.goods.search';
190 190
         $result = $this->getUrlResult($apiName, $params);
@@ -204,7 +204,7 @@ class TaoKe extends BaseController
204 204
 
205 205
         foreach ($goodsResult as $goods) {
206 206
 
207
-            log::info("=======min_normal_price====={$goods['min_normal_price']}==============");
207
+            // log::info("=======min_normal_price====={$goods['min_normal_price']}==============");
208 208
             //var_dump($goods);
209 209
             $min_normal_price = sprintf('%.2f', $goods['min_normal_price'] / 100);
210 210
             $groupPrice = sprintf('%.2f', $goods['min_group_price'] / 100);
@@ -213,7 +213,7 @@ class TaoKe extends BaseController
213 213
             //佣金比例,千分比
214 214
             $commissionRate = $goods['promotion_rate'];
215 215
 
216
-            log::info("=======min_normal_price====={$groupPrice}==========={$commissionRate}===");
216
+            // log::info("=======min_normal_price====={$groupPrice}==========={$commissionRate}===");
217 217
             $commission = sprintf('%.2f', (($groupPrice * $commissionRate) /1000));  //佣金
218 218
             //将佣金根据用户等级转成积分
219 219
             //$userCommissionIntegral = getCommission($userLevel, $commission);
@@ -229,12 +229,12 @@ class TaoKe extends BaseController
229 229
 
230 230
 //            $pv=sprintf('%.2f',$commission* 0.5);  //PV
231 231
 //            $yanglaojin=$pv; //新的养老金
232
-            Log::info("养老金:".$yanglaojin);
232
+//             Log::info("养老金:".$yanglaojin);
233 233
             // if($yanglaojin < 0.1) {
234 234
             //     continue;
235 235
             // }
236 236
 
237
-            
237
+
238 238
             try {
239 239
                 $current_goods= [
240 240
                     'type' => 1,//拼多多商品
@@ -243,13 +243,13 @@ class TaoKe extends BaseController
243 243
                     'name' => $goods['goods_name'],
244 244
                     'commission' => $yanglaojin, //养老金  //app()->make(ProductRepository::class)->thirdYanglaojin(0, $commission),
245 245
                     'commission_' => $commission,
246
-    
246
+
247 247
                     'yanglaojin' => $yanglaojin,
248 248
                     'pv' => $pv,
249 249
                     'gongxian'=>$pv,
250 250
                     'jifen'=>$pv,
251
-                    
252
-    
251
+
252
+
253 253
                     'commission_rate' => $commissionRate,
254 254
                     'sales' => $goods['sales_tip'],
255 255
                     //'desc' => $goods['goods_desc'],
@@ -257,12 +257,12 @@ class TaoKe extends BaseController
257 257
                     //'market_price' => $groupPrice,
258 258
                     'market_price' => set_price_rtrim(sprintf('%.2f', $min_normal_price - $couponMoney)),
259 259
                     'price' => set_price_rtrim(sprintf('%.2f', $groupPrice - $couponMoney)),
260
-    
260
+
261 261
                     'shopName'=>$goods['mall_name'], //店铺名称
262 262
                     'monthSales'=>$goods['sales_tip']>0?$goods['sales_tip']:mt_rand(100,10000), //月销量
263 263
                     'cat_ids'=>$goods['cat_ids']
264 264
                 ];
265
-                Log::info($current_goods);
265
+                // Log::info($current_goods);
266 266
                 $goodsList[] =$current_goods;
267 267
                 $cid=isset($goods['cat_ids'][0])?$goods['cat_ids'][0]:0;
268 268
                 // Db::name("third_party_goods")->insert([
@@ -274,10 +274,10 @@ class TaoKe extends BaseController
274 274
             } catch (\Throwable $th) {
275 275
                 Log::error($th->getMessage());
276 276
             }
277
-            
277
+
278 278
 
279 279
         }
280
-        
280
+
281 281
         shuffle($goodsList);
282 282
         $uid = $uid ?? 0;
283 283
         $repository->sproductkeywordHistory($uid, $keyword, 3);
@@ -404,7 +404,7 @@ class TaoKe extends BaseController
404 404
 
405 405
     //获取多多进宝商品详情
406 406
     public function pdd_detail()
407
-    {       
407
+    {
408 408
         $goodsId = $this->request->param('goodsId');
409 409
         try{
410 410
             $uid = $this->request->uid();
@@ -412,10 +412,10 @@ class TaoKe extends BaseController
412 412
             $uid=0;
413 413
         }
414 414
 
415
-        log::info("===doGetPinDetail==={$goodsId}+======{$uid}");
415
+        // log::info("===doGetPinDetail==={$goodsId}+======{$uid}");
416 416
         //获取商品详情
417 417
         $result = $this->doGetPinDetail($goodsId, $uid);
418
-        log::info("===doGetPinDetail=={$uid}");
418
+        // log::info("===doGetPinDetail=={$uid}");
419 419
 //        log::info($result);
420 420
         $log = [
421 421
             'flag' => '拼多多详情',
@@ -450,7 +450,7 @@ class TaoKe extends BaseController
450 450
 
451 451
         $apiName = 'pdd.ddk.goods.detail';
452 452
         $result = $this->getUrlResult($apiName, $params);
453
-        Log::info($result);
453
+        // Log::info($result);
454 454
         if(isset($result['error_response']['error_code']) && $result['error_response']['error_code']==50001)
455 455
             return ['code' => 2, 'data' => '该商品已下架或不存在~'];
456 456
         $response = $result['goods_detail_response']['goods_details'] ?? [];
@@ -462,14 +462,14 @@ class TaoKe extends BaseController
462 462
         // $detail['yanglao'] = app()->make(ProductRepository::class)
463 463
         //     ->thirdYanglaojin(0, sprintf('%.2f', $commission));
464 464
 
465
-        log::info("commission==={$commission}");
465
+        // log::info("commission==={$commission}");
466 466
         $systemvalueObj= $goods_obj = Db::name('system_config_value')
467 467
             -> where('config_key','sanfangfenpei')->find();;
468 468
         $sanfangfenpei=json_decode($systemvalueObj['value'],true);
469 469
         $ppv=$commission*$sanfangfenpei['pv'];
470 470
         $pv3=round($ppv,3);  //PV
471 471
         $pv=round($ppv,2);  //PV
472
-        log::info("pv==={$pv}===========ppv3={$pv3}");
472
+        // log::info("pv==={$pv}===========ppv3={$pv3}");
473 473
         $yanglaojin=round($commission*$sanfangfenpei['yanglaojin'],2); //新的养老金
474 474
 
475 475
 
@@ -477,7 +477,7 @@ class TaoKe extends BaseController
477 477
 
478 478
 //            $pv=sprintf('%.2f', $commission *0.5);  //PV
479 479
 //            $yanglaojin=$pv; //新的养老金
480
-        
480
+
481 481
         $gongxian=$pv;
482 482
         $jifen=$pv;
483 483
         $detail['yanglaojin'] =$yanglaojin;
@@ -559,7 +559,7 @@ class TaoKe extends BaseController
559 559
             //mobile_short_url-唤醒拼多多app的推广短链接
560 560
             //we_app_web_view_short_url-唤起微信app推广短链接
561 561
             //short_url-web推广短链接
562
-            $shortUrl = $result['mobile_short_url'];
562
+            $shortUrl = $result['mobile_short_url'] ?? '';
563 563
             $wxUrl = $result['we_app_web_view_short_url'] ?? '';
564 564
             $url['mobile_url'] = $shortUrl;
565 565
             $url['url'] = $shortUrl;
@@ -901,12 +901,12 @@ class TaoKe extends BaseController
901 901
             if (empty($order)) continue;
902 902
             //判断数据库有无此订单
903 903
             $type_shop = 1;
904
-            log::info("pddsnsnsn==={$order['order_sn']}");
904
+            // log::info("pddsnsnsn==={$order['order_sn']}");
905 905
             $localOrder = PddOrderModel::getInstance()->getOne(['order_sn' => $order['order_sn']]);
906
-            log::info("localOrder========");
907
-            log::info($localOrder);
908
-            log::info("pddorder===");
909
-            log::info($localOrder);
906
+            // log::info("localOrder========");
907
+            // log::info($localOrder);
908
+            // log::info("pddorder===");
909
+            // log::info($localOrder);
910 910
             if (empty($localOrder)) {
911 911
                 //订单写入数据库,bill_end_time再格式化订单的时候已经加入,所以写入订单的时候就不需要在计算了
912 912
                 $localOrder = PddOrderModel::create($order);

+ 9 - 7
app/controller/api/store/product/Vip.php

@@ -308,11 +308,13 @@ class Vip extends BaseController
308 308
         if($_cid){
309 309
             $goods_obj=$goods_obj->where('cid', $_cid);
310 310
         }
311
+        $salt = (int)(time() / 100);
311 312
         $data=$goods_obj->page($page, $limit)
313
+            ->orderRaw("RAND({$salt})")
312 314
             ->select()->toArray();
313 315
 
314
-        Log::info("vip=================");
315
-        log::info($data);
316
+        // Log::info("vip=================");
317
+        // log::info($data);
316 318
 
317 319
         // 获取列表数据
318 320
         // $data = Db::name('third_party_goods')->where('type', 5)->page($page, $limit)->select()->toArray();
@@ -543,7 +545,7 @@ class Vip extends BaseController
543 545
             'realCall' => 'true',
544 546
         ];
545 547
 
546
-        log::info($requestIn);
548
+        // log::info($requestIn);
547 549
         $params['request'] = $requestIn;
548 550
         $result = $this->getUrlResult($apiName, "getByGoodsIds", $params);
549 551
 //        log::info($result);
@@ -761,8 +763,8 @@ class Vip extends BaseController
761 763
                     "{$value}TimeStart" => $startTime,
762 764
                     "{$value}TimeEnd" => $endTime,
763 765
                 ];
764
-                log::info("====VIP 订单===");
765
-                log::info($params);
766
+                // log::info("====VIP 订单===");
767
+                // log::info($params);
766 768
 
767 769
                 $result = $this->doOrderVip($params);
768 770
                 $result && $orderList[] = $result;
@@ -809,8 +811,8 @@ class Vip extends BaseController
809 811
         do {
810 812
             $request = ['queryModel' => $queryModel];
811 813
             $result = $this->getUrlResult($apiName, "orderList", $request, '2.0.0');
812
-            log::info("vip===返回订单数据");
813
-            log::info($result);
814
+            // log::info("vip===返回订单数据");
815
+            // log::info($result);
814 816
             $lists = $result['result']['orderInfoList'] ?? [];
815 817
             $countList = count($lists);
816 818
             if (!empty($countList)) {

+ 1 - 0
app/controller/api/store/service/Huafei.php

@@ -162,6 +162,7 @@ class Huafei extends BaseController
162 162
 
163 163
     //充值话费推送
164 164
     public function recharge(){
165
+        return app('json')->fail('系统维护中');
165 166
 		$uid = $this->request->uid();
166 167
 		$params = $this->request->params(['phone', 'money']);
167 168
 		if(!$params['phone']) return app('json')->fail('请提交电话号码');

+ 7 - 7
app/controller/api/user/User.php

@@ -200,14 +200,14 @@ class User extends BaseController
200 200
 
201 201
     // 红包
202 202
     public function  hongbao_info(){
203
-        log::info("============hongbao");
203
+        // log::info("============hongbao");
204 204
         $user = $this->request->userInfo();
205 205
         if($user->uid>0){
206 206
             // 已经入账红包
207 207
             $data['total_source']=$user->hongbao;
208 208
             // 为生效红包
209 209
             $data['no_total_source']=Db::name('user_sign_hongbao')->where('status', -1)->where('uid', $user->uid)->sum('number');;
210
-            log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
210
+            // log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
211 211
             return app('json')->success($data);
212 212
 
213 213
         }
@@ -408,7 +408,7 @@ class User extends BaseController
408 408
 
409 409
             // 未生效贡献值
410 410
             $data['no_total_source']=Db::name('user_sign_gongxian')->where('status', -1)->where('uid', $user->uid)->sum('number');
411
-            log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
411
+            // log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
412 412
             return app('json')->success($data);
413 413
         }
414 414
 
@@ -481,7 +481,7 @@ class User extends BaseController
481 481
             $data['total_source'] = $user->jingdou;// 临时使用
482 482
             // 为生效京豆
483 483
             $data['no_total_source']=Db::name('user_sign_jingdou')->where('status', -1)->where('uid', $user->uid)->sum('number');;
484
-            log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
484
+            // log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
485 485
 
486 486
             return app('json')->success($data);
487 487
 
@@ -530,7 +530,7 @@ class User extends BaseController
530 530
             $data['total_source']=$user->fugou;
531 531
             // 为生效京豆
532 532
             $data['no_total_source']=Db::name('user_sign_fugou')->where('status', -1)->where('uid', $user->uid)->sum('number');;
533
-            log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
533
+            // log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
534 534
             return app('json')->success($data);
535 535
 
536 536
         }
@@ -577,7 +577,7 @@ class User extends BaseController
577 577
             // 为生效京豆
578 578
             $data['no_total_source']=0;
579 579
             //$data['no_total_source']=Db::name('user_sign_vr')->where('status', -1)->where('uid', $user->uid)->sum('number');;
580
-            log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
580
+            // log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
581 581
             return app('json')->success($data);
582 582
 
583 583
         }
@@ -618,7 +618,7 @@ class User extends BaseController
618 618
             $data['total_source']=$user->score;
619 619
             // 为生效积分
620 620
             $data['no_total_source']=Db::name('user_sign_score')->where('status', -1)->where('uid', $user->uid)->sum('reward_socre');;
621
-            log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
621
+            // log::info("====spread_info_yhc=={$data['total_source']}======={$data['no_total_source']}");
622 622
             return app('json')->success($data);
623 623
 
624 624
         }

+ 7 - 1
app/controller/merchant/gong/Goods.php

@@ -253,7 +253,13 @@ class Goods extends BaseController
253 253
             $spuId_info = json_decode($data['spuId_info'], true);
254 254
             $slider_image = $spuId_info['detail_img_list'] ?? '';
255 255
             $image = $spuId_info['cover_url'] ?? '';
256
-            $slider_image = empty($slider_image) ? $image : implode(',', json_decode($slider_image, true));
256
+            if (empty($slider_image)) {
257
+                $slider_image = $image;
258
+            } else if (is_string($slider_image)) {
259
+                $slider_image = implode(',', json_decode($slider_image, true));
260
+            } else if (is_array($slider_image)) {
261
+                $slider_image = implode(',', $slider_image);
262
+            }
257 263
             $yanglaojin_scale = (!empty($data['pension']) && !empty($data['market_price'])) ? bcdiv($data['pension'], $data['market_price'], 2) : 0;
258 264
 
259 265
             // 4、商品入库数据

+ 3 - 2
app/controller/merchant/store/product/Product.php

@@ -78,11 +78,12 @@ class Product extends BaseController
78 78
     {
79 79
         $skuArr = $this->request->param('skuArr', []);
80 80
         $type = $this->request->param('type');
81
+        $merchant_admin_id = $this->request->adminInfo()?$this->request->adminInfo()->merchant_admin_id:0;
81 82
 
82 83
         if (empty($skuArr) ||  !is_array($skuArr)) {
83 84
             return app('json')->fail('参数错误');
84 85
         }
85
-        $this->repository->editPrice($id, $skuArr, $type);
86
+        $this->repository->editPrice($id, $skuArr, $type, $merchant_admin_id);
86 87
         return app('json')->success("修改成功");
87 88
     }
88 89
 
@@ -90,7 +91,7 @@ class Product extends BaseController
90 91
     // 供应链商品删除
91 92
     public function deleteXp($id) {
92 93
         if (empty($id)) return app('json')->fail('请选择商品');
93
-        $this->repository->changeDelete($id,);
94
+        $this->repository->changeDelete($id);
94 95
         return app('json')->success('删除成功');
95 96
     }
96 97
 

+ 344 - 0
app/entity/data/dividend/DividendLogEntity.php

@@ -0,0 +1,344 @@
1
+<?php
2
+
3
+namespace app\entity\data\dividend;
4
+
5
+use app\entity\data\DataEntity;
6
+
7
+class DividendLogEntity extends DataEntity
8
+{
9
+    public $id = null;  // 主键
10
+    public $type = null;  // 分润类型:1合伙人分红;2联创分红;3股权分红;4佣金补贴
11
+    public $startTime = null;  // 分润周期开始时间
12
+    public $endTime = null;  // 分润周期结束时间
13
+    public $performance = null;  // 业绩
14
+    public $abatement = null;  // 扣减项(原因)
15
+    public $allocated = null;  // 实际分配业绩
16
+    public $rule = null;  // 分配规则
17
+    public $expected = null;
18
+    public $feeWaiverUids = null;  // 免分配人员ID集合(可能由于业绩不达标)
19
+    public $arrivalPoint = null;  // 到账金额
20
+    public $arrivalInfo = null;  // 到账金额
21
+    public $result = null;  // 实际分配结果
22
+    public $isTest = null;  // 是否为测试数据
23
+    public $remark = null;  // 备注
24
+    public $createTime = null;  // 创建时间
25
+    public $reissueId = null;  // 补发ID
26
+
27
+    /**
28
+     * @return mixed
29
+     */
30
+    public function getId()
31
+    {
32
+        return $this->id;
33
+    }
34
+
35
+    /**
36
+     * @param mixed $id
37
+     * @return DividendLogEntity
38
+     */
39
+    public function setId($id): DividendLogEntity
40
+    {
41
+        $this->id = $id;
42
+        return $this;
43
+    }
44
+
45
+    /**
46
+     * @return mixed
47
+     */
48
+    public function getType()
49
+    {
50
+        return $this->type;
51
+    }
52
+
53
+    /**
54
+     * @param mixed $type
55
+     * @return DividendLogEntity
56
+     */
57
+    public function setType($type): DividendLogEntity
58
+    {
59
+        $this->type = $type;
60
+        return $this;
61
+    }
62
+
63
+    /**
64
+     * @return mixed
65
+     */
66
+    public function getStartTime()
67
+    {
68
+        return $this->startTime;
69
+    }
70
+
71
+    /**
72
+     * @param mixed $startTime
73
+     * @return DividendLogEntity
74
+     */
75
+    public function setStartTime($startTime): DividendLogEntity
76
+    {
77
+        $this->startTime = $startTime;
78
+        return $this;
79
+    }
80
+
81
+    /**
82
+     * @return mixed
83
+     */
84
+    public function getEndTime()
85
+    {
86
+        return $this->endTime;
87
+    }
88
+
89
+    /**
90
+     * @param mixed $endTime
91
+     * @return DividendLogEntity
92
+     */
93
+    public function setEndTime($endTime): DividendLogEntity
94
+    {
95
+        $this->endTime = $endTime;
96
+        return $this;
97
+    }
98
+
99
+    /**
100
+     * @return mixed
101
+     */
102
+    public function getPerformance()
103
+    {
104
+        return $this->performance;
105
+    }
106
+
107
+    /**
108
+     * @param mixed $performance
109
+     * @return DividendLogEntity
110
+     */
111
+    public function setPerformance($performance): DividendLogEntity
112
+    {
113
+        $this->performance = $performance;
114
+        return $this;
115
+    }
116
+
117
+    /**
118
+     * @return mixed
119
+     */
120
+    public function getAbatement()
121
+    {
122
+        return $this->abatement;
123
+    }
124
+
125
+    /**
126
+     * @param mixed $abatement
127
+     * @return DividendLogEntity
128
+     */
129
+    public function setAbatement($abatement): DividendLogEntity
130
+    {
131
+        $this->abatement = $abatement;
132
+        return $this;
133
+    }
134
+
135
+    /**
136
+     * @return mixed
137
+     */
138
+    public function getAllocated()
139
+    {
140
+        return $this->allocated;
141
+    }
142
+
143
+    /**
144
+     * @param mixed $allocated
145
+     * @return DividendLogEntity
146
+     */
147
+    public function setAllocated($allocated): DividendLogEntity
148
+    {
149
+        $this->allocated = $allocated;
150
+        return $this;
151
+    }
152
+
153
+    /**
154
+     * @return mixed
155
+     */
156
+    public function getRule()
157
+    {
158
+        return $this->rule;
159
+    }
160
+
161
+    /**
162
+     * @param mixed $rule
163
+     * @return DividendLogEntity
164
+     */
165
+    public function setRule($rule): DividendLogEntity
166
+    {
167
+        $this->rule = $rule;
168
+        return $this;
169
+    }
170
+
171
+    /**
172
+     * @return mixed
173
+     */
174
+    public function getExpected()
175
+    {
176
+        return $this->expected;
177
+    }
178
+
179
+    /**
180
+     * @param mixed $expected
181
+     * @return DividendLogEntity
182
+     */
183
+    public function setExpected($expected): DividendLogEntity
184
+    {
185
+        $this->expected = $expected;
186
+        return $this;
187
+    }
188
+
189
+    /**
190
+     * @return mixed
191
+     */
192
+    public function getFeeWaiverUids()
193
+    {
194
+        if (is_string($this->feeWaiverUids)) {
195
+            return json_decode($this->feeWaiverUids, true);
196
+        }
197
+        return $this->feeWaiverUids;
198
+    }
199
+
200
+    /**
201
+     * @param mixed $feeWaiverUids
202
+     * @return DividendLogEntity
203
+     */
204
+    public function setFeeWaiverUids($feeWaiverUids): DividendLogEntity
205
+    {
206
+        if (is_array($feeWaiverUids)) {
207
+            $feeWaiverUids = json_encode($feeWaiverUids);
208
+        }
209
+        $this->feeWaiverUids = $feeWaiverUids;
210
+        return $this;
211
+    }
212
+
213
+    /**
214
+     * @return mixed
215
+     */
216
+    public function getArrivalPoint()
217
+    {
218
+        return $this->arrivalPoint;
219
+    }
220
+
221
+    /**
222
+     * @param mixed $arrivalPoint
223
+     * @return DividendLogEntity
224
+     */
225
+    public function setArrivalPoint($arrivalPoint): DividendLogEntity
226
+    {
227
+        $this->arrivalPoint = $arrivalPoint;
228
+        return $this;
229
+    }
230
+
231
+    /**
232
+     * @return mixed
233
+     */
234
+    public function getArrivalInfo()
235
+    {
236
+        if (is_string($this->arrivalInfo)) {
237
+            return json_decode($this->arrivalInfo, true);
238
+        }
239
+        return $this->arrivalInfo;
240
+    }
241
+
242
+    /**
243
+     * @param mixed $arrivalInfo
244
+     * @return DividendLogEntity
245
+     */
246
+    public function setArrivalInfo($arrivalInfo): DividendLogEntity
247
+    {
248
+        if (is_array($arrivalInfo)) {
249
+            $arrivalInfo = json_encode($arrivalInfo);
250
+        }
251
+        $this->arrivalInfo = $arrivalInfo;
252
+        return $this;
253
+    }
254
+
255
+    /**
256
+     * @return mixed
257
+     */
258
+    public function getResult()
259
+    {
260
+        return $this->result;
261
+    }
262
+
263
+    /**
264
+     * @param mixed $result
265
+     * @return DividendLogEntity
266
+     */
267
+    public function setResult($result): DividendLogEntity
268
+    {
269
+        $this->result = $result;
270
+        return $this;
271
+    }
272
+
273
+    /**
274
+     * @return mixed
275
+     */
276
+    public function getIsTest()
277
+    {
278
+        return $this->isTest;
279
+    }
280
+
281
+    /**
282
+     * @param mixed $isTest
283
+     * @return DividendLogEntity
284
+     */
285
+    public function setIsTest($isTest): DividendLogEntity
286
+    {
287
+        $this->isTest = $isTest;
288
+        return $this;
289
+    }
290
+
291
+    /**
292
+     * @return mixed
293
+     */
294
+    public function getRemark()
295
+    {
296
+        return $this->remark;
297
+    }
298
+
299
+    /**
300
+     * @param mixed $remark
301
+     * @return DividendLogEntity
302
+     */
303
+    public function setRemark($remark): DividendLogEntity
304
+    {
305
+        $this->remark = $remark;
306
+        return $this;
307
+    }
308
+
309
+    /**
310
+     * @return mixed
311
+     */
312
+    public function getCreateTime()
313
+    {
314
+        return $this->createTime;
315
+    }
316
+
317
+    /**
318
+     * @param mixed $createTime
319
+     * @return DividendLogEntity
320
+     */
321
+    public function setCreateTime($createTime): DividendLogEntity
322
+    {
323
+        $this->createTime = $createTime;
324
+        return $this;
325
+    }
326
+
327
+    /**
328
+     * @return mixed
329
+     */
330
+    public function getReissueId()
331
+    {
332
+        return $this->reissueId;
333
+    }
334
+
335
+    /**
336
+     * @param mixed $reissueId
337
+     * @return DividendLogEntity
338
+     */
339
+    public function setReissueId($reissueId): DividendLogEntity
340
+    {
341
+        $this->reissueId = $reissueId;
342
+        return $this;
343
+    }
344
+}

+ 110 - 0
app/entity/data/douhuomall/DouhuomallChangeLogEntity.php

@@ -0,0 +1,110 @@
1
+<?php
2
+
3
+namespace app\entity\data\douhuomall;
4
+
5
+use app\entity\data\DataEntity;
6
+
7
+class DouhuomallChangeLogEntity extends DataEntity
8
+{
9
+    public $id = null;  // 主键ID
10
+    public $spuId = null;  // spuID
11
+    public $dataJson = null;  // 历史数据信息
12
+    public $effectProductJson = null;  // 供应链sku_id
13
+    public $createTime = null;  // 记录时间
14
+
15
+    /**
16
+     * @return mixed
17
+     */
18
+    public function getId()
19
+    {
20
+        return $this->id;
21
+    }
22
+
23
+    /**
24
+     * @param mixed $id
25
+     * @return DouhuomallChangeLogEntity
26
+     */
27
+    public function setId($id): DouhuomallChangeLogEntity
28
+    {
29
+        $this->id = $id;
30
+        return $this;
31
+    }
32
+
33
+    /**
34
+     * @return mixed
35
+     */
36
+    public function getSpuId()
37
+    {
38
+        return $this->spuId;
39
+    }
40
+
41
+    /**
42
+     * @param mixed $spuId
43
+     * @return DouhuomallChangeLogEntity
44
+     */
45
+    public function setSpuId($spuId): DouhuomallChangeLogEntity
46
+    {
47
+        $this->spuId = $spuId;
48
+        return $this;
49
+    }
50
+
51
+    /**
52
+     * @return mixed
53
+     */
54
+    public function getDataJson()
55
+    {
56
+        return $this->dataJson;
57
+    }
58
+
59
+    /**
60
+     * @param mixed $dataJson
61
+     * @return DouhuomallChangeLogEntity
62
+     */
63
+    public function setDataJson($dataJson): DouhuomallChangeLogEntity
64
+    {
65
+        if (is_array($dataJson)) {
66
+            $dataJson = json_encode($dataJson, JSON_UNESCAPED_UNICODE);
67
+        }
68
+        $this->dataJson = $dataJson;
69
+        return $this;
70
+    }
71
+
72
+    /**
73
+     * @return mixed
74
+     */
75
+    public function getEffectProductJson()
76
+    {
77
+        return $this->effectProductJson;
78
+    }
79
+
80
+    /**
81
+     * @param mixed $effectProductJson
82
+     * @return DouhuomallChangeLogEntity
83
+     */
84
+    public function setEffectProductJson($effectProductJson): DouhuomallChangeLogEntity
85
+    {
86
+        if (is_array($effectProductJson)) {
87
+            $effectProductJson = json_encode($effectProductJson, JSON_UNESCAPED_UNICODE);
88
+        }
89
+        $this->effectProductJson = $effectProductJson;
90
+        return $this;
91
+    }
92
+
93
+    /**
94
+     * @return mixed
95
+     */
96
+    public function getCreateTime()
97
+    {
98
+        return $this->createTime;
99
+    }
100
+
101
+    /**
102
+     * @param mixed $createTime
103
+     * @return DouhuomallChangeLogEntity
104
+     */
105
+    public function setCreateTime($createTime): DouhuomallChangeLogEntity
106
+    {
107
+        $this->createTime = $createTime;
108
+        return $this;
109
+    }
110
+}

+ 158 - 0
app/entity/data/shared/SharedProsperityRecommendConfigEntity.php

@@ -0,0 +1,158 @@
1
+<?php
2
+
3
+namespace app\entity\data\shared;
4
+
5
+use app\entity\data\DataEntity;
6
+
7
+class SharedProsperityRecommendConfigEntity extends DataEntity
8
+{
9
+    public $id = null;  // 主键
10
+    public $level = null;  // 等级
11
+    public $name = null;  // 描述
12
+    public $rewardRatio = null;  // 推荐奖励占比
13
+    public $profitRatio = null;  // 分红奖励占比
14
+    public $pv = null;  // 业绩
15
+    public $createTime = null;  // 创建时间
16
+    public $updateTime = null;  // 更新时间
17
+
18
+    /**
19
+     * @return mixed
20
+     */
21
+    public function getId()
22
+    {
23
+        return $this->id;
24
+    }
25
+
26
+    /**
27
+     * @param mixed $id
28
+     * @return SharedProsperityRecommendConfigEntity
29
+     */
30
+    public function setId($id): SharedProsperityRecommendConfigEntity
31
+    {
32
+        $this->id = $id;
33
+        return $this;
34
+    }
35
+
36
+    /**
37
+     * @return mixed
38
+     */
39
+    public function getLevel()
40
+    {
41
+        return $this->level;
42
+    }
43
+
44
+    /**
45
+     * @param mixed $level
46
+     * @return SharedProsperityRecommendConfigEntity
47
+     */
48
+    public function setLevel($level): SharedProsperityRecommendConfigEntity
49
+    {
50
+        $this->level = $level;
51
+        return $this;
52
+    }
53
+
54
+    /**
55
+     * @return mixed
56
+     */
57
+    public function getName()
58
+    {
59
+        return $this->name;
60
+    }
61
+
62
+    /**
63
+     * @param mixed $name
64
+     * @return SharedProsperityRecommendConfigEntity
65
+     */
66
+    public function setName($name): SharedProsperityRecommendConfigEntity
67
+    {
68
+        $this->name = $name;
69
+        return $this;
70
+    }
71
+
72
+    /**
73
+     * @return mixed
74
+     */
75
+    public function getRewardRatio()
76
+    {
77
+        return $this->rewardRatio;
78
+    }
79
+
80
+    public function getProfitRatio()
81
+    {
82
+        return $this->profitRatio;
83
+    }
84
+
85
+    /**
86
+     * @param mixed $rewardRatio
87
+     * @return SharedProsperityRecommendConfigEntity
88
+     */
89
+    public function setRewardRatio($rewardRatio): SharedProsperityRecommendConfigEntity
90
+    {
91
+        $this->rewardRatio = $rewardRatio;
92
+        return $this;
93
+    }
94
+
95
+    /**
96
+     * @param mixed $profitRatio
97
+     * @return SharedProsperityRecommendConfigEntity
98
+     */
99
+    public function setProfitRatio($profitRatio): SharedProsperityRecommendConfigEntity
100
+    {
101
+        $this->profitRatio = $profitRatio;
102
+        return $this;
103
+    }
104
+
105
+    /**
106
+     * @return mixed
107
+     */
108
+    public function getPv()
109
+    {
110
+        return $this->pv;
111
+    }
112
+
113
+    /**
114
+     * @param mixed $pv
115
+     * @return SharedProsperityRecommendConfigEntity
116
+     */
117
+    public function setPv($pv): SharedProsperityRecommendConfigEntity
118
+    {
119
+        $this->pv = $pv;
120
+        return $this;
121
+    }
122
+
123
+    /**
124
+     * @return mixed
125
+     */
126
+    public function getCreateTime()
127
+    {
128
+        return $this->createTime;
129
+    }
130
+
131
+    /**
132
+     * @param mixed $createTime
133
+     * @return SharedProsperityRecommendConfigEntity
134
+     */
135
+    public function setCreateTime($createTime): SharedProsperityRecommendConfigEntity
136
+    {
137
+        $this->createTime = $createTime;
138
+        return $this;
139
+    }
140
+
141
+    /**
142
+     * @return mixed
143
+     */
144
+    public function getUpdateTime()
145
+    {
146
+        return $this->updateTime;
147
+    }
148
+
149
+    /**
150
+     * @param mixed $updateTime
151
+     * @return SharedProsperityRecommendConfigEntity
152
+     */
153
+    public function setUpdateTime($updateTime): SharedProsperityRecommendConfigEntity
154
+    {
155
+        $this->updateTime = $updateTime;
156
+        return $this;
157
+    }
158
+}

+ 180 - 0
app/entity/data/shared/SharedProsperityUserEntity.php

@@ -0,0 +1,180 @@
1
+<?php
2
+
3
+namespace app\entity\data\shared;
4
+
5
+use app\entity\data\DataEntity;
6
+
7
+class SharedProsperityUserEntity extends DataEntity
8
+{
9
+    public $id = null;  // 主键
10
+    public $userId = null;  // 用户id
11
+    public $parentId = null;  // 推荐人用户id
12
+    public $pv = null;  // pv
13
+    public $teamPv = null;  // 团队pv
14
+    public $withdrawalLimit = null;  // 提现额度
15
+    public $partnerLevel = null;  // 合伙人等级
16
+    public $createTime = null;  // 创建时间
17
+    public $updateTime = null;  // 更新时间
18
+
19
+    /**
20
+     * @return mixed
21
+     */
22
+    public function getId()
23
+    {
24
+        return $this->id;
25
+    }
26
+
27
+    /**
28
+     * @param mixed $id
29
+     * @return SharedProsperityUserEntity
30
+     */
31
+    public function setId($id): SharedProsperityUserEntity
32
+    {
33
+        $this->id = $id;
34
+        return $this;
35
+    }
36
+
37
+    /**
38
+     * @return mixed
39
+     */
40
+    public function getUserId()
41
+    {
42
+        return $this->userId;
43
+    }
44
+
45
+    /**
46
+     * @param mixed $userId
47
+     * @return SharedProsperityUserEntity
48
+     */
49
+    public function setUserId($userId): SharedProsperityUserEntity
50
+    {
51
+        $this->userId = $userId;
52
+        return $this;
53
+    }
54
+
55
+    /**
56
+     * @return mixed
57
+     */
58
+    public function getParentId()
59
+    {
60
+        return $this->parentId;
61
+    }
62
+
63
+    /**
64
+     * @param mixed $parentId
65
+     * @return SharedProsperityUserEntity
66
+     */
67
+    public function setParentId($parentId): SharedProsperityUserEntity
68
+    {
69
+        $this->parentId = $parentId;
70
+        return $this;
71
+    }
72
+
73
+    /**
74
+     * @return mixed
75
+     */
76
+    public function getPv()
77
+    {
78
+        return $this->pv;
79
+    }
80
+
81
+    /**
82
+     * @param mixed $pv
83
+     * @return SharedProsperityUserEntity
84
+     */
85
+    public function setPv($pv): SharedProsperityUserEntity
86
+    {
87
+        $this->pv = $pv;
88
+        return $this;
89
+    }
90
+
91
+    /**
92
+     * @return mixed
93
+     */
94
+    public function getTeamPv()
95
+    {
96
+        return $this->teamPv;
97
+    }
98
+
99
+    /**
100
+     * @param mixed $teamPv
101
+     * @return SharedProsperityUserEntity
102
+     */
103
+    public function setTeamPv($teamPv): SharedProsperityUserEntity
104
+    {
105
+        $this->teamPv = $teamPv;
106
+        return $this;
107
+    }
108
+
109
+    /**
110
+     * @return mixed
111
+     */
112
+    public function getWithdrawalLimit()
113
+    {
114
+        return $this->withdrawalLimit;
115
+    }
116
+
117
+    /**
118
+     * @param mixed $withdrawalLimit
119
+     * @return SharedProsperityUserEntity
120
+     */
121
+    public function setWithdrawalLimit($withdrawalLimit): SharedProsperityUserEntity
122
+    {
123
+        $this->withdrawalLimit = $withdrawalLimit;
124
+        return $this;
125
+    }
126
+
127
+    /**
128
+     * @return mixed
129
+     */
130
+    public function getPartnerLevel()
131
+    {
132
+        return $this->partnerLevel;
133
+    }
134
+
135
+    /**
136
+     * @param mixed $partnerLevel
137
+     * @return SharedProsperityUserEntity
138
+     */
139
+    public function setPartnerLevel($partnerLevel): SharedProsperityUserEntity
140
+    {
141
+        $this->partnerLevel = $partnerLevel;
142
+        return $this;
143
+    }
144
+
145
+    /**
146
+     * @return mixed
147
+     */
148
+    public function getCreateTime()
149
+    {
150
+        return $this->createTime;
151
+    }
152
+
153
+    /**
154
+     * @param mixed $createTime
155
+     * @return SharedProsperityUserEntity
156
+     */
157
+    public function setCreateTime($createTime): SharedProsperityUserEntity
158
+    {
159
+        $this->createTime = $createTime;
160
+        return $this;
161
+    }
162
+
163
+    /**
164
+     * @return mixed
165
+     */
166
+    public function getUpdateTime()
167
+    {
168
+        return $this->updateTime;
169
+    }
170
+
171
+    /**
172
+     * @param mixed $updateTime
173
+     * @return SharedProsperityUserEntity
174
+     */
175
+    public function setUpdateTime($updateTime): SharedProsperityUserEntity
176
+    {
177
+        $this->updateTime = $updateTime;
178
+        return $this;
179
+    }
180
+}

+ 180 - 0
app/entity/data/store/StoreProductAttrValueChangeLogEntity.php

@@ -0,0 +1,180 @@
1
+<?php
2
+
3
+namespace app\entity\data\store;
4
+
5
+use app\entity\data\DataEntity;
6
+
7
+class StoreProductAttrValueChangeLogEntity extends DataEntity
8
+{
9
+    public $id = null;  // 主键ID
10
+    public $productId = null;  // 商品ID
11
+    public $skuId = null;  // 供应链sku_id
12
+    public $cost = null;  // 成本价
13
+    public $otPrice = null;  // 原价
14
+    public $price = null;  // 价格
15
+    public $plateMerProfit = null;  // 商户创客利润
16
+    public $operatorId = null;  // 操作人ID
17
+    public $createTime = null;  // 记录时间
18
+
19
+    /**
20
+     * @return mixed
21
+     */
22
+    public function getId()
23
+    {
24
+        return $this->id;
25
+    }
26
+
27
+    /**
28
+     * @param mixed $id
29
+     * @return StoreProductAttrValueChangeLogEntity
30
+     */
31
+    public function setId($id): StoreProductAttrValueChangeLogEntity
32
+    {
33
+        $this->id = $id;
34
+        return $this;
35
+    }
36
+
37
+    /**
38
+     * @return mixed
39
+     */
40
+    public function getProductId()
41
+    {
42
+        return $this->productId;
43
+    }
44
+
45
+    /**
46
+     * @param mixed $productId
47
+     * @return StoreProductAttrValueChangeLogEntity
48
+     */
49
+    public function setProductId($productId): StoreProductAttrValueChangeLogEntity
50
+    {
51
+        $this->productId = $productId;
52
+        return $this;
53
+    }
54
+
55
+    /**
56
+     * @return mixed
57
+     */
58
+    public function getSkuId()
59
+    {
60
+        return $this->skuId;
61
+    }
62
+
63
+    /**
64
+     * @param mixed $skuId
65
+     * @return StoreProductAttrValueChangeLogEntity
66
+     */
67
+    public function setSkuId($skuId): StoreProductAttrValueChangeLogEntity
68
+    {
69
+        $this->skuId = $skuId;
70
+        return $this;
71
+    }
72
+
73
+    /**
74
+     * @return mixed
75
+     */
76
+    public function getCost()
77
+    {
78
+        return $this->cost;
79
+    }
80
+
81
+    /**
82
+     * @param mixed $cost
83
+     * @return StoreProductAttrValueChangeLogEntity
84
+     */
85
+    public function setCost($cost): StoreProductAttrValueChangeLogEntity
86
+    {
87
+        $this->cost = $cost;
88
+        return $this;
89
+    }
90
+
91
+    /**
92
+     * @return mixed
93
+     */
94
+    public function getOtPrice()
95
+    {
96
+        return $this->otPrice;
97
+    }
98
+
99
+    /**
100
+     * @param mixed $otPrice
101
+     * @return StoreProductAttrValueChangeLogEntity
102
+     */
103
+    public function setOtPrice($otPrice): StoreProductAttrValueChangeLogEntity
104
+    {
105
+        $this->otPrice = $otPrice;
106
+        return $this;
107
+    }
108
+
109
+    /**
110
+     * @return mixed
111
+     */
112
+    public function getPrice()
113
+    {
114
+        return $this->price;
115
+    }
116
+
117
+    /**
118
+     * @param mixed $price
119
+     * @return StoreProductAttrValueChangeLogEntity
120
+     */
121
+    public function setPrice($price): StoreProductAttrValueChangeLogEntity
122
+    {
123
+        $this->price = $price;
124
+        return $this;
125
+    }
126
+
127
+    /**
128
+     * @return mixed
129
+     */
130
+    public function getPlateMerProfit()
131
+    {
132
+        return $this->plateMerProfit;
133
+    }
134
+
135
+    /**
136
+     * @param mixed $plateMerProfit
137
+     * @return StoreProductAttrValueChangeLogEntity
138
+     */
139
+    public function setPlateMerProfit($plateMerProfit): StoreProductAttrValueChangeLogEntity
140
+    {
141
+        $this->plateMerProfit = $plateMerProfit;
142
+        return $this;
143
+    }
144
+
145
+    /**
146
+     * @return mixed
147
+     */
148
+    public function getOperatorId()
149
+    {
150
+        return $this->operatorId;
151
+    }
152
+
153
+    /**
154
+     * @param mixed $operatorId
155
+     * @return StoreProductAttrValueChangeLogEntity
156
+     */
157
+    public function setOperatorId($operatorId): StoreProductAttrValueChangeLogEntity
158
+    {
159
+        $this->operatorId = $operatorId;
160
+        return $this;
161
+    }
162
+
163
+    /**
164
+     * @return mixed
165
+     */
166
+    public function getCreateTime()
167
+    {
168
+        return $this->createTime;
169
+    }
170
+
171
+    /**
172
+     * @param mixed $createTime
173
+     * @return StoreProductAttrValueChangeLogEntity
174
+     */
175
+    public function setCreateTime($createTime): StoreProductAttrValueChangeLogEntity
176
+    {
177
+        $this->createTime = $createTime;
178
+        return $this;
179
+    }
180
+}

+ 1 - 1
app/event.php

@@ -19,7 +19,7 @@ return [
19 19
             \crmeb\listens\AutoUnLockBrokerageListen::class,//自动解冻佣金
20 20
             \crmeb\listens\AutoSendPayOrderSmsListen::class,//查询10分钟内未支付的订单,发送短信提示用户
21 21
             \crmeb\listens\SyncSmsResultCodeListen::class,//查询短信发送记录后 api返回结果
22
-            \crmeb\listens\SyncBroadcastStatusListen::class,
22
+            // \crmeb\listens\SyncBroadcastStatusListen::class,
23 23
             \crmeb\listens\ExcelFileDelListen::class,
24 24
 //            \crmeb\listens\RefundOrderAgreeListen::class,//商户自动处理退款订单期限(天)
25 25
             \crmeb\listens\SeckillTImeCheckListen::class,//自动检测秒杀结束失败

+ 3 - 1
app/middleware.php

@@ -3,7 +3,9 @@
3 3
 return [
4 4
     // 接口请求记录中间件
5 5
     \app\middleware\ApiRequestLogMiddleware::class,
6
-    
6
+    // 安全中间件 防注入
7
+    \app\middleware\SecurityMiddleware::class,
8
+
7 9
     // 全局请求缓存
8 10
     // \think\middleware\CheckRequestCache::class,
9 11
     // 多语言加载

+ 509 - 0
app/middleware/SecurityMiddleware.php

@@ -0,0 +1,509 @@
1
+<?php
2
+
3
+declare(strict_types=1);
4
+
5
+namespace app\middleware;
6
+
7
+use think\facade\Db;
8
+use think\facade\Log;
9
+use think\facade\Cache;
10
+use think\Request;
11
+use think\Response;
12
+
13
+/**
14
+ * 安全防护中间件
15
+ */
16
+class SecurityMiddleware
17
+{
18
+    // 配置参数
19
+    protected $config = [
20
+        'enable_logging' => true,        // 是否记录攻击日志
21
+        'enable_blocking' => true,       // 是否自动封禁攻击IP
22
+        'max_param_length' => 500,       // 参数最大长度(超过部分截断)
23
+        'max_logs_per_ip' => 100,        // 单个IP最大攻击记录数
24
+        'block_duration' => 86400,       // 封禁时长(秒),默认24小时
25
+        'attack_threshold' => 10,        // 攻击阈值(超过此次数自动封禁)
26
+    ];
27
+
28
+    /**
29
+     * 处理请求
30
+     */
31
+    public function handle(Request $request, \Closure $next)
32
+    {
33
+        // 检查IP是否已被封禁
34
+        if ($this->isIpBlocked($request->ip())) {
35
+            $this->logBlockedAccess($request);
36
+            return $this->blockResponse();
37
+        }
38
+
39
+        // 安全检查
40
+        $attackDetected = $this->checkSecurity($request);
41
+
42
+        if ($attackDetected) {
43
+            // 记录攻击并可能封禁IP
44
+            $this->handleAttack($request, $attackDetected);
45
+
46
+            // 返回通用错误,不泄露信息
47
+            return $this->errorResponse();
48
+        }
49
+
50
+        return $next($request);
51
+    }
52
+
53
+    /**
54
+     * 安全检查
55
+     */
56
+    protected function checkSecurity(Request $request): array
57
+    {
58
+        $attacks = [];
59
+
60
+        // 检查GET参数
61
+        foreach ($request->get() as $key => $value) {
62
+            if ($this->detectAttack($value, $key)) {
63
+                $attacks[] = [
64
+                    'type' => $this->detectAttackType($value),
65
+                    'param' => $key,
66
+                    'value' => $value
67
+                ];
68
+            }
69
+        }
70
+
71
+        // 检查POST参数
72
+        foreach ($request->post() as $key => $value) {
73
+            if ($this->detectAttack($value, $key)) {
74
+                $attacks[] = [
75
+                    'type' => $this->detectAttackType($value),
76
+                    'param' => $key,
77
+                    'value' => $value
78
+                ];
79
+            }
80
+        }
81
+
82
+        // 检查请求头(可选)
83
+        if ($this->checkHeaders($request)) {
84
+            $attacks[] = [
85
+                'type' => 'header_injection',
86
+                'param' => 'headers',
87
+                'value' => json_encode($request->header(), JSON_UNESCAPED_UNICODE)
88
+            ];
89
+        }
90
+
91
+        return $attacks;
92
+    }
93
+
94
+    /**
95
+     * 检测攻击
96
+     */
97
+    protected function detectAttack($value, $key): bool
98
+    {
99
+        if (!is_string($value)) {
100
+            return false;
101
+        }
102
+
103
+        // 检查SQL注入
104
+        if ($this->detectSqlInjection($value)) {
105
+            return true;
106
+        }
107
+
108
+        // 检查XSS攻击
109
+        if ($this->detectXss($value)) {
110
+            return true;
111
+        }
112
+
113
+        // 检查命令注入
114
+        if ($this->detectCommandInjection($value)) {
115
+            return true;
116
+        }
117
+
118
+        // 检查路径遍历
119
+        if ($this->detectPathTraversal($value)) {
120
+            return true;
121
+        }
122
+
123
+        // 检查文件包含
124
+        if ($this->detectFileInclusion($value)) {
125
+            return true;
126
+        }
127
+
128
+        return false;
129
+    }
130
+
131
+    /**
132
+     * 检测SQL注入
133
+     */
134
+    protected function detectSqlInjection(string $input): bool
135
+    {
136
+        $patterns = [
137
+            // Union注入
138
+            '/union\s+(all\s+)?select/i',
139
+
140
+            // 注释符
141
+            '/--\s+|\/\*.*?\*\//s',
142
+
143
+            // 延时注入
144
+            '/sleep\s*\(\s*\d+\s*\)/i',
145
+            '/benchmark\s*\(.*?\)/i',
146
+            '/waitfor\s+delay/i',
147
+
148
+            // 条件语句
149
+            '/or\s+[\'"]?[\d\w][\'"]?\s*=\s*[\'"]?[\d\w][\'"]?/i',
150
+            '/and\s+[\'"]?[\d\w][\'"]?\s*=\s*[\'"]?[\d\w][\'"]?/i',
151
+
152
+            // 堆叠查询
153
+            '/;\s*(select|insert|update|delete|drop|create|alter|exec)/i',
154
+
155
+            // 错误注入
156
+            '/extractvalue\s*\(|updatexml\s*\(/i',
157
+
158
+            // 盲注
159
+            '/if\s*\(.*?,\s*.*?,\s*.*?\)/i',
160
+        ];
161
+
162
+        foreach ($patterns as $pattern) {
163
+            if (preg_match($pattern, $input)) {
164
+                return true;
165
+            }
166
+        }
167
+
168
+        return false;
169
+    }
170
+
171
+    /**
172
+     * 检测XSS攻击
173
+     */
174
+    protected function detectXss(string $input): bool
175
+    {
176
+        $patterns = [
177
+            // 脚本标签
178
+            '/<script\b[^>]*>(.*?)<\/script>/is',
179
+            '/javascript\s*:/i',
180
+            '/on(load|error|click|mouse|key|focus|blur|submit)\s*=/i',
181
+
182
+            // 事件处理
183
+            '/<\w+\s+[^>]*on\w+\s*=[^>]*>/i',
184
+
185
+            // 数据协议
186
+            '/data\s*:/i',
187
+            '/vbscript\s*:/i',
188
+
189
+            // 框架/对象
190
+            '/<iframe\b[^>]*>/i',
191
+            '/<object\b[^>]*>/i',
192
+            '/<embed\b[^>]*>/i',
193
+            '/<applet\b[^>]*>/i',
194
+        ];
195
+
196
+        foreach ($patterns as $pattern) {
197
+            if (preg_match($pattern, $input)) {
198
+                return true;
199
+            }
200
+        }
201
+
202
+        return false;
203
+    }
204
+
205
+    /**
206
+     * 检测命令注入
207
+     */
208
+    protected function detectCommandInjection(string $input): bool
209
+    {
210
+        $patterns = [
211
+            // 系统命令
212
+            '/(?:system|exec|shell_exec|passthru|proc_open|popen|pcntl_exec)\s*\(/i',
213
+
214
+            // 管道符
215
+            '/\|\s*\w+/',
216
+            '/;\s*\w+/',
217
+
218
+            // 危险命令
219
+            '/\b(?:rm\s+-|cat\s+\/|wget\s+|curl\s+|nc\s+)\b/i',
220
+
221
+            // 反引号
222
+            '/`.*?`/',
223
+        ];
224
+
225
+        foreach ($patterns as $pattern) {
226
+            if (preg_match($pattern, $input)) {
227
+                return true;
228
+            }
229
+        }
230
+
231
+        return false;
232
+    }
233
+
234
+    /**
235
+     * 检测路径遍历
236
+     */
237
+    protected function detectPathTraversal(string $input): bool
238
+    {
239
+        $patterns = [
240
+            '/\.\.\//',
241
+            '/\.\.\\\/',
242
+            '/\/etc\/passwd/i',
243
+            '/\/proc\/self/i',
244
+            '/\.\.%2f/i',
245
+            '/\.\.%5c/i',
246
+        ];
247
+
248
+        foreach ($patterns as $pattern) {
249
+            if (preg_match($pattern, $input)) {
250
+                return true;
251
+            }
252
+        }
253
+
254
+        return false;
255
+    }
256
+
257
+    /**
258
+     * 检测文件包含
259
+     */
260
+    protected function detectFileInclusion(string $input): bool
261
+    {
262
+        $patterns = [
263
+            '/include\s*\(|require\s*\(|include_once|require_once/i',
264
+            '/php:\/\/filter/i',
265
+            '/phar:\/\//i',
266
+            '/zip:\/\//i',
267
+            '/expect:\/\//i',
268
+        ];
269
+
270
+        foreach ($patterns as $pattern) {
271
+            if (preg_match($pattern, $input)) {
272
+                return true;
273
+            }
274
+        }
275
+
276
+        return false;
277
+    }
278
+
279
+    /**
280
+     * 检查请求头
281
+     */
282
+    protected function checkHeaders(Request $request): bool
283
+    {
284
+        $suspiciousHeaders = [
285
+            'x-forwarded-for' => '/^[\d\.\,]+$/',
286
+            'user-agent' => '', // 可以为空,但可以检查恶意UA
287
+            'referer' => '',    // 检查可疑referer
288
+        ];
289
+
290
+        foreach ($suspiciousHeaders as $header => $pattern) {
291
+            $value = $request->header($header);
292
+            if ($value && $pattern && !preg_match($pattern, $value)) {
293
+                return true;
294
+            }
295
+        }
296
+
297
+        return false;
298
+    }
299
+
300
+    /**
301
+     * 检测攻击类型
302
+     */
303
+    protected function detectAttackType(string $input): string
304
+    {
305
+        if ($this->detectSqlInjection($input)) {
306
+            return 'sql_injection';
307
+        }
308
+        if ($this->detectXss($input)) {
309
+            return 'xss';
310
+        }
311
+        if ($this->detectCommandInjection($input)) {
312
+            return 'command_injection';
313
+        }
314
+        if ($this->detectPathTraversal($input)) {
315
+            return 'path_traversal';
316
+        }
317
+        if ($this->detectFileInclusion($input)) {
318
+            return 'file_inclusion';
319
+        }
320
+
321
+        return 'unknown';
322
+    }
323
+
324
+    /**
325
+     * 处理攻击
326
+     */
327
+    protected function handleAttack(Request $request, array $attacks): void
328
+    {
329
+        $ip = $this->getRealIp($request);
330
+
331
+        // 记录攻击日志
332
+        foreach ($attacks as $attack) {
333
+            $this->logAttack($ip, $request, $attack);
334
+        }
335
+
336
+        // 检查是否达到封禁阈值
337
+        if ($this->config['enable_blocking']) {
338
+            $this->checkAndBlockIp($ip);
339
+        }
340
+    }
341
+
342
+    /**
343
+     * 获取真实客户端IP(支持Swoole模式)
344
+     */
345
+    protected function getRealIp(Request $request): string
346
+    {
347
+        $ip = '0.0.0.0';
348
+
349
+        // 1. 优先从Swoole的header中获取
350
+        if ($this->isSwooleMode()) {
351
+            // Swoole模式下,真实IP通常在x-real-ip或x-forwarded-for中
352
+            $ip = $request->header('x-real-ip', '');
353
+
354
+            if (empty($ip)) {
355
+                // 如果有多个代理,x-forwarded-for是逗号分隔的列表,取第一个
356
+                $xff = $request->header('x-forwarded-for', '');
357
+                if (!empty($xff)) {
358
+                    $ips = explode(',', $xff);
359
+                    $ip = trim($ips[0]);
360
+                }
361
+            }
362
+        }
363
+
364
+        // 2. 如果Swoole模式获取失败,尝试常规方法
365
+        if (empty($ip) || !filter_var($ip, FILTER_VALIDATE_IP)) {
366
+            $ip = $request->ip();
367
+        }
368
+
369
+        // 3. 验证IP格式
370
+        return filter_var($ip, FILTER_VALIDATE_IP) ? $ip : '0.0.0.0';
371
+    }
372
+
373
+    /**
374
+     * 检查是否运行在Swoole模式
375
+     */
376
+    protected function isSwooleMode(): bool
377
+    {
378
+        return extension_loaded('swoole') &&
379
+            defined('SWOOLE_VERSION') &&
380
+            (php_sapi_name() === 'cli' || isset($_SERVER['SWOOLE_SERVER']));
381
+    }
382
+
383
+    /**
384
+     * 记录攻击日志到数据库
385
+     */
386
+    protected function logAttack(string $ip, Request $request, array $attack): void
387
+    {
388
+        if (!$this->config['enable_logging']) {
389
+            return;
390
+        }
391
+
392
+        try {
393
+            // 限制参数值长度
394
+            $paramValue = mb_substr($attack['value'], 0, $this->config['max_param_length'], 'UTF-8');
395
+
396
+            // 获取用户代理
397
+            $userAgent = $request->header('user-agent', '');
398
+
399
+            // 获取其他信息
400
+            $requestData = [
401
+                'method' => $request->method(),
402
+                'url' => $request->url(),
403
+                'full_url' => $request->url(true),
404
+                'get_params' => json_encode($request->get(), JSON_UNESCAPED_UNICODE),
405
+                'post_params' => json_encode($request->post(), JSON_UNESCAPED_UNICODE),
406
+            ];
407
+
408
+            // 使用参数绑定防止二次注入
409
+            Db::name('security_log')->insert([
410
+                'attack_type' => $attack['type'],
411
+                'ip_address' => $ip,
412
+                'param_name' => $attack['param'],
413
+                'param_value' => $paramValue,
414
+                'user_agent' => mb_substr($userAgent, 0, 500, 'UTF-8'),
415
+                'request_method' => $request->method(),
416
+                'request_url' => mb_substr($request->url(), 0, 500, 'UTF-8'),
417
+                'request_data' => json_encode($requestData, JSON_UNESCAPED_UNICODE),
418
+                'create_time' => date('Y-m-d H:i:s'),
419
+                'update_time' => date('Y-m-d H:i:s')
420
+            ]);
421
+
422
+            // 更新IP攻击计数
423
+            $this->incrementIpAttackCount($ip);
424
+
425
+        } catch (\Exception $e) {
426
+            // 数据库写入失败时记录到文件日志
427
+            Log::error('安全日志记录失败: ' . $e->getMessage());
428
+        }
429
+    }
430
+
431
+    /**
432
+     * 增加IP攻击计数
433
+     */
434
+    protected function incrementIpAttackCount(string $ip): void
435
+    {
436
+        $key = 'security:attack_count:' . $ip;
437
+        $count = Cache::inc($key, 1);
438
+
439
+        // 设置24小时过期
440
+        if ($count === 1) {
441
+            Cache::expire($key, 86400);
442
+        }
443
+    }
444
+
445
+    /**
446
+     * 检查并封禁IP
447
+     */
448
+    protected function checkAndBlockIp(string $ip): void
449
+    {
450
+        $key = 'security:attack_count:' . $ip;
451
+        $count = Cache::get($key, 0);
452
+
453
+        if ($count >= $this->config['attack_threshold']) {
454
+            $blockKey = 'security:blocked_ip:' . $ip;
455
+            Cache::set($blockKey, 1, $this->config['block_duration']);
456
+
457
+            // 记录封禁日志
458
+            Log::warning('IP被封禁', [
459
+                'ip' => $ip,
460
+                'attack_count' => $count,
461
+                'block_duration' => $this->config['block_duration']
462
+            ]);
463
+        }
464
+    }
465
+
466
+    /**
467
+     * 检查IP是否被封禁
468
+     */
469
+    protected function isIpBlocked(string $ip): bool
470
+    {
471
+        $key = 'security:blocked_ip:' . $ip;
472
+        return Cache::has($key);
473
+    }
474
+
475
+    /**
476
+     * 记录封禁访问
477
+     */
478
+    protected function logBlockedAccess(Request $request): void
479
+    {
480
+        Log::info('封禁IP访问被阻止', [
481
+            'ip' => $request->ip(),
482
+            'url' => $request->url(),
483
+            'method' => $request->method(),
484
+            'user_agent' => $request->header('user-agent', '')
485
+        ]);
486
+    }
487
+
488
+    /**
489
+     * 封禁响应
490
+     */
491
+    protected function blockResponse(): Response
492
+    {
493
+        return Response::create([
494
+            'code' => 403,
495
+            'msg'  => '访问被拒绝'
496
+        ], 'json')->code(403);
497
+    }
498
+
499
+    /**
500
+     * 错误响应
501
+     */
502
+    protected function errorResponse(): Response
503
+    {
504
+        return Response::create([
505
+            'code' => 400,
506
+            'msg'  => '请求参数错误'
507
+        ], 'json')->code(400);
508
+    }
509
+}

+ 3 - 3
app/traits/GongApiRequest.php

@@ -633,9 +633,9 @@ trait GongApiRequest
633 633
             $data = strstr($data,'{');
634 634
         }
635 635
         if ($url != 'https://www.douhuomall.com/api/category/get_list'){
636
-            log::info('供应链【'.$url.'】body:'.json_encode($postFields,JSON_UNESCAPED_UNICODE));
637
-            log::info('供应链【'.$url.'】headerArray:'.json_encode($header,JSON_UNESCAPED_UNICODE));
638
-            log::info('供应链【'.$url.'】data:'.$data);
636
+            // log::info('供应链【'.$url.'】body:'.json_encode($postFields,JSON_UNESCAPED_UNICODE));
637
+            // log::info('供应链【'.$url.'】headerArray:'.json_encode($header,JSON_UNESCAPED_UNICODE));
638
+            // log::info('供应链【'.$url.'】data:'.$data);
639 639
 //            Db::name("log")->insert(array('data'=>'供应链【'.$url.'】body:'.json_encode($postFields)));//日志记录
640 640
 //            Db::name("log")->insert(array('data'=>'供应链【'.$url.'】headerArray:'.json_encode($header)));//日志记录
641 641
 //            Db::name("log")->insert(array('data'=>'供应链【'.$url.'】data:'.$data));//日志记录

+ 13 - 10
app/traits/GzcApiRequest.php

@@ -56,7 +56,11 @@ trait GzcApiRequest
56 56
      */
57 57
     public static function checkAmount($user)
58 58
     {
59
-        $cardType = $user['card_type'] ? $user['card_type'] : 10;
59
+        Log::info('用户实名信息:' . json_encode($user));
60
+        $cardType = $user['card_type'];
61
+        if ($user['card_type'] == 2) {
62
+            $cardType = '10';
63
+        }
60 64
         $cxbData = [
61 65
             'platformNo' => env('GZC.PLATFORM_NO'),
62 66
             'appNo' => env('GZC.APP_NO'),
@@ -87,8 +91,6 @@ trait GzcApiRequest
87 91
 
88 92
         $amount = $cxbResponseData['extendData']['amount'] + $xfbResponseData['extendData']['amount'];
89 93
         return $amount;
90
-
91
-
92 94
     }
93 95
     public function getAmountFromGzc()
94 96
     {
@@ -107,17 +109,18 @@ trait GzcApiRequest
107 109
             return app('json')->fail('查询失败(第三方异常)');
108 110
         }
109 111
 
110
-        if (!is_array($res) || ($res['code'] ?? -1) !== 0) {
111
-            return app('json')->fail($res['message'] ?? '查询失败');
112
-        }
113
-
114
-        $amountCents = $res['extendData']['amount'] ?? $res['data']['amount'] ?? $res['amount'] ?? 0;
115
-        $amount = floatval($amountCents) * 0.01;
112
+        // 提取 amount(兼容多种字段位置)
113
+        $amountCents = $res['extendData']['amount'] ?? $res['data']['amount'] ?? $res['amount'] ?? null;
114
+        $amount = $amountCents === null ? 0.0 : floatval($amountCents) * 0.01;
116 115
         $formatted = sprintf('%.2f', $amount);
117 116
 
117
+        // 从 checkAmount 返回的 debug(若存在)
118
+        $debug = $res['debug'] ?? null;
119
+
120
+        // 返回 amount 与 debug 给调用方(前端 / 调试)
118 121
         return app('json')->success([
119 122
             'amount' => $formatted,
120
-            'debug'  => $res['debug'] ?? null,
123
+            'debug'  => $debug
121 124
         ]);
122 125
     }
123 126
     /**

+ 40 - 0
app/utils/TimeUtil.php

@@ -0,0 +1,40 @@
1
+<?php
2
+
3
+namespace app\utils;
4
+
5
+class TimeUtil
6
+{
7
+    /**
8
+     * 生成时间间隔数组
9
+     */
10
+    public static function generateTimeIntervals($startTime, $endTime, $intervalMinutes = 20): array
11
+    {
12
+        $intervals = [];
13
+        $currentStart = strtotime($startTime);
14
+        $endTimestamp = strtotime($endTime);
15
+
16
+        while ($currentStart < $endTimestamp) {
17
+            $currentEnd = $currentStart + ($intervalMinutes * 60);
18
+
19
+            // 确保不超过结束时间
20
+            if ($currentEnd > $endTimestamp) {
21
+                $currentEnd = $endTimestamp;
22
+            }
23
+
24
+            $intervals[] = [
25
+                'start' => date("Y-m-d H:i:00", $currentStart),
26
+                'end' => date("Y-m-d H:i:00", $currentEnd)
27
+            ];
28
+
29
+            $currentStart = $currentEnd;
30
+
31
+            // 如果已经到达结束时间,退出循环
32
+            if ($currentStart >= $endTimestamp) {
33
+                break;
34
+            }
35
+        }
36
+
37
+        return $intervals;
38
+    }
39
+
40
+}

+ 1 - 0
config/console.php

@@ -33,5 +33,6 @@ return [
33 33
         'movie_order' => 'app\command\MovieOrderCommand',
34 34
         'repair_pay_success' => 'app\command\repairPaySuccess',
35 35
         'repair_fzone_pay_type' => 'app\command\repairFzonePayType',
36
+        'wiwibaoproductsync' => 'app\command\WiwibaoProductSync',
36 37
     ],
37 38
 ];

+ 6 - 0
config/middleware.php

@@ -1,9 +1,15 @@
1 1
 <?php
2 2
 // 中间件配置
3 3
 return [
4
+    // 全局中间件
5
+    '' => [
6
+        // ... 其他中间件
7
+        app\middleware\SecurityMiddleware::class,
8
+    ],
4 9
     // 别名或分组
5 10
     'alias'    => [
6 11
         'api_log' => \app\middleware\ApiRequestLogMiddleware::class,
12
+        'security' => \app\middleware\SecurityMiddleware::class,
7 13
     ],
8 14
     // 优先级设置,此数组中的中间件会按照数组中的顺序优先执行
9 15
     'priority' => [],

+ 19 - 3
crmeb/listens/AutoCancelGroupOrderListen.php

@@ -5,7 +5,7 @@
5 5
  * @author xaboy
6 6
  * @day 2020/6/9
7 7
  *
8
- * 
8
+ *
9 9
  */
10 10
 
11 11
 namespace crmeb\listens;
@@ -31,7 +31,15 @@ class AutoCancelGroupOrderListen implements ListenerInterface
31 31
                 try {
32 32
                     $storeGroupOrderRepository->cancel($id);
33 33
                 } catch (\Exception $e) {
34
-                    Log::info('自动关闭订单失败' . var_export($id, 1));
34
+                    Log::error('自动关闭订单失败' . json_encode([
35
+                            'order_id' => $id,
36
+                            'error_message' => $e->getMessage(),
37
+                            'error_file' => $e->getFile(),
38
+                            'error_line' => $e->getLine(),
39
+                            'error_code' => $e->getCode(),
40
+                            'exception_class' => get_class($e),
41
+                            'trace' => $e->getTraceAsString()
42
+                        ], JSON_UNESCAPED_UNICODE));
35 43
                 }
36 44
             }
37 45
         });
@@ -47,7 +55,15 @@ class AutoCancelGroupOrderListen implements ListenerInterface
47 55
                         $storeGroupOrderRepository->cancel($id);
48 56
                     }
49 57
                 } catch (\Exception $e) {
50
-                    Log::info('自动关闭订单失败' . var_export($id, 1));
58
+                    Log::error('自动关闭代付订单失败' . json_encode([
59
+                            'order_id' => $id,
60
+                            'error_message' => $e->getMessage(),
61
+                            'error_file' => $e->getFile(),
62
+                            'error_line' => $e->getLine(),
63
+                            'error_code' => $e->getCode(),
64
+                            'exception_class' => get_class($e),
65
+                            'trace' => $e->getTraceAsString()
66
+                        ], JSON_UNESCAPED_UNICODE));
51 67
                 }
52 68
             }
53 69
         });

+ 6 - 0
route/admin.php

@@ -2,6 +2,8 @@
2 2
 
3 3
 use think\facade\Route;
4 4
 
5
+Route::get('agreement/detailContent/:id', 'admin.agreement.Agreement/detailContent');
6
+
5 7
 Route::group(config('admin.admin_prefix'), function () {
6 8
     Route::miss(function () {
7 9
         $DB = DIRECTORY_SEPARATOR;
@@ -111,6 +113,9 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
111 113
         Route::get('getConfig/:name', 'admin.system.config.ConfigValue/getByName');
112 114
         Route::post('saveConfig', 'admin.system.config.ConfigValue/saveByName');
113 115
 
116
+        // 共富区配置
117
+        Route::get('sharedProsperity/Recommend', 'admin.system.sharedProsperity.SharedProsperityRecommend/list');
118
+
114 119
         //组合数据
115 120
         Route::group('group', function () {
116 121
             Route::get('lst', '/lst')->name('groupLst');
@@ -976,6 +981,7 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
976 981
             Route::post('killOrderRewards', 'Order/killOrderRewards');//撤回订单
977 982
             Route::post('killOrderLst', 'Order/killOrderLst');//撤回订单的列表
978 983
             Route::post('easterKillOrder', 'Order/easterKillOrder');//撤回撤回订单
984
+            Route::get('merchantOfflineOrder', 'MerchantOfflineOrder/lst');//线下订单展示
979 985
         })->prefix('admin.order.');
980 986
 
981 987
         //第三方订单

+ 1 - 0
route/api.php

@@ -1341,6 +1341,7 @@ Route::group('api/', function () {
1341 1341
     ->middleware(\app\common\middleware\CheckSiteOpenMiddleware::class);
1342 1342
 Route::get('/test/assignment', 'api.store.merchant.Taskorderguquan/assignment');
1343 1343
 Route::get('test_hehuoren', 'api.store.merchant.TaskPartnerProfits/partnerProfits');
1344
+Route::get('test_resendUnissued', 'api.store.merchant.TaskPartnerProfits/resendUnissued');
1344 1345
 Route::get('test_hehuoren_zero', 'api.store.merchant.TaskZeroLinePartnerProfits/partnerProfitsByZeroLine');
1345 1346
 Route::get('test_guquan', 'api.store.merchant.Taskorderguquan/lst6');
1346 1347
 Route::get('test_lianchuang', 'api.store.merchant.Taskorderlianc/lst2');

BIN
uploads/def/20220104/112183.jpg


BIN
uploads/def/20220104/462618.jpg


BIN
uploads/def/20220104/505882.jpg


BIN
uploads/def/20220104/952252.jpg