Procházet zdrojové kódy

会员专区分账

family před 1 rokem
rodič
revize
225182d24a

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

@@ -7488,9 +7488,11 @@ class StoreOrderRepository extends BaseRepository
7488 7488
             ->inc('commission_rate', $shouxufei)//平台手续费(汇付通道服务费)
7489 7489
             ->update();
7490 7490
 
7491
+        // @todo 会员分账
7491 7492
         if ($mer_id == systemConfig('mer_365') && $order['pay_type'] > 0) {
7492 7493
 //        if ($mer_id == systemConfig('mer_365') ) {
7493
-            $this->vip_product_spilet($order, $order['pay_type'], $product_id);
7494
+//            $this->vip_product_spilet($order, $order['pay_type'], $product_id);
7495
+            $this->vip_product_spiletnew($order['order_sn'], $order['pay_type'], $product_id);
7494 7496
         }
7495 7497
     }
7496 7498
 
@@ -10619,4 +10621,33 @@ class StoreOrderRepository extends BaseRepository
10619 10621
         ];
10620 10622
         Db::name("store_split_order")->insertAll($insertData);
10621 10623
     }
10624
+
10625
+    /**
10626
+     * 会员专区分账
10627
+     * @param $order
10628
+     * @param $pay_type
10629
+     * @return bool|string
10630
+     * @throws DbException
10631
+     * @throws \think\db\exception\DataNotFoundException
10632
+     * @throws \think\db\exception\ModelNotFoundException
10633
+     */
10634
+    public function vip_product_spiletnew($order_sn, $pay_type, $product_id = 0)
10635
+    {
10636
+        $order = Db::name('store_order')->where('order_sn', $order_sn)->where('paid', 1)->find();
10637
+        $order_group_data = Db::name('store_group_order')->where('group_order_id', $order['group_order_id']??0)->find();
10638
+
10639
+        if (!empty($order) && !empty($order_group_data)) {
10640
+            // 商户信息
10641
+            $merchant = Db::name('merchant')->where('mer_id', $order['mer_id'])->find();
10642
+            // @todo 获取分账账号
10643
+            $independentAccount = $this->getIndependentAccount($order, $order_group_data, $order['mer_id'], $merchant['hf_member_id']);
10644
+
10645
+            // @todo 预分账处理 496:表示{会员专区}账户,本区分账到{会员专区}账户,故:hf_platform_member_id 为入账账户
10646
+            $isSuccessed = $this->prepareExecuteIndependentAccount(
10647
+                $order, $order_group_data, $independentAccount['api_key'], $independentAccount['hf_platform_member_id'], '', $order['con_pri'], 0
10648
+            );
10649
+
10650
+            Db::name("log")->insert(array('data' => '会员专区-订单分账:' . json_encode($order, JSON_FORCE_OBJECT)));//日志记录
10651
+        }
10652
+    }
10622 10653
 }