| | |
| | | |
| | | namespace app\api\service\order\settled; |
| | | |
| | | use app\api\model\order\OrderProduct; |
| | | use app\common\enum\order\OrderSourceEnum; |
| | | use app\api\model\order\Order as OrderModel; |
| | | /** |
| | |
| | | */ |
| | | public function validateProductList() |
| | | { |
| | | $newcomerNum =(new OrderModel()) |
| | | ->where('user_id', $this->user['user_id']) |
| | | ->where('is_newcomer', 1)->count(); |
| | | |
| | | foreach ($this->supplierData as $supplier) { |
| | | foreach ($supplier['productList'] as $product) { |
| | | // 判断商品是否下架 |
| | |
| | | $this->error = "很抱歉,商品 [{$product['product_name']}] 已下架"; |
| | | return false; |
| | | } |
| | | // 判断商品是否下架 |
| | | if ($product['is_newcomer'] == 1 && $product['total_num'] > 1) { |
| | | $this->error = "很抱歉,商品为新人专区商品只能购买1件"; |
| | | return false; |
| | | } |
| | | if ($product['is_newcomer'] == 1 && $newcomerNum > 0) { |
| | | $this->error = "很抱歉,您已购买过新人专区商品,不能购买新人专区商品"; |
| | | return false; |
| | | } |
| | | if ($this->user['purchase_count'] <= 0 && $product['is_repurchase'] == 1 ) { |
| | | $this->error = "很抱歉,还不是会员,不能购买复购专区商品,请到先到vip专区购买"; |
| | | return false; |
| | | } |
| | | // 判断商品库存 |
| | | if ($product['total_num'] > $product['product_sku']['stock_num']) { |
| | | $this->error = "很抱歉,商品 [{$product['product_name']}] 库存不足"; |