|
|
@@ -24,39 +24,14 @@ class OrderGoodsClass extends BaseClass
|
|
|
|
|
|
public static function addData($data)
|
|
|
{
|
|
|
-
|
|
|
- //库存变化
|
|
|
-// $sjId = $data['sjId'] ?? 0;
|
|
|
-// $shopId = $data['shopId'] ?? 0;
|
|
|
-// $goodsId = $data['goodsId'] ?? 0;
|
|
|
-// $unitType = $data['unitType'] ?? 0;
|
|
|
-// $num = $data['num'] ?? 0;
|
|
|
-// $ratio = $data['ratio'] ?? 0;
|
|
|
-// $orderSn = $data['orderSn'] ?? '';
|
|
|
-// $mainId = $data['mainId'] ?? 0;
|
|
|
-// $customName = $custom['name'] ?? '';
|
|
|
-// $bigNum = 0;
|
|
|
-// $smallNum = 0;
|
|
|
-// if ($unitType == dict::getDict('unitType', 'big')) {
|
|
|
-// $bigNum = $num;
|
|
|
-// } else {
|
|
|
-// $smallNum = $num;
|
|
|
-// }
|
|
|
-// //库存减少
|
|
|
-// $stockInfo = ProductClass::decreaseStock($goodsId, $bigNum, $smallNum, true);
|
|
|
-// $recordData = [];
|
|
|
-// $recordData['sjId'] = $sjId;
|
|
|
-// $recordData['shopId'] = $shopId;
|
|
|
-// $recordData['mainId'] = $mainId;
|
|
|
-// $recordData['itemId'] = 0;
|
|
|
-// $recordData['itemNum'] = ProductClass::mergeItemNum($bigNum, $smallNum, $ratio);
|
|
|
-// $recordData['oldStock'] = $stockInfo['oldStock'];
|
|
|
-// $recordData['newStock'] = $stockInfo['newStock'];
|
|
|
-// $recordData['productId'] = $goodsId;
|
|
|
-// $recordData['orderSn'] = $orderSn;
|
|
|
-// $recordData['relateName'] = $customName;
|
|
|
-// StockRecordClass::hdKdAddRecord($recordData);
|
|
|
-
|
|
|
+ $orderSn = $data['orderSn'] ?? '';
|
|
|
+ $sjId = $data['sjId'] ?? 0;
|
|
|
+ $shopId = $data['shopId'] ?? 0;
|
|
|
+ $mainId = $data['mainId'] ?? 0;
|
|
|
+ $goodsId = $data['goodsId'] ?? 0;
|
|
|
+ $num = $data['num'] ?? 0;
|
|
|
+ //减库存
|
|
|
+ self::changeStockBySellGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $num);
|
|
|
return self::add($data);
|
|
|
}
|
|
|
|
|
|
@@ -105,10 +80,10 @@ class OrderGoodsClass extends BaseClass
|
|
|
|
|
|
|
|
|
//制作工单完成,新增成品库存
|
|
|
- public static function addGoodsStockByMakeGoods($orderSn,$sjId,$shopId,$mainId,$goodsId,$goodsNum)
|
|
|
+ public static function addGoodsStockByMakeGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $goodsNum)
|
|
|
{
|
|
|
//加成品库存
|
|
|
- $respond = GoodsClass::addStock($goodsId,$mainId,$goodsNum);
|
|
|
+ $respond = GoodsClass::addStock($goodsId, $mainId, $goodsNum);
|
|
|
//成品流水记录
|
|
|
$data = [];
|
|
|
$data['sjId'] = $sjId;
|
|
|
@@ -125,63 +100,63 @@ class OrderGoodsClass extends BaseClass
|
|
|
|
|
|
|
|
|
//制作工单消耗花材(单个)
|
|
|
- public static function consumeItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType)
|
|
|
+ public static function consumeItemByMakeGoods($orderSn, $sjId, $shopId, $productId, $num, $unitType)
|
|
|
{
|
|
|
- $respond = self::changeItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType,self::ACTION_CONSUME);
|
|
|
+ $respond = self::changeItemByMakeGoods($orderSn, $sjId, $shopId, $productId, $num, $unitType, self::ACTION_CONSUME);
|
|
|
return $respond;
|
|
|
}
|
|
|
|
|
|
|
|
|
//制作工单 花材损耗(单个)
|
|
|
- public static function wastageItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType)
|
|
|
+ public static function wastageItemByMakeGoods($orderSn, $sjId, $shopId, $productId, $num, $unitType)
|
|
|
{
|
|
|
- $respond = self::changeItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType,self::ACTION_WASTAGE);
|
|
|
+ $respond = self::changeItemByMakeGoods($orderSn, $sjId, $shopId, $productId, $num, $unitType, self::ACTION_WASTAGE);
|
|
|
return $respond;
|
|
|
}
|
|
|
|
|
|
//取消工单 花材消耗退回(单个)
|
|
|
- public static function consumeItemByMakeGoodsCancel($orderSn,$sjId,$shopId,$productId,$num,$unitType)
|
|
|
+ public static function consumeItemByMakeGoodsCancel($orderSn, $sjId, $shopId, $productId, $num, $unitType)
|
|
|
{
|
|
|
- $respond = self::changeItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType,self::ACTION_CONSUME_CANCEL);
|
|
|
+ $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)
|
|
|
+ public static function wastageItemByMakeGoodsCancel($orderSn, $sjId, $shopId, $productId, $num, $unitType)
|
|
|
{
|
|
|
- $respond = self::changeItemByMakeGoods($orderSn,$sjId,$shopId,$productId,$num,$unitType,self::ACTION_WASTAGE_CANCEL);
|
|
|
+ $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)
|
|
|
+ public static function changeItemByMakeGoods($orderSn, $sjId, $shopId, $productId, $num, $unitType, $action)
|
|
|
{
|
|
|
$bigNum = 0;
|
|
|
$smallNum = 0;
|
|
|
- if($unitType){
|
|
|
+ if ($unitType) {
|
|
|
//大单位
|
|
|
- $bigNum =$num;
|
|
|
- }else{
|
|
|
+ $bigNum = $num;
|
|
|
+ } else {
|
|
|
//小单位
|
|
|
$smallNum = $num;
|
|
|
}
|
|
|
- $stockInfo= [];
|
|
|
- switch ($action){
|
|
|
+ $stockInfo = [];
|
|
|
+ switch ($action) {
|
|
|
case self::ACTION_WASTAGE:
|
|
|
case self::ACTION_CONSUME:
|
|
|
- $stockInfo = ProductClass::decreaseStock($productId, $bigNum, $smallNum, true);
|
|
|
- break;
|
|
|
+ $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;
|
|
|
+ $stockInfo = ProductClass::addStock($productId, $bigNum, $smallNum);
|
|
|
+ break;
|
|
|
default:
|
|
|
util::fail("非法参数");
|
|
|
}
|
|
|
|
|
|
- if(empty($stockInfo)){
|
|
|
+ if (empty($stockInfo)) {
|
|
|
util::fail("非法参数");
|
|
|
}
|
|
|
//记录流流水
|
|
|
@@ -195,9 +170,9 @@ class OrderGoodsClass extends BaseClass
|
|
|
$record['productId'] = $productId;
|
|
|
$record['itemNum'] = $stockInfo['itemNum'];
|
|
|
$record['oldStock'] = $stockInfo['oldStock'];
|
|
|
- $record['newStock'] =$stockInfo['newStock'];
|
|
|
+ $record['newStock'] = $stockInfo['newStock'];
|
|
|
|
|
|
- switch ($action){
|
|
|
+ switch ($action) {
|
|
|
case self::ACTION_CONSUME:
|
|
|
StockRecordClass::makeGoodsConsume($record);
|
|
|
break;
|
|
|
@@ -215,10 +190,10 @@ class OrderGoodsClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
//销售成品库存变更方法(减库存)
|
|
|
- public static function changeStockBySellGoods($orderSn,$sjId,$shopId,$mainId,$goodsId,$goodsNum)
|
|
|
+ public static function changeStockBySellGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $goodsNum)
|
|
|
{
|
|
|
//减成品库存
|
|
|
- GoodsClass::decreaseStock($goodsId,$mainId,$goodsNum);
|
|
|
+ GoodsClass::decreaseStock($goodsId, $mainId, $goodsNum);
|
|
|
//成品流水记录
|
|
|
$data = [];
|
|
|
$data['sjId'] = $sjId;
|
|
|
@@ -231,27 +206,23 @@ class OrderGoodsClass extends BaseClass
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
//制作工单消耗花材(批量)
|
|
|
//消耗花材信息:$consumeItemInfo = [{"id":12233,"num":1,"unitType":0}]
|
|
|
- public static function consumeItemByMakeGoodsBatch($orderSn,$sjId,$shopId,$consumeItemInfo)
|
|
|
+ public static function consumeItemByMakeGoodsBatch($orderSn, $sjId, $shopId, $consumeItemInfo)
|
|
|
{
|
|
|
- if(empty($consumeItemInfo)){
|
|
|
+ if (empty($consumeItemInfo)) {
|
|
|
util::fail("参数错误");
|
|
|
}
|
|
|
//花材消耗
|
|
|
- foreach ($consumeItemInfo as $v){
|
|
|
+ foreach ($consumeItemInfo as $v) {
|
|
|
//库存减少
|
|
|
$bigNum = 0;
|
|
|
$smallNum = 0;
|
|
|
$productId = $v['id'];
|
|
|
- if($v['unitType']==0){
|
|
|
+ if ($v['unitType'] == 0) {
|
|
|
//大单位
|
|
|
$bigNum = $v['num'];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//小单位
|
|
|
$smallNum = $v['num'];
|
|
|
}
|
|
|
@@ -268,7 +239,7 @@ class OrderGoodsClass extends BaseClass
|
|
|
$record['productId'] = $productId;
|
|
|
$record['itemNum'] = $stockInfo['itemNum'];
|
|
|
$record['oldStock'] = $stockInfo['oldStock'];
|
|
|
- $record['newStock'] =$stockInfo['newStock']; //
|
|
|
+ $record['newStock'] = $stockInfo['newStock']; //
|
|
|
StockRecordClass::makeGoodsConsume($record);
|
|
|
}
|
|
|
return true;
|
|
|
@@ -276,21 +247,21 @@ class OrderGoodsClass extends BaseClass
|
|
|
|
|
|
//制作工单 花材损耗(批量)
|
|
|
//损耗花材信息:$wastageItemInfo = [{"id":12233,"num":1,"unitType":0}]
|
|
|
- public static function wastageItemByMakeGoodsBatch($orderSn,$sjId,$shopId,$wastageItemInfo)
|
|
|
+ public static function wastageItemByMakeGoodsBatch($orderSn, $sjId, $shopId, $wastageItemInfo)
|
|
|
{
|
|
|
//花材损耗
|
|
|
- if(empty($wastageItemInfo)){
|
|
|
+ if (empty($wastageItemInfo)) {
|
|
|
util::fail("参数错误");
|
|
|
}
|
|
|
- foreach ($wastageItemInfo as $v){
|
|
|
+ foreach ($wastageItemInfo as $v) {
|
|
|
//库存减少
|
|
|
$bigNum = 0;
|
|
|
$smallNum = 0;
|
|
|
$productId = $v['id'];
|
|
|
- if($v['unitType']==0){
|
|
|
+ if ($v['unitType'] == 0) {
|
|
|
//大单位
|
|
|
$bigNum = $v['num'];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//小单位
|
|
|
$smallNum = $v['num'];
|
|
|
}
|
|
|
@@ -307,13 +278,11 @@ class OrderGoodsClass extends BaseClass
|
|
|
$record['productId'] = $productId;
|
|
|
$record['itemNum'] = $stockInfo['itemNum'];
|
|
|
$record['oldStock'] = $stockInfo['oldStock'];
|
|
|
- $record['newStock'] =$stockInfo['newStock']; //
|
|
|
+ $record['newStock'] = $stockInfo['newStock']; //
|
|
|
StockRecordClass::makeGoodsWastage($record);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//制作单取消
|
|
|
//退回花材损耗,退回花材消耗,退回成品库存
|
|
|
public static function cancelMakeGoods($orderSn)
|
|
|
@@ -322,11 +291,11 @@ class OrderGoodsClass extends BaseClass
|
|
|
$whereWastage = [];
|
|
|
$whereWastage['orderSn'] = $orderSn;
|
|
|
$whereWastage['recordType'] = StockRecordClass::STOCK_RECORD_TYPE_GOODS_WASTAGE;
|
|
|
- $wastageDatas = StockRecordClass::getAllByCondition($whereWastage,null,"*");
|
|
|
- if($wastageDatas){
|
|
|
- foreach ($wastageDatas as $v){
|
|
|
+ $wastageData = StockRecordClass::getAllByCondition($whereWastage, null, "*");
|
|
|
+ if ($wastageData) {
|
|
|
+ foreach ($wastageData as $v) {
|
|
|
//加库存
|
|
|
- $stockInfo = ProductClass::addStockByItemNum($v['productId'],$v['itemNum']);
|
|
|
+ $stockInfo = ProductClass::addStockByItemNum($v['productId'], $v['itemNum']);
|
|
|
//加流水记录
|
|
|
$wastageRecord = $v;
|
|
|
$wastageRecord['oldStock'] = $stockInfo['oldStock'];
|
|
|
@@ -339,11 +308,11 @@ class OrderGoodsClass extends BaseClass
|
|
|
$whereConsume = [];
|
|
|
$whereConsume['orderSn'] = $orderSn;
|
|
|
$whereConsume['recordType'] = StockRecordClass::STOCK_RECORD_TYPE_GOODS_CONSUME;
|
|
|
- $consumeDatas = StockRecordClass::getAllByCondition($whereConsume,null,"*");
|
|
|
- if($consumeDatas){
|
|
|
- foreach ($consumeDatas as $c){
|
|
|
+ $consumeData = StockRecordClass::getAllByCondition($whereConsume, null, "*");
|
|
|
+ if ($consumeData) {
|
|
|
+ foreach ($consumeData as $c) {
|
|
|
//加库存
|
|
|
- $stockInfo = ProductClass::addStockByItemNum($c['productId'],$c['itemNum']);
|
|
|
+ $stockInfo = ProductClass::addStockByItemNum($c['productId'], $c['itemNum']);
|
|
|
//加流水记录
|
|
|
$consumeRecord = $c;
|
|
|
$consumeRecord['oldStock'] = $stockInfo['oldStock'];
|
|
|
@@ -357,30 +326,26 @@ class OrderGoodsClass extends BaseClass
|
|
|
$whereGoods = [];
|
|
|
$whereGoods['orderSn'] = $orderSn;
|
|
|
$whereGoods['recordType'] = GoodsStockRecordClass::STOCK_RECORD_TYPE_PURCHASE;
|
|
|
- $goodsData = GoodsStockRecordClass::getByCondition($whereGoods,null,"*");
|
|
|
- if($goodsData){
|
|
|
+ $goodsData = GoodsStockRecordClass::getByCondition($whereGoods, null, "*");
|
|
|
+ if ($goodsData) {
|
|
|
//减库存
|
|
|
- GoodsClass::decreaseStock($goodsData['goodsId'],$goodsData['mainId'],$goodsData['goodsNum']);
|
|
|
+ GoodsClass::decreaseStock($goodsData['goodsId'], $goodsData['mainId'], $goodsData['goodsNum']);
|
|
|
//流水记录
|
|
|
unset($goodsData['id']);
|
|
|
GoodsStockRecordClass::cancelMakeGoods($goodsData);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//该方法已经拆开来了(弃用)
|
|
|
//制作成品库存变更方法(加成品库存,减花材库存(消耗、损耗))
|
|
|
//消耗花材信息:$consumeItemInfo = [{"id":12233,"num":1,"unitType":0}]
|
|
|
//损耗花材信息:$wastageItemInfo = [{"id":12233,"num":1,"unitType":0}]
|
|
|
//id 是当前产品的id,单价unitType 是当前单位类型,0表示大单位,1表示小单位,默认0 num 是当前花材数量
|
|
|
- public static function changeStockByMakeGoods($orderSn,$sjId,$shopId,$mainId,$goodsId,$goodsNum,$consumeItemInfo,$wastageItemInfo)
|
|
|
+ public static function changeStockByMakeGoods($orderSn, $sjId, $shopId, $mainId, $goodsId, $goodsNum, $consumeItemInfo, $wastageItemInfo)
|
|
|
{
|
|
|
//加成品库存
|
|
|
- GoodsClass::addStock($goodsId,$mainId,$goodsNum);
|
|
|
+ GoodsClass::addStock($goodsId, $mainId, $goodsNum);
|
|
|
//成品流水记录
|
|
|
$data = [];
|
|
|
$data['sjId'] = $sjId;
|
|
|
@@ -391,16 +356,16 @@ class OrderGoodsClass extends BaseClass
|
|
|
$data['goodsNum'] = $goodsNum;
|
|
|
GoodsStockRecordClass::addMakeGoods($data);
|
|
|
//花材消耗
|
|
|
- if(!empty($consumeItemInfo)){
|
|
|
- foreach ($consumeItemInfo as $v){
|
|
|
+ if (!empty($consumeItemInfo)) {
|
|
|
+ foreach ($consumeItemInfo as $v) {
|
|
|
//库存减少
|
|
|
$bigNum = 0;
|
|
|
$smallNum = 0;
|
|
|
$productId = $v['id'];
|
|
|
- if($v['unitType']==0){
|
|
|
+ if ($v['unitType'] == 0) {
|
|
|
//大单位
|
|
|
$bigNum = $v['num'];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//小单位
|
|
|
$smallNum = $v['num'];
|
|
|
}
|
|
|
@@ -417,21 +382,21 @@ class OrderGoodsClass extends BaseClass
|
|
|
$record['productId'] = $productId;
|
|
|
$record['itemNum'] = $stockInfo['itemNum'];
|
|
|
$record['oldStock'] = $stockInfo['oldStock'];
|
|
|
- $record['newStock'] =$stockInfo['newStock']; //
|
|
|
+ $record['newStock'] = $stockInfo['newStock']; //
|
|
|
StockRecordClass::makeGoodsConsume($record);
|
|
|
}
|
|
|
}
|
|
|
//花材损耗
|
|
|
- if(!empty($wastageItemInfo)){
|
|
|
- foreach ($wastageItemInfo as $v){
|
|
|
+ if (!empty($wastageItemInfo)) {
|
|
|
+ foreach ($wastageItemInfo as $v) {
|
|
|
//库存减少
|
|
|
$bigNum = 0;
|
|
|
$smallNum = 0;
|
|
|
$productId = $v['id'];
|
|
|
- if($v['unitType']==0){
|
|
|
+ if ($v['unitType'] == 0) {
|
|
|
//大单位
|
|
|
$bigNum = $v['num'];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//小单位
|
|
|
$smallNum = $v['num'];
|
|
|
}
|
|
|
@@ -448,7 +413,7 @@ class OrderGoodsClass extends BaseClass
|
|
|
$record['productId'] = $productId;
|
|
|
$record['itemNum'] = $stockInfo['itemNum'];
|
|
|
$record['oldStock'] = $stockInfo['oldStock'];
|
|
|
- $record['newStock'] =$stockInfo['newStock']; //
|
|
|
+ $record['newStock'] = $stockInfo['newStock']; //
|
|
|
StockRecordClass::makeGoodsWastage($record);
|
|
|
}
|
|
|
}
|