|
|
@@ -107,7 +107,9 @@ class StockInOrderClass extends BaseClass
|
|
|
$tmp['itemId'] = $itemId;
|
|
|
$tmp['itemStock'] = $itemData[$itemId]['stock'] ?? 0;//当时库存
|
|
|
$tmp['itemNum'] = $v['itemNum'];
|
|
|
- $tmp['itemPrice'] = $v['itemPrice']; //售卖的价格
|
|
|
+ $tmp['itemPrice'] = $v['itemPrice'] ?? 0;
|
|
|
+ $tmp['price'] = $v['price'] ?? 0;
|
|
|
+ $tmp['skPrice'] = $v['skPrice'] ?? 0;
|
|
|
$ratio = $itemData[$itemId]['ratio'] ?? 0;
|
|
|
$formatStock = ProductClass::formatStock($tmp['itemStock'], $ratio);
|
|
|
$itemInfo = [
|
|
|
@@ -161,17 +163,31 @@ class StockInOrderClass extends BaseClass
|
|
|
}
|
|
|
$totalCost = $orderData['price'] ?? 0;
|
|
|
foreach ($itemInfo as $k => $v) {
|
|
|
- $stockInfo = ProductClass::addStockByItemNum($v['productId'], $v['itemNum']);
|
|
|
+ $currentItemId = $v['productId'] ?? 0;
|
|
|
+ $currentCost = $v['itemPrice'] ?? 0;
|
|
|
+ $currentHdPrice = $v['price'] ?? 0;
|
|
|
+ $currentSkPrice = $v['skPrice'] ?? 0;
|
|
|
+ if ($carSale == 1) {
|
|
|
+ //如果是车销,只同步成本价 ssh 20221113
|
|
|
+ ProductClass::updateById($currentItemId, ['cost' => $currentCost]);
|
|
|
+ } else {
|
|
|
+ //如果当前花材没有库存,则成本和价格都传导过来
|
|
|
+ $currentInfo = ProductClass::getById($currentItemId, true);
|
|
|
+ if (isset($currentInfo->stock) && floatval($currentInfo->stock) == 0) {
|
|
|
+ $upData = ['cost' => $currentCost];
|
|
|
+ if ($currentHdPrice > 0) {
|
|
|
+ $upData['price'] = $currentHdPrice;
|
|
|
+ }
|
|
|
+ if ($currentSkPrice > 0) {
|
|
|
+ $upData['skPrice'] = $currentSkPrice;
|
|
|
+ }
|
|
|
+ ProductClass::updateById($currentItemId, $upData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $stockInfo = ProductClass::addStockByItemNum($currentItemId, $v['itemNum']);
|
|
|
$itemInfo[$k]['oldStock'] = $stockInfo['oldStock'];
|
|
|
$itemInfo[$k]['itemStock'] = $stockInfo['oldStock'];
|
|
|
$itemInfo[$k]['newStock'] = $stockInfo['newStock'];
|
|
|
-
|
|
|
- if ($carSale == 1) {
|
|
|
- //调拨入库之后,如果门店是车销,则成本也同步 ssh 20221113
|
|
|
- $currentCost = $v['itemPrice'] ?? 0;
|
|
|
- ProductClass::updateById($v['productId'], ['cost' => $currentCost]);
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//流水记录
|