|
|
@@ -63,9 +63,21 @@ class CheckOrderController extends BaseController
|
|
|
if ($totalNum > $mother->stock) {
|
|
|
util::fail($motherName . "不足{$totalNum}扎");
|
|
|
}
|
|
|
- $bigNum = bcsub($mother->stock, $totalNum, 2);
|
|
|
- $bigNum = floatval($bigNum);
|
|
|
- $itemList[] = ['productId' => $motherId, 'bigNum' => $bigNum, 'smallNum' => 0];
|
|
|
+ $motherBigNum = bcsub($mother->stock, $totalNum, 2);
|
|
|
+ $motherBigNum = floatval($motherBigNum);
|
|
|
+
|
|
|
+ $ids = array_column($itemList, 'productId');
|
|
|
+ $infoList = ProductClass::getByIds($ids, null, 'id');
|
|
|
+ if (!empty($infoList)) {
|
|
|
+ foreach ($itemList as $itemKey => $itemVal) {
|
|
|
+ $productId = $itemVal['productId'] ?? 0;
|
|
|
+ $bigNum = $itemVal['bigNum'] ?? 0;
|
|
|
+ $addBigNum = $infoList[$productId]['stock'] ?? 0;
|
|
|
+ $newBigNum = bcadd($bigNum, $addBigNum, 2);
|
|
|
+ $itemList[$itemKey]['bigNum'] = $newBigNum;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $itemList[] = ['productId' => $motherId, 'bigNum' => $motherBigNum, 'smallNum' => 0];
|
|
|
$newJson = json_encode($itemList);
|
|
|
$post['itemInfo'] = $newJson;
|
|
|
|