|
|
@@ -194,6 +194,8 @@ class PurchaseController extends BaseController
|
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
|
|
|
|
+ $version = $post['version']??0;
|
|
|
+
|
|
|
//多颜色数据整理
|
|
|
$colorItem = $post['xj'] ?? [];
|
|
|
$newXj = [];
|
|
|
@@ -276,6 +278,15 @@ class PurchaseController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //收集客户要下单的花材数量
|
|
|
+ $orderNum = [];
|
|
|
+ foreach($productList as $key => $product) {
|
|
|
+ $bigNum = $product['bigNum']??0;
|
|
|
+ $productId = $product['productId']??0;
|
|
|
+ $orderNum[$productId] = ['num'=>$bigNum];
|
|
|
+ }
|
|
|
+ $lack = [];
|
|
|
+
|
|
|
$ids = array_unique(array_filter(array_column($productList, 'productId')));
|
|
|
$productInfoList = ProductClass::getByIds($ids, null, 'id');
|
|
|
if (!empty($productInfoList)) {
|
|
|
@@ -313,6 +324,19 @@ class PurchaseController extends BaseController
|
|
|
$post['presell'] = 1;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if($version >= 10){
|
|
|
+ $stock = $currentInfo['stock']??0;
|
|
|
+ $stock = floatval($stock);
|
|
|
+ $productId = $currentInfo['id']??0;
|
|
|
+ $productName = $currentInfo['name']??'';
|
|
|
+ $num = $orderNum[$productId] && $orderNum[$productId]['num'] ? $orderNum[$productId]['num'] : 0;
|
|
|
+ $num = floatval($num);
|
|
|
+ if($num>$stock){
|
|
|
+ $lack[] = ['name'=>$productName,'stock'=>$stock];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
if (count($productInfoList) != count($ids)) {
|
|
|
util::fail('存在无效商品');
|
|
|
@@ -321,6 +345,14 @@ class PurchaseController extends BaseController
|
|
|
if (count($presellData) > 1) {
|
|
|
util::fail('预售和非预售花材不能一起下单');
|
|
|
}
|
|
|
+
|
|
|
+ if($version >= 10){
|
|
|
+ if(!empty($lack)){
|
|
|
+ util::success(['lack'=>$lack,'hasLackError'=>1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ die;
|
|
|
+
|
|
|
} else {
|
|
|
util::fail('花材不存在');
|
|
|
}
|