|
|
|
@@ -34,6 +34,9 @@ public class WxCouponController extends BaseController { |
|
|
|
@Autowired |
|
|
|
private WxCouponChannelService wxCouponChannelService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private WxCouponService couponService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Qualifier("couponDetailRedisTemplate") |
|
|
|
RedisTemplate<String, WxCouponCVo> cdRedisTemplate; |
|
|
|
@@ -42,14 +45,18 @@ public class WxCouponController extends BaseController { |
|
|
|
@ApiOperation("根据id(couponChannel)查询接口") |
|
|
|
@GetMapping("/detail") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true)}) |
|
|
|
public ResultData detailC(String couponChannelId) { |
|
|
|
@ApiImplicitParam(name = "couponChannelId", value = "couponChannelId", dataType = "String", paramType = "query", required = true), |
|
|
|
@ApiImplicitParam(name = "couponId", value = "couponId", dataType = "String", paramType = "query", required = false)}) |
|
|
|
public ResultData detailC(String couponChannelId, String couponId) { |
|
|
|
if (StringUtils.isBlank(couponChannelId) || couponChannelId.equalsIgnoreCase(Constant.UNDEFINED)) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId为空"); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId/couponId为空"); |
|
|
|
} |
|
|
|
Long couponChannelIdL = 0L; |
|
|
|
Long couponChannelIdL = 0L, couponIdL = 0L; |
|
|
|
try { |
|
|
|
couponChannelIdL = Long.valueOf(couponChannelId); |
|
|
|
if (StringUtils.isNotBlank(couponId) && !couponId.equalsIgnoreCase(Constant.UNDEFINED)) { |
|
|
|
couponIdL = Long.valueOf(couponId); |
|
|
|
} |
|
|
|
} catch (NumberFormatException e) { |
|
|
|
logger.error("id转换失败" + couponChannelId); |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId转换失败" + couponChannelId); |
|
|
|
@@ -60,16 +67,26 @@ public class WxCouponController extends BaseController { |
|
|
|
ValueOperations<String, WxCouponCVo> operations = cdRedisTemplate.opsForValue(); |
|
|
|
// 缓存 |
|
|
|
boolean hasKey = cdRedisTemplate.hasKey(key); |
|
|
|
if(hasKey) { |
|
|
|
if (hasKey) { |
|
|
|
// 从缓存获取用户信息 |
|
|
|
WxCouponCVo wxCouponCVo = operations.get(key); |
|
|
|
// 更新状态 |
|
|
|
WxCouponCVo couponCVo = wxCouponChannelService.findVoStatusDetail(couponChannelIdL); |
|
|
|
if (wxCouponCVo == null) { |
|
|
|
return new ResultData(ErrorCode.COUPON_IS_EMPTY); |
|
|
|
if (couponIdL > 0L) { |
|
|
|
// 更新状态 |
|
|
|
WxCouponCVo couponCVo = couponService.getVoStatusById(couponIdL); |
|
|
|
if (wxCouponCVo == null) { |
|
|
|
return new ResultData(ErrorCode.COUPON_IS_EMPTY); |
|
|
|
} |
|
|
|
wxCouponCVo.setRemainInventory(couponCVo.getRemainInventory()); |
|
|
|
wxCouponCVo.setStatus(couponCVo.getStatus()); |
|
|
|
} else { |
|
|
|
// 更新状态 |
|
|
|
WxCouponCVo couponCVo = wxCouponChannelService.findVoStatusDetail(couponChannelIdL); |
|
|
|
if (wxCouponCVo == null) { |
|
|
|
return new ResultData(ErrorCode.COUPON_IS_EMPTY); |
|
|
|
} |
|
|
|
wxCouponCVo.setRemainInventory(couponCVo.getRemainInventory()); |
|
|
|
wxCouponCVo.setStatus(couponCVo.getStatus()); |
|
|
|
} |
|
|
|
wxCouponCVo.setRemainInventory(couponCVo.getRemainInventory()); |
|
|
|
wxCouponCVo.setStatus(couponCVo.getStatus()); |
|
|
|
// end of 更新状态 |
|
|
|
updateActivityStatus(wxCouponCVo); |
|
|
|
return new ResultData(wxCouponCVo); |
|
|
|
@@ -89,7 +106,7 @@ public class WxCouponController extends BaseController { |
|
|
|
} |
|
|
|
|
|
|
|
private void updateActivityStatus(WxCouponCVo wxCouponCVo) { |
|
|
|
if (wxCouponCVo.getTargetAd()!= null && |
|
|
|
if (wxCouponCVo.getTargetAd() != null && |
|
|
|
wxCouponCVo.getTargetAd().equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())) { |
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
|