|
|
@@ -1426,12 +1426,27 @@ class OrderController extends BaseController
|
|
|
$addPriceMap['risePercent'] = $custom['risePercent'] ?? 0;
|
|
|
|
|
|
$level = $custom['level'] ?? 1;
|
|
|
+ $skipLimitBuy = !empty($shop->skCustomId) && intval($shop->skCustomId) == intval($customId);
|
|
|
+ $limitBuyCheckList = [];
|
|
|
+ foreach ($productList as $currentProduct) {
|
|
|
+ $limitBuyCheckList[] = [
|
|
|
+ 'id' => $currentProduct['productId'] ?? 0,
|
|
|
+ 'bigCount' => $currentProduct['bigNum'] ?? 0,
|
|
|
+ 'smallCount' => $currentProduct['smallNum'] ?? 0,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $limitBuyInfoList = ProductClass::getLimitBuyInfoByList($limitBuyCheckList, $customId);
|
|
|
+ $limitBuyInfoMap = array_column($limitBuyInfoList, null, 'id');
|
|
|
foreach ($productList as $ptKey => $currentProduct) {
|
|
|
$currentPrice = $currentProduct['price'] ?? 0;
|
|
|
$currentId = $currentProduct['productId'] ?? 0;
|
|
|
$systemInfo = $itemInfo[$currentId] ?? [];
|
|
|
$name = $systemInfo['name'] ?? '';
|
|
|
- $systemPrice = ProductClass::getFinalPrice($systemInfo, $level, $priceMap, $addPriceMap);
|
|
|
+ $limitBuyInfo = $limitBuyInfoMap[$currentId] ?? [];
|
|
|
+ $buyNum = $skipLimitBuy ? 0 : ($limitBuyInfo['currentBuyNum'] ?? 0);
|
|
|
+ $hasBuyNum = $skipLimitBuy ? 0 : ($limitBuyInfo['hasBuyNum'] ?? 0);
|
|
|
+ $totalBuyNum = $skipLimitBuy ? 0 : bcadd($hasBuyNum, $buyNum, 2);
|
|
|
+ $systemPrice = ProductClass::getFinalPrice($systemInfo, $level, $priceMap, $addPriceMap, 0, $buyNum, $totalBuyNum);
|
|
|
|
|
|
if (getenv('YII_ENV') == 'production') {
|
|
|
//苏州小蔡鲜花,几个出车,不能低于原价卖,但可以高于原价卖的
|
|
|
@@ -1538,6 +1553,7 @@ class OrderController extends BaseController
|
|
|
try {
|
|
|
$return = OrderService::createNewOrder($post, $custom, $hasPay);
|
|
|
$transaction->commit();
|
|
|
+ ProductClass::clearLimitBuyRollbackSnapshot();
|
|
|
} catch (\Exception $exception) {
|
|
|
if ($transaction->isActive) {
|
|
|
$transaction->rollBack();
|
|
|
@@ -1604,6 +1620,7 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
util::success($return);
|
|
|
} catch (\Exception $e) {
|
|
|
+ ProductClass::rollbackLimitBuySnapshot();
|
|
|
Yii::error("下单失败原因:" . $e->getMessage());
|
|
|
noticeUtil::push("批发线下开单失败,原因:" . $e->getMessage(), '15280215347');
|
|
|
if (util::isDbConcurrencyException($e)) {
|