|
@@ -786,6 +786,40 @@ class OrderController extends BaseController
|
|
|
if (empty($productList)) {
|
|
if (empty($productList)) {
|
|
|
util::fail('请选择花材');
|
|
util::fail('请选择花材');
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ $dealPrice = $post['dealPrice'] ?? 0;
|
|
|
|
|
+ $ids = array_unique(array_filter(array_column($productList, 'productId')));
|
|
|
|
|
+ $itemInfo = ProductClass::getByIds($ids, null, 'id');
|
|
|
|
|
+ if (empty($itemInfo)) {
|
|
|
|
|
+ util::fail('请选择花材哦');
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach ($itemInfo as $itemData) {
|
|
|
|
|
+ if (isset($itemData['mainId']) == false || $itemData['mainId'] != $this->mainId) {
|
|
|
|
|
+ util::fail('只能选择同一家的商品下单');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //开单提交订单时,别人修改价格,暂成提交价格不是真实卖价问题解决
|
|
|
|
|
+ if ($dealPrice == 0) {
|
|
|
|
|
+ $diff = [];
|
|
|
|
|
+ foreach ($productList as $currentProduct) {
|
|
|
|
|
+ $currentPrice = $currentProduct['price'] ?? 0;
|
|
|
|
|
+ $currentId = $currentProduct['productId'] ?? 0;
|
|
|
|
|
+ $systemInfo = $itemInfo[$currentId] ?? [];
|
|
|
|
|
+ $systemPrice = $systemInfo['price'] ?? 0;
|
|
|
|
|
+ $name = $systemInfo['name'] ?? '';
|
|
|
|
|
+ if (floatval($currentPrice) != floatval($systemPrice)) {
|
|
|
|
|
+ $diff[] = [
|
|
|
|
|
+ 'name' => $name,
|
|
|
|
|
+ 'price' => $systemPrice,
|
|
|
|
|
+ 'kdPrice' => $currentPrice,
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!empty($diff)) {
|
|
|
|
|
+ util::success(['diff' => $diff, 'respondType' => 'priceError']);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$connection = Yii::$app->db;//事务处理
|
|
$connection = Yii::$app->db;//事务处理
|
|
|
$transaction = $connection->beginTransaction();
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
try {
|