shish 7 сар өмнө
parent
commit
5dff9e5837

+ 13 - 0
biz-hd/purchase/services/PurchaseService.php

@@ -56,6 +56,19 @@ class PurchaseService extends BaseService
         if (empty($custom)) {
             util::fail('没有找到客户');
         }
+
+        //欠款超额,是否允许使用现金下单
+        if ($custom['debtLimitPay'] == 1) {
+            //欠款超额,不允许使用现金下单
+            $debtLimit = $custom['debtLimit'] ?? 0;
+            $debtAmount = $custom['debtAmount'] ?? 0;
+            $actPrice = $respond->actPrice ?? 0;
+            $finalDebtAmount = bcadd($debtAmount, $actPrice, 2);
+            if ($finalDebtAmount > $debtLimit && $debtLimit > 0) {
+                util::fail('请结清欠款再下单');
+            }
+        }
+
         $customName = $custom['name'] ?? '';
         $customNamePy = $custom['py'] ?? '';
         $customMobile = $custom['mobile'] ?? '';