Przeglądaj źródła

Merge branch 'after-sale' into dev

shish 2 godzin temu
rodzic
commit
627e721c04

+ 29 - 6
biz-ghs/order/services/NextDayRefundService.php

@@ -117,7 +117,32 @@ class NextDayRefundService
     }
 
     /**
-     * 解析隔天资金方式:挂账/余额强制返余额;在线可选原路/返余额/仅记账。
+     * 原单是否为微信/支付宝线上支付(隔天也可原路退回的前提)
+     */
+    public static function isOnlinePayOrder($order)
+    {
+        if (empty($order)) {
+            return false;
+        }
+        $payWay = intval($order->payWay ?? 0);
+        $onlinePay = intval($order->onlinePay ?? dict::getDict('onlinePay', 'not'));
+        $wxPay = dict::getDict('payWay', 'wxPay');
+        $aliPay = dict::getDict('payWay', 'alipay');
+        return $onlinePay == dict::getDict('onlinePay', 'yes')
+            && in_array($payWay, [$wxPay, $aliPay], true);
+    }
+
+    /**
+     * 隔天售后未选手选资金时的默认值:线上默认原路,其它默认返余额。
+     * 最终仍须经 resolveFundType 收敛(挂账/余额强制返余额)。
+     */
+    public static function defaultNextDayFundType($order)
+    {
+        return self::isOnlinePayOrder($order) ? self::FUND_ORIGINAL : self::FUND_BALANCE;
+    }
+
+    /**
+     * 解析隔天资金方式:挂账/余额强制返余额;线上可选原路/返余额/仅记账。
      * $hasRelateOrder=false 表示无原单退款(工作台「退款」),不可原路退。
      */
     public static function resolveFundType($fundType, $order, $hasRelateOrder = true)
@@ -134,16 +159,14 @@ class NextDayRefundService
             return $fundType;
         }
         $payWay = intval($order->payWay ?? 0);
-        $onlinePay = intval($order->onlinePay ?? dict::getDict('onlinePay', 'not'));
         $debtPay = dict::getDict('payWay', 'debtPay');
         $balancePay = dict::getDict('payWay', 'balancePay');
-        $wxPay = dict::getDict('payWay', 'wxPay');
-        $aliPay = dict::getDict('payWay', 'alipay');
-        $isOnline = $onlinePay == dict::getDict('onlinePay', 'yes') && in_array($payWay, [$wxPay, $aliPay], true);
+        // 挂账/余额付款:隔天只能返余额
         if ($payWay === $debtPay || $payWay === $balancePay) {
             return self::FUND_BALANCE;
         }
-        if ($isOnline) {
+        // 线上付款:隔天也允许原路退回(与当天售后一致)
+        if (self::isOnlinePayOrder($order)) {
             if (!in_array($fundType, [self::FUND_ORIGINAL, self::FUND_BALANCE, self::FUND_NONE], true)) {
                 util::fail('请选择资金处理方式');
             }

+ 5 - 4
biz-ghs/order/services/RefundOrderService.php

@@ -134,13 +134,14 @@ class RefundOrderService extends BaseService
 
     /**
      * 将当天售后单转为隔天冲销类型(审核跨日/已结清时调用)
-     * 同步写销售售后单与采购售后单的 sameDay、fundType;花店申请无资金弹窗时默认返余额。
+     * 同步写销售售后单与采购售后单的 sameDay、fundType;
+     * 花店申请无资金弹窗时:线上默认原路,其它默认返余额。
      */
     public static function convertRefundToNextDay($refund, $order)
     {
         $fundType = intval($refund->fundType ?? 0);
         if ($fundType === NextDayRefundService::FUND_UNUSED) {
-            $fundType = NextDayRefundService::FUND_BALANCE;
+            $fundType = NextDayRefundService::defaultNextDayFundType($order);
         }
         $fundType = NextDayRefundService::resolveFundType($fundType, $order, true);
 
@@ -279,9 +280,9 @@ class RefundOrderService extends BaseService
                 util::fail($check['reason'] ?? '当前订单不可隔天冲销');
             }
             $fundTypeInput = intval($post['fundType'] ?? 0);
-            // 未选手选资金时默认返余额(商家弹窗会覆盖;漏传/花店申请兜底
+            // 未选手选资金时:线上默认原路,其它默认返余额(商家弹窗会覆盖)
             if ($fundTypeInput === NextDayRefundService::FUND_UNUSED) {
-                $fundTypeInput = NextDayRefundService::FUND_BALANCE;
+                $fundTypeInput = NextDayRefundService::defaultNextDayFundType($order);
             }
             $fundType = NextDayRefundService::resolveFundType($fundTypeInput, $order, true);
             $data['sameDay'] = RefundOrderClass::SAME_DAY_NO;

+ 2 - 2
biz-hd/cg/services/CgRefundService.php

@@ -56,13 +56,13 @@ class CgRefundService extends BaseService
         // 无支付时间不能售后;仅用 payTime 判当天/隔天
         NextDayRefundService::assertCanRefund($order);
 
-        // 非当天 / 已结账 / 挂账结清 → 申请即写隔天售后;无资金弹窗时默认返余额
+        // 非当天 / 已结账 / 挂账结清 → 申请即写隔天售后;无资金弹窗时按支付方式默认(线上原路,其它返余额
         $sameDay = CgRefundClass::SAME_DAY_YES;
         $fundType = NextDayRefundService::FUND_UNUSED;
         if (NextDayRefundService::mustUseNextDay($order)) {
             $sameDay = CgRefundClass::SAME_DAY_NO;
             $fundType = NextDayRefundService::resolveFundType(
-                NextDayRefundService::FUND_BALANCE,
+                NextDayRefundService::defaultNextDayFundType($order),
                 $order,
                 true
             );