Commit 9ee905dc by 吕明尚

修改优惠卷日志查询问题

parent 757cac98
...@@ -90,7 +90,7 @@ public class QPServiceImplAspect { ...@@ -90,7 +90,7 @@ public class QPServiceImplAspect {
JSONObject jsonObject = JSON.parseObject(params); JSONObject jsonObject = JSON.parseObject(params);
//获得出参 //获得出参
String outParams = JSON.toJSONString(result); String outParams = JSON.toJSONString(result);
saveLog(couponLog, jsonObject); saveLog(couponLog, jsonObject, UserStatusEnum.USED.getCode());
couponLog.setStatus(YesNoEnum.yes.getDisplay_3()); couponLog.setStatus(YesNoEnum.yes.getDisplay_3());
couponLog.setMessage(outParams); couponLog.setMessage(outParams);
couponLog.setCreateTime(new Date()); couponLog.setCreateTime(new Date());
...@@ -128,7 +128,7 @@ public class QPServiceImplAspect { ...@@ -128,7 +128,7 @@ public class QPServiceImplAspect {
String params = argsArrayToString(paramNames, joinPoint.getArgs()); String params = argsArrayToString(paramNames, joinPoint.getArgs());
//转JSON //转JSON
JSONObject jsonObject = JSON.parseObject(params); JSONObject jsonObject = JSON.parseObject(params);
saveLog(couponLog, jsonObject); saveLog(couponLog, jsonObject, UserStatusEnum.UNUSED.getCode());
couponLog.setStatus(YesNoEnum.no.getDisplay_3()); couponLog.setStatus(YesNoEnum.no.getDisplay_3());
couponLog.setNumber(TRY_NUMBER); couponLog.setNumber(TRY_NUMBER);
couponLog.setCreateTime(new Date()); couponLog.setCreateTime(new Date());
...@@ -148,20 +148,12 @@ public class QPServiceImplAspect { ...@@ -148,20 +148,12 @@ public class QPServiceImplAspect {
} }
} }
private void saveLog(CouponLog couponLog, JSONObject jsonObject) { private void saveLog(CouponLog couponLog, JSONObject jsonObject, Integer code) {
couponLog.setCode(jsonObject.getString("code")); couponLog.setCode(jsonObject.getString("code"));
LambdaQueryWrapper<SConsumerCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SConsumerCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(SConsumerCoupon::getCouponCode, couponLog.getCode()); lambdaQueryWrapper.eq(SConsumerCoupon::getCouponCode, couponLog.getCode());
lambdaQueryWrapper.in(SConsumerCoupon::getUseStatus, UserStatusEnum.UNUSED.getCode(), UserStatusEnum.USED.getCode()); lambdaQueryWrapper.eq(SConsumerCoupon::getUseStatus, code);
List<SConsumerCoupon> list = sConsumerCouponService.list(lambdaQueryWrapper); SConsumerCoupon one = sConsumerCouponService.getOne(lambdaQueryWrapper);
//过滤只有已使用
SConsumerCoupon one = null;
//判断是否存在已使用的券
if (list.stream().anyMatch(sConsumerCoupon -> sConsumerCoupon.getUseStatus().equals(UserStatusEnum.USED.getCode()))) {
one = list.stream().filter(sConsumerCoupon -> sConsumerCoupon.getUseStatus().equals(UserStatusEnum.USED.getCode())).findFirst().orElse(null);
} else {
one = list.stream().filter(sConsumerCoupon -> sConsumerCoupon.getUseStatus().equals(UserStatusEnum.UNUSED.getCode())).findFirst().orElse(null);
}
couponLog.setConsumerId(one.getConsumerId()); couponLog.setConsumerId(one.getConsumerId());
couponLog.setCouponId(one.getId()); couponLog.setCouponId(one.getId());
LambdaQueryWrapper<SStore> sStoreLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SStore> sStoreLambdaQueryWrapper = new LambdaQueryWrapper<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment