|
|
@@ -2,7 +2,9 @@
|
|
|
|
|
|
namespace bizHd\order\classes;
|
|
|
|
|
|
-use common\components\business;
|
|
|
+use bizGhs\product\classes\ProductClass;
|
|
|
+use bizGhs\stock\classes\StockRecordClass;
|
|
|
+use common\components\dict;
|
|
|
use Yii;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
|
|
|
@@ -12,8 +14,42 @@ class OrderItemClass extends BaseClass
|
|
|
public static $baseFile = '\bizHd\order\models\OrderItem';
|
|
|
|
|
|
//添加记录
|
|
|
- public static function addData($data)
|
|
|
+ public static function addData($data, $custom)
|
|
|
{
|
|
|
+
|
|
|
+ //库存变化
|
|
|
+ $sjId = $data['sjId'] ?? 0;
|
|
|
+ $shopId = $data['shopId'] ?? 0;
|
|
|
+ $itemId = $data['itemId'] ?? 0;
|
|
|
+ $unitType = $data['unitType'] ?? 0;
|
|
|
+ $num = $data['num'] ?? 0;
|
|
|
+ $ptItemId = $data['ptItemId'] ?? 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($itemId, $bigNum, $smallNum, true);
|
|
|
+ $recordData = [];
|
|
|
+ $recordData['sjId'] = $sjId;
|
|
|
+ $recordData['shopId'] = $shopId;
|
|
|
+ $recordData['mainId'] = $mainId;
|
|
|
+ $recordData['itemId'] = $ptItemId;
|
|
|
+ $recordData['itemNum'] = ProductClass::mergeItemNum($bigNum, $smallNum, $ratio);
|
|
|
+ $recordData['oldStock'] = $stockInfo['oldStock'];
|
|
|
+ $recordData['newStock'] = $stockInfo['newStock'];
|
|
|
+ $recordData['productId'] = $itemId;
|
|
|
+ $recordData['orderSn'] = $orderSn;
|
|
|
+ $recordData['relateName'] = $customName;
|
|
|
+ StockRecordClass::hdKdAddRecord($recordData);
|
|
|
+
|
|
|
return self::add($data);
|
|
|
}
|
|
|
|