Parcourir la source

代码格式化

cup il y a 2 ans
Parent
commit
e9e94d9b3d

+ 107 - 107
mp-admin/src/main/java/com/qs/mp/web/controller/api/channel/ChannelCouponVerifyController.java

@@ -41,125 +41,125 @@ import org.springframework.web.bind.annotation.RestController;
 @Component
 public class ChannelCouponVerifyController extends BaseApiController {
 
-  @Autowired
-  private IChannelService channelService;
+    @Autowired
+    private IChannelService channelService;
 
-  @Autowired
-  private IUserCouponService userCouponService;
+    @Autowired
+    private IUserCouponService userCouponService;
 
-  @Autowired
-  private IUserCouponChannelService userCouponChannelService;
+    @Autowired
+    private IUserCouponChannelService userCouponChannelService;
 
-  @Autowired
-  private IChannelCouponVerifyLogService channelCouponVerifyLogService;
+    @Autowired
+    private IChannelCouponVerifyLogService channelCouponVerifyLogService;
 
-  @Autowired
-  private MapperFacade mapperFacade;
+    @Autowired
+    private MapperFacade mapperFacade;
 
-  /**
-   * 优惠券查询
-   *
-   * @param
-   * @return
-   */
-  @PostMapping(value = "coupon/query")
-  public AjaxResult query(@RequestBody JSONObject param) {
-    String verifyCode = param.getString("verifyCode");
-    Long channelId = SecurityUtils.getLoginUser().getChannelId();
-    UserCoupon userCoupon = userCouponService.getOne(new LambdaQueryWrapper<UserCoupon>()
-        .eq(UserCoupon::getVerifyCode, verifyCode));
-    if (null == userCoupon) {
-      return error("券码非法");
-    }
-    AjaxResult result = checkCoupon(verifyCode, channelId, userCoupon);
-    if (null != result) {
-      return result;
-    }
-    List<UserCouponVO> userCouponVOList = userCouponService.listUserCouponVO(
-        new QueryWrapper<UserCoupon>()
-            .eq("t1.verify_code", verifyCode));
+    /**
+     * 优惠券查询
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "coupon/query")
+    public AjaxResult query(@RequestBody JSONObject param) {
+        String verifyCode = param.getString("verifyCode");
+        Long channelId = SecurityUtils.getLoginUser().getChannelId();
+        UserCoupon userCoupon = userCouponService.getOne(new LambdaQueryWrapper<UserCoupon>()
+            .eq(UserCoupon::getVerifyCode, verifyCode));
+        if (null == userCoupon) {
+            return error("券码非法");
+        }
+        AjaxResult result = checkCoupon(verifyCode, channelId, userCoupon);
+        if (null != result) {
+            return result;
+        }
+        List<UserCouponVO> userCouponVOList = userCouponService.listUserCouponVO(
+            new QueryWrapper<UserCoupon>()
+                .eq("t1.verify_code", verifyCode));
 
-    return AjaxResult.success(userCouponVOList.get(0));
-  }
+        return AjaxResult.success(userCouponVOList.get(0));
+    }
 
-  private AjaxResult checkCoupon(String verifyCode, Long channelId, UserCoupon userCoupon) {
-    AjaxResult result = null;
+    private AjaxResult checkCoupon(String verifyCode, Long channelId, UserCoupon userCoupon) {
+        AjaxResult result = null;
 
-    if (StringUtils.isBlank(verifyCode)) {
-      result = error(ErrorCodeEnum.ERROR_CODE_1001);
-    }
-    if (null == userCoupon) {
-      result = error("该券不存在!");
-    }
-    if (userCoupon.getStatus() == UserCouponStatusEnum.USED) {
-      result = error("该券已使用!");
+        if (StringUtils.isBlank(verifyCode)) {
+            result = error(ErrorCodeEnum.ERROR_CODE_1001);
+        }
+        if (null == userCoupon) {
+            result = error("该券不存在!");
+        }
+        if (userCoupon.getStatus() == UserCouponStatusEnum.USED) {
+            result = error("该券已使用!");
+        }
+        if (userCoupon.getValidEnd().before(new Date())) {
+            result = error("该券已过期!");
+        }
+        UserCouponChannel couponChannel = userCouponChannelService.getOne(
+            new LambdaQueryWrapper<UserCouponChannel>()
+                .eq(UserCouponChannel::getUserCouponId, userCoupon.getId())
+                .eq(UserCouponChannel::getChannelId, channelId));
+        if (null == couponChannel) {
+            result = error("无权核销该券");
+        }
+        return result;
     }
-    if (userCoupon.getValidEnd().before(new Date())) {
-      result = error("该券已过期!");
-    }
-    UserCouponChannel couponChannel = userCouponChannelService.getOne(
-        new LambdaQueryWrapper<UserCouponChannel>()
-            .eq(UserCouponChannel::getUserCouponId, userCoupon.getId())
-            .eq(UserCouponChannel::getChannelId, channelId));
-    if (null == couponChannel) {
-      result = error("无权核销该券");
-    }
-    return result;
-  }
 
-  /**
-   * 优惠券核销
-   *
-   * @param
-   * @return
-   */
-  @PostMapping(value = "coupon/verify")
-  public AjaxResult verify(@RequestBody JSONObject param) {
-    String verifyCode = param.getString("verifyCode");
-    Long channelId = SecurityUtils.getLoginUser().getChannelId();
-    UserCoupon userCoupon = userCouponService.getOne(new LambdaQueryWrapper<UserCoupon>()
-        .eq(UserCoupon::getVerifyCode, verifyCode));
-    if (null == userCoupon) {
-      return error("券码非法");
-    }
-    AjaxResult result = checkCoupon(verifyCode, channelId, userCoupon);
-    if (null != result) {
-      return result;
+    /**
+     * 优惠券核销
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "coupon/verify")
+    public AjaxResult verify(@RequestBody JSONObject param) {
+        String verifyCode = param.getString("verifyCode");
+        Long channelId = SecurityUtils.getLoginUser().getChannelId();
+        UserCoupon userCoupon = userCouponService.getOne(new LambdaQueryWrapper<UserCoupon>()
+            .eq(UserCoupon::getVerifyCode, verifyCode));
+        if (null == userCoupon) {
+            return error("券码非法");
+        }
+        AjaxResult result = checkCoupon(verifyCode, channelId, userCoupon);
+        if (null != result) {
+            return result;
+        }
+        channelCouponVerifyLogService.verify(channelId, userCoupon);
+        return AjaxResult.success("核销成功");
     }
-    channelCouponVerifyLogService.verify(channelId, userCoupon);
-    return AjaxResult.success("核销成功");
-  }
 
-  /**
-   * 获取我的核销记录
-   *
-   * @return
-   */
-  @PostMapping("coupon/verify/log/list")
-  public TableDataInfo list(@RequestBody JSONObject jsonObject) {
-    Long channelId = SecurityUtils.getLoginUser().getChannelId();
-    startPage();
-    List<ChannelCouponVerifyLog> verifyLogList = channelCouponVerifyLogService.list(
-        new LambdaQueryWrapper<ChannelCouponVerifyLog>()
-            .eq(ChannelCouponVerifyLog::getChannelId, channelId)
-            .orderByDesc(ChannelCouponVerifyLog::getVerifyTime));
-    return getDataTable(verifyLogList);
-  }
+    /**
+     * 获取我的核销记录
+     *
+     * @return
+     */
+    @PostMapping("coupon/verify/log/list")
+    public TableDataInfo list(@RequestBody JSONObject jsonObject) {
+        Long channelId = SecurityUtils.getLoginUser().getChannelId();
+        startPage();
+        List<ChannelCouponVerifyLog> verifyLogList = channelCouponVerifyLogService.list(
+            new LambdaQueryWrapper<ChannelCouponVerifyLog>()
+                .eq(ChannelCouponVerifyLog::getChannelId, channelId)
+                .orderByDesc(ChannelCouponVerifyLog::getVerifyTime));
+        return getDataTable(verifyLogList);
+    }
 
-	/**
-	 * 优惠券核销记录详情
-	 *
-	 * @param
-	 * @return
-	 */
-	@PostMapping(value = "coupon/verify/log/detail")
-	public AjaxResult detail(@RequestBody JSONObject param) {
-		Long logId = param.getLong("logId");
-		if (null == logId || 0 == logId) {
-			return error(ErrorCodeEnum.ERROR_CODE_1001);
-		}
-		ChannelCouponVerifyLog verifyLog = channelCouponVerifyLogService.getById(logId);
-		return AjaxResult.success(verifyLog);
-	}
+    /**
+     * 优惠券核销记录详情
+     *
+     * @param
+     * @return
+     */
+    @PostMapping(value = "coupon/verify/log/detail")
+    public AjaxResult detail(@RequestBody JSONObject param) {
+        Long logId = param.getLong("logId");
+        if (null == logId || 0 == logId) {
+            return error(ErrorCodeEnum.ERROR_CODE_1001);
+        }
+        ChannelCouponVerifyLog verifyLog = channelCouponVerifyLogService.getById(logId);
+        return AjaxResult.success(verifyLog);
+    }
 
 }

+ 51 - 51
mp-common/src/main/java/com/qs/mp/common/enums/ErrorCodeEnum.java

@@ -7,56 +7,56 @@ package com.qs.mp.common.enums;
  */
 public enum ErrorCodeEnum {
 
-  ERROR_CODE_1000(1000, "数据访问错误"),
-  ERROR_CODE_1001(1001, "请求参数为空"),
-  ERROR_CODE_1002(1002, "用户登录信息为空"),
-  ERROR_CODE_1004(1004, "获取锁失败"),
-  ERROR_CODE_1005(1005, "用户微信未授权登录"),
-  ERROR_CODE_1006(1006, "客户ID不存在"),
-  ERROR_CODE_1007(1007, "收支类型错误"),
-  ERROR_CODE_1008(1008, "余额不足,结算失败"),
-  ERROR_CODE_1009(1009, "数据更新异常"),
-  ERROR_CODE_1010(1010, "数据对象不存在或者返回重复记录"),
-  ERROR_CODE_1011(1011, "请求参数错误"),
-  ERROR_CODE_1012(1012, "查询微信用户信息失败"),
-  ERROR_CODE_1013(1013, "账号不存在"),
-  ERROR_CODE_1014(1014, "当前账号不能删除"),
-  ERROR_CODE_1015(1015, "保存失败"),
-  ERROR_CODE_1016(1016, "账号未认证,请先完成认证再提交"),
-  ERROR_CODE_1017(1017, "盲票已兑奖"),
-  ERROR_CODE_1018(1018, "无权限查看"),
-  ERROR_CODE_1019(1019, "盲票未付款"),
-  ERROR_CODE_1020(1020, "库存不足"),
-  ERROR_CODE_1021(1021, "盲豆余额不足"),
-  ERROR_CODE_1022(1022, "订单支付中"),
-  ERROR_CODE_1023(1023, "盲票未激活"),
-  ERROR_CODE_1024(1024, "删除失败,分类下存在商品"),
-  ERROR_CODE_1025(1025, "删除失败,标签下存在商品"),
-
-  ERROR_CODE_1026(1026, "用户支付宝未授权登录"),
-  ;
-  private int code;
-  private String msg;
-
-  ErrorCodeEnum(int code, String description) {
-    this.code = code;
-    this.msg = description;
-  }
-
-  public void setCode(int code) {
-    this.code = code;
-  }
-
-  public int getCode() {
-    return code;
-  }
-
-  public void setMsg(String description) {
-    this.msg = description;
-  }
-
-  public String getMsg() {
-    return msg;
-  }
+    ERROR_CODE_1000(1000, "数据访问错误"),
+    ERROR_CODE_1001(1001, "请求参数为空"),
+    ERROR_CODE_1002(1002, "用户登录信息为空"),
+    ERROR_CODE_1004(1004, "获取锁失败"),
+    ERROR_CODE_1005(1005, "用户微信未授权登录"),
+    ERROR_CODE_1006(1006, "客户ID不存在"),
+    ERROR_CODE_1007(1007, "收支类型错误"),
+    ERROR_CODE_1008(1008, "余额不足,结算失败"),
+    ERROR_CODE_1009(1009, "数据更新异常"),
+    ERROR_CODE_1010(1010, "数据对象不存在或者返回重复记录"),
+    ERROR_CODE_1011(1011, "请求参数错误"),
+    ERROR_CODE_1012(1012, "查询微信用户信息失败"),
+    ERROR_CODE_1013(1013, "账号不存在"),
+    ERROR_CODE_1014(1014, "当前账号不能删除"),
+    ERROR_CODE_1015(1015, "保存失败"),
+    ERROR_CODE_1016(1016, "账号未认证,请先完成认证再提交"),
+    ERROR_CODE_1017(1017, "盲票已兑奖"),
+    ERROR_CODE_1018(1018, "无权限查看"),
+    ERROR_CODE_1019(1019, "盲票未付款"),
+    ERROR_CODE_1020(1020, "库存不足"),
+    ERROR_CODE_1021(1021, "盲豆余额不足"),
+    ERROR_CODE_1022(1022, "订单支付中"),
+    ERROR_CODE_1023(1023, "盲票未激活"),
+    ERROR_CODE_1024(1024, "删除失败,分类下存在商品"),
+    ERROR_CODE_1025(1025, "删除失败,标签下存在商品"),
+
+    ERROR_CODE_1026(1026, "用户支付宝未授权登录"),
+    ;
+    private int code;
+    private String msg;
+
+    ErrorCodeEnum(int code, String description) {
+        this.code = code;
+        this.msg = description;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setMsg(String description) {
+        this.msg = description;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
 
 }

+ 26 - 26
mp-common/src/main/java/com/qs/mp/common/enums/UserCouponStatusEnum.java

@@ -6,39 +6,39 @@ import com.baomidou.mybatisplus.annotation.IEnum;
 import com.qs.mp.common.json.EnumValueDeserializer;
 
 /**
- *
  * 用户卡券使用状态
- *
  */
 @JSONType(deserializer = EnumValueDeserializer.class)
 public enum UserCouponStatusEnum implements IEnum<Integer> {
 
-  UNUSED(1, "未使用"),
-  USED(2, "已使用"),
-  OVERDUE(3, "已过期"),;
+    UNUSED(1, "未使用"),
+    USED(2, "已使用"),
+    OVERDUE(3, "已过期"),
+    ;
 
-  private final Integer value;
-  private final String desc;
+    private final Integer value;
+    private final String desc;
 
-  UserCouponStatusEnum(final Integer value, final String desc) {
-    this.value = value;
-    this.desc = desc;
-  }
+    UserCouponStatusEnum(final Integer value, final String desc) {
+        this.value = value;
+        this.desc = desc;
+    }
 
-  @Override
-  public Integer getValue() {
-    return value;
-  }
+    @Override
+    public Integer getValue() {
+        return value;
+    }
 
-  /**
-   * 重写toString,单个转化成json
-   * @return
-   */
-  @Override
-  public String toString() {
-    JSONObject object = new JSONObject();
-    object.put("value",value);
-    object.put("desc", desc);
-    return object.toString();
-  }
+    /**
+     * 重写toString,单个转化成json
+     *
+     * @return
+     */
+    @Override
+    public String toString() {
+        JSONObject object = new JSONObject();
+        object.put("value", value);
+        object.put("desc", desc);
+        return object.toString();
+    }
 }

+ 87 - 87
mp-service/src/main/java/com/qs/mp/user/domain/UserCoupon.java

@@ -25,93 +25,93 @@ import lombok.Data;
 @ApiModel("用户的优惠券实体类")
 public class UserCoupon implements Serializable {
 
-  private static final long serialVersionUID = 1L;
-
-  /**
-   * 主键
-   */
-  @ApiModelProperty("主键")
-  @TableId(value = "id", type = IdType.INPUT)
-  private String id;
-
-  /**
-   * 用户ID
-   */
-  @ApiModelProperty("用户id")
-  @TableField("user_id")
-  private Long userId;
-
-  /**
-   * 核销码
-   */
-  @ApiModelProperty("核销码")
-  @TableField("verify_code")
-  private String verifyCode;
-
-  /**
-   * 优惠券ID
-   */
-  @ApiModelProperty("优惠券id")
-  @TableField("coupon_id")
-  private Long couponId;
-
-  /**
-   * 生效日
-   */
-  @ApiModelProperty("生效日")
-  @TableField("valid_start")
-  private Date validStart;
-
-  /**
-   * 到期日
-   */
-  @ApiModelProperty("到期日")
-  @TableField("valid_end")
-  private Date validEnd;
-
-  /**
-   * 适用范围说明
-   */
-  @ApiModelProperty("使用范围;0通用, 1指定范围, 2门店消费,发放时动态指定范围, 3线上票, 4线下票")
-  @TableField("use_area_desc")
-  private String useAreaDesc;
-
-  /**
-   * 使用订单ID
-   */
-  @ApiModelProperty("使用订单id")
-  @TableField("order_id")
-  private String orderId;
-
-  /**
-   * 核销时间
-   */
-  @ApiModelProperty("核销时间")
-  @TableField("verify_time")
-  private Date verifyTime;
-
-  /**
-   * 状态;1未使用 2已使用 3已过期
-   */
-  @ApiModelProperty("状态;1未使用 2已使用 3已过期")
-  @TableField("status")
-  @JSONField(serialzeFeatures = SerializerFeature.WriteEnumUsingToString)
-  private UserCouponStatusEnum status;
-
-  /**
-   * 创建时间
-   */
-  @ApiModelProperty("创建时间")
-  @TableField("created_time")
-  private Date createdTime;
-
-  /**
-   * 更新时间
-   */
-  @ApiModelProperty("更新时间")
-  @TableField("updated_time")
-  @Version
-  private Date updatedTime;
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @ApiModelProperty("主键")
+    @TableId(value = "id", type = IdType.INPUT)
+    private String id;
+
+    /**
+     * 用户ID
+     */
+    @ApiModelProperty("用户id")
+    @TableField("user_id")
+    private Long userId;
+
+    /**
+     * 核销码
+     */
+    @ApiModelProperty("核销码")
+    @TableField("verify_code")
+    private String verifyCode;
+
+    /**
+     * 优惠券ID
+     */
+    @ApiModelProperty("优惠券id")
+    @TableField("coupon_id")
+    private Long couponId;
+
+    /**
+     * 生效日
+     */
+    @ApiModelProperty("生效日")
+    @TableField("valid_start")
+    private Date validStart;
+
+    /**
+     * 到期日
+     */
+    @ApiModelProperty("到期日")
+    @TableField("valid_end")
+    private Date validEnd;
+
+    /**
+     * 适用范围说明
+     */
+    @ApiModelProperty("使用范围;0通用, 1指定范围, 2门店消费,发放时动态指定范围, 3线上票, 4线下票")
+    @TableField("use_area_desc")
+    private String useAreaDesc;
+
+    /**
+     * 使用订单ID
+     */
+    @ApiModelProperty("使用订单id")
+    @TableField("order_id")
+    private String orderId;
+
+    /**
+     * 核销时间
+     */
+    @ApiModelProperty("核销时间")
+    @TableField("verify_time")
+    private Date verifyTime;
+
+    /**
+     * 状态;1未使用 2已使用 3已过期
+     */
+    @ApiModelProperty("状态;1未使用 2已使用 3已过期")
+    @TableField("status")
+    @JSONField(serialzeFeatures = SerializerFeature.WriteEnumUsingToString)
+    private UserCouponStatusEnum status;
+
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty("创建时间")
+    @TableField("created_time")
+    private Date createdTime;
+
+    /**
+     * 更新时间
+     */
+    @ApiModelProperty("更新时间")
+    @TableField("updated_time")
+    @Version
+    private Date updatedTime;
 
 
 }