Explorar o código

订单结算-共富区结算时间从T+1结算改为立即结算

sunxbiao hai 5 meses
pai
achega
5cfb82a524

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

@@ -47,6 +47,7 @@ use think\exception\ValidateException;
47 47
 use think\facade\Db;
48 48
 use think\facade\Log;
49 49
 use think\model\Relation;
50
+use Throwable;
50 51
 
51 52
 /**
52 53
  * Class StoreGroupOrderRepository
@@ -197,7 +198,7 @@ class StoreGroupOrderRepository extends BaseRepository
197 198
                     $storeOrderRepository->closeStoreOrder($storeOrderEntity, $uid, $changeMessage, $remark);
198 199
                 }
199 200
             });
200
-        } catch (\Throwable $e) {
201
+        } catch (Throwable $e) {
201 202
             throw new ValidateException('关闭订单失败:' . json_encode([
202 203
                     'error_message' => $e->getMessage(),
203 204
                     'error_file' => $e->getFile(),
@@ -921,7 +922,7 @@ class StoreGroupOrderRepository extends BaseRepository
921 922
                     $storeGroupOrderRepository->storeGroupOrderPaySuccess($storeGroupOrderEntity->getGroupOrderId());
922 923
                 }
923 924
             });
924
-        } catch (\Throwable  $e) {
925
+        } catch (Throwable  $e) {
925 926
             Log::error('StoreGroupOrderRepository-createStoreGroupOrder:' . $e->getMessage());
926 927
             return [
927 928
                 'code' => 10001,
@@ -941,7 +942,7 @@ class StoreGroupOrderRepository extends BaseRepository
941 942
      * @param string $rand 当现金支付时,汇付会在订单尾部跟一个随机数
942 943
      * @param string|null $payOpenId 当现金支付时,付款人的Id
943 944
      * @return void
944
-     * @throws DbException
945
+     * @throws Throwable
945 946
      */
946 947
     public function storeGroupOrderPaySuccess(int $groupOrderId, string $rand = '', string $payOpenId = null): void
947 948
     {
@@ -978,8 +979,9 @@ class StoreGroupOrderRepository extends BaseRepository
978 979
             // 生成奖励数据
979 980
             $storeOrderRepository->createRewardMechanismByStoreOrderId($storeOrderEntity->getOrderId());
980 981
 
981
-            if ($storeOrderEntity->getMerId() == CommonEnum::DESIGN_MERCHANT_ID['MemberZone']['code']) {
982
+            if (in_array($storeOrderEntity->getMerId(), [CommonEnum::DESIGN_MERCHANT_ID['MemberZone']['code'], CommonEnum::DESIGN_MERCHANT_ID['SharedProsperity']['code']])) {
982 983
                 // 会员专区的 订单立即结算
984
+                // 共富区的订单立即结算
983 985
                 $settlementOrderIdList[] = $storeOrderEntity->getOrderId();
984 986
             }
985 987
 

+ 20 - 1
app/controller/api/Notify.php

@@ -202,7 +202,26 @@ class Notify
202 202
                             }
203 203
 
204 204
                             // 3、支付成功 处理逻辑
205
-                            $storeGroupOrderRepository->storeGroupOrderPaySuccess($storeGroupOrderEntity->getGroupOrderId());
205
+                            try {
206
+                                Db::transaction(function () use (
207
+                                    $storeGroupOrderRepository,
208
+                                    $storeGroupOrderEntity
209
+                                ) {
210
+                                    $storeGroupOrderRepository->storeGroupOrderPaySuccess($storeGroupOrderEntity->getGroupOrderId());
211
+                                });
212
+                            } catch (\Throwable $e) {
213
+                                Db::name("log")
214
+                                    ->insert([
215
+                                        'data' => '【订单支付回调】【结算订单失败】:时间:' . date('Y-m-d H:i:s', time()) . ';订单编号:' . $groupOrderSn_Rand . ';订单失败原因:' . json_encode([
216
+                                                'error_message' => $e->getMessage(),
217
+                                                'error_file' => $e->getFile(),
218
+                                                'error_line' => $e->getLine(),
219
+                                                'error_code' => $e->getCode(),
220
+                                                'exception_class' => get_class($e),
221
+                                                'trace' => $e->getTraceAsString()
222
+                                            ], JSON_UNESCAPED_UNICODE)
223
+                                    ]);
224
+                            }
206 225
                             /*
207 226
                             $group_order = Db::name('store_group_order')->where('group_order_sn', $requestId[0])->find();
208 227
                             $uid = $group_order['uid'];