...
|
...
|
@@ -189,7 +189,7 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ |
|
|
if (!couponTypeEnum.isPresent()){
|
|
|
throw new ServiceException(400, "错误:不合法的优惠券类型");
|
|
|
}
|
|
|
parseSkupForbidType(req);
|
|
|
parseSkupAllowType(req);
|
|
|
|
|
|
int productLimitType = req.getProductLimitType().intValue();
|
|
|
List<Integer> productIds = getProductIdsAndCheckProductLimitParam(productLimitType,req.getProductLimitValue());
|
...
|
...
|
@@ -256,27 +256,37 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{ |
|
|
return new ApiResponse.ApiResponseBuilder().build();
|
|
|
}
|
|
|
|
|
|
private void parseSkupForbidType(CouponSaveUpdateReq req) {
|
|
|
if (StringUtils.isBlank(req.getSkupForbidType())) {
|
|
|
req.setSkupForbidType(SKUP_FORBID_TYPE_NONE);
|
|
|
return;
|
|
|
}
|
|
|
List<String> limitTypes = Splitter.on(",").omitEmptyStrings().trimResults().splitToList(req.getSkupForbidType());
|
|
|
if (CollectionUtils.isEmpty(limitTypes)) {
|
|
|
req.setSkupForbidType(SKUP_FORBID_TYPE_NONE);
|
|
|
return;
|
|
|
}
|
|
|
for (String limitType : limitTypes) {
|
|
|
if (!limitType.matches("\\d+")) {
|
|
|
throw new ServiceException(400, "错误:不合法的限制类型");
|
|
|
}
|
|
|
if (!SkupType.of(Integer.parseInt(limitType)).isPresent() && !SKUP_FORBID_TYPE_NONE.equals(limitType)) {
|
|
|
throw new ServiceException(401, "错误:不合法的限制类型");
|
|
|
}
|
|
|
|
|
|
private void parseSkupAllowType(CouponSaveUpdateReq req) {
|
|
|
if (StringUtils.isBlank(req.getSkupAllowType())) {
|
|
|
throw new ServiceException(403, "可使用该优惠券的商品属性不能为空");
|
|
|
}
|
|
|
req.setSkupForbidType(Joiner.on(",").join(limitTypes));
|
|
|
List<String> allowAttributeTypes = Splitter.on(",").omitEmptyStrings().trimResults().splitToList(req.getSkupAllowType());
|
|
|
req.setSkupAllowType(Joiner.on(",").join(allowAttributeTypes));
|
|
|
}
|
|
|
|
|
|
|
|
|
// private void parseSkupForbidType(CouponSaveUpdateReq req) {
|
|
|
// if (StringUtils.isBlank(req.getSkupForbidType())) {
|
|
|
// req.setSkupForbidType(SKUP_FORBID_TYPE_NONE);
|
|
|
// return;
|
|
|
// }
|
|
|
// List<String> limitTypes = Splitter.on(",").omitEmptyStrings().trimResults().splitToList(req.getSkupForbidType());
|
|
|
// if (CollectionUtils.isEmpty(limitTypes)) {
|
|
|
// req.setSkupForbidType(SKUP_FORBID_TYPE_NONE);
|
|
|
// return;
|
|
|
// }
|
|
|
// for (String limitType : limitTypes) {
|
|
|
// if (!limitType.matches("\\d+")) {
|
|
|
// throw new ServiceException(400, "错误:不合法的限制类型");
|
|
|
// }
|
|
|
// if (!SkupType.of(Integer.parseInt(limitType)).isPresent() && !SKUP_FORBID_TYPE_NONE.equals(limitType)) {
|
|
|
// throw new ServiceException(401, "错误:不合法的限制类型");
|
|
|
// }
|
|
|
// }
|
|
|
// req.setSkupForbidType(Joiner.on(",").join(limitTypes));
|
|
|
// }
|
|
|
|
|
|
private void saveProductLimitItems(CouponSaveUpdateReq req, int productLimitType, List<Integer> productIds) {
|
|
|
if(req.getProductLimitType() == Coupon.PRODUCTLIMITTYPE_SPECIALPRODUCT || req.getProductLimitType() == Coupon.PRODUCTLIMITTYPE_EXCLUDE){
|
|
|
// 清理之前的记录
|
...
|
...
|
|