Pārlūkot izejas kodu

关于单位名称的修改

shish 5 gadi atpakaļ
vecāks
revīzija
717649a126

+ 11 - 9
app-ghs/controllers/ItemController.php

@@ -1,21 +1,23 @@
 <?php
-namespace ghs\controllers;
 
+namespace ghs\controllers;
 
 use bizGhs\item\classes\ItemClass;
 use bizGhs\item\services\ItemService;
 use common\components\util;
 use common\services\xhItemService;
 use Yii;
+
 class ItemController extends BaseController
 {
 
     public function actionList()
     {
-        //classId
-        $classId = Yii::$app->request->get('classId',0);
-        $where['merchantId'] =  $this->sjId;
-        $where['classId'] =  $classId;
+        $classId = Yii::$app->request->get('classId', 0);
+        $where['merchantId'] = $this->sjId;
+        if (!empty($classId)) {
+            $where['classId'] = $classId;
+        }
         $list = ItemClass::getGhsItemList($where);
         util::success($list);
     }
@@ -43,19 +45,19 @@ class ItemController extends BaseController
     {
         $get = Yii::$app->request->get();
         $id = isset($get['id']) ? $get['id'] : 0;
-        ItemService::deleteGhsItem($id,$this->shopId,$this->sjId,$this->adminId);
+        ItemService::deleteGhsItem($id, $this->shopId, $this->sjId, $this->adminId);
         util::complete('操作成功');
     }
 
     //获取平台里的花材信息
     public function actionPlatformItem()
     {
-        $py = Yii::$app->request->get('py','');
+        $py = Yii::$app->request->get('py', '');
         $where = [];
-        if($py){
+        if ($py) {
             $where = ['py' => $py];
         }
-        $list = xhItemService::getItemList('*',$where,'id desc');
+        $list = xhItemService::getItemList('*', $where, 'id desc');
         util::success($list);
     }
 }

+ 2 - 2
app-ghs/controllers/ProductController.php

@@ -126,7 +126,7 @@ class ProductController extends BaseController
             if (!$itemData) {
                 util::fail("出错拉");
             }
-            $price = bcadd($itemData['unitCost'], $itemData['unitAddPrice'], 2);
+            $price = bcadd($itemData['cost'], $itemData['addPrice'], 2);
             ProductClass::changePrice($productId, $this->shopId, $price, ProductClass::PRICE_LABEL_AUTO);
         }
         util::success(['price'=>$price]);
@@ -147,7 +147,7 @@ class ProductController extends BaseController
         if (!$itemData) {
             util::fail("出错拉");
         }
-        $price = bcadd($itemData['unitCost'], $itemData['unitAddPrice'], 2);
+        $price = bcadd($itemData['cost'], $itemData['addPrice'], 2);
         ProductClass::changePrice($productId, $this->shopId, $price, ProductClass::PRICE_LABEL_AUTO);
         util::complete("操作成功");
     }

+ 6 - 6
biz-ghs/item/classes/ItemClass.php

@@ -45,13 +45,13 @@ class ItemClass extends BaseClass
     }
 
     //修改花材的信息(库存预警、每扎加价、每扎重量)
-    public static function updateGshItem($id,$stockWarning,$unitAddPrice,$unitWeight,$unitCost)
+    public static function updateGshItem($id,$stockWarning,$addPrice,$weight,$cost)
     {
 
         $data['stockWarning'] = $stockWarning;
-        $data['unitAddPrice'] = $unitAddPrice;
-        $data['unitWeight'] = $unitWeight;
-        $data['unitCost'] = $unitCost;
+        $data['addPrice'] = $addPrice;
+        $data['weight'] = $weight;
+        $data['cost'] = $cost;
         self::updateById($id,$data);
         return true;
 
@@ -105,8 +105,8 @@ class ItemClass extends BaseClass
     }
 
     //修改某个花材的成本价(采购之后要用到) linqh 2021.1.28
-    public static function changeCost($itemId,$merchantId,$unitCost)
+    public static function changeCost($itemId,$merchantId,$cost)
     {
-        return self::updateByCondition(['itemId'=>$itemId,'merchantId'=>$merchantId],['unitCost'=>$unitCost]);
+        return self::updateByCondition(['itemId'=>$itemId,'merchantId'=>$merchantId],['cost'=>$cost]);
     }
 }

+ 1 - 1
biz-ghs/item/classes/ItemClassClass.php

@@ -20,7 +20,7 @@ class ItemClassClass extends BaseClass
 
     public static function getGhsItemClassList($where)
     {
-        $data = self::getList('*', $where, 'addTime DESC');
+        $data = self::getList('*', $where, 'inTurn DESC');
         $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
         if (empty($list)) {
             return $data;

+ 7 - 7
biz-ghs/item/services/ItemService.php

@@ -90,19 +90,19 @@ class ItemService extends BaseService
     {
         $id = $data['id']??0;
         $stockWarning = $data['stockWarning']??0;
-        $unitAddPrice = $data['unitAddPrice']??0;
-        $unitWeight = $data['unitWeight']??0;
-        $unitCost = $data['unitCost']??0; //成本价
+        $addPrice = $data['addPrice']??0;
+        $weight = $data['weight']??0;
+        $cost = $data['cost']??0; //成本价
         if($stockWarning < 0 ){
             util::fail("库存预警不能小于0");
         }
-        if($unitAddPrice < 0 ){
+        if($addPrice < 0 ){
             util::fail("每扎加价不能小于0");
         }
-        if($unitWeight < 0 ){
+        if($weight < 0 ){
             // util::fail("每扎重量不能小于0");
         }
-        if($unitCost < 0 ){
+        if($cost < 0 ){
             util::fail("成本价不能小于0");
         }
 
@@ -114,7 +114,7 @@ class ItemService extends BaseService
             util::fail("参数错误");
         }
 
-        ItemClass::updateGshItem($id,$stockWarning,$unitAddPrice,$unitWeight,$unitCost);
+        ItemClass::updateGshItem($id,$stockWarning,$addPrice,$weight,$cost);
     }
 
     //删除花材,同时修改itemInfo 的状态值 delStatus = 1

+ 2 - 2
biz-ghs/product/services/ProductService.php

@@ -115,9 +115,9 @@ class ProductService extends BaseService
             $productId = $v['productId'];
             $itemId = $productData[$productId]['itemId'];
             $unitNum = $itemData[$itemId]['unitNum']??0;
-            $unitWeight = $itemData[$itemId]['unitWeight']??0;// 每扎重量
+            $weight = $itemData[$itemId]['weight']??0;// 每扎重量
             $itemNum = ProductClass::mergeItemNum($v['bigNum'],$v['smallNum'],$unitNum); // 总共多少扎
-            $weight = bcmul($unitWeight,$itemNum,2);
+            $weight = bcmul($weight,$itemNum,2);
             $itemPrice =$productData[$productId]['price']??0; //当时售卖的价格
             $price = bcmul($itemNum,$itemPrice,2);
             $data['totalWeight'] = bcadd($data['totalWeight'],$weight,2);

+ 6 - 6
biz-hd/item/classes/ItemClass.php

@@ -36,16 +36,16 @@ class ItemClass extends BaseClass
     }
 
     //修改花材的信息(库存预警、每扎加价、每扎重量)
-    public static function updateItem($id,$stockWarning,$unitAddPrice,$unitWeight,$unitCost)
+    public static function updateItem($id,$stockWarning,$addPrice,$weight,$cost)
     {
         $model = self::getById($id);
         if(!$model){
             util::fail("该花材不存在");
         }
         $data['stockWarning'] = $stockWarning;
-        $data['unitAddPrice'] = $unitAddPrice;
-        $data['unitWeight'] = $unitWeight;
-        $data['unitCost'] = $unitCost;
+        $data['addPrice'] = $addPrice;
+        $data['weight'] = $weight;
+        $data['cost'] = $cost;
         self::updateById($id,$data);
         return true;
 
@@ -99,9 +99,9 @@ class ItemClass extends BaseClass
     }
 
     //修改某个花材的成本价(采购之后要用到) linqh 2021.1.28
-    public static function changeCost($itemId,$merchantId,$unitCost)
+    public static function changeCost($itemId,$merchantId,$cost)
     {
-        return self::updateByCondition(['itemId'=>$itemId,'sjId'=>$merchantId],['unitCost'=>$unitCost]);
+        return self::updateByCondition(['itemId'=>$itemId,'sjId'=>$merchantId],['cost'=>$cost]);
     }
 
 }

+ 7 - 7
biz-hd/item/services/ItemService.php

@@ -84,23 +84,23 @@ class ItemService extends BaseService
     {
         $id = $data['id']??0;
         $stockWarning = $data['stockWarning']??0;
-        $unitAddPrice = $data['unitAddPrice']??0;
-        $unitWeight = $data['unitWeight']??0;
-        $unitCost = $data['unitCost']??0; //成本价
+        $addPrice = $data['addPrice']??0;
+        $weight = $data['weight']??0;
+        $cost = $data['cost']??0; //成本价
         if($stockWarning < 0 ){
             util::fail("库存预警不能小于0");
         }
-        if($unitAddPrice < 0 ){
+        if($addPrice < 0 ){
             util::fail("每扎加价不能小于0");
         }
-        if($unitWeight < 0 ){
+        if($weight < 0 ){
             // util::fail("每扎重量不能小于0");
         }
-        if($unitCost < 0 ){
+        if($cost < 0 ){
             util::fail("成本价不能小于0");
         }
 
-        ItemClass::updateItem($id,$stockWarning,$unitAddPrice,$unitWeight,$unitCost);
+        ItemClass::updateItem($id,$stockWarning,$addPrice,$weight,$cost);
     }
 
     //删除花材,同时修改itemInfo 的状态值 delStatus = 1

+ 23 - 0
sql.sql

@@ -1900,3 +1900,26 @@ ALTER TABLE `xhGhsOrderExpress`
 ADD COLUMN `dmName`  varchar(200) NOT NULL DEFAULT '' COMMENT '骑手名' AFTER `sendTime`,
 ADD COLUMN `dmMobile`  varchar(30) NOT NULL DEFAULT '' COMMENT '骑手手机号' AFTER `dbName`;
 
+============
+==shish
+ALTER TABLE `xhGhsItemClass` ADD num SMALLINT NOT NULL DEFAULT 0 COMMENT '花材数量' AFTER `name`;
+ALTER TABLE `xhGhsItemClass` DROP COLUMN `addTime`;
+ALTER TABLE `xhGhsItemClass` DROP COLUMN `updateTime`;
+ALTER TABLE `xhGhsItemClass` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER adminId;
+ALTER TABLE `xhGhsItemClass` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `addTime`;
+ALTER TABLE `xhItemClass` ADD num SMALLINT NOT NULL DEFAULT 0 COMMENT '花材数量' AFTER `name`;
+ALTER TABLE `xhItemClass` DROP COLUMN `addTime`;
+ALTER TABLE `xhItemClass` DROP COLUMN `updateTime`;
+ALTER TABLE `xhItemClass` ADD `addTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间' AFTER adminId;
+ALTER TABLE `xhItemClass` ADD `updateTime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `addTime`;
+
+所有小程序 基础库最低版本 设置为2.1.1
+
+ALTER TABLE `xhGhsItem` ADD inTurn INT NOT NULL DEFAULT 100 COMMENT '排序' AFTER `unitAddPrice`;
+
+ALTER TABLE `xhItem` CHANGE `unitWeight` `weight` FLOAT(10,2) NOT NULL DEFAULT '0.00' COMMENT '每扎(大单位)重量(公斤)';
+ALTER TABLE `xhItem` CHANGE `unitCost` `cost` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎(大单位)成本价';
+ALTER TABLE `xhItem` CHANGE `unitAddPrice` `addPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎(大单位)加价';
+ALTER TABLE `xhGhsItem` CHANGE `unitWeight` `weight` FLOAT(10,2) NOT NULL DEFAULT '0.00' COMMENT '每扎(大单位)重量(公斤)';
+ALTER TABLE `xhGhsItem` CHANGE `unitCost` `cost` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎(大单位)成本价';
+ALTER TABLE `xhGhsItem` CHANGE `unitAddPrice` `addPrice` DECIMAL(9,2) NOT NULL DEFAULT '0.00' COMMENT '每扎(大单位)加价';