Sfoglia il codice sorgente

开单生成制作单

shish 4 anni fa
parent
commit
ba307c4b3c

+ 9 - 2
app-hd/controllers/OrderController.php

@@ -6,6 +6,7 @@ use biz\shop\classes\ShopExtClass;
 use biz\sj\services\MerchantExtendService;
 use biz\sj\services\MerchantService;
 use bizHd\custom\classes\CustomClass;
+use bizHd\goods\classes\GoodsClass;
 use bizHd\merchant\services\ShopService;
 use bizHd\order\classes\OrderClass;
 use bizHd\order\classes\OrderSendClass;
@@ -381,15 +382,21 @@ class OrderController extends BaseController
         $productJson = $post['product'] ?? '';
         if (empty($productJson) && empty($groupId)) {
             if (isset($post['lsGoodsPrice']) == false || $post['lsGoodsPrice'] <= 0) {
-                util::fail('请选商品');
+                util::fail('请填写金额或选商品');
             }
         }
         $productList = json_decode($productJson, true);
         if (empty($productList) && empty($groupId)) {
             if (isset($post['lsGoodsPrice']) == false || $post['lsGoodsPrice'] <= 0) {
-                util::fail('请选商品');
+                util::fail('请填写金额或选商品');
             }
         }
+
+        //商家上传图片开单并要求生成制作单
+        if (isset($post['cover']) && !empty($post['cover'])) {
+            $productList = GoodsClass::kdWorkGoods($post);
+        }
+
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
         try {

+ 40 - 0
biz-hd/goods/classes/GoodsClass.php

@@ -26,6 +26,46 @@ class GoodsClass extends BaseClass
 
     const LOCK_STOCK_GOODS = 'lock_stock_goods_';//修改库存锁
 
+    public static function kdWorkGoods($data)
+    {
+        $name = $data['name'] ?? '';
+        $salePrice = 0;
+        $sjId = $data['sjId'] ?? 0;
+        $mainId = $data['mainId'] ?? 0;
+        $shopId = $data['shopId'] ?? 0;
+        $status = 0;
+        $delStatus = 0;
+        $catId = $data['catId'] ?? 0;
+        if(empty($catId)){
+            util::fail('请选择分类');
+        }
+        $catIds = [$catId];
+        $cover = $data['cover']??'';
+        $shopImg = [$cover];
+        $addGoodsData = [
+            'name' => $name,
+            'flower' => 0,
+            'property' => 0,
+            'price' => $salePrice,
+            'sjId' => $sjId,
+            'mainId' => $mainId,
+            'shopId' => $shopId,
+            'status' => $status,
+            'delStatus' => $delStatus,
+            'shopImg' => $shopImg,
+            'catIds' => $catIds,
+            'cover' => $cover,
+        ];
+        $respond = self::addGoods($addGoodsData);
+        $id = $respond->id ?? 0;
+        $property = dict::getDict('property', 'goods');
+        $num = $data['num'] ?? 0;
+        $unitType = 0;
+        $unitPrice = 0;
+        $product = [['productId' => $id, 'num' => $num, 'unitType' => $unitType, 'unitPrice' => $unitPrice, 'property' => $property]];
+        return $product;
+    }
+
     public static function cgPlant($data, $shop)
     {
         //[{"goodsId":"1486","num":"1","price":"2"}]