|
|
@@ -472,6 +472,7 @@ class OrderController extends BaseController
|
|
|
$post['sjId'] = $this->sjId;
|
|
|
$post['shopId'] = $this->shopId;
|
|
|
$post['mainId'] = $this->mainId ?? 0;
|
|
|
+ $shop = $this->shop;
|
|
|
$now = time();
|
|
|
$orderValidTime = getenv('ORDER_VALID_TIME') == false ? 600 : getenv('ORDER_VALID_TIME');
|
|
|
$expireTime = $now + $orderValidTime;
|
|
|
@@ -597,29 +598,64 @@ class OrderController extends BaseController
|
|
|
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('要选择花材哦');
|
|
|
+ $productIds = [];
|
|
|
+ $hsIds = [];
|
|
|
+ foreach ($productList as $pv) {
|
|
|
+ $property = $pv['property'] ?? 0;
|
|
|
+ $puId = $pv['productId'] ?? 0;
|
|
|
+ if ($property == 0) {
|
|
|
+ $hsIds[] = $puId;
|
|
|
+ } else {
|
|
|
+ $productIds[] = $puId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $itemInfo = [];
|
|
|
+ if (!empty($productIds)) {
|
|
|
+ $itemInfo = ProductClass::getByIds($productIds, null, 'id');
|
|
|
+ }
|
|
|
+ $hsInfo = [];
|
|
|
+ if (!empty($hsIds)) {
|
|
|
+ $hsInfo = GoodsClass::getByIds($hsIds, null, 'id');
|
|
|
}
|
|
|
$diff = [];
|
|
|
$priceMap = \bizGhs\custom\classes\CustomClass::$levelPriceKeyMap;
|
|
|
$addPriceMap = \bizGhs\custom\classes\CustomClass::$levelAddPriceKeyMap;
|
|
|
$level = 0;
|
|
|
foreach ($productList as $currentProduct) {
|
|
|
+ $property = $currentProduct['property'] ?? 0;
|
|
|
$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 ($property == 1) {
|
|
|
+ $systemInfo = $itemInfo[$currentId] ?? [];
|
|
|
+ if (!empty($systemInfo)) {
|
|
|
+ $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,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $systemInfo = $hsInfo[$currentId] ?? [];
|
|
|
+ if (!empty($systemInfo)) {
|
|
|
+ $params = [];
|
|
|
+ $name = $systemInfo['name'] ?? '';
|
|
|
+ $hsData = GoodsClass::getFinalPrice($systemInfo, $shop, $custom, $params);
|
|
|
+ $systemPrice = $hsData['price'] ?? 0;
|
|
|
+ if (floatval($currentPrice) != floatval($systemPrice)) {
|
|
|
+ $diff[] = [
|
|
|
+ 'name' => $name,
|
|
|
+ 'price' => $systemPrice,
|
|
|
+ 'kdPrice' => $currentPrice,
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if (!empty($diff)) {
|
|
|
util::success(['diff' => $diff, 'respondType' => 'priceError']);
|
|
|
}
|