sunxbiao пре 6 месеци
родитељ
комит
9edb38bf52

+ 743 - 0
app/command/WiwibaoProductSync.php

@@ -0,0 +1,743 @@
1
+<?php
2
+declare (strict_types=1);
3
+
4
+namespace app\command;
5
+
6
+use app\common\enum\douhuomall\DouhuomallEnum;
7
+use app\common\enum\store\ProductEnum;
8
+use app\traits\GongApiRequest;
9
+use think\console\Command;
10
+use think\console\Input;
11
+use think\console\Output;
12
+use think\db\exception\DataNotFoundException;
13
+use think\db\exception\DbException;
14
+use think\db\exception\ModelNotFoundException;
15
+use think\facade\Db;
16
+use think\facade\Log;
17
+
18
+class WiwibaoProductSync extends Command
19
+{
20
+
21
+    use GongApiRequest;
22
+
23
+    // 配置参数
24
+    protected $config = [
25
+        'page_size' => 100,      // 每页拉取数量
26
+        'max_pages' => 0,       // 最大页数限制
27
+        'price_change_rate' => 0.0, // 价格变动比率阈值(10%)
28
+    ];
29
+
30
+    protected function configure()
31
+    {
32
+        // 指令配置
33
+        $this->setName('wiwibaoproductsync')
34
+            ->setDescription('the wiwibaoproductsync command');
35
+    }
36
+
37
+    protected function execute(Input $input, Output $output)
38
+    {
39
+        $output->writeln('定时任务执行中...');
40
+
41
+        $this->syncGoodsFromGong();
42
+
43
+        $output->writeln('定时任务执行完成');
44
+    }
45
+
46
+    /**
47
+     * 同步微唯宝商品数据(主方法)
48
+     */
49
+    public function syncGoodsFromGong()
50
+    {
51
+        try {
52
+            set_time_limit(0);
53
+
54
+            // 1. 批量拉取所有商品数据
55
+            $allProducts = $this->fetchAllProducts();
56
+
57
+            if (empty($allProducts)) {
58
+                Log::info('未拉取到任何商品数据');
59
+                return 'success';
60
+            }
61
+
62
+            // 2. 获取本地所有SPU ID
63
+            $localSpuIds = Db::name('douhuomall')->column('spu_id');
64
+            $syncedSpuIds = [];
65
+
66
+            // 3. 批量处理商品数据
67
+            foreach ($allProducts as $product) {
68
+                try {
69
+                    $spuId = $this->processSingleProduct($product);
70
+                    if ($spuId) {
71
+                        $syncedSpuIds[] = $spuId;
72
+                    }
73
+                } catch (\Exception $e) {
74
+                    Log::error("处理商品 {$product['goods_id']} 失败: " . $e->getMessage());
75
+                    continue;
76
+                }
77
+            }
78
+
79
+            // 4. 处理需要下架的商品(本地有但第三方已下架)
80
+            $this->handleOfflineProducts($localSpuIds, $syncedSpuIds);
81
+
82
+            return 'success';
83
+
84
+        } catch (\Exception $e) {
85
+            $this->logError('商品同步失败', $e);
86
+            return 'error';
87
+        }
88
+    }
89
+
90
+    /**
91
+     * 批量拉取所有商品数据
92
+     */
93
+    protected function fetchAllProducts()
94
+    {
95
+        $allData = [];
96
+
97
+        // 第一页
98
+        $firstPageData = GongApiRequest::get_goods_list(1, $this->config['page_size']);
99
+        if (empty($firstPageData['list'])) {
100
+            return [];
101
+        }
102
+
103
+        $allData = $firstPageData['list'];
104
+        $totalPages = $firstPageData['pages'] ?? 1;
105
+        if (!empty($this->config['max_pages'])) {
106
+            $totalPages = min($totalPages, $this->config['max_pages']);
107
+        }
108
+
109
+        // 并行获取剩余页面
110
+        for ($page = 2; $page <= $totalPages; $page++) {
111
+            $pageData = GongApiRequest::get_goods_list($page, $this->config['page_size']);
112
+            if (!empty($pageData['list'])) {
113
+                $allData = array_merge($allData, $pageData['list']);
114
+            }
115
+        }
116
+
117
+        return $allData;
118
+    }
119
+
120
+    /**
121
+     * 处理单个商品
122
+     */
123
+    protected function processSingleProduct($productData)
124
+    {
125
+        $goodsId = $productData['goods_id'];
126
+
127
+        // 1. 获取商品详情
128
+        $goodsInfo = GongApiRequest::get_goods_info($goodsId);
129
+        if (!$goodsInfo) {
130
+            return null;
131
+        }
132
+
133
+        // 2. 处理图片信息
134
+        $imageData = $this->processProductImages($goodsId, $goodsInfo);
135
+
136
+        // 3. 处理SKU信息
137
+        $skuInfo = $this->processSkuInfo($goodsInfo['sku_list'] ?? [], $goodsId);
138
+
139
+        // 4. 构建保存数据
140
+        $saveData = $this->buildSaveData($goodsInfo, $skuInfo, $imageData);
141
+
142
+        // 5. 保存到本地(使用原有的add方法逻辑)
143
+        $spuId = $this->addToDouhuomall($saveData);
144
+
145
+        // 6. 检查并处理已上架商品的价格变动
146
+        $this->checkAndProcessOnlineProduct($spuId, $saveData);
147
+
148
+        return $spuId;
149
+    }
150
+
151
+    /**
152
+     * 处理商品图片信息
153
+     */
154
+    protected function processProductImages($goodsId, $goodsInfo)
155
+    {
156
+        // 如果你需要保存图片到本地,可以在这里实现
157
+        // 否则直接返回URL
158
+        return [
159
+            'cover_url' => $goodsInfo['main_img'] ?? '',
160
+            'detail_images' => $goodsInfo['detail_img'] ?? [],
161
+            'detail_img_list' => $goodsInfo['detail_img'] ?? [] // 为了兼容以前写的代码,建议保留这个数据项,之前用的是detail_img_list字段,但我感觉他们意义一样
162
+        ];
163
+    }
164
+
165
+    /**
166
+     * 处理SKU信息
167
+     */
168
+    protected function processSkuInfo($skuList, $goodsId)
169
+    {
170
+        if (empty($skuList)) {
171
+            return [];
172
+        }
173
+
174
+        $processedSkus = [];
175
+        foreach ($skuList as $sku) {
176
+            if (empty($sku['plat_price'])) {
177
+                continue;
178
+            }
179
+
180
+            $processedSku = [
181
+                'sku_id' => $sku['sku_id'] ?? 0,
182
+                'plat_price' => $sku['plat_price'],
183
+                'img_url' => $sku['main_img'],
184
+                'retail_price' => $sku['retail_price'] ?? 0,
185
+                'cost_price' => $this->calculateCostPrice($sku['plat_price']),
186
+                'market_price' => $this->calculateMarketPrice($sku['plat_price']),
187
+                'profit' => $this->calculateProfit($sku['plat_price']),
188
+                'mer_profit' => $this->calculateMerProfit($sku['plat_price']),
189
+                'yanglaojin' => '0.00',
190
+                'main_img' => $sku['main_img'] ?? '',
191
+                'attribute_json' => !empty($sku['attr']) ? $sku['attr'] : [['val' => '默认', 'name' => '默认']]
192
+            ];
193
+
194
+            $processedSkus[] = array_merge($sku, $processedSku);
195
+        }
196
+
197
+        return $processedSkus;
198
+    }
199
+
200
+    /**
201
+     * 构建保存数据
202
+     */
203
+    protected function buildSaveData($goodsInfo, $skuInfo, $imageData)
204
+    {
205
+        // 构建详情HTML
206
+        $detailHtml = $this->buildDetailHtml($imageData['detail_images']);
207
+
208
+        return [
209
+            'spu_id' => $goodsInfo['goods_id'],
210
+            'skuId_info' => $skuInfo,
211
+            'sys_id' => '112',
212
+            'goods_id' => $goodsInfo['goods_id'],
213
+            'spuId_info' => array_merge(
214
+                $goodsInfo,
215
+                [
216
+                    'cover_url' => $imageData['cover_url'],
217
+                    'detail' => $detailHtml,
218
+                    'detail_img_list' => $imageData['detail_img_list']
219
+                ]
220
+            ),
221
+            'sku_id' => $skuInfo[0]['sku_id'] ?? 0,
222
+            'status' => $goodsInfo['status'] ?? 0,
223
+            'cate_ids' => $goodsInfo['cate_ids'] ?? '',
224
+            'title' => $goodsInfo['spu_name'] ?? '',
225
+            'cxb_cate_id' => 0
226
+        ];
227
+    }
228
+
229
+    /**
230
+     * 构建详情HTML
231
+     */
232
+    protected function buildDetailHtml($detailImages)
233
+    {
234
+        if (empty($detailImages)) {
235
+            return '';
236
+        }
237
+
238
+        $detailHtml = '';
239
+        foreach ((array)$detailImages as $imgUrl) {
240
+            $detailHtml .= "<img src='{$imgUrl}' referrerpolicy='no-referrer' />";
241
+        }
242
+
243
+        return $detailHtml;
244
+    }
245
+
246
+    /**
247
+     * 保存到douhuomall表(基于原有add方法)
248
+     */
249
+    protected function addToDouhuomall($data)
250
+    {
251
+        try {
252
+            $findData = Db::name('douhuomall')->where('spu_id', $data['spu_id'])->find();
253
+
254
+            // 对SKU按成本价排序,获取最低成本价的SKU
255
+            $skuInfo = $this->arrSort($data['skuId_info'], 'cost_price', SORT_ASC);
256
+
257
+            // 计算价格字段
258
+            $data['cost_price'] = $skuInfo[0]['cost_price'] ?? 0;
259
+            $data['market_price'] = $skuInfo[0]['market_price'] ?? 0;
260
+            $data['ot_price'] = $skuInfo[0]['retail_price'] ?? 0;
261
+            $data['mer_profit'] = $skuInfo[0]['mer_profit'] ?? 0;
262
+            $data['pension'] = $skuInfo[0]['yanglaojin'] ?? 0;
263
+            $data['profit'] = (empty($data['cost_price']) || empty($data['market_price']))
264
+                ? 0
265
+                : bcdiv((string)$data['market_price'], (string)$data['cost_price'], 2);
266
+
267
+            $now = date('Y-m-d H:i:s');
268
+
269
+            if (empty($findData)) {
270
+                // 新增
271
+                $insertData = [
272
+                    'spu_id' => $data['spu_id'],
273
+                    'skuId_info' => json_encode($data['skuId_info'], JSON_UNESCAPED_UNICODE),
274
+                    'sys_id' => $data['sys_id'],
275
+                    'goods_id' => $data['goods_id'],
276
+                    'spuId_info' => json_encode($data['spuId_info'], JSON_UNESCAPED_UNICODE),
277
+                    'create_time' => $now,
278
+                    'update_time' => $now,
279
+                    'sku_id' => $data['sku_id'],
280
+                    'status' => $data['status'],
281
+                    'cate_ids' => $data['cate_ids'],
282
+                    'title' => $data['title'],
283
+                    'cost_price' => $data['cost_price'],
284
+                    'market_price' => $data['market_price'],
285
+                    'ot_price' => $data['ot_price'],
286
+                    'profit' => $data['profit'],
287
+                    'mer_profit' => $data['mer_profit'],
288
+                    'pension' => $data['pension'],
289
+                    'cxb_cate_id' => $data['cxb_cate_id']
290
+                ];
291
+                Db::name('douhuomall')->insert($insertData);
292
+            } else {
293
+                // 更新
294
+                // 检查是否需要恢复已删除商品的上架状态
295
+                $shouldRestore = $this->shouldRestoreProduct($findData, $data);
296
+                if ($shouldRestore) {
297
+                    $this->restoreProduct($data['spu_id']);
298
+                }
299
+                $updateData = [
300
+                    'status' => $data['status'],
301
+                    'update_time' => $now,
302
+                    'cost_price' => $data['cost_price'],
303
+                    'market_price' => $data['market_price'],
304
+                    'ot_price' => $data['ot_price'],
305
+                    'mer_profit' => $data['mer_profit'],
306
+                    'pension' => $data['pension'],
307
+                    'profit' => $data['profit'],
308
+                    'skuId_info' => json_encode($data['skuId_info'], JSON_UNESCAPED_UNICODE),
309
+                    'spuId_info' => json_encode($data['spuId_info'], JSON_UNESCAPED_UNICODE),
310
+                    'title' => $data['title'],
311
+                    'cate_ids' => $data['cate_ids'],
312
+                    'cxb_cate_id' => $data['cxb_cate_id']
313
+                ];
314
+                Db::name('douhuomall')
315
+                    ->where('spu_id', $findData['spu_id'])
316
+                    ->update($updateData);
317
+            }
318
+
319
+            return $data['spu_id'];
320
+
321
+        } catch (\Exception $e) {
322
+            Log::error("保存商品到douhuomall失败: " . $e->getMessage());
323
+            throw $e;
324
+        }
325
+    }
326
+
327
+    /**
328
+     * 检查是否需要恢复已删除商品的上架状态
329
+     */
330
+    protected function shouldRestoreProduct($findData, $newData)
331
+    {
332
+        // 原有逻辑:如果货物属于已被删除状态,并且新更新进来的状态非删除状态
333
+        // 并且成本价、零售价、市场价、利润率没有变动的话
334
+        if ($findData['status'] == DouhuomallEnum::STATUS['Delete']['code']
335
+            && $newData['status'] !== DouhuomallEnum::STATUS['Delete']['code']
336
+            && $newData['cost_price'] == $findData['cost_price']
337
+            && $newData['ot_price'] == $findData['ot_price']
338
+            && $newData['market_price'] == $findData['market_price']
339
+            && $newData['profit'] == $findData['profit']) {
340
+
341
+            // 检查是否有已下架的商品
342
+            $count = Db::name('store_product')
343
+                ->where('spu_id', $newData['spu_id'])
344
+                ->where('is_show', ProductEnum::IS_SHOW['No']['code'])
345
+                ->where('is_status', ProductEnum::IS_STATUS['Automatic']['code'])
346
+                ->count();
347
+
348
+            return $count > 0;
349
+        }
350
+
351
+        return false;
352
+    }
353
+
354
+    /**
355
+     * 恢复商品上架状态
356
+     */
357
+    protected function restoreProduct($spuId)
358
+    {
359
+        Db::name('store_product')
360
+            ->where('spu_id', $spuId)
361
+            ->update([
362
+                'is_show' => ProductEnum::IS_SHOW['No']['code'],
363
+                'status' => ProductEnum::STATUS['Approved']['code']
364
+            ]);
365
+
366
+        Log::info("恢复商品上架(恢复到仓库中)状态: spu_id={$spuId}");
367
+    }
368
+
369
+    /**
370
+     * 检查并处理已上架商品
371
+     */
372
+    protected function checkAndProcessOnlineProduct($spuId, $syncData)
373
+    {
374
+        // 检查商品是否已上架
375
+        try {
376
+            $productList = Db::name('store_product')
377
+                ->where('is_show', ProductEnum::IS_SHOW['Yes']['code'])
378
+                ->where('spu_id', $spuId)
379
+                ->select()
380
+                ->toArray();
381
+
382
+            if (empty($productList)) {
383
+                return;
384
+            }
385
+
386
+            // 解析同步数据中的价格
387
+            $syncPrices = [];
388
+            foreach ($syncData['skuId_info'] as $sku) {
389
+                $syncPrices[] = [
390
+                    'sku_id' => $sku['sku_id'] ?? '',
391
+                    'market_price' => $sku['market_price'] ?? 0,
392
+                    'cost_price' => $sku['cost_price'] ?? 0,
393
+                    'retail_price' => $sku['retail_price'] ?? 0
394
+                ];
395
+            }
396
+
397
+            foreach ($productList as $product) {
398
+                // 获取本地商品价格信息
399
+                // 获取SKU价格
400
+                $skus = Db::name('store_product_attr_value')
401
+                    ->where('product_id', $product['product_id'])
402
+                    ->field('gong_sku_id, sku, price, cost')
403
+                    ->select()
404
+                    ->toArray();
405
+                $localPrices = [
406
+                    'product_price' => $product['price'] ?? 0,
407
+                    'product_cost' => $product['cost'] ?? 0,
408
+                    'product_ot_price' => $product['ot_price'] ?? 0,
409
+                    'skus' => $skus
410
+                ];
411
+
412
+                // 比较价格,判断是否需要下架
413
+                $priceChanged = $this->checkPriceChange($localPrices, $syncPrices);
414
+
415
+                if ($priceChanged) {
416
+                    // 价格变动超过阈值,下架商品并记录
417
+                    $this->offlineProductWithRecord($product, $syncData, $localPrices, $syncPrices);
418
+                } else {
419
+                    // 价格未变动或变动很小,只更新图片
420
+                    $this->updateProductImages($spuId);
421
+                }
422
+            }
423
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
424
+
425
+        }
426
+    }
427
+
428
+    /**
429
+     * 检查价格是否变动超过阈值
430
+     */
431
+    protected function checkPriceChange($localPrices, $syncPrices)
432
+    {
433
+        // 如果没有SKU,比较商品主价格
434
+        if (empty($localPrices['skus'])) {
435
+            $localPrice = $localPrices['product_price'];
436
+            $syncPrice = $syncPrices[0]['market_price'] ?? 0;
437
+
438
+            if ($localPrice > 0 && $syncPrice > 0) {
439
+                $changeRate = abs(($syncPrice - $localPrice) / $localPrice);
440
+                return $changeRate > $this->config['price_change_rate'];
441
+            }
442
+            return false;
443
+        }
444
+
445
+        // 如果有SKU,匹配SKU进行比较
446
+        foreach ($localPrices['skus'] as $localSku) {
447
+            foreach ($syncPrices as $syncSku) {
448
+                // 尝试匹配SKU
449
+                if ($this->matchSku($localSku, $syncSku)) {
450
+                    $localPrice = $localSku['price'] ?? 0;
451
+                    $syncPrice = $syncSku['market_price'] ?? 0;
452
+
453
+                    if ($localPrice > 0 && $syncPrice > 0) {
454
+                        $changeRate = abs(($syncPrice - $localPrice) / $localPrice);
455
+                        if ($changeRate > $this->config['price_change_rate']) {
456
+                            return true;
457
+                        }
458
+                    }
459
+                }
460
+            }
461
+        }
462
+
463
+        return false;
464
+    }
465
+
466
+    /**
467
+     * 匹配SKU(根据业务逻辑实现)
468
+     */
469
+    protected function matchSku($localSku, $syncSku)
470
+    {
471
+        // 根据SKU ID匹配
472
+        if (!empty($localSku['gong_sku_id']) && !empty($syncSku['sku_id'])) {
473
+            return $localSku['gong_sku_id'] == $syncSku['sku_id'];
474
+        }
475
+
476
+        // 可以根据其他属性匹配,如规格等
477
+        return false;
478
+    }
479
+
480
+    /**
481
+     * 下架商品并记录变动
482
+     */
483
+    protected function offlineProductWithRecord($product, $syncData, $localPrices, $syncPrices)
484
+    {
485
+        $productId = $product['product_id'];
486
+        $spuId = $product['spu_id'];
487
+
488
+        // 1. 收集变动前数据
489
+        $beforeData = [
490
+            'product_id' => $productId,
491
+            'spu_id' => $spuId,
492
+            'title' => $product['store_name'] ?? '',
493
+            'status' => $product['is_show'] ?? 0,
494
+            'price_info' => $localPrices,
495
+            'images' => [
496
+                'image' => $product['image'] ?? '',
497
+                'slider_image' => $product['slider_image'] ?? ''
498
+            ],
499
+            'record_time' => date('Y-m-d H:i:s')
500
+        ];
501
+
502
+        // 2. 下架商品
503
+        Db::name('store_product')
504
+            ->where('product_id', $productId)
505
+            ->update([
506
+                'is_show' => ProductEnum::IS_SHOW['No']['code'],
507
+                'status' => ProductEnum::STATUS['Withdrawn']['code'],
508
+                'is_status' => ProductEnum::IS_STATUS['Automatic']['code']
509
+            ]);
510
+
511
+        // 3. 收集变动后数据
512
+        $afterData = [
513
+            'spu_id' => $spuId,
514
+            'sync_price_info' => $syncPrices,
515
+            'sync_title' => $syncData['title'],
516
+            'sync_status' => $syncData['status'],
517
+            'sync_time' => date('Y-m-d H:i:s')
518
+        ];
519
+
520
+        // 4. 记录变动日志
521
+        $this->recordChangeLog(
522
+            $productId,
523
+            $spuId,
524
+            'price_change',
525
+            '第三方平台价格变动超过阈值',
526
+            $beforeData,
527
+            $afterData
528
+        );
529
+
530
+        Log::info("商品下架: product_id={$productId}, spu_id={$spuId}, 原因: 价格变动");
531
+    }
532
+
533
+    /**
534
+     * 更新商品图片(基于原有updata_product_img方法)
535
+     */
536
+    protected function updateProductImages($spuId)
537
+    {
538
+        // 1. 验证该SPU是否已上架
539
+        $productId = Db::name('store_product')
540
+            ->where('spu_id', $spuId)
541
+            ->value('product_id');
542
+
543
+        if (!$productId) {
544
+            return true;
545
+        }
546
+
547
+        // 2. 查找微唯宝商品
548
+        $data = Db::name('douhuomall')
549
+            ->where('spu_id', $spuId)
550
+            ->find();
551
+
552
+        if (!$data) {
553
+            return false;
554
+        }
555
+
556
+        // 3. 解析商品信息
557
+        $spuIdInfo = json_decode($data['spuId_info'], true);
558
+
559
+        // 4. 处理图片数据
560
+        $sliderImage = $spuIdInfo['detail_img_list'] ?: '[]';
561
+        $image = $spuIdInfo['cover_url'] ?? '';
562
+
563
+        if (is_string($sliderImage)) {
564
+            $sliderImage = implode(',', json_decode($sliderImage, true));
565
+        } else if (is_array($sliderImage)) {
566
+            $sliderImage = implode(',', $sliderImage);
567
+        } else {
568
+            $sliderImage = $image;
569
+        }
570
+
571
+        // 5. 更新产品图片数据
572
+        $updateData = [
573
+            'image' => $image,
574
+            'slider_image' => $sliderImage,
575
+        ];
576
+
577
+        Db::name('store_product')
578
+            ->where('product_id', $productId)
579
+            ->update($updateData);
580
+
581
+        // 6. 更新商品详情
582
+        $detail = $spuIdInfo['detail'] ?? '';
583
+        if (!is_null(json_decode($detail))) {
584
+            $detailList = json_decode($detail);
585
+            $newDetail = '';
586
+            foreach ($detailList as $value) {
587
+                $newDetail .= "<img src='{$value}' referrerpolicy='no-referrer' /></img>";
588
+            }
589
+            $detail = $newDetail;
590
+        }
591
+
592
+        Db::name('store_product_content')
593
+            ->where('product_id', $productId)
594
+            ->update(['content' => $detail]);
595
+
596
+        return true;
597
+    }
598
+
599
+    /**
600
+     * 处理需要下架的商品(第三方已下架)
601
+     */
602
+    protected function handleOfflineProducts($localSpuIds, $syncedSpuIds)
603
+    {
604
+        $offlineSpuIds = array_diff($localSpuIds, $syncedSpuIds);
605
+
606
+        if (empty($offlineSpuIds)) {
607
+            return;
608
+        }
609
+
610
+        foreach ($offlineSpuIds as $spuId) {
611
+            $this->offlineProductBySpuId($spuId, 'third_party_offline');
612
+        }
613
+
614
+        Log::info("下架第三方已下架商品" . json_encode(['count' => count($offlineSpuIds), 'spu_ids' => $offlineSpuIds]));
615
+    }
616
+
617
+    /**
618
+     * 根据SPU ID下架商品
619
+     */
620
+    protected function offlineProductBySpuId($spuId, $reason)
621
+    {
622
+        // 查找已上架的商品
623
+        $products = Db::name('store_product')
624
+            ->where('spu_id', $spuId)
625
+            ->select();
626
+
627
+        foreach ($products as $product) {
628
+            // 记录下架前数据
629
+            $beforeData = $product;
630
+
631
+            // 下架商品
632
+            Db::name('store_product')
633
+                ->where('product_id', $product['product_id'])
634
+                ->update([
635
+                    'is_show' => ProductEnum::IS_SHOW['No']['code'],
636
+                    'status' => ProductEnum::STATUS['Withdrawn']['code'],
637
+                    'is_status' => ProductEnum::IS_STATUS['Automatic']['code']
638
+                ]);
639
+
640
+            // 记录日志
641
+            $this->recordChangeLog(
642
+                $product['product_id'],
643
+                $spuId,
644
+                'third_party_offline',
645
+                $reason,
646
+                $beforeData,
647
+                []
648
+            );
649
+        }
650
+
651
+        // 从douhuomall表中删除
652
+        Db::name('douhuomall')->where('spu_id', $spuId)->delete();
653
+    }
654
+
655
+    /**
656
+     * 记录变动日志
657
+     */
658
+    protected function recordChangeLog($productId, $spuId, $changeType, $reason, $beforeData, $afterData)
659
+    {
660
+        $logData = [
661
+            'product_id' => $productId,
662
+            'spu_id' => $spuId,
663
+            'change_type' => $changeType,
664
+            'change_reason' => $reason,
665
+            'before_data' => json_encode($beforeData, JSON_UNESCAPED_UNICODE),
666
+            'after_data' => json_encode($afterData, JSON_UNESCAPED_UNICODE),
667
+            'change_time' => time(),
668
+            'create_time' => time()
669
+        ];
670
+
671
+        Db::name('product_change_log')->insert($logData);
672
+    }
673
+
674
+    /**
675
+     * 数组排序(从原有add方法中提取)
676
+     */
677
+    protected function arrSort($array, $keys, $sort = SORT_DESC)
678
+    {
679
+        $keysValue = [];
680
+        foreach ($array as $k => $v) {
681
+            $keysValue[$k] = $v[$keys] ?? 0;
682
+        }
683
+        array_multisort($keysValue, $sort, $array);
684
+        return $array;
685
+    }
686
+
687
+    /**
688
+     * 计算成本价
689
+     */
690
+    protected function calculateCostPrice($platPrice)
691
+    {
692
+        return bcadd((string)$platPrice, bcmul((string)$platPrice, '0.03', 4), 2);
693
+    }
694
+
695
+    /**
696
+     * 计算市场价
697
+     */
698
+    protected function calculateMarketPrice($platPrice)
699
+    {
700
+        $costPrice = $this->calculateCostPrice($platPrice);
701
+        return bcadd($costPrice, bcmul($costPrice, '0.2', 4), 2);
702
+    }
703
+
704
+    /**
705
+     * 计算利润率
706
+     */
707
+    protected function calculateProfit($platPrice)
708
+    {
709
+        $costPrice = $this->calculateCostPrice($platPrice);
710
+        $marketPrice = $this->calculateMarketPrice($platPrice);
711
+        return bcdiv($marketPrice, $costPrice, 2);
712
+    }
713
+
714
+    /**
715
+     * 计算毛利
716
+     */
717
+    protected function calculateMerProfit($platPrice)
718
+    {
719
+        $costPrice = $this->calculateCostPrice($platPrice);
720
+        $marketPrice = $this->calculateMarketPrice($platPrice);
721
+        return bcsub($marketPrice, $costPrice, 2);
722
+    }
723
+
724
+    /**
725
+     * 记录错误
726
+     */
727
+    protected function logError($message, \Exception $e)
728
+    {
729
+        $errorInfo = [
730
+            'message' => $message,
731
+            'file' => $e->getFile(),
732
+            'line' => $e->getLine(),
733
+            'error' => $e->getMessage()
734
+        ];
735
+
736
+        Log::error('商品同步错误' . json_encode($errorInfo, JSON_UNESCAPED_UNICODE));
737
+
738
+        Db::name('log')->insert([
739
+            'data' => json_encode($errorInfo, JSON_UNESCAPED_UNICODE),
740
+            'time' => date('Y-m-d H:i:s')
741
+        ]);
742
+    }
743
+}

+ 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'));

+ 2 - 0
app/common/repositories/finance/FinanceRepository.php

@@ -1076,6 +1076,8 @@ class FinanceRepository extends BaseRepository
1076 1076
         //导出数据
1077 1077
         $is_excel = request()->param('is_excel', 0);
1078 1078
         if($is_excel == 1){
1079
+            ini_set('memory_limit', '-1');
1080
+            set_time_limit(0);
1079 1081
             $date['list'] = $this->date_where($query, $where['date'], 'ub.create_time')
1080 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')
1081 1083
             ->order('ub.bill_id', 'desc')

+ 43 - 0
app/common/repositories/merchant/order/OrderMerchantRepository.php

@@ -163,6 +163,49 @@ class OrderMerchantRepository extends BaseRepository
163 163
             ->whereNull('refund_time')
164 164
             ->find();
165 165
 
166
+        $is_excel = request()->param('is_excel', 0);
167
+        if($is_excel){
168
+            ini_set('memory_limit', '-1');
169
+            set_time_limit(0);
170
+            $list = clone $query;
171
+            $list = $list->with(['merchant' => function ($query) {
172
+                return $query->field('mer_id,mer_name,mer_avatar');
173
+            }])->order('id desc')->select()->each(function ($item) {
174
+                $item->actual = bcsub($item->money, ($item->available + $item->swipe_fee), 2);
175
+                return $item;
176
+            });
177
+
178
+            $arr = [];
179
+            foreach ($list as $item){
180
+                $status = $item['paid'] == 1 ? '已支付' : '未支付';
181
+                if($item['refund_time']) $status = '已退款';
182
+
183
+                $arr[] = [
184
+                    $item['id'],
185
+                    $item['mer_id'],
186
+                    $item['merchant']['mer_name'] ?? '',
187
+                    $item['uid'],
188
+                    $item['money'],
189
+                    $item['available'],
190
+                    $item['service_money'],
191
+                    $item['pension'],
192
+                    $item['swipe_fee'],
193
+                    $item['mer_money'],
194
+                    $item['mer_fanyong'],
195
+                    $item['actual'],
196
+                    $status,
197
+                    $item['create_time'],
198
+                    $item['out_trade_no']
199
+                ];
200
+            }
201
+            $header = [
202
+                'ID', '商户ID', '商户名称', '用户ID',
203
+                '充值金额', '可分佣总额', '服务商返利', '养老金', '刷卡手续费', '商户金额', '商户返佣', '实到金额',
204
+                '状态', '时间', '订单号'
205
+            ];
206
+            return app()->make(\crmeb\services\SpreadsheetExcelService::class)->setExcelContent($header, $arr, '线下订单');
207
+        }
208
+
166 209
         $count = $query->count();
167 210
         $list = $query->with(['merchant', 'merchant' => function ($query) {
168 211
             return $query->field('mer_id,mer_name,mer_avatar');

+ 4 - 2
app/common/repositories/store/order/StoreGroupOrderRepository.php

@@ -165,7 +165,9 @@ class StoreGroupOrderRepository extends BaseRepository
165 165
             $groupOrder->save();
166 166
 
167 167
             //取消订单,返还京豆和积分
168
-            $orderId = $order->order_id;
168
+            if (!empty($order)) {
169
+                $orderId = $order->order_id;
170
+
169 171
             $userSignScoreInfo = Db::name('user_sign_score')->where('order_id', $orderId)->where('status',-1)->where('order_type','store_order')->find();
170 172
             if($userSignScoreInfo){
171 173
                 $userDecScore = $userSignScoreInfo['reward_socre'];
@@ -219,7 +221,7 @@ class StoreGroupOrderRepository extends BaseRepository
219 221
                     ->insertGetId($ins_data);
220 222
                 Db::name('user')->where('uid', $uid)->inc('jingdou', $userDecJingScore)->update();
221 223
             }
222
-
224
+            }
223 225
 
224 226
 
225 227
             app()->make(StoreOrderStatusRepository::class)->insertAll($orderStatus);

+ 1 - 1
app/common/repositories/store/order/StoreOrderRepository.php

@@ -6887,7 +6887,7 @@ class StoreOrderRepository extends BaseRepository
6887 6887
         try {
6888 6888
             $order = Db::name('store_order')->where('status', 0)->where('pay_type', '>', 0)->where('douhuomall', 1)->where('douhuomall_status', 9)->select();
6889 6889
             if ($order) {
6890
-                log::info("传参数据333========");
6890
+                // log::info("传参数据333========");
6891 6891
                 $gong = app()->make(ProductAttrValueRepository::class);
6892 6892
                 $order = $order->toArray();
6893 6893
                 foreach ($order as $key => $value) {

+ 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 = [[

+ 6 - 6
app/common/repositories/store/product/ProductRepository.php

@@ -859,7 +859,7 @@ class ProductRepository extends BaseRepository
859 859
 
860 860
         //搜索记录
861 861
         if ($userInfo && isset($where['keyword']) && !empty($where['keyword'])){
862
-            log::info("======sousuojilu====");
862
+            // log::info("======sousuojilu====");
863 863
             app()->make(UserVisitRepository::class)->searchProduct($userInfo['uid'], $where['keyword']);
864 864
         }
865 865
 
@@ -1949,18 +1949,18 @@ class ProductRepository extends BaseRepository
1949 1949
                 $base_commission= floatval(systemConfig('extension_tao_rate'));
1950 1950
                 $logs['extension_tao_rate'] = $base_commission;
1951 1951
                 //返佣总额 返利总额=(交易金额-手续费)*返利比例
1952
-                log::info("计算养老金 good_id: {$good_id},yanglao : $yanglao");
1952
+                // log::info("计算养老金 good_id: {$good_id},yanglao : $yanglao");
1953 1953
                 $yanglao=bcmul($yanglao-$souxufees,$base_commission/100,3);
1954
-                log::info("计算养老金 good_id: {$good_id},yanglao-$souxufees 保留三位$yanglao");
1954
+                // log::info("计算养老金 good_id: {$good_id},yanglao-$souxufees 保留三位$yanglao");
1955 1955
             }
1956 1956
             $yanglao = $yanglao * $yanglaojin_admin /100  ;//养老金比例
1957
-            log::info("计算养老金 good_id: {$good_id},yanglao : $yanglao");
1957
+            // log::info("计算养老金 good_id: {$good_id},yanglao : $yanglao");
1958 1958
 
1959 1959
             $yanglao= decimal2($yanglao);// 取两位小数 后面舍去
1960 1960
         }
1961 1961
 
1962
-        log::info(json_encode($logs));
1963
-        log::info("计算养老金 good_id: {$good_id},price{$total_price},yanglao:{$yanglao}");
1962
+        // log::info(json_encode($logs));
1963
+        // log::info("计算养老金 good_id: {$good_id},price{$total_price},yanglao:{$yanglao}");
1964 1964
 
1965 1965
         return set_price_rtrim($yanglao);
1966 1966
     }

+ 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']='';

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

@@ -4623,11 +4623,13 @@ class UserRepository extends BaseRepository
4623 4623
      * @return void
4624 4624
      */
4625 4625
     public function sproductkeywordHistory($uid, $keyword, $type){
4626
-        Db::name('third_history')->insert([
4627
-            'uid' => $uid,
4628
-            'keyword' => $keyword,
4629
-            'type' => $type,
4630
-        ]);
4626
+        if (!empty($keyword)) {
4627
+            Db::name('third_history')->insert([
4628
+                'uid' => $uid,
4629
+                'keyword' => $keyword,
4630
+                'type' => $type,
4631
+            ]);
4632
+        }
4631 4633
     }
4632 4634
 
4633 4635
 

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

@@ -0,0 +1,42 @@
1
+<?php
2
+
3
+namespace app\controller\admin\order;
4
+use app\common\repositories\merchant\order\OrderMerchantRepository;
5
+use crmeb\basic\BaseController;
6
+use think\App;
7
+
8
+class MerchantOfflineOrder extends BaseController
9
+{
10
+    /**
11
+     * @var OrderMerchantRepository
12
+     */
13
+    protected $repository;
14
+
15
+    /**
16
+     * @var int
17
+     */
18
+    protected $merId;
19
+
20
+    /**
21
+     * MerchantIntention constructor.
22
+     * @param App $app
23
+     * @param OrderMerchantRepository $repository
24
+     */
25
+    public function __construct(App $app, OrderMerchantRepository $repository)
26
+    {
27
+        parent::__construct($app);
28
+        $this->repository = $repository;
29
+        $this->merId = 0;
30
+    }
31
+    /**
32
+     * @return mixed
33
+     * 展示线下订单
34
+     */
35
+    public function lst()
36
+    {
37
+        [$page, $limit] = $this->getPage();
38
+        $where = $this->request->params(['keyword', 'date', 'status', 'mer_id']);
39
+        return app('json')->success($this->repository->getMerchantListAdmin($this->merId, $where, $page, $limit));
40
+    }
41
+
42
+}

+ 4 - 4
app/controller/api/Auth.php

@@ -1462,6 +1462,7 @@ class Auth extends BaseController
1462 1462
                 if (!$data['code'])
1463 1463
                     return app('json')->make(402, '操作过于频繁,请稍后重试~');
1464 1464
             }
1465
+            Cache::set($sms_num_key, $num + 1, 300);
1465 1466
         }
1466 1467
         $sms_key = 'api.auth.sms.' . $data['phone'];
1467 1468
         $sms_code = str_pad(random_int(1, 9999), 4, 0, STR_PAD_LEFT);
@@ -1474,11 +1475,10 @@ class Auth extends BaseController
1474 1475
             return app('json')->fail('操作过于频繁,请稍后重试~');
1475 1476
         }
1476 1477
 
1477
-        log::info("sms_key==={$sms_key}" );
1478
-        log::info("sms_code==={$sms_code}" );
1479
-        log::info("sms_time==={$sms_time}" );
1478
+        // log::info("sms_key==={$sms_key}" );
1479
+        // log::info("sms_code==={$sms_code}" );
1480
+        // log::info("sms_time==={$sms_time}" );
1480 1481
         Cache::set($sms_key, $sms_code,$sms_time * 60);
1481
-        Cache::set($sms_num_key, $num + 1, 300);
1482 1482
         //'短信发送成功'
1483 1483
         return app('json')->success('短信发送成功');
1484 1484
     }

+ 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
         }

+ 3 - 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
 

+ 5 - 5
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,7 +229,7 @@ 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
             // }
@@ -262,7 +262,7 @@ class TaoKe extends BaseController
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([

+ 4 - 4
app/controller/api/store/product/Vip.php

@@ -313,8 +313,8 @@ class Vip extends BaseController
313 313
             ->orderRaw("RAND({$salt})")
314 314
             ->select()->toArray();
315 315
 
316
-        Log::info("vip=================");
317
-        log::info($data);
316
+        // Log::info("vip=================");
317
+        // log::info($data);
318 318
 
319 319
         // 获取列表数据
320 320
         // $data = Db::name('third_party_goods')->where('type', 5)->page($page, $limit)->select()->toArray();
@@ -763,8 +763,8 @@ class Vip extends BaseController
763 763
                     "{$value}TimeStart" => $startTime,
764 764
                     "{$value}TimeEnd" => $endTime,
765 765
                 ];
766
-                log::info("====VIP 订单===");
767
-                log::info($params);
766
+                // log::info("====VIP 订单===");
767
+                // log::info($params);
768 768
 
769 769
                 $result = $this->doOrderVip($params);
770 770
                 $result && $orderList[] = $result;

+ 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、商品入库数据

+ 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 - 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));//日志记录

+ 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
 ];

+ 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
         });

+ 1 - 0
route/admin.php

@@ -978,6 +978,7 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
978 978
             Route::post('killOrderRewards', 'Order/killOrderRewards');//撤回订单
979 979
             Route::post('killOrderLst', 'Order/killOrderLst');//撤回订单的列表
980 980
             Route::post('easterKillOrder', 'Order/easterKillOrder');//撤回撤回订单
981
+            Route::get('merchantOfflineOrder', 'MerchantOfflineOrder/lst');//线下订单展示
981 982
         })->prefix('admin.order.');
982 983
 
983 984
         //第三方订单