|
|
@@ -444,24 +444,28 @@ class OrderClass extends BaseClass
|
|
|
$staffName = $params['staffName'] ?? '';
|
|
|
$element = ['staffId' => $staffId, 'staffName' => $staffName];
|
|
|
self::orderSend($order, $element, true);
|
|
|
- $cg = PurchaseClass::getById($cgId, true);
|
|
|
+ //$cg = PurchaseClass::getById($cgId, true);
|
|
|
}
|
|
|
- // 构建“冲销”函数的参数 -- 变动前的花材存库数据
|
|
|
- $purchaseItems = PurchaseItemClass::getAllByCondition(['orderSn' => $cg->orderSn], null, "productId");
|
|
|
- $productIds = ArrayHelper::getColumn($purchaseItems, 'productId'); //$productIds 是本次入库涉及的花材ID数组
|
|
|
- $oldStocks = [];
|
|
|
- foreach ($productIds as $productId) {
|
|
|
- $product = ProductClass::getById($productId, true);
|
|
|
- $oldStocks[$productId] = $product;
|
|
|
+ if ($cg->cgIn == 0) { // cgIn: 0-不入库(即得执行冲销), 1-入库
|
|
|
+ // 构建“冲销”函数的参数 -- 变动前的花材存库数据
|
|
|
+ $purchaseItems = PurchaseItemClass::getAllByCondition(['orderSn' => $cg->orderSn], null, "productId");
|
|
|
+ $productIds = ArrayHelper::getColumn($purchaseItems, 'productId'); //$productIds 是本次入库涉及的花材ID数组
|
|
|
+ $oldStocks = [];
|
|
|
+ foreach ($productIds as $productId) {
|
|
|
+ $product = ProductClass::getById($productId, true);
|
|
|
+ $oldStocks[$productId] = $product;
|
|
|
+ }
|
|
|
}
|
|
|
PurchaseClass::takeToPutIn($cg);
|
|
|
- $shop = ShopClass::getLockById($shopId);
|
|
|
- if (empty($shop)) {
|
|
|
- util::fail('没有找到门店14');
|
|
|
+ if ($cg->cgIn == 0) {
|
|
|
+ $shop = ShopClass::getLockById($shopId);
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::fail('没有找到门店14');
|
|
|
+ }
|
|
|
+ $adminId = $shop->adminId;
|
|
|
+ $mainId = $shop->mainId;
|
|
|
+ PurchaseClass::rollbackProductStock($oldStocks, $shop, $adminId, $mainId, '系统');
|
|
|
}
|
|
|
- $adminId = $shop->adminId;
|
|
|
- $mainId = $shop->mainId;
|
|
|
- PurchaseClass::rollbackProductStock($oldStocks, $shop, $adminId, $mainId, '系统');
|
|
|
}
|
|
|
|
|
|
//订单发货主方法 ssh 20231119
|