调整异常机制

This commit is contained in:
Chopper
2021-05-19 14:11:12 +08:00
parent 0528a1e1ca
commit a10110e1f0
196 changed files with 733 additions and 1233 deletions

View File

@@ -3,6 +3,7 @@ package cn.lili.common.enums;
/**
* 返回状态码
* 第一位 1:商品2:用户3:交易,4:促销,5:店铺,6:页面,7:设置,8:其他
*
* @author Chopper
* @date 2020/4/8 1:36 下午
*/
@@ -16,89 +17,97 @@ public enum ResultCode {
/**
* 失败返回码
*/
ERROR(400,"失败"),
ERROR(400, "失败"),
/**
* 失败返回码
*/
DEMO_SITE_EXCEPTION(400,"演示站点禁止使用"),
DEMO_SITE_EXCEPTION(4001, "演示站点禁止使用"),
/**
* 参数异常
*/
PARAMS_ERROR(4002, "参数异常"),
/**
* 系统异常
*/
WECHAT_CONNECT_NOT_EXIST(1001,"微信联合登录未配置"),
WECHAT_CONNECT_NOT_EXIST(1001, "微信联合登录未配置"),
/**
* 分类
*/
CATEGORY_NOT_EXIST(10001,"商品分类不存在"),
CATEGORY_NAME_IS_EXIST(10002,"该分类名称已存在"),
CATEGORY_PARENT_NOT_EXIST(10003,"该分类名称已存在"),
CATEGORY_BEYOND_THREE(10004,"最多为三级分类,添加失败"),
CATEGORY_HAS_CHILDREN(10005,"此类别下存在子类别不能删除"),
CATEGORY_HAS_GOODS(10006,"此类别下存在商品不能删除"),
CATEGORY_SAVE_ERROR(10007,"此类别下存在商品不能删除"),
CATEGORY_PARAMETER_SAVE_ERROR(10008,"分类绑定参数组添加失败"),
CATEGORY_PARAMETER_UPDATE_ERROR(10009,"分类绑定参数组添加失败"),
CATEGORY_NOT_EXIST(10001, "商品分类不存在"),
CATEGORY_NAME_IS_EXIST(10002, "该分类名称已存在"),
CATEGORY_PARENT_NOT_EXIST(10003, "该分类名称已存在"),
CATEGORY_BEYOND_THREE(10004, "最多为三级分类,添加失败"),
CATEGORY_HAS_CHILDREN(10005, "此类别下存在子类别不能删除"),
CATEGORY_HAS_GOODS(10006, "此类别下存在商品不能删除"),
CATEGORY_SAVE_ERROR(10007, "此类别下存在商品不能删除"),
CATEGORY_PARAMETER_SAVE_ERROR(10008, "分类绑定参数组添加失败"),
CATEGORY_PARAMETER_UPDATE_ERROR(10009, "分类绑定参数组添加失败"),
/**
* 商品
*/
GOODS_NOT_EXIST(11001,"商品已下架"),
GOODS_NAME_ERROR(11002,"商品名称不正确名称应为2-50字符"),
GOODS_UNDER_ERROR(11003,"商品下架失败"),
GOODS_UPPER_ERROR(11004,"商品上架失败"),
GOODS_AUTH_ERROR(11005,"商品审核失败"),
GOODS_NOT_EXIST(11001, "商品已下架"),
GOODS_NAME_ERROR(11002, "商品名称不正确名称应为2-50字符"),
GOODS_UNDER_ERROR(11003, "商品下架失败"),
GOODS_UPPER_ERROR(11004, "商品上架失败"),
GOODS_AUTH_ERROR(11005, "商品审核失败"),
POINT_GOODS_ERROR(11006, "积分商品业务异常,请稍后重试"),
/**
* 参数
*/
PARAMETER_SAVE_ERROR(12001,"参数添加失败"),
PARAMETER_UPDATE_ERROR(12002,"参数编辑失败"),
PARAMETER_SAVE_ERROR(12001, "参数添加失败"),
PARAMETER_UPDATE_ERROR(12002, "参数编辑失败"),
/**
* 规格
*/
SPEC_SAVE_ERROR(13001,"规格修改失败"),
SPEC_UPDATE_ERROR(13002,"规格修改失败"),
SPEC_DELETE_ERROR(13003,"此规格已绑定分类不允许删除"),
SPEC_SAVE_ERROR(13001, "规格修改失败"),
SPEC_UPDATE_ERROR(13002, "规格修改失败"),
SPEC_DELETE_ERROR(13003, "此规格已绑定分类不允许删除"),
/**
* 品牌
*/
BRAND_SAVE_ERROR(14001,"品牌添加失败"),
BRAND_UPDATE_ERROR(14002,"品牌修改失败"),
BRAND_DISABLE_ERROR(14003,"品牌禁用失败"),
BRAND_DELETE_ERROR(14004,"品牌删除失败"),
BRAND_SAVE_ERROR(14001, "品牌添加失败"),
BRAND_UPDATE_ERROR(14002, "品牌修改失败"),
BRAND_DISABLE_ERROR(14003, "品牌禁用失败"),
BRAND_DELETE_ERROR(14004, "品牌删除失败"),
/**
* 用户
*/
USER_EDIT_SUCCESS(20001,"用户修改成功"),
USER_EDIT_SUCCESS(20001, "用户修改成功"),
USER_NOT_EXIST(20002, "用户不存在"),
USER_NOT_LOGIN(20003, "用户未登录"),
USER_AUTH_EXPIRED(20004, "认证过期"),
USER_AUTHORITY_ERROR(20005,"权限不足"),
USER_CONNECT_LOGIN_ERROR(20006,"未找到登录信息"),
USER_AUTHORITY_ERROR(20005, "权限不足"),
USER_CONNECT_LOGIN_ERROR(20006, "未找到登录信息"),
USER_NAME_EXIST(20007, "该用户名已被注册"),
USER_PHONE_EXIST(20008, "该手机号已被注册"),
USER_PHONE_NOT_EXIST(20009, "手机号不存在"),
USER_PASSWORD_ERROR(20010, "密码不正确"),
USER_NOT_PHONE(20011,"非当前用户的手机号"),
USER_CONNECT_ERROR(20012,"联合第三方登录,授权信息错误"),
USER_RECEIPT_REPEAT_ERROR(20013,"会员发票信息重复"),
USER_RECEIPT_NOT_EXIST(20014,"会员发票信息不存在"),
USER_EDIT_ERROR(20015,"用户修改失败"),
USER_NOT_PHONE(20011, "非当前用户的手机号"),
USER_CONNECT_ERROR(20012, "联合第三方登录,授权信息错误"),
USER_RECEIPT_REPEAT_ERROR(20013, "会员发票信息重复"),
USER_RECEIPT_NOT_EXIST(20014, "会员发票信息不存在"),
USER_EDIT_ERROR(20015, "用户修改失败"),
USER_OLD_PASSWORD_ERROR(20016, "旧密码不正确"),
USER_COLLECTION_EXIST(2001,"无法重复收藏"),
USER_COLLECTION_EXIST(2001, "无法重复收藏"),
DELETE_EXIST(2001, "无法重复收藏"),
/**
* 权限
*/
PERMISSION_DEPARTMENT_ROLE_ERROR(21001,"角色已绑定部门,请逐个删除"),
PERMISSION_USER_ROLE_ERROR(21002,"角色已绑定管理员,请逐个删除"),
PERMISSION_MENU_ROLE_ERROR(21003,"菜单已绑定角色,请先删除或编辑角色"),
PERMISSION_DEPARTMENT_DELETE_ERROR(21004,"部门已经绑定管理员,请先删除或编辑管理员"),
PERMISSION_BEYOND_TEN(21005,"最多可以设置10个角色"),
PERMISSION_DEPARTMENT_ROLE_ERROR(21001, "角色已绑定部门,请逐个删除"),
PERMISSION_USER_ROLE_ERROR(21002, "角色已绑定管理员,请逐个删除"),
PERMISSION_MENU_ROLE_ERROR(21003, "菜单已绑定角色,请先删除或编辑角色"),
PERMISSION_DEPARTMENT_DELETE_ERROR(21004, "部门已经绑定管理员,请先删除或编辑管理员"),
PERMISSION_BEYOND_TEN(21005, "最多可以设置10个角色"),
/**
* 分销
@@ -127,156 +136,166 @@ public enum ResultCode {
ORDER_LOGISTICS_ERROR(31005, "物流错误"),
ORDER_DELIVER_ERROR(31006, "物流错误"),
ORDER_NOT_USER(31007, "非当前会员的订单"),
ORDER_TAKE_ERROR(31008,"当前订单无法核销"),
ORDER_TAKE_ERROR(31008, "当前订单无法核销"),
MEMBER_ADDRESS_NOT_EXIST(31009, "订单无收货地址,请先配置收货地址"),
/**
* 支付
*/
PAY_SUCCESS(32001,"支付成功"),
PAY_INCONSISTENT_ERROR(32002,"付款金额和应付金额不一致"),
PAY_DOUBLE_ERROR(32003,"订单已支付,不能再次进行支付"),
PAY_CASHIER_ERROR(32004,"收银台信息获取错误"),
PAY_ERROR(32005,"支付业务异常,请稍后重试"),
PAY_BAN(32006,"当前订单不需要付款,请返回订单列表重新操作"),
PAY_PARTIAL_ERROR(32007,"该订单已部分支付,请前往订单中心进行支付"),
PAY_NOT_SUPPORT(32008,"支付暂不支持"),
PAY_CLIENT_TYPE_ERROR(32009,"错误的客户端"),
PAY_POINT_ENOUGH(32010,"积分不足,不能兑换"),
PAY_NOT_EXIST_ORDER(32011,"支付订单不存在"),
PAY_SUCCESS(32001, "支付成功"),
PAY_INCONSISTENT_ERROR(32002, "付款金额和应付金额不一致"),
PAY_DOUBLE_ERROR(32003, "订单已支付,不能再次进行支付"),
PAY_CASHIER_ERROR(32004, "收银台信息获取错误"),
PAY_ERROR(32005, "支付业务异常,请稍后重试"),
PAY_BAN(32006, "当前订单不需要付款,请返回订单列表重新操作"),
PAY_PARTIAL_ERROR(32007, "该订单已部分支付,请前往订单中心进行支付"),
PAY_NOT_SUPPORT(32008, "支付暂不支持"),
PAY_CLIENT_TYPE_ERROR(32009, "错误的客户端"),
PAY_POINT_ENOUGH(32010, "积分不足,不能兑换"),
PAY_NOT_EXIST_ORDER(32011, "支付订单不存在"),
/**
* 售后
*/
AFTER_SALES_NOT_PAY_ERROR(33001,"当前订单未支付,不能申请售后"),
AFTER_SALES_CANCEL_ERROR(33002,"当前售后单无法取消"),
AFTER_SALES_BAN(33003,"订单状态不允许申请售后,请联系平台或商家"),
AFTER_SALES_DOUBLE_ERROR(33004,"售后已审核,无法重复操作"),
AFTER_SALES_LOGISTICS_ERROR(33005,"物流公司错误,请重新选择"),
AFTER_SALES_NOT_PAY_ERROR(33001, "当前订单未支付,不能申请售后"),
AFTER_SALES_CANCEL_ERROR(33002, "当前售后单无法取消"),
AFTER_SALES_BAN(33003, "订单状态不允许申请售后,请联系平台或商家"),
AFTER_SALES_DOUBLE_ERROR(33004, "售后已审核,无法重复操作"),
AFTER_SALES_LOGISTICS_ERROR(33005, "物流公司错误,请重新选择"),
AFTER_STATUS_ERROR(33006, "售后状态错误,请刷新页面"),
/**
* 投诉
*/
COMPLAINT_ORDER_ITEM_EMPTY_ERROR(33100,"订单不存在"),
COMPLAINT_SKU_EMPTY_ERROR(33101,"商品已下架,如需投诉请联系平台客服"),
COMPLAINT_ERROR(33102,"投诉异常,请稍后重试"),
COMPLAINT_ORDER_ITEM_EMPTY_ERROR(33100, "订单不存在"),
COMPLAINT_SKU_EMPTY_ERROR(33101, "商品已下架,如需投诉请联系平台客服"),
COMPLAINT_ERROR(33102, "投诉异常,请稍后重试"),
/**
* 余额
*/
WALLET_INSUFFICIENT(34001,"余额不足以支付订单,请充值!"),
WALLET_WITHDRAWAL_INSUFFICIENT(34002,"可提现金额不足!"),
WALLET_ERROR_INSUFFICIENT(34003,"零钱提现失败"),
WALLET_REMARK_ERROR(34004,"请填写审核备注"),
WALLET_NOT_EXIT_ERROR(34000, "钱包不存在,请联系管理员"),
WALLET_INSUFFICIENT(34001, "余额不足以支付订单,请充值!"),
WALLET_WITHDRAWAL_INSUFFICIENT(34002, "可提现金额不足"),
WALLET_ERROR_INSUFFICIENT(34003, "零钱提现失败"),
WALLET_REMARK_ERROR(34004, "请填写审核备注!"),
WALLET_APPLY_ERROR(34005, "提现申请异常!"),
/**
* 评价
*/
EVALUATION_DOUBLE_ERROR(35001,"无法重复提交评价"),
EVALUATION_DOUBLE_ERROR(35001, "无法重复提交评价"),
/**
* 签到
*/
MEMBER_SIGN_REPEAT(40001,"请勿重复签到"),
MEMBER_SIGN_REPEAT(40001, "请勿重复签到"),
/**
* 优惠券
*/
COUPON_EDIT_STATUS_SUCCESS(41001,"修改状态成功!"),
COUPON_CANCELLATION_SUCCESS(41002,"会员优惠券作废成功"),
COUPON_EXPIRED(41003,"优惠券已使用/已过期,不能使用"),
COUPON_EDIT_STATUS_ERROR(41004,"优惠券修改状态失败!"),
COUPON_EDIT_STATUS_SUCCESS(41001, "修改状态成功!"),
COUPON_CANCELLATION_SUCCESS(41002, "会员优惠券作废成功"),
COUPON_EXPIRED(41003, "优惠券已使用/已过期,不能使用"),
COUPON_EDIT_STATUS_ERROR(41004, "优惠券修改状态失败!"),
/**
* 拼团
*/
PINTUAN_MANUAL_OPEN_SUCCESS(42001,"手动开启拼团活动成功"),
PINTUAN_MANUAL_CLOSE_SUCCESS(42002,"手动关闭拼团活动成功"),
PINTUAN_ADD_SUCCESS(42003,"添加拼团活动成功"),
PINTUAN_EDIT_SUCCESS(42004,"修改拼团活动成功"),
PINTUAN_DELETE_SUCCESS(42005,"删除拼团活动成功"),
PINTUAN_MANUAL_OPEN_ERROR(42006,"手动开启拼团活动失败"),
PINTUAN_MANUAL_CLOSE_ERROR(42007,"手动关闭拼团活动失败"),
PINTUAN_ADD_ERROR(42008,"添加拼团活动失败"),
PINTUAN_EDIT_ERROR(42009,"修改拼团活动失败"),
PINTUAN_DELETE_ERROR(42010,"删除拼团活动失败"),
PINTUAN_MANUAL_OPEN_SUCCESS(42001, "手动开启拼团活动成功"),
PINTUAN_MANUAL_CLOSE_SUCCESS(42002, "手动关闭拼团活动成功"),
PINTUAN_ADD_SUCCESS(42003, "添加拼团活动成功"),
PINTUAN_EDIT_SUCCESS(42004, "修改拼团活动成功"),
PINTUAN_DELETE_SUCCESS(42005, "删除拼团活动成功"),
PINTUAN_MANUAL_OPEN_ERROR(42006, "手动开启拼团活动失败"),
PINTUAN_MANUAL_CLOSE_ERROR(42007, "手动关闭拼团活动失败"),
PINTUAN_ADD_ERROR(42008, "添加拼团活动失败"),
PINTUAN_EDIT_ERROR(42009, "修改拼团活动失败"),
PINTUAN_DELETE_ERROR(42010, "删除拼团活动失败"),
/**
* 满额活动
*/
FULL_DISCOUNT_EDIT_SUCCESS(43001,"修改满优惠活动成功"),
FULL_DISCOUNT_EDIT_DELETE(43002,"删除满优惠活动成功"),
FULL_DISCOUNT_EDIT_SUCCESS(43001, "修改满优惠活动成功"),
FULL_DISCOUNT_EDIT_DELETE(43002, "删除满优惠活动成功"),
/**
* 店铺
*/
STORE_NOT_EXIST(50001,"此店铺不存在"),
STORE_NAME_EXIST_ERROR(50002,"店铺名称已存在!"),
STORE_APPLY_DOUBLE_ERROR(50003,"已有店铺,无需重复申请!"),
STORE_NOT_EXIST(50001, "此店铺不存在"),
STORE_NAME_EXIST_ERROR(50002, "店铺名称已存在!"),
STORE_APPLY_DOUBLE_ERROR(50003, "已有店铺,无需重复申请!"),
/**
* 结算单
*/
BILL_CHECK_ERROR(51001,"只有已出账结算单可以核对"),
BILL_COMPLETE_ERROR(51002,"只有已审核结算单可以支付"),
BILL_CHECK_ERROR(51001, "只有已出账结算单可以核对"),
BILL_COMPLETE_ERROR(51002, "只有已审核结算单可以支付"),
/**
* 文章
*/
ARTICLE_CATEGORY_NAME_EXIST(60001,"文章分类名称已存在"),
ARTICLE_CATEGORY_PARENT_NOT_EXIST(60002,"文章分类父分类不存在"),
ARTICLE_CATEGORY_BEYOND_TWO(60003,"最多为二级分类,操作失败"),
ARTICLE_CATEGORY_DELETE_ERROR(60004,"该文章分类下存在子分类,不能删除"),
ARTICLE_CATEGORY_HAS_ARTICLE(60005,"该文章分类下存在文章,不能删除"),
ARTICLE_CATEGORY_NO_DELETION(60007,"默认文章分类不能进行删除"),
ARTICLE_NO_DELETION(60008,"默认文章不能进行删除"),
ARTICLE_CATEGORY_NAME_EXIST(60001, "文章分类名称已存在"),
ARTICLE_CATEGORY_PARENT_NOT_EXIST(60002, "文章分类父分类不存在"),
ARTICLE_CATEGORY_BEYOND_TWO(60003, "最多为二级分类,操作失败"),
ARTICLE_CATEGORY_DELETE_ERROR(60004, "该文章分类下存在子分类,不能删除"),
ARTICLE_CATEGORY_HAS_ARTICLE(60005, "该文章分类下存在文章,不能删除"),
ARTICLE_CATEGORY_NO_DELETION(60007, "默认文章分类不能进行删除"),
ARTICLE_NO_DELETION(60008, "默认文章不能进行删除"),
/**
* 页面
*/
PAGE_NOT_EXIST(61001,"页面不存在"),
PAGE_OPEN_DELETE_ERROR(61002,"当前页面为开启状态,无法删除"),
PAGE_DELETE_ERROR(61003,"当前页面为唯一页面,无法删除"),
PAGE_RELEASE_ERROR(61004,"页面已发布,无需重复提交"),
PAGE_NOT_EXIST(61001, "页面不存在"),
PAGE_OPEN_DELETE_ERROR(61002, "当前页面为开启状态,无法删除"),
PAGE_DELETE_ERROR(61003, "当前页面为唯一页面,无法删除"),
PAGE_RELEASE_ERROR(61004, "页面已发布,无需重复提交"),
/**
* 设置
*/
SETTING_NOT_TO_SET(70001,"该参数不需要设置"),
SETTING_NOT_TO_SET(70001, "该参数不需要设置"),
/**
* 短信
*/
SMS_SIGN_EXIST_ERROR(80001,"短信签名已存在"),
SMS_SIGN_EXIST_ERROR(80001, "短信签名已存在"),
/**
* 站内信
*/
NOTICE_NOT_EXIST(80101,"当前消息模板不存在"),
NOTICE_NOT_EXIST(80101, "当前消息模板不存在"),
NOTICE_ERROR(80102, "修改站内信异常,请稍后重试"),
/**
* OSS
*/
OSS_NOT_EXIST(80201,"OSS未配置"),
OSS_EXCEPTION(80202,"文件上传失败,请稍后重试"),
OSS_NOT_EXIST(80201, "OSS未配置"),
OSS_EXCEPTION(80202, "文件上传失败,请稍后重试"),
/**
* 验证码
*/
VERIFICATION_SEND_SUCCESS(80301,"短信验证码,发送成功"),
VERIFICATION_ERROR(80302,"验证失败"),
VERIFICATION_SMS_ERROR(80303,"短信验证码错误,请重新校验"),
VERIFICATION_SMS_EXPIRED_ERROR(80304,"验证码已失效,请重新校验"),
VERIFICATION_SEND_SUCCESS(80301, "短信验证码,发送成功"),
VERIFICATION_ERROR(80302, "验证失败"),
VERIFICATION_SMS_ERROR(80303, "短信验证码错误,请重新校验"),
VERIFICATION_SMS_EXPIRED_ERROR(80304, "验证码已失效,请重新校验"),
/**
* 配置错误
*/
ALIPAY_NOT_SETTING(80401,"支付宝支付未配置"),
ALIPAY_EXCEPTION(80402,"支付宝支付错误,请稍后重试"),
ALIPAY_PARAMS_EXCEPTION(80403,"支付宝参数异常"),
WECHAT_PAY_NOT_SETTING(80402,"微信支付未配置"),
ALIPAY_NOT_SETTING(80401, "支付宝支付未配置"),
ALIPAY_EXCEPTION(80402, "支付宝支付错误,请稍后重试"),
ALIPAY_PARAMS_EXCEPTION(80403, "支付宝参数异常"),
/**
* 微信相关异常
*/
WECHAT_CONNECT_NOT_SETTING(80500, "微信联合登陆信息未配置"),
WECHAT_PAYMENT_NOT_SETTING(80501, "微信支付信息未配置"),
WECHAT_QRCODE_ERROR(80502, "微信二维码生成异常"),
WECHAT_MP_MESSAGE_ERROR(80503, "微信小程序小消息订阅异常"),
;

View File

@@ -1,7 +1,6 @@
package cn.lili.common.utils;
package cn.lili.common.enums;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.vo.ResultMessage;
/**
@@ -62,9 +61,57 @@ public class ResultUtil<T> {
/**
* 返回成功
*
* @param resultCode 返回状态码
*/
public static <T> ResultMessage<T> success(ResultCode resultCode) {
return new ResultUtil<T>().setSuccessMsg(resultCode);
}
/**
* 返回成功
*/
public static <T> ResultMessage<T> success() {
return new ResultUtil<T>().setSuccessMsg(ResultCode.SUCCESS);
}
/**
* 返回失败
* @param resultCode 返回状态码
*/
public static <T> ResultMessage<T> error(ResultCode resultCode) {
return new ResultUtil<T>().setErrorMsg(resultCode);
}
/**
* 返回失败
* @param code 状态码
* @param msg 返回消息
*/
public static <T> ResultMessage<T> error(Integer code, String msg) {
return new ResultUtil<T>().setErrorMsg(code, msg);
}
/**
* 服务器异常 追加状态码
*
* @param resultCode 返回码
*/
public ResultMessage<T> setErrorMsg(ResultCode resultCode) {
this.resultMessage.setSuccess(false);
this.resultMessage.setMessage(resultCode.message());
this.resultMessage.setCode(resultCode.code());
return this.resultMessage;
}
/**
* 服务器异常 追加状态码
* @param code 状态码
* @param msg 返回消息
*/
public ResultMessage<T> setErrorMsg(Integer code, String msg) {
this.resultMessage.setSuccess(false);
this.resultMessage.setMessage(msg);
this.resultMessage.setCode(code);
return this.resultMessage;
}
}

View File

@@ -1,6 +1,7 @@
package cn.lili.common.exception;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
@@ -45,7 +46,7 @@ public class GlobalControllerExceptionHandler {
if (e instanceof ServiceException) {
ResultCode resultCode = ((ServiceException) e).getResultCode();
if (resultCode != null) {
throw new ServiceException(resultCode);
return ResultUtil.error(resultCode.code(), resultCode.message());
}
}
@@ -54,7 +55,7 @@ public class GlobalControllerExceptionHandler {
if (e != null && e.getMessage() != null && e.getMessage().length() < MAX_LENGTH) {
errorMsg = e.getMessage();
}
throw new ServiceException(ResultCode.ERROR, errorMsg);
return ResultUtil.error(ResultCode.ERROR.code(), errorMsg);
}
@ExceptionHandler(RuntimeException.class)
@@ -63,7 +64,7 @@ public class GlobalControllerExceptionHandler {
log.error("全局异常[RuntimeException]:", e);
throw new ServiceException(ResultCode.ERROR, "服务器异常,请稍后重试");
return ResultUtil.error(ResultCode.ERROR);
}
// /**
@@ -100,9 +101,9 @@ public class GlobalControllerExceptionHandler {
BindException exception = (BindException) e;
List<FieldError> fieldErrors = exception.getBindingResult().getFieldErrors();
for (FieldError error : fieldErrors) {
throw new ServiceException(ResultCode.ERROR, error.getDefaultMessage());
return ResultUtil.error(ResultCode.PARAMS_ERROR.code(), error.getDefaultMessage());
}
throw new ServiceException(ResultCode.ERROR);
return ResultUtil.error(ResultCode.PARAMS_ERROR);
}
}

View File

@@ -1,244 +0,0 @@
package cn.lili.generator;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.ResultMessage;
import cn.lili.generator.bean.Field;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.beetl.core.Configuration;
import org.beetl.core.GroupTemplate;
import org.beetl.core.Template;
import org.beetl.core.resource.ClasspathResourceLoader;
import org.elasticsearch.common.util.ArrayUtils;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* @author lili
*/
@Slf4j
@RestController
@Api(tags = "Vue代码生成")
@RequestMapping(value = "/manager/generate")
public class VueCodeGenerator {
@RequestMapping(value = "/table/{vueName}/{rowNum}", method = RequestMethod.POST)
@ApiOperation(value = "增删改表格生成")
public ResultMessage<Object> generateTable(@PathVariable String vueName,
@PathVariable Integer rowNum,
@RequestBody List<Field> fields) throws IOException {
String result = generate("table.btl", vueName, rowNum, fields);
return ResultUtil.data(result);
}
@RequestMapping(value = "/tree/{vueName}/{rowNum}", method = RequestMethod.POST)
@ApiOperation(value = "树形结构生成")
public ResultMessage<Object> generateTree(@PathVariable String vueName,
@PathVariable Integer rowNum,
@RequestBody List<Field> fields) throws IOException {
String result = generate("tree.btl", vueName, rowNum, fields);
return ResultUtil.data(result);
}
@RequestMapping(value = "/getEntityData/{path}", method = RequestMethod.GET)
@ApiOperation(value = "通过实体类生成Vue代码Json数据")
public ResultMessage<Object> getEntityData(@PathVariable String path) {
String result = "";
try {
result = generateClassData(path);
} catch (Exception e) {
throw new ServiceException(ResultCode.ERROR);
}
return ResultUtil.data(result);
}
/**
* 生成代码
*
* @param template 模版名称
* @param vueName 表单名称
* @param rowNum 树形表格所需参数,一行几列
* @param fields
* @return
* @throws IOException
*/
public String generate(String template, String vueName, Integer rowNum, List<Field> fields) throws IOException {
// 模板路径
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader("/templates/vue/");
Configuration cfg = Configuration.defaultConfiguration();
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
Template tableTemplate = gt.getTemplate(template);
// 排序
Collections.sort(fields, Comparator.comparing(Field::getSortOrder));
// 绑定变量
tableTemplate.binding("vueName", vueName);
tableTemplate.binding("fields", fields);
// 判断有无upload和日期范围搜索
Boolean upload = false;
for (Field f : fields) {
if ("upload".equals(f.getType())) {
upload = true;
}
}
tableTemplate.binding("upload", upload);
if ("table.btl".equals(template)) {
// 判断有无upload和日期范围搜索
Boolean daterangeSearch = false;
for (Field f : fields) {
if (f.getSearchable() && "daterange".equals(f.getSearchType())) {
daterangeSearch = true;
}
}
tableTemplate.binding("daterangeSearch", daterangeSearch);
// 统计搜索栏个数 判断是否隐藏搜索栏
Boolean hideSearch = false;
List<Field> firstTwo = new ArrayList<>();
List<Field> rest = new ArrayList<>();
Integer count = 0;
for (Field f : fields) {
if (f.getSearchable()) {
count++;
if (count <= 2) {
firstTwo.add(f);
} else {
rest.add(f);
}
}
}
if (count >= 4) {
hideSearch = true;
tableTemplate.binding("firstTwo", firstTwo);
tableTemplate.binding("rest", rest);
}
tableTemplate.binding("searchSize", count);
tableTemplate.binding("hideSearch", hideSearch);
// 获取默认排序字段
String defaultSort = "", defaultSortType = "";
for (Field f : fields) {
if (f.getDefaultSort()) {
defaultSort = f.getField();
defaultSortType = f.getDefaultSortType();
break;
}
}
tableTemplate.binding("defaultSort", defaultSort);
tableTemplate.binding("defaultSortType", defaultSortType);
}
// 一行几列
tableTemplate.binding("rowNum", rowNum);
if (rowNum == 1) {
tableTemplate.binding("modalWidth", 500);
tableTemplate.binding("width", "100%");
tableTemplate.binding("editWidth", "100%");
tableTemplate.binding("itemWidth", "");
tableTemplate.binding("span", "9");
} else if (rowNum == 2) {
tableTemplate.binding("modalWidth", 770);
tableTemplate.binding("width", "250px");
tableTemplate.binding("editWidth", "250px");
tableTemplate.binding("itemWidth", "350px");
tableTemplate.binding("span", "17");
} else if (rowNum == 3) {
tableTemplate.binding("modalWidth", 980);
tableTemplate.binding("width", "200px");
tableTemplate.binding("editWidth", "200px");
tableTemplate.binding("itemWidth", "300px");
tableTemplate.binding("span", "17");
} else if (rowNum == 4) {
tableTemplate.binding("modalWidth", 1130);
tableTemplate.binding("width", "160px");
tableTemplate.binding("editWidth", "160px");
tableTemplate.binding("itemWidth", "260px");
tableTemplate.binding("span", "17");
} else {
throw new ServiceException("rowNum仅支持数字1-4");
}
// 生成代码
String result = tableTemplate.render();
return result;
}
/**
* 生成代码数据
*
* @param path
* @return
* @throws Exception
*/
public String generateClassData(String path) throws Exception {
Class c = Class.forName(path);
Object obj = c.newInstance();
java.lang.reflect.Field[] fields = ArrayUtils.concat(obj.getClass().getDeclaredFields(), obj.getClass().getSuperclass().getDeclaredFields(), java.lang.reflect.Field.class);
//下标
int index = 0;
StringBuffer fieldsData = new StringBuffer();
for (java.lang.reflect.Field field : fields) {
index++;
field.setAccessible(true);
// 字段名
String fieldName = field.getName();
String fieldType = field.getType().getName();
// 序列化id不参与表单
if ("serialVersionUID".equals(fieldName)) {
continue;
}
// 获得字段注解
ApiModelProperty myFieldAnnotation = field.getAnnotation(ApiModelProperty.class);
//表单名称
String formName = fieldName;
if (myFieldAnnotation != null) {
formName = myFieldAnnotation.value();
}
formName = StringUtils.isEmpty(formName) ? fieldName : formName;
//默认类型
String type = "text";
String searchType = "text";
// 日期字段特殊处理,其他一律按 字符串界面处理
if (fieldType == "java.lang.Date" || fieldType == "java.util.Date" || fieldType == "Date") {
type = "date";
searchType = "daterange";
}
//表单子属性
String formItem = "{" +
"\"sortOrder\":" + index + "," +
"\"field\":\"" + fieldName + "\"," +
"\"name\":\"" + formName + "\"," +
"\"level\":\"2\"," +
"\"tableShow\":true," +
"\"editable\":true," +
"\"type\":\"" + type + "\"," +
"\"searchType\":\"" + searchType + "\"," +
"\"searchLevel\":\"2\"," +
"\"validate\":false," +
"\"searchable\":true," +
"\"sortable\":false," +
"\"defaultSort\":false," +
"\"defaultSortType\":\"desc\"},";
fieldsData.append(formItem);
}
String start = "{\"data\":[";
String end = "]}";
String json = start + fieldsData.substring(0, fieldsData.length()-1) + end;
return json;
}
}

View File

@@ -1,40 +0,0 @@
package cn.lili.generator.bean;
import lombok.Data;
import java.math.BigDecimal;
/**
* @author lili
*/
@Data
public class Field {
private String field;
private String name;
private String level;
private Boolean tableShow;
private BigDecimal sortOrder;
private Boolean searchable;
private Boolean editable;
private String type;
private Boolean validate;
private String searchType;
private String searchLevel;
private Boolean sortable;
private Boolean defaultSort;
private String defaultSortType;
}

View File

@@ -6,7 +6,7 @@ import cn.lili.common.cache.CachePrefix;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.token.Token;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.config.properties.ApiProperties;
import cn.lili.config.properties.DomainProperties;

View File

@@ -143,11 +143,8 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
//分销员金额相关处理
distributionService.updateById(distribution);
//修改分销提现申请
Boolean bool = this.updateById(distributorCash);
if (bool) {
return distributorCash;
}
throw new ServiceException(ResultCode.ERROR);
this.updateById(distributorCash);
return distributorCash;
}
throw new ServiceException(ResultCode.DISTRIBUTION_NOT_EXIST);
}

View File

@@ -145,7 +145,7 @@ public class Goods extends BaseEntity {
/**
* 谁承担运费 BUYER买家承担STORE卖家承担
*/
@ApiModelProperty(value = "运费承担者 BUYER买家承担STORE卖家承担")
@ApiModelProperty(value = " 谁承担运费 BUYER买家承担STORE卖家承担")
private String freightPayer;
/**
* 审核状态

View File

@@ -131,7 +131,7 @@ public class GoodsSku extends BaseEntity {
@ApiModelProperty(value = "运费模板id")
private String templateId;
@ApiModelProperty(value = "运费承担者")
@ApiModelProperty(value = " 谁承担运费 BUYER买家承担STORE卖家承担")
private String freightPayer;
/**
* @see GoodsAuthEnum

View File

@@ -66,10 +66,7 @@ public class GoodsOperationDTO implements Serializable {
@Max(value = 99999999, message = "重量不能超过99999999")
private Double weight;
@ApiModelProperty(value = "谁承担运费0:买家承担,1:卖家承担", required = true)
@NotNull(message = "承担运费不能为空")
@Min(value = 0, message = "承担运费值不正确")
@Max(value = 1, message = "承担运费值不正确")
@ApiModelProperty(value = "谁承担运费 BUYER:买家承担,STORE:卖家承担", required = true)
private String freightPayer;
@ApiModelProperty(value = "详情")

View File

@@ -11,7 +11,6 @@ import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* 会员地址
@@ -51,7 +50,6 @@ public class MemberAddress extends BaseEntity {
@ApiModelProperty(value = "详细地址")
private String detail;
@NotNull(message = "是否默认不能为空")
@ApiModelProperty(value = "是否为默认收货地址")
private Boolean isDefault;

View File

@@ -315,12 +315,10 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
//添加会员
Member member = new Member(memberAddDTO.getUsername(), memberAddDTO.getPassword(), memberAddDTO.getMobile());
if (this.save(member)) {
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_REGISTER.name();
rocketMQTemplate.asyncSend(destination, member, RocketmqSendCallbackBuilder.commonCallback());
return member;
}
throw new ServiceException(ResultCode.ERROR);
this.save(member);
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_REGISTER.name();
rocketMQTemplate.asyncSend(destination, member, RocketmqSendCallbackBuilder.commonCallback());
return member;
}
@Override
@@ -342,10 +340,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
Member member = this.findByUsername(managerMemberEditDTO.getUsername());
//传递修改会员信息
BeanUtil.copyProperties(managerMemberEditDTO, member);
if (this.updateById(member)) {
return member;
}
throw new ServiceException(ResultCode.ERROR);
this.updateById(member);
return member;
}
@Override

View File

@@ -34,8 +34,6 @@ import java.util.Date;
@Transactional
public class MemberWithdrawApplyServiceImpl extends ServiceImpl<MemberWithdrawApplyMapper, MemberWithdrawApply> implements MemberWithdrawApplyService {
//提现申请数据层
@Autowired
private MemberWithdrawApplyMapper memberWithdrawApplyMapper;
//会员余额
@Autowired
private MemberWalletService memberWalletService;
@@ -43,9 +41,10 @@ public class MemberWithdrawApplyServiceImpl extends ServiceImpl<MemberWithdrawAp
@Override
public Boolean audit(String applyId, Boolean result, String remark) {
//查询申请记录
MemberWithdrawApply memberWithdrawApply = memberWithdrawApplyMapper.selectById(applyId);
memberWithdrawApply.setInspectRemark(remark);
MemberWithdrawApply memberWithdrawApply = baseMapper.selectById(applyId);
if (memberWithdrawApply != null) {
//写入备注
memberWithdrawApply.setInspectRemark(remark);
//如果审核通过 则微信直接提现,反之则记录审核状态
if (result) {
//校验金额是否满足提现,因为是从冻结金额扣减,所以校验的是冻结金额
@@ -55,7 +54,7 @@ public class MemberWithdrawApplyServiceImpl extends ServiceImpl<MemberWithdrawAp
}
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.VIA_AUDITING.name());
//保存审核记录
memberWithdrawApplyMapper.updateById(memberWithdrawApply);
baseMapper.updateById(memberWithdrawApply);
//提现,微信提现成功后扣减冻结金额
Boolean bool = memberWalletService.withdrawal(memberWithdrawApply);
if (bool) {
@@ -68,13 +67,13 @@ public class MemberWithdrawApplyServiceImpl extends ServiceImpl<MemberWithdrawAp
throw new ServiceException(ResultCode.WALLET_REMARK_ERROR);
}
memberWithdrawApply.setApplyStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
memberWithdrawApplyMapper.updateById(memberWithdrawApply);
baseMapper.updateById(memberWithdrawApply);
//需要从冻结金额扣减到余额
memberWalletService.increaseWithdrawal(memberWithdrawApply.getApplyMoney(), memberWithdrawApply.getMemberId(), "审核拒绝,提现金额解冻到余额", DepositServiceTypeEnum.WALLET_WITHDRAWAL.name());
return true;
}
}
throw new ServiceException(ResultCode.ERROR);
throw new ServiceException(ResultCode.WALLET_APPLY_ERROR);
}
@@ -98,6 +97,6 @@ public class MemberWithdrawApplyServiceImpl extends ServiceImpl<MemberWithdrawAp
}
queryWrapper.orderByDesc("create_time");
//查询返回数据
return this.memberWithdrawApplyMapper.selectPage(PageUtil.initPage(pageVO), queryWrapper);
return this.baseMapper.selectPage(PageUtil.initPage(pageVO), queryWrapper);
}
}

View File

@@ -83,7 +83,7 @@ public class WechatMpCodeUtil {
return Base64.getEncoder().encodeToString(bytes);
} catch (Exception e) {
log.error("生成二维码错误:", e);
throw new ServiceException(ResultCode.ERROR);
throw new ServiceException(ResultCode.WECHAT_QRCODE_ERROR);
}
}
@@ -140,7 +140,7 @@ public class WechatMpCodeUtil {
return Base64.getEncoder().encodeToString(bytes);
} catch (Exception e) {
log.error("生成二维码错误:", e);
throw new ServiceException(ResultCode.ERROR);
throw new ServiceException(ResultCode.WECHAT_QRCODE_ERROR);
}
}

View File

@@ -52,6 +52,9 @@ public class CartSkuVO extends CartBase implements Serializable {
private Boolean checked;
@ApiModelProperty(value = " 谁承担运费 BUYER买家承担STORE卖家承担")
private String freightPayer;
@ApiModelProperty(value = "是否免运费")
private Boolean isFreeFreight;
@@ -97,6 +100,7 @@ public class CartSkuVO extends CartBase implements Serializable {
this.isShip = true;
this.purchasePrice = goodsSku.getIsPromotion() != null && goodsSku.getIsPromotion() ? goodsSku.getPromotionPrice() : goodsSku.getPrice();
this.isFreeFreight = false;
this.freightPayer = goodsSku.getFreightPayer();
this.setStoreId(goodsSku.getStoreId());
this.setStoreName(goodsSku.getStoreName());
}

View File

@@ -82,6 +82,7 @@ public class TradeBuilder {
public TradeDTO buildTrade(CartTypeEnum checkedWay) {
TradeDTO tradeDTO = cartService.readDTO(checkedWay);
List<CartSkuVO> collect = tradeDTO.getSkuList().parallelStream().filter(i -> Boolean.TRUE.equals(i.getChecked())).collect(Collectors.toList());
//拼团类型订单预处理
if (checkedWay.equals(CartTypeEnum.PINTUAN)) {
for (CartSkuVO cartSkuVO : collect) {
cartSkuVO.setPintuanId("");

View File

@@ -2,6 +2,7 @@ package cn.lili.modules.order.cart.render.impl;
import cn.hutool.core.util.NumberUtil;
import cn.lili.common.utils.CurrencyUtil;
import cn.lili.modules.member.entity.dos.MemberAddress;
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
import cn.lili.modules.order.cart.entity.vo.CartSkuVO;
import cn.lili.modules.order.cart.render.CartRenderStep;
@@ -10,7 +11,6 @@ import cn.lili.modules.store.entity.dto.FreightTemplateChildDTO;
import cn.lili.modules.store.entity.enums.FreightTemplateEnum;
import cn.lili.modules.store.entity.vos.FreightTemplateVO;
import cn.lili.modules.store.service.FreightTemplateService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
@@ -33,17 +33,43 @@ public class SkuFreightRender implements CartRenderStep {
@Override
public void render(TradeDTO tradeDTO) {
List<CartSkuVO> cartSkuVOS = tradeDTO.getSkuList();
//会员收货地址问题处理
MemberAddress memberAddress = tradeDTO.getMemberAddress();
if(memberAddress==null){
return;
}
//循环渲染购物车商品运费价格
for (CartSkuVO cartSkuVO : cartSkuVOS) {
String freightTemplateId = cartSkuVO.getGoodsSku().getFreightTemplateId();
//如果商品设置卖家承担运费,则跳出计算
if (cartSkuVO.getFreightPayer().equals("STORE")) {
continue;
}
//免运费则跳出运费计算
if (Boolean.TRUE.equals(cartSkuVO.getIsFreeFreight()) || freightTemplateId == null) {
continue;
}
//寻找对应对商品运费计算模版
FreightTemplateVO freightTemplate = freightTemplateService.getFreightTemplate(freightTemplateId);
if (freightTemplate != null && freightTemplate.getFreightTemplateChildList() != null && !freightTemplate.getFreightTemplateChildList().isEmpty()) {
FreightTemplateChild freightTemplateChild = freightTemplate.getFreightTemplateChildList().get(0);
FreightTemplateChild freightTemplateChild = null;
//获取市级别id
String addressId = memberAddress.getConsigneeAddressIdPath().split(",")[1];
//获取匹配的收货地址
for (FreightTemplateChild templateChild : freightTemplate.getFreightTemplateChildList()) {
//如果当前模版包含,则返回
if (templateChild.getAreaId().indexOf(addressId) > 0) {
freightTemplateChild = templateChild;
break;
}
}
FreightTemplateChildDTO freightTemplateChildDTO = new FreightTemplateChildDTO(freightTemplateChild);
freightTemplateChildDTO.setPricingMethod(freightTemplate.getPricingMethod());
//要计算的基数 数量/重量

View File

@@ -2,6 +2,7 @@ package cn.lili.modules.order.cart.service;
import cn.hutool.core.text.CharSequenceUtil;
import cn.lili.common.cache.Cache;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.AuthUser;
import cn.lili.common.security.context.UserContext;
@@ -100,7 +101,7 @@ public class CartServiceImpl implements CartService {
int newNum = oldNum + num;
this.checkSetGoodsQuantity(cartSkuVO, skuId, newNum);
//计算购物车小计
cartSkuVO.setSubTotal(CurrencyUtil.mul(cartSkuVO.getPurchasePrice(),cartSkuVO.getNum()));
cartSkuVO.setSubTotal(CurrencyUtil.mul(cartSkuVO.getPurchasePrice(), cartSkuVO.getNum()));
} else {
//先清理一下 如果商品无效的话
cartSkuVOS.remove(cartSkuVO);
@@ -112,7 +113,7 @@ public class CartServiceImpl implements CartService {
//再设置加入购物车的数量
this.checkSetGoodsQuantity(cartSkuVO, skuId, num);
//计算购物车小计
cartSkuVO.setSubTotal(CurrencyUtil.mul(cartSkuVO.getPurchasePrice(),cartSkuVO.getNum()));
cartSkuVO.setSubTotal(CurrencyUtil.mul(cartSkuVO.getPurchasePrice(), cartSkuVO.getNum()));
cartSkuVOS.add(cartSkuVO);
}
@@ -132,13 +133,13 @@ public class CartServiceImpl implements CartService {
//再设置加入购物车的数量
this.checkSetGoodsQuantity(cartSkuVO, skuId, num);
//计算购物车小计
cartSkuVO.setSubTotal(CurrencyUtil.mul(cartSkuVO.getPurchasePrice(),cartSkuVO.getNum()));
cartSkuVO.setSubTotal(CurrencyUtil.mul(cartSkuVO.getPurchasePrice(), cartSkuVO.getNum()));
cartSkuVOS.add(cartSkuVO);
}
tradeDTO.setCartTypeEnum(cartTypeEnum);
this.resetTradeDTO(tradeDTO);
} catch (Exception e) {
log.error("购物车渲染异常",e);
log.error("购物车渲染异常", e);
throw new ServiceException(errorMessage);
}
}
@@ -160,10 +161,10 @@ public class CartServiceImpl implements CartService {
}
String originKey = this.getOriginKey(CartTypeEnum.CART);
cache.put(originKey, tradeDTO);
}catch (ServiceException se){
} catch (ServiceException se) {
log.error("购物车渲染异常", se);
} catch (Exception e) {
log.error("购物车渲染异常",e);
log.error("购物车渲染异常", e);
throw new ServiceException(errorMessage);
}
}
@@ -478,10 +479,13 @@ public class CartServiceImpl implements CartService {
@Override
public Trade createTrade(TradeParams tradeParams) {
//获取购物车
CartTypeEnum cartTypeEnum = getCartType(tradeParams.getWay());
TradeDTO tradeDTO = this.readDTO(cartTypeEnum);
//设置基础属性
tradeDTO.setClientType(tradeParams.getClient());
tradeDTO.setStoreRemark(tradeParams.getRemark());
//过滤勾选商品
List<CartSkuVO> collect = tradeDTO.getSkuList().parallelStream().filter(i -> Boolean.TRUE.equals(i.getChecked())).collect(Collectors.toList());
MemberAddress memberAddress = tradeDTO.getMemberAddress();
this.checkAddressScope(collect, memberAddress);
@@ -499,17 +503,21 @@ public class CartServiceImpl implements CartService {
*/
@Override
public void checkAddressScope(List<CartSkuVO> skuList, MemberAddress memberAddress) {
//如果收货地址为空,则抛出异常
if (memberAddress == null) {
return;
throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST);
}
for (CartSkuVO cartSkuVO : skuList) {
if (Boolean.TRUE.equals(cartSkuVO.getIsFreeFreight())) {
//店铺支付运费则跳过
if (cartSkuVO.getFreightPayer().equals("STORE")) {
break;
}
String freightTemplateId = cartSkuVO.getGoodsSku().getFreightTemplateId();
FreightTemplateVO freightTemplate = freightTemplateService.getFreightTemplate(freightTemplateId);
String[] addressId = memberAddress.getConsigneeAddressIdPath().split(",");
//收货地址判定
if (freightTemplate != null && freightTemplate.getFreightTemplateChildList() != null && !freightTemplate.getFreightTemplateChildList().isEmpty()) {
FreightTemplateChild freightTemplateChild = freightTemplate.getFreightTemplateChildList().get(0);
// 检查当前配送地址的城市id是否存在与配送模版的城市id里面
if (!freightTemplateChild.getAreaId().contains(addressId[1])) {

View File

@@ -209,6 +209,7 @@ public class Order extends BaseEntity {
BeanUtil.copyProperties(cartVO, this);
this.setId(oldId);
this.setOrderType(OrderTypeEnum.NORMAL.name());
//促销信息填充
if (cartVO.getSkuList().get(0).getPromotions() != null) {
Optional<String> pintuanId = cartVO.getSkuList().get(0).getPromotions().stream().filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst();
if (pintuanId.isPresent()) {
@@ -222,14 +223,19 @@ public class Order extends BaseEntity {
this.setOrderStatus(OrderStatusEnum.UNPAID.name());
this.setPayStatus(PayStatusEnum.UNPAID.name());
this.setDeliverStatus(DeliverStatusEnum.UNDELIVERED.name());
this.setConsigneeAddressIdPath(tradeDTO.getMemberAddress().getConsigneeAddressIdPath());
this.setConsigneeAddressPath(tradeDTO.getMemberAddress().getConsigneeAddressPath());
this.setConsigneeDetail(tradeDTO.getMemberAddress().getDetail());
this.setConsigneeMobile(tradeDTO.getMemberAddress().getMobile());
this.setConsigneeName(tradeDTO.getMemberAddress().getName());
//如果有收货地址,才记录收货地址
if (tradeDTO.getMemberAddress() != null) {
this.setConsigneeAddressIdPath(tradeDTO.getMemberAddress().getConsigneeAddressIdPath());
this.setConsigneeAddressPath(tradeDTO.getMemberAddress().getConsigneeAddressPath());
this.setConsigneeDetail(tradeDTO.getMemberAddress().getDetail());
this.setConsigneeMobile(tradeDTO.getMemberAddress().getMobile());
this.setConsigneeName(tradeDTO.getMemberAddress().getName());
}
//平台优惠券判定
if (tradeDTO.getPlatformCoupon() != null) {
this.setUsePlatformMemberCouponId(tradeDTO.getPlatformCoupon().getMemberCoupon().getId());
}
//店铺优惠券判定
if (tradeDTO.getStoreCoupons() != null && !tradeDTO.getStoreCoupons().isEmpty()) {
StringBuilder storeCouponIds = new StringBuilder();
for (String s : tradeDTO.getStoreCoupons().keySet()) {

View File

@@ -201,7 +201,7 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
//判断为已审核通过,待邮寄的售后服务
if (!afterSale.getServiceStatus().equals(AfterSaleStatusEnum.PASS.name())) {
throw new ServiceException(ResultCode.ERROR);
throw new ServiceException(ResultCode.AFTER_STATUS_ERROR);
}
//查询会员回寄的物流公司信息
@@ -209,7 +209,7 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
//判断物流公司是否为空
if (logistics == null) {
throw new ServiceException(ResultCode.AFTER_SALES_LOGISTICS_ERROR);
throw new ServiceException(ResultCode.AFTER_STATUS_ERROR);
}
afterSale.setMLogisticsCode(logistics.getId());
@@ -244,7 +244,7 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
//判断是否为已邮寄售后单
if (!afterSale.getServiceStatus().equals(AfterSaleStatusEnum.BUYER_RETURN.name())) {
throw new ServiceException(ResultCode.ERROR);
throw new ServiceException(ResultCode.AFTER_STATUS_ERROR);
}
AfterSaleStatusEnum afterSaleStatusEnum = null;
//判断审核状态

View File

@@ -2,20 +2,17 @@ package cn.lili.modules.order.order.serviceimpl;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.PageUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.order.order.entity.dos.Receipt;
import cn.lili.modules.order.order.entity.dto.OrderReceiptDTO;
import cn.lili.modules.order.order.entity.dto.ReceiptSearchParams;
import cn.lili.modules.order.order.mapper.OrderItemMapper;
import cn.lili.modules.order.order.mapper.ReceiptMapper;
import cn.lili.modules.order.order.service.ReceiptService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -64,7 +61,7 @@ public class ReceiptServiceImpl extends ServiceImpl<ReceiptMapper, Receipt> impl
this.save(receipt);
return receipt;
}
throw new ServiceException(ResultCode.ERROR);
return null;
}
@Override
@@ -76,6 +73,6 @@ public class ReceiptServiceImpl extends ServiceImpl<ReceiptMapper, Receipt> impl
this.saveOrUpdate(receipt);
return receipt;
}
throw new ServiceException(ResultCode.ERROR);
throw new ServiceException(ResultCode.USER_RECEIPT_NOT_EXIST);
}
}

View File

@@ -15,7 +15,6 @@ import cn.lili.modules.page.service.ArticleCategoryService;
import cn.lili.modules.page.service.ArticleService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -60,12 +59,10 @@ public class ArticleCategoryServiceImpl extends ServiceImpl<ArticleCategoryMappe
}
}
articleCategory.setType(ArticleCategoryEnum.OTHER.name());
if (this.save(articleCategory)) {
//清除文章分类缓存
this.clearCache();
return articleCategory;
}
throw new ServiceException(ResultCode.ERROR);
this.save(articleCategory);
//清除文章分类缓存
this.clearCache();
return articleCategory;
}
@@ -93,7 +90,7 @@ public class ArticleCategoryServiceImpl extends ServiceImpl<ArticleCategoryMappe
this.clearCache();
return category;
}
throw new ServiceException(ResultCode.ERROR);
return null;
}
@Override
@@ -114,7 +111,7 @@ public class ArticleCategoryServiceImpl extends ServiceImpl<ArticleCategoryMappe
throw new ServiceException(ResultCode.ARTICLE_CATEGORY_HAS_ARTICLE);
}
//判断是否为默认的分类
if(!this.getById(id).getType().equals(ArticleEnum.OTHER.name())){
if (!this.getById(id).getType().equals(ArticleEnum.OTHER.name())) {
throw new ServiceException(ResultCode.ARTICLE_CATEGORY_NO_DELETION);
}

View File

@@ -5,7 +5,7 @@ import cn.hutool.core.net.URLEncoder;
import cn.hutool.json.JSONUtil;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.utils.SnowFlake;
import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.ResultMessage;
@@ -168,7 +168,7 @@ public class AliPayPlugin implements Payment {
if (StringUtils.isNotEmpty(refundLog.getPaymentReceivableNo())) {
model.setTradeNo(refundLog.getPaymentReceivableNo());
} else {
throw new ServiceException(ResultCode.ERROR);
throw new ServiceException(ResultCode.ALIPAY_PARAMS_EXCEPTION);
}
model.setRefundAmount(refundLog.getTotalAmount() + "");
model.setRefundReason(refundLog.getRefundReason());

View File

@@ -3,7 +3,7 @@ package cn.lili.modules.payment.kit.plugin.wallet;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.member.service.MemberWalletService;
import cn.lili.modules.order.trade.entity.enums.DepositServiceTypeEnum;

View File

@@ -11,7 +11,7 @@ import cn.lili.common.enums.ResultCode;
import cn.lili.common.exception.ServiceException;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.CurrencyUtil;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.utils.SnowFlake;
import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.ResultMessage;

View File

@@ -1,7 +1,7 @@
package ${entity.controllerPackage};
import cn.lili.common.utils.PageUtil;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.SearchVO;
import cn.lili.common.vo.ResultMessage;