Browse Source

精彩生活区、会员专区分账mer_id调整

family 1 year ago
parent
commit
bbbbf34050

+ 5 - 5
app/command/CommercialAreaOrderIndependentAccount.php

@@ -28,8 +28,8 @@ class CommercialAreaOrderIndependentAccount extends Command
28 28
 
29 29
     protected function execute(Input $input, Output $output)
30 30
     {
31
-        // @todo 商贸区订单分账
32
-        $this->doCommercialAreaOrderIndependentAccount([439,491,496]);
31
+        // @todo 商贸区订单分账 496:会员专区,439:精品生活区
32
+        $this->doCommercialAreaOrderIndependentAccount([439, 491, 496]);
33 33
     }
34 34
 
35 35
     /**
@@ -97,9 +97,9 @@ class CommercialAreaOrderIndependentAccount extends Command
97 97
 //                    if ($test_user == 0 && $check <= 0) {
98 98
 //                        $OrderGzcRepository->create($create);
99 99
 //                    }
100
-                    $order                  = StoreOrder::getInstance()->find($value['order_id']);
101
-                    $order->gzc             = 1;
102
-                    $order->save();
100
+                $order = StoreOrder::getInstance()->find($value['order_id']);
101
+                $order->gzc = 1;
102
+                $order->save();
103 103
 //                });
104 104
             }
105 105
         }

+ 17 - 14
app/command/GreatLifeOrderIndependentAccount.php

@@ -28,37 +28,37 @@ class GreatLifeOrderIndependentAccount extends Command
28 28
 
29 29
     protected function execute(Input $input, Output $output)
30 30
     {
31
-        // @todo 精彩生活区订单分账
32
-        $this->doGreatLifeOrderIndependentAccount();
31
+        // @todo 会员专区、精彩生活区订单分账,496:会员专区,439:精品生活区
32
+        $this->doGreatLifeOrderIndependentAccount([439, 496]);
33 33
     }
34 34
 
35 35
     /**
36
-     * 精彩生活区订单分账
36
+     * 会员专区、精彩生活区订单分账
37 37
      *
38
-     * @param $timeLimit
39 38
      * @param $merId
39
+     * @param $timeLimit
40 40
      * @return void
41 41
      * @throws \think\db\exception\DataNotFoundException
42 42
      * @throws \think\db\exception\DbException
43 43
      * @throws \think\db\exception\ModelNotFoundException
44 44
      */
45
-    private function doGreatLifeOrderIndependentAccount($timeLimit = 30, $merId = 439)
45
+    private function doGreatLifeOrderIndependentAccount($merId = [], $timeLimit = 30)
46 46
     {
47
+        // 商户信息
48
+        $merchants = [];
49
+
47 50
         $time = time();
48 51
         // 已支付、未结算
49
-        $where = [
50
-            'paid' => 1, 'gzc' => 0, 'mer_id' => $merId, 'is_del' => 0, 'is_system_del' => 0
51
-        ];
52
+        $where = ['paid' => 1, 'gzc' => 0, 'is_del' => 0, 'is_system_del' => 0];
52 53
         // 订单状态(0:待发货;1:待收货;2:待评价;3:已完成;4已申请退款;-1:已退款)5未支付 6已取消'
53
-        $status = [2,3];
54
+        $status = [2, 3];
54 55
         // 普通订单
55
-        $cursor = Db::table('rrx_store_order')->where($where)->where('pay_type', 'in', '1,2,4')->whereIn('status', $status)->cursor();
56
+        $cursor = Db::table('rrx_store_order')->where($where)->where('pay_type', 'in', '1,2,4')->whereIn('status', $status)
57
+            ->whereIn('mer_id', $merId)->cursor();
56 58
 
57 59
 //        $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
58 60
 //        $OrderMerchantRepository    = app()->make(OrderMerchantRepository::class);
59 61
 //        $OrderGzcRepository         = app()->make(OrderGzcRepository::class);
60
-        // 商户信息
61
-        $merchant = Db::name('merchant')->where('mer_id', $merId)->find();
62 62
 
63 63
         /** @var StoreOrderRepository $storeOrderRepository */
64 64
         $storeOrderRepository = app()->make(StoreOrderRepository::class);
@@ -67,17 +67,20 @@ class GreatLifeOrderIndependentAccount extends Command
67 67
             $settlement_period_time = strtotime($value['create_time']) + $timeLimit * 24 * 3600;
68 68
             // @todo 下单后第{$timeLimit}天后可分账
69 69
             if ($settlement_period_time >= $time) {
70
+                if (!isset($merchants[$value['mer_id']])) {
71
+                    $merchants[$value['mer_id']] = Db::name('merchant')->where('mer_id', $value['mer_id'])->find();
72
+                }
70 73
                 $group_order = Db::name('store_group_order')->alias('sgo')->where('sgo.group_order_id', $value['group_order_id'])->find();
71 74
 
72 75
                 // 分账账号 496:表示{会员专区}账户,精彩生活区分账到{会员专区}账户
73
-                $independentAccount = $storeOrderRepository->getIndependentAccount($value, $group_order, 496, $merchant['hf_member_id']);
76
+                $independentAccount = $storeOrderRepository->getIndependentAccount($value, $group_order, 496, $merchants[$value['mer_id']]['hf_member_id']);
74 77
 
75 78
                 // @todo 预分账处理 496:表示{会员专区}账户,精彩生活区分账到{会员专区}账户,故:hf_platform_member_id 为入账账户
76 79
                 $isSuccessed = $storeOrderRepository->prepareExecuteIndependentAccount(
77 80
                     $value, $group_order, $independentAccount['api_key'], $independentAccount['hf_platform_member_id'], '', $value['con_pri'], 0
78 81
                 );
79 82
 
80
-                Db::name("log")->insert(array('data' => '精彩生活区-订单分账:' . json_encode($value,JSON_FORCE_OBJECT)));//日志记录
83
+                Db::name("log")->insert(array('data' => '精彩生活区-订单分账:' . json_encode($value, JSON_FORCE_OBJECT)));//日志记录
81 84
 
82 85
 //                Db::transaction(function () use ($certification, $online, $pension, $OrderGzcRepository, $OrderMerchantRepository, $StoreOrderRepository) {
83 86
 //                    //新增入账明细记录