Jelajahi Sumber

申请售后

shish 2 tahun lalu
induk
melakukan
d9c101ef0d
1 mengubah file dengan 12 tambahan dan 1 penghapusan
  1. 12 1
      app-hd/controllers/CgRefundController.php

+ 12 - 1
app-hd/controllers/CgRefundController.php

@@ -8,6 +8,7 @@ use bizGhs\order\classes\RefundOrderClass;
 use bizHd\cg\classes\CgRefundClass;
 use bizHd\cg\classes\CgRefundItemClass;
 use bizHd\cg\services\CgRefundService;
+use bizHd\ghs\classes\GhsClass;
 use bizHd\purchase\classes\PurchaseClass;
 use bizHd\shop\classes\ShopClass;
 use common\components\imgUtil;
@@ -48,7 +49,7 @@ class CgRefundController extends BaseController
     public function actionCreateRefund()
     {
         $post = Yii::$app->request->post();
-        $id = isset($post['id']) ? $post['id'] : 0;
+        $id = $post['id'] ?? 0;
         $cg = PurchaseClass::getById($id, true);
         if (empty($cg)) {
             util::fail('没有找到采购单');
@@ -56,6 +57,16 @@ class CgRefundController extends BaseController
         if ($cg->mainId != $this->mainId) {
             util::fail('没有权限操作');
         }
+        $ghsId = $cg->ghsId ?? 0;
+        $ghs = GhsClass::getById($ghsId, true);
+        if (empty($ghs)) {
+            util::fail('没有供货商信息');
+        }
+        $ghsShopId = $ghs->shopId ?? 0;
+        $ghsShop = ShopClass::getById($ghsShopId, true);
+        if (isset($ghsShop->afterSale) && $ghsShop->afterSale == 0) {
+            util::fail('申请售后功能未开通');
+        }
         if ($cg->status == PurchaseClass::STATUS_UN_PAY) {
             util::fail("待付款订单,不能申请售后");
         }