添加ResultCode

This commit is contained in:
lifenlong 2021-06-30 15:45:33 +08:00
parent 800437473d
commit 346465630c
18 changed files with 87 additions and 29 deletions

View File

@ -66,7 +66,7 @@ public class MemberBuyerController {
if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) { if (smsUtil.verifyCode(mobile, VerificationEnums.LOGIN, uuid, code)) {
return ResultUtil.data(memberService.mobilePhoneLogin(mobile)); return ResultUtil.data(memberService.mobilePhoneLogin(mobile));
} else { } else {
throw new ServiceException("验证码错误"); throw new ServiceException(ResultCode.VERIFICATION_SMS_ERROR);
} }
} }

View File

@ -3,6 +3,7 @@ package cn.lili.timetask.handler.impl.order;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.member.entity.dto.MemberEvaluationDTO; import cn.lili.modules.member.entity.dto.MemberEvaluationDTO;
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum; import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
@ -58,7 +59,7 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
//自动确认收货 //自动确认收货
OrderSetting orderSetting = JSONUtil.toBean(setting.getSettingValue(), OrderSetting.class); OrderSetting orderSetting = JSONUtil.toBean(setting.getSettingValue(), OrderSetting.class);
if (orderSetting == null) { if (orderSetting == null) {
throw new ServiceException("系统配置异常"); throw new ServiceException(ResultCode.ORDER_SETTING_ERROR);
} }
//自动确认收货 //自动确认收货

View File

@ -64,6 +64,7 @@ public enum ResultCode {
GOODS_SKU_WEIGHT_ERROR(11010, "商品重量不能为负数"), GOODS_SKU_WEIGHT_ERROR(11010, "商品重量不能为负数"),
GOODS_SKU_QUANTITY_ERROR(11011, "商品库存数量不能为负数"), GOODS_SKU_QUANTITY_ERROR(11011, "商品库存数量不能为负数"),
GOODS_SKU_QUANTITY_NOT_ENOUGH(11011, "商品库存不足"), GOODS_SKU_QUANTITY_NOT_ENOUGH(11011, "商品库存不足"),
MUST_HAVE_GOODS_SKU(11012,"规格必须要有一个!"),
/** /**
* 参数 * 参数
@ -92,6 +93,12 @@ public enum ResultCode {
BRAND_DELETE_ERROR(14004, "品牌删除失败"), BRAND_DELETE_ERROR(14004, "品牌删除失败"),
BRAND_NAME_EXIST_ERROR(20002, "品牌名称重复!"),
BRAND_USE_DISABLE_ERROR(20003, "当前品牌下存在分类不可禁用"),
BRAND_NOT_EXIST(20004, "品牌不存在"),
/** /**
* 用户 * 用户
*/ */
@ -131,7 +138,9 @@ public enum ResultCode {
USER_GRADE_IS_DEFAULT(20018, "会员等级为默认会员等级"), USER_GRADE_IS_DEFAULT(20018, "会员等级为默认会员等级"),
DELETE_EXIST(2001, "无法重复收藏"), DELETE_EXIST(20019, "无法重复收藏"),
NOT_BINDING_USER(20020,"未绑定用户"),
/** /**
* 权限 * 权限
@ -201,6 +210,9 @@ public enum ResultCode {
ORDER_CAN_NOT_CANCEL(31012, "当前订单状态不可取消"), ORDER_CAN_NOT_CANCEL(31012, "当前订单状态不可取消"),
BATCH_DELIVER_ERROR(31013, "批量发货,文件读取失败"),
/** /**
* 支付 * 支付
*/ */
@ -230,6 +242,7 @@ public enum ResultCode {
CAN_NOT_RECHARGE_WALLET(32012, "不能使用余额进行充值"), CAN_NOT_RECHARGE_WALLET(32012, "不能使用余额进行充值"),
/** /**
* 售后 * 售后
*/ */
@ -290,6 +303,12 @@ public enum ResultCode {
COUPON_EDIT_STATUS_ERROR(41004, "优惠券修改状态失败!"), COUPON_EDIT_STATUS_ERROR(41004, "优惠券修改状态失败!"),
COUPON_RECEIVE_ERROR(41005, "当前优惠券状态不可领取"),
COUPON_NUM_INSUFFICIENT_ERROR(41006, "优惠券剩余领取数量不足"),
COUPON_NOT_EXIST(41007, "当前优惠券不存在"),
/** /**
* 拼团 * 拼团
*/ */
@ -313,6 +332,10 @@ public enum ResultCode {
PINTUAN_DELETE_ERROR(42010, "删除拼团活动失败"), PINTUAN_DELETE_ERROR(42010, "删除拼团活动失败"),
PINTUAN_JOIN_ERROR(42011, "不能参与自己发起的拼团活动!"),
PINTUAN_LIMIT_NUM_ERROR(42012, "购买数量超过拼团活动限制数量!"),
/** /**
* 满额活动 * 满额活动
*/ */
@ -320,20 +343,35 @@ public enum ResultCode {
FULL_DISCOUNT_EDIT_DELETE(43002, "删除满优惠活动成功"), FULL_DISCOUNT_EDIT_DELETE(43002, "删除满优惠活动成功"),
FULL_DISCOUNT_MODIFY_ERROR(43003,"当前编辑的满优惠活动已经开始或者已经结束,无法修改"),
/** /**
* 直播 * 直播
*/ */
STODIO_GOODS_EXIST_ERROR(44001,"直播商品已存在"), STODIO_GOODS_EXIST_ERROR(44001,"直播商品已存在"),
/**
* 秒杀
*/
SECKILL_NOT_EXIST(45001,"当前参与的秒杀活动不存在!"),
/**
* 优惠券活动
*/
COUPON_ACTIVITY_START_TIME_ERROR(46001,"活动时间小于当前时间,不能进行编辑删除操作"),
/** /**
* 店铺 * 店铺
*/ */
STORE_NOT_EXIST(50001, "此店铺不存在"), STORE_NOT_EXIST(50001, "此店铺不存在"),
STORE_NAME_EXIST_ERROR(50002, "店铺名称已存在!"), STORE_NAME_EXIST_ERROR(50002, "店铺名称已存在!"),
STORE_APPLY_DOUBLE_ERROR(50003, "已有店铺,无需重复申请!"), STORE_APPLY_DOUBLE_ERROR(50003, "已有店铺,无需重复申请!"),
STORE_NOT_OPEN(50004, "该会员未开通店铺"),
/** /**
* 结算单 * 结算单
*/ */
@ -380,6 +418,7 @@ public enum ResultCode {
*/ */
SMS_SIGN_EXIST_ERROR(80001, "短信签名已存在"), SMS_SIGN_EXIST_ERROR(80001, "短信签名已存在"),
/** /**
* 站内信 * 站内信
*/ */
@ -414,6 +453,13 @@ public enum ResultCode {
ALIPAY_PARAMS_EXCEPTION(80403, "支付宝参数异常"), ALIPAY_PARAMS_EXCEPTION(80403, "支付宝参数异常"),
LOGISTICS_NOT_SETTING(80404,"您还未配置快递查询"),
ORDER_SETTING_ERROR(80405,"系统订单配置异常"),
ALI_SMS_SETTING_ERROR(80406,"您还未配置阿里云短信"),
/** /**
* 微信相关异常 * 微信相关异常
*/ */
@ -425,6 +471,10 @@ public enum ResultCode {
WECHAT_MP_MESSAGE_ERROR(80503, "微信小程序小消息订阅异常"), WECHAT_MP_MESSAGE_ERROR(80503, "微信小程序小消息订阅异常"),
WECHAT_JSAPI_SIGN_ERROR(80504,"微信JsApi签名异常"),
WECHAT_CERT_ERROR(80505,"证书获取失败"),
APP_VERSION_EXIST(80600, "APP版本已存在"); APP_VERSION_EXIST(80600, "APP版本已存在");
private final Integer code; private final Integer code;

View File

@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.cache.CachePrefix; import cn.lili.common.cache.CachePrefix;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.context.UserContext; import cn.lili.common.security.context.UserContext;
import cn.lili.common.sms.AliSmsUtil; import cn.lili.common.sms.AliSmsUtil;
@ -64,7 +65,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
//获取短信配置 //获取短信配置
Setting setting = settingService.get(SettingEnum.SMS_SETTING.name()); Setting setting = settingService.get(SettingEnum.SMS_SETTING.name());
if (StrUtil.isBlank(setting.getSettingValue())) { if (StrUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException("您还未配置阿里云短信"); throw new ServiceException(ResultCode.ALI_SMS_SETTING_ERROR);
} }
SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class); SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class);
@ -351,7 +352,7 @@ public class SmsUtilAliImplService implements SmsUtil, AliSmsUtil {
try { try {
Setting setting = settingService.get(SettingEnum.SMS_SETTING.name()); Setting setting = settingService.get(SettingEnum.SMS_SETTING.name());
if (StrUtil.isBlank(setting.getSettingValue())) { if (StrUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException("您还未配置阿里云短信"); throw new ServiceException(ResultCode.ALI_SMS_SETTING_ERROR);
} }
SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class); SmsSetting smsSetting = new Gson().fromJson(setting.getSettingValue(), SmsSetting.class);

View File

@ -1,5 +1,6 @@
package cn.lili.common.token.base.generate; package cn.lili.common.token.base.generate;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.AuthUser; import cn.lili.common.security.AuthUser;
import cn.lili.common.security.enums.UserEnums; import cn.lili.common.security.enums.UserEnums;
@ -19,7 +20,6 @@ import org.springframework.stereotype.Component;
* *
* @author Chopper * @author Chopper
* @version v4.0 * @version v4.0
* @Description:
* @since 2020/11/16 10:51 * @since 2020/11/16 10:51
*/ */
@Component @Component
@ -36,7 +36,7 @@ public class StoreTokenGenerate extends AbstractTokenGenerate {
//生成token //生成token
Member member = memberService.findByUsername(username); Member member = memberService.findByUsername(username);
if (!member.getHaveStore()) { if (!member.getHaveStore()) {
throw new ServiceException("该会员未开通店铺"); throw new ServiceException(ResultCode.STORE_NOT_OPEN);
} }
AuthUser user = new AuthUser(member.getUsername(), member.getId(), member.getNickName(), UserEnums.STORE); AuthUser user = new AuthUser(member.getUsername(), member.getId(), member.getNickName(), UserEnums.STORE);
LambdaQueryWrapper<Store> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Store> queryWrapper = new LambdaQueryWrapper<>();

View File

@ -108,11 +108,11 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
CookieUtil.addCookie(CONNECT_TYPE, type, 1800, ThreadContextHolder.getHttpResponse()); CookieUtil.addCookie(CONNECT_TYPE, type, 1800, ThreadContextHolder.getHttpResponse());
//自动登录失败则把信息缓存起来 //自动登录失败则把信息缓存起来
cache.put(ConnectService.cacheKey(type, uuid), authUser, 30L, TimeUnit.MINUTES); cache.put(ConnectService.cacheKey(type, uuid), authUser, 30L, TimeUnit.MINUTES);
throw new ServiceException("未绑定用户"); throw new ServiceException(ResultCode.NOT_BINDING_USER);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("联合登陆异常:", e); log.error("联合登陆异常:", e);
throw new ServiceException("未知错误,请稍后重试"); throw new ServiceException(ResultCode.ERROR);
} }
return token; return token;
} }

View File

@ -1,5 +1,6 @@
package cn.lili.modules.goods.serviceimpl; package cn.lili.modules.goods.serviceimpl;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.PageUtil; import cn.lili.common.utils.PageUtil;
import cn.lili.modules.goods.entity.dos.Brand; import cn.lili.modules.goods.entity.dos.Brand;
@ -62,7 +63,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
public boolean addBrand(BrandVO brandVO) { public boolean addBrand(BrandVO brandVO) {
if (getOne(new LambdaQueryWrapper<Brand>().eq(Brand::getName, brandVO.getName())) != null) { if (getOne(new LambdaQueryWrapper<Brand>().eq(Brand::getName, brandVO.getName())) != null) {
throw new ServiceException("品牌名称重复!"); throw new ServiceException(ResultCode.BRAND_NAME_EXIST_ERROR);
} }
return this.save(brandVO); return this.save(brandVO);
} }
@ -71,7 +72,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
public boolean updateBrand(BrandVO brandVO) { public boolean updateBrand(BrandVO brandVO) {
this.checkExist(brandVO.getId()); this.checkExist(brandVO.getId());
if (getOne(new LambdaQueryWrapper<Brand>().eq(Brand::getName, brandVO.getName()).ne(Brand::getId, brandVO.getId())) != null) { if (getOne(new LambdaQueryWrapper<Brand>().eq(Brand::getName, brandVO.getName()).ne(Brand::getId, brandVO.getId())) != null) {
throw new ServiceException("品牌名称重复!"); throw new ServiceException(ResultCode.BRAND_NAME_EXIST_ERROR);
} }
return this.updateById(brandVO); return this.updateById(brandVO);
} }
@ -80,7 +81,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
public boolean brandDisable(String brandId, boolean disable) { public boolean brandDisable(String brandId, boolean disable) {
Brand brand = this.checkExist(brandId); Brand brand = this.checkExist(brandId);
if (Boolean.TRUE.equals(disable) && !categoryBrandService.getCategoryBrandListByBrandId(brandId).isEmpty()) { if (Boolean.TRUE.equals(disable) && !categoryBrandService.getCategoryBrandListByBrandId(brandId).isEmpty()) {
throw new ServiceException("当前品牌下存在分类不可禁用"); throw new ServiceException(ResultCode.BRAND_USE_DISABLE_ERROR);
} }
brand.setDeleteFlag(disable); brand.setDeleteFlag(disable);
return updateById(brand); return updateById(brand);
@ -90,7 +91,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
Brand brand = getById(brandId); Brand brand = getById(brandId);
if (brand == null) { if (brand == null) {
log.error("品牌ID为" + brandId + "的品牌不存在"); log.error("品牌ID为" + brandId + "的品牌不存在");
throw new ServiceException(); throw new ServiceException(ResultCode.BRAND_NOT_EXIST);
} }
return brand; return brand;
} }

View File

@ -96,7 +96,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
// 添加商品sku // 添加商品sku
newSkuList = this.addGoodsSku(skuList, goods); newSkuList = this.addGoodsSku(skuList, goods);
} else { } else {
throw new ServiceException("规格必须要有一个!"); throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU);
} }
this.updateStock(newSkuList); this.updateStock(newSkuList);
@ -107,7 +107,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regeneratorSkuFlag) { public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regeneratorSkuFlag) {
// 是否存在规格 // 是否存在规格
if (skuList == null || skuList.isEmpty()) { if (skuList == null || skuList.isEmpty()) {
throw new ServiceException("规格必须要有一个!"); throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU);
} }
List<GoodsSku> newSkuList; List<GoodsSku> newSkuList;
//删除旧的sku信息 //删除旧的sku信息

View File

@ -4,6 +4,7 @@ import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.cache.CachePrefix; import cn.lili.common.cache.CachePrefix;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.base.entity.enums.ClientTypeEnum; import cn.lili.modules.base.entity.enums.ClientTypeEnum;
import cn.lili.modules.connect.util.HttpUtils; import cn.lili.modules.connect.util.HttpUtils;
@ -105,7 +106,7 @@ public class WechatAccessTokenUtil {
return ticket; return ticket;
} catch (Exception e) { } catch (Exception e) {
log.error("微信JsApi签名异常", e); log.error("微信JsApi签名异常", e);
throw new ServiceException("微信JsApi签名异常"); throw new ServiceException(ResultCode.WECHAT_JSAPI_SIGN_ERROR);
} }
} }

View File

@ -544,7 +544,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
orderBatchDeliverDTOList.add(orderBatchDeliverDTO); orderBatchDeliverDTOList.add(orderBatchDeliverDTO);
} }
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("文件读取失败"); throw new ServiceException(ResultCode.BATCH_DELIVER_ERROR);
} }
//循环检查是否符合规范 //循环检查是否符合规范
checkBatchDeliver(orderBatchDeliverDTOList); checkBatchDeliver(orderBatchDeliverDTOList);
@ -778,7 +778,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
//判断用户不能参与自己发起的拼团活动 //判断用户不能参与自己发起的拼团活动
Order parentOrder = this.getBySn(tradeDTO.getParentOrderSn()); Order parentOrder = this.getBySn(tradeDTO.getParentOrderSn());
if (parentOrder.getMemberId().equals(UserContext.getCurrentUser().getId())) { if (parentOrder.getMemberId().equals(UserContext.getCurrentUser().getId())) {
throw new ServiceException("不能参与自己发起的拼团活动!"); throw new ServiceException(ResultCode.PINTUAN_JOIN_ERROR);
} }
} }
} }
@ -794,7 +794,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
Pintuan pintuan = pintuanService.getPintuanById(order.getPromotionId()); Pintuan pintuan = pintuanService.getPintuanById(order.getPromotionId());
Integer limitNum = pintuan.getLimitNum(); Integer limitNum = pintuan.getLimitNum();
if (limitNum != 0 && order.getGoodsNum() > limitNum) { if (limitNum != 0 && order.getGoodsNum() > limitNum) {
throw new ServiceException("购买数量超过拼团活动限制数量"); throw new ServiceException(ResultCode.PINTUAN_LIMIT_NUM_ERROR);
} }
} }
} }

View File

@ -57,7 +57,7 @@ public class CashierSupport {
HttpServletRequest request, HttpServletResponse response, HttpServletRequest request, HttpServletResponse response,
PayParam payParam) { PayParam payParam) {
if (paymentClientEnum == null || paymentMethodEnum == null) { if (paymentClientEnum == null || paymentMethodEnum == null) {
throw new ServiceException("未知的支付方式"); throw new ServiceException(ResultCode.PAY_NOT_SUPPORT);
} }
//获取支付插件 //获取支付插件
Payment payment = (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin()); Payment payment = (Payment) SpringContextUtil.getBean(paymentMethodEnum.getPlugin());

View File

@ -95,7 +95,7 @@ public class AliPayPlugin implements Payment {
@Override @Override
public ResultMessage<Object> JSApiPay(HttpServletRequest request, PayParam payParam) { public ResultMessage<Object> JSApiPay(HttpServletRequest request, PayParam payParam) {
throw new ServiceException("当前支付通道暂不支持"); throw new ServiceException(ResultCode.PAY_NOT_SUPPORT);
} }
@Override @Override

View File

@ -620,7 +620,7 @@ public class WechatPlugin implements Payment {
cache.put(CachePrefix.WECHAT_PLAT_FORM_CERT.getPrefix(), publicCert, second); cache.put(CachePrefix.WECHAT_PLAT_FORM_CERT.getPrefix(), publicCert, second);
} else { } else {
log.error("证书获取失败:{}" + body); log.error("证书获取失败:{}" + body);
throw new ServiceException("证书获取失败:" + body); throw new ServiceException(ResultCode.WECHAT_CERT_ERROR);
} }
return PayKit.getCertificate(publicCert); return PayKit.getCertificate(publicCert);
} catch (Exception e) { } catch (Exception e) {

View File

@ -1,6 +1,7 @@
package cn.lili.modules.promotion.serviceimpl; package cn.lili.modules.promotion.serviceimpl;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.trigger.enums.DelayTypeEnums; import cn.lili.common.trigger.enums.DelayTypeEnums;
import cn.lili.common.trigger.interfaces.TimeTrigger; import cn.lili.common.trigger.interfaces.TimeTrigger;
@ -208,7 +209,7 @@ public class CouponActivityServiceImpl extends ServiceImpl<CouponActivityMapper,
//检测活动时间超过当前时间不能进行操作 //检测活动时间超过当前时间不能进行操作
long nowTime = DateUtil.getDateline() * 1000; long nowTime = DateUtil.getDateline() * 1000;
if (couponActivity.getStartTime().getTime() < nowTime && couponActivity.getEndTime().getTime() > nowTime) { if (couponActivity.getStartTime().getTime() < nowTime && couponActivity.getEndTime().getTime() > nowTime) {
throw new ServiceException("活动时间小于当前时间,不能进行编辑删除操作"); throw new ServiceException(ResultCode.COUPON_ACTIVITY_START_TIME_ERROR);
} }
//活动时间需超过当前时间 //活动时间需超过当前时间
PromotionTools.checkPromotionTime(couponActivity.getStartTime().getTime(), couponActivity.getEndTime().getTime()); PromotionTools.checkPromotionTime(couponActivity.getStartTime().getTime(), couponActivity.getEndTime().getTime());

View File

@ -1,5 +1,6 @@
package cn.lili.modules.promotion.serviceimpl; package cn.lili.modules.promotion.serviceimpl;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.trigger.util.DelayQueueTools; import cn.lili.common.trigger.util.DelayQueueTools;
import cn.lili.common.trigger.enums.DelayTypeEnums; import cn.lili.common.trigger.enums.DelayTypeEnums;
import cn.lili.common.trigger.message.PromotionMessage; import cn.lili.common.trigger.message.PromotionMessage;
@ -135,7 +136,7 @@ public class FullDiscountServiceImpl extends ServiceImpl<FullDiscountMapper, Ful
//检查满优惠活动是否存在 //检查满优惠活动是否存在
FullDiscountVO fullDiscount = this.checkFullDiscountExist(fullDiscountVO.getId()); FullDiscountVO fullDiscount = this.checkFullDiscountExist(fullDiscountVO.getId());
if (!fullDiscount.getPromotionStatus().equals(PromotionStatusEnum.NEW.name())) { if (!fullDiscount.getPromotionStatus().equals(PromotionStatusEnum.NEW.name())) {
throw new ServiceException("当前编辑的满优惠活动已经开始或者已经结束,无法修改"); throw new ServiceException(ResultCode.FULL_DISCOUNT_MODIFY_ERROR);
} }
//检查活动是否已经开始 //检查活动是否已经开始
PromotionTools.checkPromotionTime(fullDiscountVO.getStartTime().getTime(), fullDiscountVO.getEndTime().getTime()); PromotionTools.checkPromotionTime(fullDiscountVO.getStartTime().getTime(), fullDiscountVO.getEndTime().getTime());

View File

@ -53,10 +53,10 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
.eq(MemberCoupon::getMemberId, memberId); .eq(MemberCoupon::getMemberId, memberId);
int haveCoupons = this.count(queryWrapper); int haveCoupons = this.count(queryWrapper);
if (!PromotionStatusEnum.START.name().equals(coupon.getPromotionStatus())) { if (!PromotionStatusEnum.START.name().equals(coupon.getPromotionStatus())) {
throw new ServiceException("当前优惠券状态不可领取"); throw new ServiceException(ResultCode.COUPON_RECEIVE_ERROR);
} }
if (coupon.getPublishNum() != 0 && coupon.getReceivedNum() >= coupon.getPublishNum()) { if (coupon.getPublishNum() != 0 && coupon.getReceivedNum() >= coupon.getPublishNum()) {
throw new ServiceException("优惠券剩余领取数量不足"); throw new ServiceException(ResultCode.COUPON_NUM_INSUFFICIENT_ERROR);
} }
if (haveCoupons >= coupon.getCouponLimitNum()) { if (haveCoupons >= coupon.getCouponLimitNum()) {
throw new ServiceException("此优惠券最多领取" + coupon.getCouponLimitNum() + ""); throw new ServiceException("此优惠券最多领取" + coupon.getCouponLimitNum() + "");
@ -76,7 +76,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
this.save(memberCoupon); this.save(memberCoupon);
couponService.receiveCoupon(couponId, 1); couponService.receiveCoupon(couponId, 1);
} else { } else {
throw new ServiceException("当前优惠券不存在"); throw new ServiceException(ResultCode.COUPON_NOT_EXIST);
} }
} }

View File

@ -6,6 +6,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.cache.Cache; import cn.lili.common.cache.Cache;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.common.vo.PageVO; import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsSku; import cn.lili.modules.goods.entity.dos.GoodsSku;
@ -145,7 +146,7 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
public void addSeckillApply(String seckillId, String storeId, List<SeckillApplyVO> seckillApplyList) { public void addSeckillApply(String seckillId, String storeId, List<SeckillApplyVO> seckillApplyList) {
SeckillVO seckill = mongoTemplate.findById(seckillId, SeckillVO.class); SeckillVO seckill = mongoTemplate.findById(seckillId, SeckillVO.class);
if (seckill == null) { if (seckill == null) {
throw new ServiceException("当前参与的秒杀活动不存在!"); throw new ServiceException(ResultCode.SECKILL_NOT_EXIST);
} }
//检查秒杀活动申请是否合法 //检查秒杀活动申请是否合法
checkSeckillApplyList(seckill.getHours(), seckillApplyList, storeId); checkSeckillApplyList(seckill.getHours(), seckillApplyList, storeId);

View File

@ -1,6 +1,7 @@
package cn.lili.modules.system.serviceimpl; package cn.lili.modules.system.serviceimpl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.SwitchEnum; import cn.lili.common.enums.SwitchEnum;
import cn.lili.common.exception.ServiceException; import cn.lili.common.exception.ServiceException;
import cn.lili.modules.system.entity.dos.Logistics; import cn.lili.modules.system.entity.dos.Logistics;
@ -72,7 +73,7 @@ public class LogisticsServiceImpl extends ServiceImpl<LogisticsMapper, Logistics
private Traces getOrderTracesByJson(String logisticsId, String expNo) throws Exception { private Traces getOrderTracesByJson(String logisticsId, String expNo) throws Exception {
Setting setting = settingService.get(SettingEnum.KUAIDI_SETTING.name()); Setting setting = settingService.get(SettingEnum.KUAIDI_SETTING.name());
if (StrUtil.isBlank(setting.getSettingValue())) { if (StrUtil.isBlank(setting.getSettingValue())) {
throw new ServiceException("您还未配置快递查询"); throw new ServiceException(ResultCode.LOGISTICS_NOT_SETTING);
} }
KuaidiSetting kuaidiSetting = new Gson().fromJson(setting.getSettingValue(), KuaidiSetting.class); KuaidiSetting kuaidiSetting = new Gson().fromJson(setting.getSettingValue(), KuaidiSetting.class);