|
@@ -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);
|
|
|
+ }
|
|
|
|
|
|
}
|