shish 11 місяців тому
батько
коміт
69e5703916

+ 19 - 7
app-hd/controllers/OrderController.php

@@ -628,14 +628,26 @@ class OrderController extends BaseController
             }
         }
 
-        if (empty($productList) && empty($groupId)) {
-            if ($post['lsGoodsPrice'] <= 0) {
-                $lsGoodsPrice = $post['lsGoodsPrice'];
-                if (!is_numeric($lsGoodsPrice)) {
-                    util::fail('请输入正确的金额');
-                }
-                util::fail('请填写金额或选商品');
+        //直接收款
+        $zjGathering = $post['zjGathering'] ?? 0;
+        if ($zjGathering == 1) {
+            $lsGoodsPrice = $post['lsGoodsPrice'] ?? 0;
+            if (!is_numeric($lsGoodsPrice) || $lsGoodsPrice <= 0) {
+                util::fail('请填写价格');
+            }
+            //直接收款不需要打印小票
+            $post['needPrint'] = dict::getDict('needPrint', 'noNeed');
+            $shopId = $this->shopId;
+            $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+            $gatheringItem = !empty($ext) ? $ext->gatheringItem : 0;
+            if (empty($gatheringItem)) {
+                util::fail('请设置付款用的商品');
+            }
+            $gatheringItemInfo = ProductClass::getById($gatheringItem, true);
+            if (empty($gatheringItemInfo)) {
+                util::fail('付款用的商品没有设置');
             }
+            $productList = [['productId' => $gatheringItem, 'unitType' => 0, 'num' => 1, 'property' => '1', 'unitPrice' => $lsGoodsPrice]];
         }
 
         $connection = Yii::$app->db;

+ 2 - 10
biz-hd/order/services/OrderService.php

@@ -51,9 +51,7 @@ class OrderService extends BaseService
             util::fail('暂不支持使用组合功能');
         }
         if (empty($product)) {
-            if (!isset($data['lsGoodsPrice']) || $data['lsGoodsPrice'] <= 0) {
-                util::fail('没有商品');
-            }
+            util::fail('没有商品');
         }
 
         $currentGoodsIds = [];
@@ -79,13 +77,7 @@ class OrderService extends BaseService
             $itemInfo = \bizGhs\item\classes\ItemClass::getByIds($currentItemIds, null, 'id');
         }
 
-        if (isset($data['lsGoodsPrice']) && $data['lsGoodsPrice'] > 0) {
-            //临时收款不需要打印小票
-            $data['needPrint'] = dict::getDict('needPrint', 'noNeed');
-        }
-        //临时收款会传商品金额
-        $goodsPrice = isset($data['lsGoodsPrice']) && $data['lsGoodsPrice'] > 0 ? $data['lsGoodsPrice'] : 0;
-
+        $goodsPrice = 0;
         $manyType = count($product) > 1 ? 1 : 0;
         $totalWeight = 0;
         $orderCover = '';