|
@@ -991,7 +991,8 @@ class PurchaseOrderClass extends BaseClass
|
|
|
foreach ($batchData as $currentKey => $v) {
|
|
foreach ($batchData as $currentKey => $v) {
|
|
|
$itemId = $v['itemId'];
|
|
$itemId = $v['itemId'];
|
|
|
$productId = $v['productId'];
|
|
$productId = $v['productId'];
|
|
|
-
|
|
|
|
|
|
|
+ //单位采购价
|
|
|
|
|
+ $unitCgPrice = $v['bigPrice'] ?? 0;
|
|
|
$presell = $productList[$productId]['presell'] ?? 0;
|
|
$presell = $productList[$productId]['presell'] ?? 0;
|
|
|
//普通入库增加库存,预售入库不增加库存 ssh 20220109
|
|
//普通入库增加库存,预售入库不增加库存 ssh 20220109
|
|
|
if ($presell == 0) {
|
|
if ($presell == 0) {
|
|
@@ -1015,7 +1016,9 @@ class PurchaseOrderClass extends BaseClass
|
|
|
ProductClass::addOnStockByItemNum($productId, $v['itemNum']);
|
|
ProductClass::addOnStockByItemNum($productId, $v['itemNum']);
|
|
|
|
|
|
|
|
if ($inType == self::IN_TYPE_NOW) {
|
|
if ($inType == self::IN_TYPE_NOW) {
|
|
|
|
|
+
|
|
|
//增加库存
|
|
//增加库存
|
|
|
|
|
+ $stockInfo = ProductClass::addStockByItemNum($productId, $v['itemNum'], ['cost' => $unitCgPrice]);
|
|
|
$record = [];
|
|
$record = [];
|
|
|
$record['sjId'] = $sjId;
|
|
$record['sjId'] = $sjId;
|
|
|
$record['shopId'] = $shopId;
|
|
$record['shopId'] = $shopId;
|
|
@@ -1025,10 +1028,14 @@ class PurchaseOrderClass extends BaseClass
|
|
|
$record['itemId'] = $itemId;
|
|
$record['itemId'] = $itemId;
|
|
|
$record['relateName'] = $ghsName;
|
|
$record['relateName'] = $ghsName;
|
|
|
$record['itemNum'] = $v['itemNum'];
|
|
$record['itemNum'] = $v['itemNum'];
|
|
|
- $record['oldStock'] = $v['itemStock'];
|
|
|
|
|
- $record['newStock'] = bcadd($v['itemStock'], $v['itemNum'], 2);
|
|
|
|
|
|
|
+ $record['oldStock'] = $stockInfo['oldStock'];
|
|
|
|
|
+ $record['newStock'] = $stockInfo['newStock'];
|
|
|
|
|
+ $record['unitCost'] = $stockInfo['unitCost'];
|
|
|
|
|
+ $record['changeCost'] = $stockInfo['changeCost'];
|
|
|
|
|
+ $record['totalStock'] = $stockInfo['totalStock'];
|
|
|
|
|
+ $record['totalCost'] = $stockInfo['totalCost'];
|
|
|
|
|
+ $record['avCost'] = $stockInfo['avCost'];
|
|
|
StockRecordClass::addPurchaseOrderRecord($record);
|
|
StockRecordClass::addPurchaseOrderRecord($record);
|
|
|
- ProductClass::addStockByItemNum($productId, $v['itemNum']);
|
|
|
|
|
|
|
|
|
|
//减少路上库存
|
|
//减少路上库存
|
|
|
$onRecord = [];
|
|
$onRecord = [];
|
|
@@ -1048,8 +1055,6 @@ class PurchaseOrderClass extends BaseClass
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //单位采购价
|
|
|
|
|
- $unitCgPrice = $v['bigPrice'] ?? 0;
|
|
|
|
|
$productWeight = $productList[$productId]['weight'] ?? 0;
|
|
$productWeight = $productList[$productId]['weight'] ?? 0;
|
|
|
$unitFreight = bcmul($avgKgWeight, $productWeight, 3);
|
|
$unitFreight = bcmul($avgKgWeight, $productWeight, 3);
|
|
|
$unitCost = bcadd($unitCgPrice, $unitFreight, 3);
|
|
$unitCost = bcadd($unitCgPrice, $unitFreight, 3);
|