|
|
@@ -215,6 +215,7 @@ class OrderForm extends Model
|
|
|
/**
|
|
|
* 判断支付方式
|
|
|
* @param $attribute
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
public function isPayType($attribute){
|
|
|
if(!array_key_exists($this->payType, ShopGoods::payTypes())){
|
|
|
@@ -224,9 +225,13 @@ class OrderForm extends Model
|
|
|
|
|
|
// 一个订单只能包含一类商品
|
|
|
$goods = ShopGoods::find()->select('ID,CATEGORY_TYPE')->where(['in', 'ID', $this->goodsId])->andWhere(['STATUS' => 1])->asArray()->all();
|
|
|
+ if (!$goods) {
|
|
|
+ throw new Exception('Products does not exists!');
|
|
|
+ return;
|
|
|
+ }
|
|
|
$goodsCategoryType = array_unique(array_column($goods, 'CATEGORY_TYPE'));
|
|
|
- if (count($goodsCategoryType) != 1) {
|
|
|
- $this->addError($attribute, '订单不能包含多种商品分类');
|
|
|
+ if (count($goodsCategoryType) > 1) {
|
|
|
+ $this->addError($attribute, 'Order cannot contain multiple product categories'); // 订单不能包含多种商品分类
|
|
|
return;
|
|
|
}
|
|
|
|