shish před 8 měsíci
rodič
revize
5c6720d885

+ 22 - 3
app-ghs/controllers/CustomController.php

@@ -147,7 +147,7 @@ class CustomController extends BaseController
         if (getenv('YII_ENV') == 'production') {
             //小向花卉
             if (in_array($this->shopId, [23580, 24713])) {
-                if (!in_array($this->adminId, [24043, 23960, 4,77951])) {
+                if (!in_array($this->adminId, [24043, 23960, 4, 77951])) {
                     util::fail('不能销单哦!!');
                 }
             }
@@ -681,7 +681,7 @@ class CustomController extends BaseController
                 $producer = Yii::$app->rabbitmq->getProducer('customProducer');
                 $msg = serialize(['type' => 'add_custom', 'name' => $name, 'mobile' => $mobile, 'sjId' => $this->sjId,
                     'shopId' => $this->shop->id, 'sjName' => $this->sj->name, 'staffId' => $this->shopAdminId]);
-                $producer->publish($msg, 'customExchange', 'customRoute',['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
+                $producer->publish($msg, 'customExchange', 'customRoute', ['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
             } catch (\Exception $e) {
                 $msg = $e->getMessage();
                 $remind = "供货商创建新客户,生产消息报错 {$name} {$mobile} {$this->sj->name} {$msg}";
@@ -730,7 +730,7 @@ class CustomController extends BaseController
         try {
             $producer = Yii::$app->rabbitmq->getProducer('customProducer');
             $msg = serialize(['type' => 'pull_custom_from_other_shop', 'toShopId' => $toShopId, 'fromShopId' => $fromShopId]);
-            $producer->publish($msg, 'customExchange', 'customRoute',['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
+            $producer->publish($msg, 'customExchange', 'customRoute', ['delivery_mode' => 2, 'content_type' => 'application/octet-stream']);
         } catch (\Exception $e) {
             $msg = $e->getMessage();
             $remind = "供货商拉取其他门店客户,生产消息报错 {$toShopId} {$fromShopId} {$msg}";
@@ -1195,4 +1195,23 @@ class CustomController extends BaseController
         util::complete('删除成功');
     }
 
+    public function actionChangeDebtLimitPay()
+    {
+        $get = Yii::$app->request->get();
+        $customId = $get['customId'] ?? 0;
+        $debtLimitPay = $get['pay'] ?? 0;
+        $custom = CustomClass::getById($customId, true);
+        CustomClass::valid($custom, $this->shopId);
+        $ghsId = $custom->ghsId ?? 0;
+        $ghs = GhsClass::getById($ghsId, true);
+        if (empty($ghs)) {
+            util::fail('客户信息有问题');
+        }
+        $custom->debtLimitPay = $debtLimitPay;
+        $custom->save();
+        $ghs->debtLimitPay = $debtLimitPay;
+        $ghs->save();
+        util::complete('修改成功');
+    }
+
 }

+ 19 - 0
app-hd/controllers/PurchaseController.php

@@ -267,6 +267,25 @@ class PurchaseController extends BaseController
             if (empty($custom)) {
                 util::fail('用户信息缺失');
             }
+
+            //欠款超额,是否允许使用现金下单
+            if ($custom->debtLimitPay == 1) {
+                //欠款超额,不允许使用现金下单
+                $debtLimit = $custom->debtLimit ?? 0;
+                $debtAmount = $custom->debtAmount ?? 0;
+                if ($debtAmount > $debtLimit && $debtLimit > 0) {
+                    if (getenv('YII_ENV') == 'production') {
+                        //福清辉煌鲜花
+                        $myMainId = 45984;
+                    } else {
+                        $myMainId = 644;
+                    }
+                    if ($ghsInfo['mainId'] == $myMainId) {
+                        util::fail('请先结清欠款再下单');
+                    }
+                }
+            }
+
             $post['customId'] = $customId;
             $shopAdmin = $this->shopAdmin ?? null;
             $name = $shopAdmin->name ?? '';