Procházet zdrojové kódy

优化下单方法结构-调整支付成功回调方法及触发事件

sunxbiao před 9 měsíci
rodič
revize
77275f582f

+ 20 - 16
app/common/dao/store/order/StoreGroupOrderDao.php

@@ -17,6 +17,7 @@ use app\common\model\store\order\StoreGroupOrder;
17 17
 use app\entity\CommonEntity;
18 18
 use app\entity\data\store\StoreGroupOrderEntity;
19 19
 use think\db\exception\DbException;
20
+use think\exception\ValidateException;
20 21
 
21 22
 /**
22 23
  * Class StoreGroupOrderDao
@@ -145,24 +146,27 @@ class StoreGroupOrderDao extends BaseDao
145 146
     }
146 147
 
147 148
     /**
148
-     * @param int $groupOrderId
149
-     * @param string $rand
150
-     * @return int
151
-     * @throws DbException
149
+     * @param StoreGroupOrderEntity $storeGroupOrderEntity
150
+     * @return StoreGroupOrderEntity
152 151
      */
153
-    public function paySuccessUpdateDB(int $groupOrderId, string $rand = ''): int
152
+    public function paySuccessUpdateDB(StoreGroupOrderEntity $storeGroupOrderEntity): StoreGroupOrderEntity
154 153
     {
155
-        $data = [
156
-            'paid' => StoreGroupOrderEnum::PAID['YES']['code'],
157
-            'pay_time' => date('Y-m-d H:i:s')
158
-        ];
159
-        if (!empty($rand)) {
160
-            $data['rand'] = $rand;
154
+        try {
155
+            if (empty($storeGroupOrderEntity->getGroupOrderId())) {
156
+                throw new ValidateException('更新订单组支付成功状态失败');
157
+            }
158
+            $storeGroupOrderEntity
159
+                ->setPaid(StoreGroupOrderEnum::PAID['YES']['code'])
160
+                ->setPayTime(date('Y-m-d H:i:s'));
161
+
162
+            /** @var StoreGroupOrder $model */
163
+            $model = $this->getModel();
164
+            $model::getDB()
165
+                ->where('group_order_id', '=', $storeGroupOrderEntity->getGroupOrderId())
166
+                ->update($storeGroupOrderEntity->toUnderlineArray());
167
+        } catch (\Exception $e) {
168
+            throw new ValidateException('更新订单组支付成功状态失败');
161 169
         }
162
-        /** @var StoreGroupOrder $model */
163
-        $model = $this->getModel();
164
-        return $model::getDB()
165
-            ->where('group_order_id', '=', $groupOrderId)
166
-            ->update($data);
170
+        return $storeGroupOrderEntity;
167 171
     }
168 172
 }

+ 32 - 15
app/common/dao/store/order/StoreOrderDao.php

@@ -659,26 +659,43 @@ class StoreOrderDao extends BaseDao
659 659
     }
660 660
 
661 661
     /**
662
-     * @param array $storeOrderIdList
663
-     * @param string|null $payOpenId 现金 付款人ID
662
+     * 订单支付成功 更新订单状态
663
+     * @param StoreOrderEntity[] $storeOrderEntityList
664
+     * @return StoreOrderEntity[]
665
+     * @throws DbException
666
+     */
667
+    public function paySuccessUpdateDB(array $storeOrderEntityList): array
668
+    {
669
+        /** @var StoreOrder $model */
670
+        $model = $this->getModel();
671
+        return array_map(function ($storeOrderEntity) use ($model) {
672
+            $storeOrderEntity
673
+                ->setPaid(StoreOrderEnum::PAID['YES']['code'])
674
+                ->setPayTime(date('Y-m-d H:i:s'))
675
+                ->setStatus(StoreOrderEnum::STATUS['WAITING_SHIPMENT']['code'])
676
+                ->setDistributionMode(StoreOrderEnum::DISTRIBUTION_MODE['ExpressDelivery']['code']);
677
+            $model::getDB()
678
+                ->where('order_id', '=', $storeOrderEntity->getOrderId())
679
+                ->update($storeOrderEntity->toUnderlineArray());
680
+            return $storeOrderEntity;
681
+        }, $storeOrderEntityList);
682
+    }
683
+
684
+    /**
685
+     * 订单结算 更新订单信息
686
+     * @param array $orderIdList
664 687
      * @return int
665 688
      * @throws DbException
666 689
      */
667
-    public function paySuccessUpdateDB(array $storeOrderIdList, string $payOpenId = null): int
668
-    {
669
-        $data = [
670
-            'paid' => StoreOrderEnum::PAID['YES']['code'],
671
-            'pay_time' => date('Y-m-d H:i:s'),
672
-            'status' => StoreOrderEnum::STATUS['WAITING_SHIPMENT']['code'],
673
-            'distribution_mode' => StoreOrderEnum::DISTRIBUTION_MODE['ExpressDelivery']['code'] // 配送方式
674
-        ];
675
-        if (!empty($payOpenId)) {
676
-            $data['pay_open_id'] = $payOpenId;
677
-        }
690
+    public function settlementOrderByOrderIdList(array $orderIdList): int
691
+    {
678 692
         /** @var StoreOrder $model */
679 693
         $model = $this->getModel();
680 694
         return $model::getDB()
681
-            ->whereIn('group_order_id', $storeOrderIdList)
682
-            ->update($data);
695
+            ->whereIn('order_id', $orderIdList)
696
+            ->update([
697
+                'is_settlement' => StoreOrderEnum::IS_SETTLEMENT['YES']['code'],
698
+                'settlement_time' => date('Y-m-d H:i:s')
699
+            ]);
683 700
     }
684 701
 }

+ 17 - 0
app/common/enum/financial/FinancialRecordEnum.php

@@ -0,0 +1,17 @@
1
+<?php
2
+
3
+namespace app\common\enum\financial;
4
+
5
+class FinancialRecordEnum
6
+{
7
+    // 0 - 支出,1 - 获得
8
+    const FINANCIAL_TYPE = [
9
+        'Order' => ['code' => 'order', 'name' => '订单']
10
+    ];
11
+
12
+    // 0 - 支出,1 - 获得
13
+    const PM = [
14
+        'Expend' => ['code' => 0, 'name' => '支出'],
15
+        'Income' => ['code' => 1, 'name' => '获得'],
16
+    ];
17
+}

+ 35 - 34
app/common/repositories/store/order/StoreGroupOrderRepository.php

@@ -896,34 +896,35 @@ class StoreGroupOrderRepository extends BaseRepository
896 896
      */
897 897
     public function storeGroupOrderPaySuccess(int $groupOrderId, string $rand = '', string $payOpenId = null): void
898 898
     {
899
-        /** @var StoreGroupOrderRepository $storeGroupOrderRepository */
899
+        // 1、声明关联到的模块
900
+        /** @var StoreGroupOrderRepository $storeGroupOrderRepository 订单组 */
900 901
         $storeGroupOrderRepository = app()->make(StoreGroupOrderRepository::class);
901
-        /** @var StoreOrderRepository $storeOrderRepository */
902
+        /** @var StoreOrderRepository $storeOrderRepository 订单 */
902 903
         $storeOrderRepository = app()->make(StoreOrderRepository::class);
904
+        /** @var StoreOrderStatusRepository $storeOrderStatusRepository 订单状态 */
905
+        $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
903 906
 
907
+        // 2、获取订单组 实体数据
904 908
         $storeGroupOrderEntity = $storeGroupOrderRepository->getStoreGroupOrderEntityByGroupOrderId($groupOrderId);
905
-        // 修改订单组的 支付状态
906
-        $storeGroupOrderRepository->paySuccessUpdateDB($storeGroupOrderEntity->getGroupOrderId(), $rand);
907 909
 
908
-        // 获取订单组 内的 所有订单
909
-        $storeOrderEntityList = $storeOrderRepository->getStoreOrderEntityListByGroupOrderId($storeGroupOrderEntity->getGroupOrderId());
910
-        $storeOrderIdList = array_column($storeOrderEntityList, 'orderId');
911
-        $storeCartIdList = array_column($storeOrderEntityList, 'cartId');
910
+        // 3、修改订单组的 支付状态 并返回更新后的实体
911
+        $storeGroupOrderEntity->setRand($rand);
912
+        $storeGroupOrderEntity = $storeGroupOrderRepository->paySuccessUpdateDB($storeGroupOrderEntity);
912 913
 
913
-        // 修改订单的 支付状态
914
-        $storeOrderRepository->paySuccessUpdateDB($storeOrderIdList, $payOpenId);
914
+        // 4、获取订单信息
915
+        $storeOrderEntityList = $storeOrderRepository->getStoreOrderEntityListByGroupOrderId($storeGroupOrderEntity->getGroupOrderId());
915 916
 
916
-        // 获取购物车信息
917
-        /** @var StoreCartRepository $storeCartRepository */
918
-        $storeCartRepository = app()->make(StoreCartRepository::class);
919
-        $cartEntityList = $storeCartRepository->getCartEntityListByCartIdList($storeCartIdList);
920
-        /** @var CartEntity[] $cartEntityMap 发起创建订单的购物车映射 */
921
-        $cartEntityMap = array_column($cartEntityList, null, 'cartId');
917
+        // 5、修改订单的 支付状态 并返回更新后的实体
918
+        if (!is_null($payOpenId)) {
919
+            $storeOrderEntityList = array_map(function ($storeOrderEntity) use ($payOpenId) {
920
+                return $storeOrderEntity->setPayOpenId($payOpenId);
921
+            }, $storeOrderEntityList);
922
+        }
923
+        $storeOrderEntityList = $storeOrderRepository->paySuccessUpdateDB($storeOrderEntityList);
922 924
 
923
-        // 记录 需要立即计算的订单ID
925
+        // 6、循环订单列表 生成奖励数据、记录需要立即结算的订单数据、创建订单“支付成功”状态信息
924 926
         $settlementOrderIdList = [];
925 927
         $storeOrderStatusEntityList = [];
926
-        $financialRecordDataList = [];
927 928
         foreach ($storeOrderEntityList as $storeOrderEntity) {
928 929
             // 生成奖励数据
929 930
             $storeOrderRepository->createRewardMechanismByStoreOrderId($storeOrderEntity->getOrderId());
@@ -932,38 +933,38 @@ class StoreGroupOrderRepository extends BaseRepository
932 933
                 // 会员专区的 订单立即结算
933 934
                 $settlementOrderIdList[] = $storeOrderEntity->getOrderId();
934 935
             }
935
-            // 获取当前 订单绑定的购物车
936
-            $cartEntity = $cartEntityMap[$storeOrderEntity->getCartId()];
936
+
937 937
             // 准备订单的 状态数据
938 938
             $storeOrderStatusEntityList[] = StoreOrderStatusEntity::newInstance()
939 939
                 ->setOrderId($storeOrderEntity->getOrderId())
940 940
                 ->setChangeType(StoreOrderStatusEnum::CHANGE_TYPE['PaySuccess']['code'])
941 941
                 ->setChangeMessage(StoreOrderStatusEnum::CHANGE_TYPE['PaySuccess']['name']);
942
-
943
-            $financialRecordDataList[] = [
944
-
945
-            ];
946 942
         }
947 943
 
948
-        // 4.6 订单操作记录表
949
-        /** @var StoreOrderStatusRepository $storeOrderStatusRepository */
950
-        $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
944
+        // 7、批量写入 订单状态记录
951 945
         $storeOrderStatusRepository->createByEntityList($storeOrderStatusEntityList);
952 946
 
947
+        // 8、结算订单 奖励
953 948
         if (!empty($settlementOrderIdList)) {
954
-            // 将订单 生成的奖励数据 立即结算(发放)
949
+            // 将订单 生成的奖励数据 立即结算(发放) 并更新这些订单的 结算字段以及结算时间
955 950
             $storeOrderRepository->settlementOrderByOrderIdList($settlementOrderIdList);
951
+
952
+            // 结算完成后更新用户的身份信息 设置用户 身份
953
+            /** @var UserRepository $userRepository */
954
+            $userRepository = app()->make(UserRepository::class);
955
+            $userRepository->setUserIdentity($storeGroupOrderEntity->getUid());
956 956
         }
957
+
958
+        // 9、订单 分账 将收入的现金 商户部分 发放给 商户
959
+        $storeOrderRepository->independentAccountByOrderIdList(array_column($storeOrderEntityList, 'orderId'));
957 960
     }
958 961
 
959 962
     /**
960
-     * @param int $groupOrderId
961
-     * @param string $rand
962
-     * @return int
963
-     * @throws DbException
963
+     * @param StoreGroupOrderEntity $storeGroupOrderEntity
964
+     * @return StoreGroupOrderEntity
964 965
      */
965
-    public function paySuccessUpdateDB(int $groupOrderId, string $rand = ''): int
966
+    public function paySuccessUpdateDB(StoreGroupOrderEntity $storeGroupOrderEntity): StoreGroupOrderEntity
966 967
     {
967
-        return $this->dao->paySuccessUpdateDB($groupOrderId, $rand);
968
+        return $this->dao->paySuccessUpdateDB($storeGroupOrderEntity);
968 969
     }
969 970
 }

+ 108 - 67
app/common/repositories/store/order/StoreOrderRepository.php

@@ -10966,14 +10966,13 @@ class StoreOrderRepository extends BaseRepository
10966 10966
 
10967 10967
     /**
10968 10968
      * 订单支付成功后,更新订单信息
10969
-     * @param array $storeOrderIdList
10970
-     * @param string|null $payOpenId
10971
-     * @return int
10969
+     * @param StoreOrderEntity[] $storeOrderEntityList
10970
+     * @return StoreOrderEntity[]
10972 10971
      * @throws DbException
10973 10972
      */
10974
-    public function paySuccessUpdateDB(array $storeOrderIdList, string $payOpenId = null): int
10973
+    public function paySuccessUpdateDB(array $storeOrderEntityList): array
10975 10974
     {
10976
-        return $this->dao->paySuccessUpdateDB($storeOrderIdList, $payOpenId);
10975
+        return $this->dao->paySuccessUpdateDB($storeOrderEntityList);
10977 10976
     }
10978 10977
     /**
10979 10978
      * 根据 订单ID 来生 成奖励数据(待生效)
@@ -11736,71 +11735,77 @@ class StoreOrderRepository extends BaseRepository
11736 11735
             if (empty($unsettledOrderIdList)) {
11737 11736
                 return;
11738 11737
             }
11738
+            try {
11739
+                /** 结算 养老金 佣金 */
11740
+                /** @var UserBillRepository $userBillRepository */
11741
+                $userBillRepository = app()->make(UserBillRepository::class);
11742
+                $userBillEntityList = $userBillRepository->getUserBillEntityListByOrderIdListAndPending(UserBillEnum::TYPE_SHOP['Platform']['code'], $unsettledOrderIdList);
11743
+                if (!empty($userBillEntityList)) {
11744
+                    $billIdList = array_map(function ($userBillEntity) {
11745
+                        return $userBillEntity->getBillId();
11746
+                    }, $userBillEntityList);
11747
+                    // 去结算 养老金 和佣金
11748
+                    $userBillRepository->executeByIdList($billIdList);
11749
+                }
11750
+
11751
+                /** @var UserSignFugouRepository $userSignFugouRepository */
11752
+                $userSignFugouRepository = app()->make(UserSignFugouRepository::class);
11753
+                $userSignFugouEntityList = $userSignFugouRepository->getUserSignFugouEntityListByOrderIdListAndPending(UserSignFugouEnum::ORDER_TYPE['Platform']['code'], $unsettledOrderIdList);
11754
+                if (!empty($userSignFugouEntityList)) {
11755
+                    $fugouIdList = array_map(function ($userSignFugouEntity) {
11756
+                        return $userSignFugouEntity->getId();
11757
+                    }, $userSignFugouEntityList);
11758
+                    // 去结算 养老金 和佣金
11759
+                    $userSignFugouRepository->executeByIdList($fugouIdList);
11760
+                }
11761
+
11762
+                /** 结算 积分 */
11763
+                /** @var UserSignScoreRepository $userSignScoreRepository */
11764
+                $userSignScoreRepository = app()->make(UserSignScoreRepository::class);
11765
+                $userSignScoreEntityList = $userSignScoreRepository->getUserSignScoreEntityListByOrderIdListAndPending(UserSignScoreEnum::ORDER_TYPE['Platform']['code'], $unsettledOrderIdList);
11766
+                if (!empty($userSignScoreEntityList)) {
11767
+                    $userSignScoreIdList = array_map(function ($userSignScoreEntity) {
11768
+                        return $userSignScoreEntity->getId();
11769
+                    }, $userSignScoreEntityList);
11770
+                    $userSignScoreRepository->executeByIdList($userSignScoreIdList);
11771
+                }
11772
+                /** 结算 贡献值 */
11773
+                /** @var UserSignGongxianRepository $userSignGongxianRepository */
11774
+                $userSignGongxianRepository = app()->make(UserSignGongxianRepository::class);
11775
+                $userSignGongxianEntityList = $userSignGongxianRepository->getUserSignGongxianEntityListByOrderIdListAndPending(UserSignGongxianEnum::ORDER_TYPE['Platform']['code'], $unsettledOrderIdList);
11776
+                if (!empty($userSignGongxianEntityList)) {
11777
+                    $userSignGongxianIdList = array_map(function ($userSignGongxianEntity) {
11778
+                        return $userSignGongxianEntity->getId();
11779
+                    }, $userSignGongxianEntityList);
11780
+                    $userSignGongxianRepository->executeByIdList($userSignGongxianIdList);
11781
+                }
11739 11782
 
11740
-            /** 结算 养老金 佣金 */
11741
-            /** @var UserBillRepository $userBillRepository */
11742
-            $userBillRepository = app()->make(UserBillRepository::class);
11743
-            $userBillEntityList = $userBillRepository->getUserBillEntityListByOrderIdListAndPending(UserBillEnum::TYPE_SHOP['Platform']['code'], $unsettledOrderIdList);
11744
-            if (!empty($userBillEntityList)) {
11745
-                $billIdList = array_map(function ($userBillEntity) {
11746
-                    return $userBillEntity->getBillId();
11747
-                }, $userBillEntityList);
11748
-                // 去结算 养老金 和佣金
11749
-                $userBillRepository->executeByIdList($billIdList);
11750
-            }
11751
-
11752
-            /** @var UserSignFugouRepository $userSignFugouRepository */
11753
-            $userSignFugouRepository = app()->make(UserSignFugouRepository::class);
11754
-            $userSignFugouEntityList = $userSignFugouRepository->getUserSignFugouEntityListByOrderIdListAndPending(UserSignFugouEnum::ORDER_TYPE['Platform']['code'], $unsettledOrderIdList);
11755
-            if (!empty($userSignFugouEntityList)) {
11756
-                $fugouIdList = array_map(function ($userSignFugouEntity) {
11757
-                    return $userSignFugouEntity->getId();
11758
-                }, $userSignFugouEntityList);
11759
-                // 去结算 养老金 和佣金
11760
-                $userSignFugouRepository->executeByIdList($fugouIdList);
11761
-            }
11762
-
11763
-            /** 结算 积分 */
11764
-            /** @var UserSignScoreRepository $userSignScoreRepository */
11765
-            $userSignScoreRepository = app()->make(UserSignScoreRepository::class);
11766
-            $userSignScoreEntityList = $userSignScoreRepository->getUserSignScoreEntityListByOrderIdListAndPending(UserSignScoreEnum::ORDER_TYPE['Platform']['code'], $unsettledOrderIdList);
11767
-            if (!empty($userSignScoreEntityList)) {
11768
-                $userSignScoreIdList = array_map(function ($userSignScoreEntity) {
11769
-                    return $userSignScoreEntity->getId();
11770
-                }, $userSignScoreEntityList);
11771
-                $userSignScoreRepository->executeByIdList($userSignScoreIdList);
11772
-            }
11773
-            /** 结算 贡献值 */
11774
-            /** @var UserSignGongxianRepository $userSignGongxianRepository */
11775
-            $userSignGongxianRepository = app()->make(UserSignGongxianRepository::class);
11776
-            $userSignGongxianEntityList = $userSignGongxianRepository->getUserSignGongxianEntityListByOrderIdListAndPending(UserSignGongxianEnum::ORDER_TYPE['Platform']['code'], $unsettledOrderIdList);
11777
-            if (!empty($userSignGongxianEntityList)) {
11778
-                $userSignGongxianIdList = array_map(function ($userSignGongxianEntity) {
11779
-                    return $userSignGongxianEntity->getId();
11780
-                }, $userSignGongxianEntityList);
11781
-                $userSignGongxianRepository->executeByIdList($userSignGongxianIdList);
11782
-            }
11783
+                /** 结算 PV */
11784
+                /** @var UserPvLogRepository $userPvLogRepository */
11785
+                $userPvLogRepository = app()->make(UserPvLogRepository::class);
11786
+                $userPvLogEntityList = $userPvLogRepository->getUserPvLogEntityListByOrderIdListAndPending(UserPvLogEnum::ORDER_TYPE['Platform']['code'], $unsettledOrderIdList);
11787
+                if (!empty($userPvLogEntityList)) {
11788
+                    $userPvLogIdList = array_map(function ($userPvLogEntity) {
11789
+                        return $userPvLogEntity->getId();
11790
+                    }, $userPvLogEntityList);
11791
+                    $userPvLogRepository->executeByIdList($userPvLogIdList);
11792
+                }
11783 11793
 
11784
-            /** 结算 PV */
11785
-            /** @var UserPvLogRepository $userPvLogRepository */
11786
-            $userPvLogRepository = app()->make(UserPvLogRepository::class);
11787
-            $userPvLogEntityList = $userPvLogRepository->getUserPvLogEntityListByOrderIdListAndPending(UserPvLogEnum::ORDER_TYPE['Platform']['code'], $unsettledOrderIdList);
11788
-            if (!empty($userPvLogEntityList)) {
11789
-                $userPvLogIdList = array_map(function ($userPvLogEntity) {
11790
-                    return $userPvLogEntity->getId();
11791
-                }, $userPvLogEntityList);
11792
-                $userPvLogRepository->executeByIdList($userPvLogIdList);
11793
-            }
11794
+                /** 结算 红包 */
11795
+                /** @var UserSignHongbaoRepository $userSignHongbaoRepository */
11796
+                $userSignHongbaoRepository = app()->make(UserSignHongbaoRepository::class);
11797
+                $userSignHongbaoEntityList = $userSignHongbaoRepository->getUserSignHongbaoEntityListByOrderIdListAndPending(UserSignHongbaoEnum::ORDER_TYPE['Platform']['code'], $unsettledOrderIdList);
11798
+                if (!empty($userSignHongbaoEntityList)) {
11799
+                    $userSignHongbaoIdList = array_map(function ($userSignHongbaoEntity) {
11800
+                        return $userSignHongbaoEntity->getId();
11801
+                    }, $userSignHongbaoEntityList);
11802
+                    $userSignHongbaoRepository->executeByIdList($userSignHongbaoIdList);
11803
+                }
11794 11804
 
11795
-            /** 结算 红包 */
11796
-            /** @var UserSignHongbaoRepository $userSignHongbaoRepository */
11797
-            $userSignHongbaoRepository = app()->make(UserSignHongbaoRepository::class);
11798
-            $userSignHongbaoEntityList = $userSignHongbaoRepository->getUserSignHongbaoEntityListByOrderIdListAndPending(UserSignHongbaoEnum::ORDER_TYPE['Platform']['code'], $unsettledOrderIdList);
11799
-            if (!empty($userSignHongbaoEntityList)) {
11800
-                $userSignHongbaoIdList = array_map(function ($userSignHongbaoEntity) {
11801
-                    return $userSignHongbaoEntity->getId();
11802
-                }, $userSignHongbaoEntityList);
11803
-                $userSignHongbaoRepository->executeByIdList($userSignHongbaoIdList);
11805
+                // 订单奖励结算时 更新订单自身 结算字段
11806
+                $this->dao->settlementOrderByOrderIdList($unsettledOrderIdList);
11807
+            } catch (DbException $e) {
11808
+                throw new ValidateException('订单结算失败');
11804 11809
             }
11805 11810
         }
11806 11811
     }
@@ -12152,4 +12157,40 @@ class StoreOrderRepository extends BaseRepository
12152 12157
         }
12153 12158
         return $paySuccess;
12154 12159
     }
12160
+
12161
+    /**
12162
+     * 订单 分账 方法
12163
+     * @param array $orderIdList
12164
+     * @return void
12165
+     */
12166
+    public function independentAccountByOrderIdList(array $orderIdList)
12167
+    {
12168
+        /** @var StoreOrderRepository $storeOrderRepository */
12169
+        $storeOrderRepository = app()->make(StoreOrderRepository::class);
12170
+        $storeOrderEntityList = $storeOrderRepository->getStoreOrderEntityListByOrderIdList($orderIdList);
12171
+        if (!empty($storeOrderEntityList)) {
12172
+            // 筛选 未分账的 订单ID
12173
+            foreach ($storeOrderEntityList as $storeOrderEntity) {
12174
+                if ($storeOrderEntity->getIsIndependentaccount() == StoreOrderEnum::IS_INDEPENDENT_ACCOUNT['NO']['code']) {
12175
+                    if (0.00 < (double)$storeOrderEntity->getFzonePayPrice()) {
12176
+                        try {
12177
+                            if ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['MemberZone']['code']) {
12178
+                                // 会员专区分账
12179
+                                $storeOrderRepository->vip_product_spiletnew($storeOrderEntity->getOrderSn(), $storeOrderEntity->getPayType());
12180
+                            } elseif ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['WonderfulLiving']['code']) {
12181
+                                // 精彩生活区 走宝塔定时任务 调用 great_life_order_independent_account 命令
12182
+                            } elseif ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['Repurchase']['code']) {
12183
+                                // 复购区不用分账,没有现金支付 只用复购金支付
12184
+                            } else {
12185
+                                // 商贸区 走宝塔定时任务 调用 commercial_area_order_independent_account 命令
12186
+                            }
12187
+                        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
12188
+                            Log::error('订单分账失败:' . $storeOrderEntity->getOrderSn());
12189
+                            throw new ValidateException('分账失败');
12190
+                        }
12191
+                    }
12192
+                }
12193
+            }
12194
+        }
12195
+    }
12155 12196
 }

+ 2 - 2
app/controller/api/Notify.php

@@ -959,9 +959,9 @@ class Notify
959 959
                             $orderss = Db::name('store_order')->where('group_order_id', $group_order_id)->update(['paid'=>1,'pay_time'=>date('Y-m-d H:i:s'),'pay_open_id' => $post_data_str['expend']['open_id']]);
960 960
 
961 961
                             Db::name('store_group_order')->where('group_order_id',$group_order_id)->update(['paid'=>1,'pay_time'=>date('Y-m-d H:i:s')]);
962
-*/
963
-                            event('pay_success_order', ['order_sn' => $requestId[0],'pay_type'=>$pay_type]);
964 962
 
963
+                            event('pay_success_order', ['order_sn' => $requestId[0],'pay_type'=>$pay_type]);
964
+*/
965 965
                             break;
966 966
                         case 'pay_channel':
967 967
                             //渠道商

+ 218 - 0
app/entity/data/financial/FinancialRecordEntity.php

@@ -0,0 +1,218 @@
1
+<?php
2
+
3
+namespace app\entity\data\financial;
4
+
5
+use app\entity\data\DataEntity;
6
+
7
+class FinancialRecordEntity extends DataEntity
8
+{
9
+    public $financialRecordId = null;  // 流水号ID
10
+    public $financialRecordSn = null;  // 流水号
11
+    public $orderId = null;  // 订单号
12
+    public $orderSn = null;  // 订单编号
13
+    public $userInfo = null;  // 用户名
14
+    public $userId = null;  // 用户ID
15
+    public $financialType = null;  // 流水类型
16
+    public $financialPm = null;  // 0 = 支出 1 = 获得
17
+    public $number = null;  // 金额
18
+    public $merId = null;  // 商户ID
19
+    public $createTime = null;  // 创建时间
20
+
21
+    /**
22
+     * @return mixed
23
+     */
24
+    public function getFinancialRecordId()
25
+    {
26
+        return $this->financialRecordId;
27
+    }
28
+
29
+    /**
30
+     * @param mixed $financialRecordId
31
+     * @return FinancialRecordEntity
32
+     */
33
+    public function setFinancialRecordId($financialRecordId): FinancialRecordEntity
34
+    {
35
+        $this->financialRecordId = $financialRecordId;
36
+        return $this;
37
+    }
38
+
39
+    /**
40
+     * @return mixed
41
+     */
42
+    public function getFinancialRecordSn()
43
+    {
44
+        return $this->financialRecordSn;
45
+    }
46
+
47
+    /**
48
+     * @param mixed $financialRecordSn
49
+     * @return FinancialRecordEntity
50
+     */
51
+    public function setFinancialRecordSn($financialRecordSn): FinancialRecordEntity
52
+    {
53
+        $this->financialRecordSn = $financialRecordSn;
54
+        return $this;
55
+    }
56
+
57
+    /**
58
+     * @return mixed
59
+     */
60
+    public function getOrderId()
61
+    {
62
+        return $this->orderId;
63
+    }
64
+
65
+    /**
66
+     * @param mixed $orderId
67
+     * @return FinancialRecordEntity
68
+     */
69
+    public function setOrderId($orderId): FinancialRecordEntity
70
+    {
71
+        $this->orderId = $orderId;
72
+        return $this;
73
+    }
74
+
75
+    /**
76
+     * @return mixed
77
+     */
78
+    public function getOrderSn()
79
+    {
80
+        return $this->orderSn;
81
+    }
82
+
83
+    /**
84
+     * @param mixed $orderSn
85
+     * @return FinancialRecordEntity
86
+     */
87
+    public function setOrderSn($orderSn): FinancialRecordEntity
88
+    {
89
+        $this->orderSn = $orderSn;
90
+        return $this;
91
+    }
92
+
93
+    /**
94
+     * @return mixed
95
+     */
96
+    public function getUserInfo()
97
+    {
98
+        return $this->userInfo;
99
+    }
100
+
101
+    /**
102
+     * @param mixed $userInfo
103
+     * @return FinancialRecordEntity
104
+     */
105
+    public function setUserInfo($userInfo): FinancialRecordEntity
106
+    {
107
+        $this->userInfo = $userInfo;
108
+        return $this;
109
+    }
110
+
111
+    /**
112
+     * @return mixed
113
+     */
114
+    public function getUserId()
115
+    {
116
+        return $this->userId;
117
+    }
118
+
119
+    /**
120
+     * @param mixed $userId
121
+     * @return FinancialRecordEntity
122
+     */
123
+    public function setUserId($userId): FinancialRecordEntity
124
+    {
125
+        $this->userId = $userId;
126
+        return $this;
127
+    }
128
+
129
+    /**
130
+     * @return mixed
131
+     */
132
+    public function getFinancialType()
133
+    {
134
+        return $this->financialType;
135
+    }
136
+
137
+    /**
138
+     * @param mixed $financialType
139
+     * @return FinancialRecordEntity
140
+     */
141
+    public function setFinancialType($financialType): FinancialRecordEntity
142
+    {
143
+        $this->financialType = $financialType;
144
+        return $this;
145
+    }
146
+
147
+    /**
148
+     * @return mixed
149
+     */
150
+    public function getFinancialPm()
151
+    {
152
+        return $this->financialPm;
153
+    }
154
+
155
+    /**
156
+     * @param mixed $financialPm
157
+     * @return FinancialRecordEntity
158
+     */
159
+    public function setFinancialPm($financialPm): FinancialRecordEntity
160
+    {
161
+        $this->financialPm = $financialPm;
162
+        return $this;
163
+    }
164
+
165
+    /**
166
+     * @return mixed
167
+     */
168
+    public function getNumber()
169
+    {
170
+        return $this->number;
171
+    }
172
+
173
+    /**
174
+     * @param mixed $number
175
+     * @return FinancialRecordEntity
176
+     */
177
+    public function setNumber($number): FinancialRecordEntity
178
+    {
179
+        $this->number = $number;
180
+        return $this;
181
+    }
182
+
183
+    /**
184
+     * @return mixed
185
+     */
186
+    public function getMerId()
187
+    {
188
+        return $this->merId;
189
+    }
190
+
191
+    /**
192
+     * @param mixed $merId
193
+     * @return FinancialRecordEntity
194
+     */
195
+    public function setMerId($merId): FinancialRecordEntity
196
+    {
197
+        $this->merId = $merId;
198
+        return $this;
199
+    }
200
+
201
+    /**
202
+     * @return mixed
203
+     */
204
+    public function getCreateTime()
205
+    {
206
+        return $this->createTime;
207
+    }
208
+
209
+    /**
210
+     * @param mixed $createTime
211
+     * @return FinancialRecordEntity
212
+     */
213
+    public function setCreateTime($createTime): FinancialRecordEntity
214
+    {
215
+        $this->createTime = $createTime;
216
+        return $this;
217
+    }
218
+}