|
|
@@ -17,6 +17,11 @@ class OrderGoodsClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\bizHd\order\models\OrderGoods';
|
|
|
|
|
|
+ const ACTION_CONSUME = 'consume'; //消耗花材
|
|
|
+ const ACTION_CONSUME_CANCEL = 'consumeCancel'; //取消消耗花材
|
|
|
+ const ACTION_WASTAGE = 'wastage'; //取消消耗花材
|
|
|
+ const ACTION_WASTAGE_CANCEL = 'wastageCancel'; //取消消耗花材
|
|
|
+
|
|
|
public static function addData($data)
|
|
|
{
|
|
|
|
|
|
@@ -118,9 +123,121 @@ class OrderGoodsClass extends BaseClass
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- //制作工单消耗花材
|
|
|
+
|
|
|
+ //制作工单消耗花材(单个)
|
|
|
+ public static function consumeItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType)
|
|
|
+ {
|
|
|
+ $respond = self::changeItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType,self::ACTION_CONSUME);
|
|
|
+ return $respond;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //制作工单 花材损耗(单个)
|
|
|
+ public static function wastageItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType)
|
|
|
+ {
|
|
|
+ $respond = self::changeItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType,self::ACTION_WASTAGE);
|
|
|
+ return $respond;
|
|
|
+ }
|
|
|
+
|
|
|
+ //取消工单 花材消耗退回(单个)
|
|
|
+ public static function consumeItemByMakeGoodsCancel($orderSn,$sjId,$shopId,$productId,$num,$unitType)
|
|
|
+ {
|
|
|
+ $respond = self::changeItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType,self::ACTION_CONSUME_CANCEL);
|
|
|
+ return $respond;
|
|
|
+ }
|
|
|
+
|
|
|
+ //取消工单 花材损耗退回(单个)
|
|
|
+ public static function wastageItemByMakeGoodsCancel($orderSn,$sjId,$shopId,$productId,$num,$unitType)
|
|
|
+ {
|
|
|
+ $respond = self::changeItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType,self::ACTION_WASTAGE_CANCEL);
|
|
|
+ return $respond;
|
|
|
+ }
|
|
|
+
|
|
|
+ //action 值
|
|
|
+ // consume(制作工单消耗花材) ,cancelConsume(取消制作工单消耗花材)
|
|
|
+ // wastage (制作工单损耗花材),cancelWastage (取消制作工单损耗花材)
|
|
|
+ public static function changeItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType,$action)
|
|
|
+ {
|
|
|
+ $bigNum = 0;
|
|
|
+ $smallNum = 0;
|
|
|
+ if($unitType){
|
|
|
+ //大单位
|
|
|
+ $bigNum =$num;
|
|
|
+ }else{
|
|
|
+ //小单位
|
|
|
+ $smallNum = $num;
|
|
|
+ }
|
|
|
+ $stockInfo= [];
|
|
|
+ switch ($action){
|
|
|
+ case self::ACTION_WASTAGE:
|
|
|
+ case self::ACTION_CONSUME:
|
|
|
+ $stockInfo = ProductClass::decreaseStock($productId, $bigNum, $smallNum, true);
|
|
|
+ break;
|
|
|
+ case self::ACTION_CONSUME_CANCEL:
|
|
|
+ case self::ACTION_WASTAGE_CANCEL:
|
|
|
+ $stockInfo = ProductClass::addStock($productId, $bigNum, $smallNum);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ util::fail("非法参数");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($stockInfo)){
|
|
|
+ util::fail("非法参数");
|
|
|
+ }
|
|
|
+ //记录流流水
|
|
|
+ $productData = ProductClass::getById($productId);
|
|
|
+ $record = [];
|
|
|
+ $record['sjId'] = $sjId;
|
|
|
+ $record['shopId'] = $shopId;
|
|
|
+ $record['mainId'] = $productData['mainId'];
|
|
|
+ $record['orderSn'] = $orderSn;
|
|
|
+ $record['itemId'] = $productData['itemId'];
|
|
|
+ $record['productId'] = $productId;
|
|
|
+ $record['itemNum'] = $stockInfo['itemNum'];
|
|
|
+ $record['oldStock'] = $stockInfo['oldStock'];
|
|
|
+ $record['newStock'] =$stockInfo['newStock'];
|
|
|
+
|
|
|
+ switch ($action){
|
|
|
+ case self::ACTION_CONSUME:
|
|
|
+ StockRecordClass::makeGoodsConsume($record);
|
|
|
+ break;
|
|
|
+ case self::ACTION_WASTAGE:
|
|
|
+ StockRecordClass::makeGoodsWastage($record);
|
|
|
+ break;
|
|
|
+ case self::ACTION_CONSUME_CANCEL:
|
|
|
+ StockRecordClass::cancelMakeGoodsConsume($record);
|
|
|
+ break;
|
|
|
+ case self::ACTION_WASTAGE_CANCEL:
|
|
|
+ StockRecordClass::cancelMakeGoodsWastage($record);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return $stockInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ //销售成品库存变更方法(减库存)
|
|
|
+ public static function changeStockBySellGoods($orderSn,$sjId,$shopId,$mainId,$goodsId,$goodsNum)
|
|
|
+ {
|
|
|
+ //减成品库存
|
|
|
+ GoodsClass::decreaseStock($goodsId,$mainId,$goodsNum);
|
|
|
+ //成品流水记录
|
|
|
+ $data = [];
|
|
|
+ $data['sjId'] = $sjId;
|
|
|
+ $data['shopId'] = $shopId;
|
|
|
+ $data['mainId'] = $mainId;
|
|
|
+ $data['orderSn'] = $orderSn;
|
|
|
+ $data['goodsId'] = $goodsId;
|
|
|
+ $data['goodsNum'] = $goodsNum;
|
|
|
+ GoodsStockRecordClass::sellGoods($data);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //制作工单消耗花材(批量)
|
|
|
//消耗花材信息:$consumeItemInfo = [{"id":12233,"num":1,"unitType":0}]
|
|
|
- public static function consumeItemByMakeGoods($orderSn,$sjId,$shopId,$consumeItemInfo)
|
|
|
+ public static function consumeItemByMakeGoodsBatch($orderSn,$sjId,$shopId,$consumeItemInfo)
|
|
|
{
|
|
|
if(empty($consumeItemInfo)){
|
|
|
util::fail("参数错误");
|
|
|
@@ -157,9 +274,9 @@ class OrderGoodsClass extends BaseClass
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- //制作工单 花材损耗
|
|
|
+ //制作工单 花材损耗(批量)
|
|
|
//损耗花材信息:$wastageItemInfo = [{"id":12233,"num":1,"unitType":0}]
|
|
|
- public static function wastageItemByMakeGoods($orderSn,$sjId,$shopId,$wastageItemInfo)
|
|
|
+ public static function wastageItemByMakeGoodsBatch($orderSn,$sjId,$shopId,$wastageItemInfo)
|
|
|
{
|
|
|
//花材损耗
|
|
|
if(empty($wastageItemInfo)){
|
|
|
@@ -195,22 +312,7 @@ class OrderGoodsClass extends BaseClass
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //销售成品库存变更方法(减库存)
|
|
|
- public static function changeStockBySellGoods($orderSn,$sjId,$shopId,$mainId,$goodsId,$goodsNum)
|
|
|
- {
|
|
|
- //减成品库存
|
|
|
- GoodsClass::decreaseStock($goodsId,$mainId,$goodsNum);
|
|
|
- //成品流水记录
|
|
|
- $data = [];
|
|
|
- $data['sjId'] = $sjId;
|
|
|
- $data['shopId'] = $shopId;
|
|
|
- $data['mainId'] = $mainId;
|
|
|
- $data['orderSn'] = $orderSn;
|
|
|
- $data['goodsId'] = $goodsId;
|
|
|
- $data['goodsNum'] = $goodsNum;
|
|
|
- GoodsStockRecordClass::sellGoods($data);
|
|
|
- return true;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
//制作单取消
|
|
|
//退回花材损耗,退回花材消耗,退回成品库存
|