|
|
@@ -191,6 +191,13 @@ class StockInOrderClass extends BaseClass
|
|
|
util::fail("订单异常");
|
|
|
}
|
|
|
|
|
|
+ $chainShopList = [];
|
|
|
+ $default = $shop->default ?? 0;
|
|
|
+ $sjId = $shop->sjId ?? 0;
|
|
|
+ if ($default == 1) {
|
|
|
+ $chainShopList = \bizGhs\merchant\classes\ShopClass::getAllByCondition(['sjId' => $sjId, 'join' => 0], null, '*', null, true);
|
|
|
+ }
|
|
|
+
|
|
|
$totalCost = $orderData['price'] ?? 0;
|
|
|
foreach ($itemInfo as $k => $v) {
|
|
|
$currentItemId = $v['productId'] ?? 0;
|
|
|
@@ -203,15 +210,6 @@ class StockInOrderClass extends BaseClass
|
|
|
$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;
|
|
|
- }
|
|
|
- if ($currentHjPrice > 0) {
|
|
|
- $upData['hjPrice'] = $currentHjPrice;
|
|
|
- }
|
|
|
ProductClass::updateById($currentItemId, $upData);
|
|
|
//成本变动记录
|
|
|
$changeData = [
|
|
|
@@ -231,24 +229,23 @@ class StockInOrderClass extends BaseClass
|
|
|
];
|
|
|
CostChangeClass::addData($changeData);
|
|
|
if ($currentHdPrice > 0) {
|
|
|
- $changeData = [
|
|
|
- 'ptStyle' => 2,
|
|
|
- 'sjId' => $currentInfo->sjId ?? 0,
|
|
|
- 'mainId' => $mainId,
|
|
|
- 'itemId' => $currentInfo->id ?? 0,
|
|
|
- 'ptItemId' => $currentInfo->itemId ?? 0,
|
|
|
- 'price' => $currentHdPrice,
|
|
|
- 'skPrice' => $currentSkPrice,
|
|
|
- 'hjPrice' => $currentHjPrice,
|
|
|
- 'staffId' => $staffId,
|
|
|
- 'staffName' => $staffName,
|
|
|
- 'name' => $currentInfo->name ?? '',
|
|
|
- 'cover' => $currentInfo->cover ?? '',
|
|
|
- 'event' => $event,
|
|
|
- 'targetId' => $orderId,
|
|
|
- 'type' => 2,
|
|
|
- ];
|
|
|
- PriceChangeClass::addData($changeData);
|
|
|
+ $ptItemId = $currentInfo->itemId ?? 0;
|
|
|
+ $changeParams = ['staffId' => $staffId, 'staffName' => $staffName, 'event' => '调拨入库改价', 'targetId' => $orderId];
|
|
|
+ ProductClass::changeSinglePrice($shop, $ptItemId, $currentHdPrice, $currentSkPrice, $currentHjPrice, $changeParams);
|
|
|
+ //在首店修改需要同步到所有直营店
|
|
|
+ if ($default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
|
|
|
+ foreach ($chainShopList as $chain) {
|
|
|
+ if ($chain->id == $shop->id) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $chainMainId = $chain->mainId ?? 0;
|
|
|
+ $staff = ShopAdminClass::getByCondition(['mainId' => $chainMainId, 'adminId' => $adminId], true);
|
|
|
+ $staffId = $staff->id ?? 0;
|
|
|
+ $staffName = $staff->name ?? '';
|
|
|
+ $changeParams2 = ['staffId' => $staffId, 'staffName' => $staffName, 'event' => '调拨入库改价,同步给分店'];
|
|
|
+ ProductClass::changeSinglePrice($chain, $ptItemId, $currentHdPrice, $currentSkPrice, $currentHjPrice, $changeParams2);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|