|
@@ -168,6 +168,31 @@ class TradeService extends CrudService {
|
|
result.result = false;
|
|
result.result = false;
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+ // 判断是否有购买限制
|
|
|
|
+ if (_.get(goodsSpecData, 'buy_limit', '0') !== '0') {
|
|
|
|
+ // 有购买限制,需要检测购买限制
|
|
|
|
+ const buy_limit = _.get(goodsSpecData, 'buy_limit');
|
|
|
|
+ const limit_num = _.get(goodsSpecData, 'limit_num', 0);
|
|
|
|
+ if (buy_limit === '1') {
|
|
|
|
+ if (num < limit_num) {
|
|
|
|
+ result.msg = `改规格至少购买 ${limit_num} 份, 购买数量不足`;
|
|
|
|
+ result.result = false;
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ } else if (buy_limit === '2') {
|
|
|
|
+ if (num > limit_num) {
|
|
|
|
+ result.msg = `改规格至多购买 ${limit_num} 份, 购买数量超过上限`;
|
|
|
|
+ result.result = false;
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ } else if (buy_limit === '3') {
|
|
|
|
+ if (num !== limit_num) {
|
|
|
|
+ result.msg = `改规格只能购买 ${limit_num} 份`;
|
|
|
|
+ result.result = false;
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|