|
|
@@ -581,14 +581,8 @@ class OrderController extends BaseController
|
|
|
try {
|
|
|
$post['product'] = $productList;
|
|
|
|
|
|
- //3秒内不允许重复开单
|
|
|
- $staffId = $this->shopAdminId ?? 0;
|
|
|
- $cacheKey = 'hd_create_order_' . $staffId . '_' . $customId;
|
|
|
- $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
|
|
|
- if (!empty($has)) {
|
|
|
- util::fail('稍等5秒再开单');
|
|
|
- }
|
|
|
- Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 3, 'has']);
|
|
|
+ //解决重复提交
|
|
|
+ util::checkRepeatCommit($this->adminId, 3);
|
|
|
|
|
|
$reduceStock = $post['reduceStock'] ?? 0;
|
|
|
if ($reduceStock == 1) {
|
|
|
@@ -598,6 +592,40 @@ class OrderController extends BaseController
|
|
|
util::success($return);
|
|
|
}
|
|
|
|
|
|
+ //解决开单提交订单时,别人修改价格,造成提交价格不是真实卖价问题!!
|
|
|
+ $version = $post['version'] ?? 0;
|
|
|
+ if ($version == 2) {
|
|
|
+ $dealPrice = $post['dealPrice'] ?? 0;
|
|
|
+ if ($dealPrice == 0) {
|
|
|
+ $ids = array_unique(array_filter(array_column($productList, 'productId')));
|
|
|
+ $itemInfo = ProductClass::getByIds($ids, null, 'id');
|
|
|
+ if (empty($itemInfo)) {
|
|
|
+ util::fail('要选择花材哦');
|
|
|
+ }
|
|
|
+ $diff = [];
|
|
|
+ $priceMap = \bizGhs\custom\classes\CustomClass::$levelPriceKeyMap;
|
|
|
+ $addPriceMap = \bizGhs\custom\classes\CustomClass::$levelAddPriceKeyMap;
|
|
|
+ $level = 0;
|
|
|
+ foreach ($productList as $currentProduct) {
|
|
|
+ $currentPrice = $currentProduct['unitPrice'] ?? 0;
|
|
|
+ $currentId = $currentProduct['productId'] ?? 0;
|
|
|
+ $systemInfo = $itemInfo[$currentId] ?? [];
|
|
|
+ $name = $systemInfo['name'] ?? '';
|
|
|
+ $systemPrice = \bizGhs\product\classes\ProductClass::getFinalPrice($systemInfo, $level, $priceMap, $addPriceMap);
|
|
|
+ if (floatval($currentPrice) != floatval($systemPrice)) {
|
|
|
+ $diff[] = [
|
|
|
+ 'name' => $name,
|
|
|
+ 'price' => $systemPrice,
|
|
|
+ 'kdPrice' => $currentPrice,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!empty($diff)) {
|
|
|
+ util::success(['diff' => $diff, 'respondType' => 'priceError']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//多处调用这个方法,注意同步修改,搜索关键词 createHdNewOrder
|
|
|
$return = OrderService::createHdOrder($post, $custom, $hasPay);
|
|
|
$shop = $this->shop;
|