Browse Source

采购列表

shish 4 years ago
parent
commit
13768456ac

+ 2 - 2
app-hd/controllers/GoodsController.php

@@ -40,9 +40,9 @@ class GoodsController extends BaseController
             $staff = $this->shopAdmin ?? [];
             $staffName = $staff->name ?? '';
             $post['staffName'] = $staffName;
-            GoodsClass::cgPlant($post, $this->shop);
+            $respond = GoodsClass::cgPlant($post, $this->shop);
             $transaction->commit();
-            util::complete();
+            util::success($respond);
         } catch (Exception $e) {
             $transaction->rollBack();
             util::fail();

+ 24 - 0
app-hd/controllers/PlantCgController.php

@@ -0,0 +1,24 @@
+<?php
+
+namespace hd\controllers;
+
+use bizHd\goods\classes\PlantCgClass;
+use bizHd\goods\classes\PlantCgItemClass;
+use common\components\util;
+use Yii;
+
+class PlantCgController extends BaseController
+{
+
+    //获取采购详情 ssh 20220508
+    public function actionGetFullInfo()
+    {
+        $id = Yii::$app->request->get('id');
+        $cg = PlantCgClass::getById($id, true);
+        PlantCgClass::valid($cg, $this->mainId);
+        $orderSn = $cg->orderSn ?? '';
+        $itemList = PlantCgItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
+        util::success(['info' => $cg, 'itemList' => $itemList]);
+    }
+
+}

+ 6 - 1
biz-hd/goods/classes/GoodsClass.php

@@ -67,7 +67,9 @@ class GoodsClass extends BaseClass
             ];
             $respond = self::addGoods($addGoodsData);
             $goodsId = $respond->id ?? 0;
-            $goodsData = json_encode([['goodsId' => $goodsId, 'num' => $num, 'price' => $cgPrice]]);
+            $goodsSn = $respond->sn ?? '';
+            $cover = isset($shopImg[0]) ? $shopImg[0] : '';
+            $goodsData = json_encode([['goodsId' => $goodsId, 'num' => $num, 'price' => $cgPrice, 'goodsSn' => $goodsSn, 'cover' => $cover]]);
         }
         $goodsData = json_decode($goodsData, true);
         if (empty($goodsData) || !is_array($goodsData)) {
@@ -89,6 +91,7 @@ class GoodsClass extends BaseClass
         $totalNum = 0;
         foreach ($goodsData as $postGoods) {
             $goodsId = $postGoods['goodsId'] ?? 0;
+            $goodsSn = $postGoods['goodsSn'] ?? '';
             $name = $goodsInfo[$goodsId]['name'] ?? '';
             $cover = $goodsInfo[$goodsId]['cover'] ?? '';
             $num = $postGoods['num'] ?? 0;
@@ -98,6 +101,7 @@ class GoodsClass extends BaseClass
             $addCgItem = [
                 'orderSn' => $orderSn,
                 'goodsId' => $goodsId,
+                'goodsSn' => $goodsSn,
                 'name' => $name,
                 'cover' => $cover,
                 'num' => $num,
@@ -164,6 +168,7 @@ class GoodsClass extends BaseClass
         //采购总量统计
         $cgNum = $return->num ?? 0;
         StatCgPlantClass::replace($main, $orderPrice, $cgNum);
+        return $return;
     }
 
     //获取商品完整详情,包括商品的分类 ssh 2019.12.3

+ 11 - 0
biz-hd/goods/classes/PlantCgClass.php

@@ -3,6 +3,7 @@
 namespace bizHd\goods\classes;
 
 use bizHd\base\classes\BaseClass;
+use common\components\util;
 
 class PlantCgClass extends BaseClass
 {
@@ -15,4 +16,14 @@ class PlantCgClass extends BaseClass
         return self::add($data, true);
     }
 
+    public static function valid($cg, $mainId)
+    {
+        if (empty($cg)) {
+            util::fail('没有找到采购信息');
+        }
+        if ($cg->mainId != $mainId) {
+            util::fail('没有权限');
+        }
+    }
+
 }

+ 2 - 1
sql.sql

@@ -1010,4 +1010,5 @@ ALTER TABLE xhShop ADD defaultCustomId INT NOT NULL DEFAULT 0 COMMENT '门店默
 ALTER TABLE xhGhsCustom ADD mainId INT NOT NULL DEFAULT 0 COMMENT '' AFTER `shopId`;
 ALTER TABLE xhGhs ADD mainId INT NOT NULL DEFAULT 0 COMMENT '中央id' AFTER `shopId`;
 ALTER TABLE xhOrder ADD `getStaffId` INT NOT NULL DEFAULT 0 COMMENT '收款人id' AFTER `shopAdminName`;
-ALTER TABLE xhOrder ADD `getStaffName` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '收款人名称' AFTER `getStaffId`;
+ALTER TABLE xhOrder ADD `getStaffName` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '收款人名称' AFTER `getStaffId`;
+ALTER TABLE xhPlantCgItem ADD goodsSn CHAR(30) NOT NULL DEFAULT '' COMMENT '编号' AFTER `goodsId`;