Przeglądaj źródła

Merge branch 'redesign‌-260706' into dev

shizhongqi 1 dzień temu
rodzic
commit
b58dda25b5

+ 19 - 5
app-mall/controllers/OrderController.php

@@ -12,6 +12,7 @@ use bizHd\order\classes\OrderClass as HdOrderClass;
 use bizHd\order\classes\PsMethodClass;
 use bizHd\order\classes\WholeOrderDiscountClass;
 use bizHd\refund\classes\HdRefundClass;
+use bizHd\refund\classes\HdRefundMallClass;
 use bizHd\hb\classes\HbClass;
 use bizHd\hb\classes\HbScopeClass;
 use bizHd\homePageConfig\classes\HomePageModuleClass;
@@ -1985,7 +1986,7 @@ class OrderController extends BaseController
         util::complete('提交成功');
     }
 
-    //订单详情 ssh 2019.12.16
+    // 订单详情:含 canApplyRefund / refundApplyId,供底部申请售后、查看申请
     public function actionDetail()
     {
         $id = Yii::$app->request->get('id', 0);
@@ -2009,9 +2010,19 @@ class OrderController extends BaseController
         $detail['balance'] = $balance;
 
         $detail['rechargeWeal'] = $this->shop->rechargeWeal; //是否开启余额支付
-        // 与 RefundController::canApplyRefund 对齐,供详情页「申请售后」显隐
+        // 与 RefundController::canApplyRefund 对齐;最新申请供详情页「查看申请」入口
         $detail['distOrderSettled'] = DistributionOrderClass::isDistOrderSettled((int)$id) ? 1 : 0;
-        $detail['canApplyRefund'] = $this->canApplyRefundForDetail($detail) ? 1 : 0;
+        $apply = HdRefundClass::getLatestByOrderId((int)$id);
+        $detail['canApplyRefund'] = $this->canApplyRefundForDetail($detail, $apply) ? 1 : 0;
+        $detail['refundApplyId'] = 0;
+        $detail['refundApplyStatus'] = '';
+        $detail['refundApplyStatusText'] = '';
+        // 有顾客申请才给入口;商家即时售后 userId=0 不展示「查看申请」
+        if (!empty($apply) && !empty($apply['id'])) {
+            $detail['refundApplyId'] = (int)$apply['id'];
+            $detail['refundApplyStatus'] = (int)($apply['status'] ?? 0);
+            $detail['refundApplyStatusText'] = HdRefundMallClass::statusText($apply['status'] ?? 0);
+        }
         // 配送方式名称:xhPsMethod.name(style = 订单 sendType)
         $detail['psMethodName'] = $this->resolvePsMethodName($detail);
         util::success($detail);
@@ -2042,9 +2053,10 @@ class OrderController extends BaseController
     /**
      * 订单详情是否可申请售后(与 mall RefundController::canApplyRefund 规则一致)
      * @param array $order 订单详情
+     * @param array|null $apply 最新顾客申请,避免详情里重复查
      * @return bool
      */
-    protected function canApplyRefundForDetail($order)
+    protected function canApplyRefundForDetail($order, $apply = null)
     {
         if ((int)($order['payStatus'] ?? 0) !== 1) {
             return false;
@@ -2056,7 +2068,9 @@ class OrderController extends BaseController
         if ((int)($order['forward'] ?? 0) === 1) {
             return false;
         }
-        $apply = HdRefundClass::getLatestByOrderId((int)($order['id'] ?? 0));
+        if ($apply === null) {
+            $apply = HdRefundClass::getLatestByOrderId((int)($order['id'] ?? 0));
+        }
         if (!empty($apply) && (int)($apply['status'] ?? -1) === HdRefundClass::STATUS_PENDING) {
             return false;
         }

+ 1 - 1
sql/20260825_hd_refund_mall_apply.sql

@@ -6,7 +6,7 @@ ALTER TABLE `xhHdRefund`
   MODIFY COLUMN `status` tinyint(2) unsigned NOT NULL DEFAULT 0 COMMENT '0待审核 1已通过 2已驳回 3已取消',
   ADD COLUMN `userId` int(11) NOT NULL DEFAULT 0 COMMENT '商城用户id,商家发起为0' AFTER `customId`,
   ADD COLUMN `hdId` int(11) NOT NULL DEFAULT 0 COMMENT '花店客户id(xhHd)' AFTER `userId`,
-  ADD COLUMN `product` text COMMENT '待审核阶段勾选商品/花材JSON快照,通过后转 xhHdRefundItem/Goods' AFTER `refundType`,
+  ADD COLUMN `product` varchar(2000) NOT NULL DEFAULT '' COMMENT '待审核阶段勾选商品/花材JSON快照,通过后转 xhHdRefundItem/Goods' AFTER `refundType`,
   ADD COLUMN `rejectReason` varchar(255) NOT NULL DEFAULT '' COMMENT '驳回原因' AFTER `remark`,
   ADD KEY `idx_userId_status` (`userId`,`status`),
   ADD KEY `idx_shop_status` (`shopId`,`status`);