Commit 1e64c640 authored by zhaobiyan's avatar zhaobiyan

撤销参数修改

parent 2c9157f1
...@@ -83,14 +83,14 @@ public class RedeemRewardController { ...@@ -83,14 +83,14 @@ public class RedeemRewardController {
@PostMapping("record/cancel/check") @PostMapping("record/cancel/check")
@ApiOperation("撤销检查") @ApiOperation("撤销检查")
public CommonResult<RedeemCancelCheckRespVO> cancelCheck(@Valid @RequestBody RewardRedeemUpdateReqVO reqVO) { public CommonResult<RedeemCancelCheckRespVO> cancelCheck(@Valid @RequestBody List<Long> ids) {
return success(rewardRedeemService.cancelCheck(reqVO)); return success(rewardRedeemService.cancelCheck(ids));
} }
@PostMapping("record/cancel") @PostMapping("record/cancel")
@ApiOperation("撤销") @ApiOperation("撤销")
public CommonResult<Boolean> cancel(@Valid @RequestBody RewardRedeemUpdateReqVO reqVO) { public CommonResult<Boolean> cancel(@Valid @RequestBody List<Long> ids) {
return success(rewardRedeemService.cancel(reqVO)); return success(rewardRedeemService.cancel(ids));
} }
@PostMapping("record/import/template") @PostMapping("record/import/template")
......
...@@ -34,7 +34,7 @@ public interface RewardRedeemService extends IService<RewardRedeemDO> { ...@@ -34,7 +34,7 @@ public interface RewardRedeemService extends IService<RewardRedeemDO> {
RecordInfoImportRespVO recordImport(List<RedeemInfoImportExcelVO> dataList); RecordInfoImportRespVO recordImport(List<RedeemInfoImportExcelVO> dataList);
Boolean cancel(RewardRedeemUpdateReqVO reqVO); Boolean cancel(List<Long> ids);
RedeemCancelCheckRespVO cancelCheck(RewardRedeemUpdateReqVO reqVO); RedeemCancelCheckRespVO cancelCheck(List<Long> ids);
} }
...@@ -245,45 +245,49 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper, ...@@ -245,45 +245,49 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
} }
@Override @Override
@Transactional public Boolean cancel(List<Long> ids) {
public Boolean cancel(RewardRedeemUpdateReqVO reqVO) { if (CollectionUtils.isEmpty(ids)) {
//取消兑换 状态改为已取消 回退扣减的积分 ,如果存在已过期的积分,则直接过期
if (reqVO.getId() == null) {
throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST); throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST);
} }
RewardRedeemDO rewardRedeemDO = this.getById(reqVO.getId()); ids.forEach(id -> {
if (rewardRedeemDO == null) { //取消兑换 状态改为已取消 回退扣减的积分 ,如果存在已过期的积分,则直接过期
throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST); if (id == null) {
} throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST);
if (rewardRedeemDO.getStatus() != RewardRedeemStatusEnum.REDEEMING.getValue()) { }
throw exception(ErrorCodeConstants.REDEEM_CANCEL_STATUS_ERROR); RewardRedeemDO rewardRedeemDO = this.getById(id);
} if (rewardRedeemDO == null) {
LambdaUpdateWrapper<RewardRedeemDO> updateWrapper = Wrappers.lambdaUpdate(); throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST);
updateWrapper.eq(RewardRedeemDO::getId, reqVO.getId()); }
updateWrapper.eq(RewardRedeemDO::getStatus, RewardRedeemStatusEnum.REDEEMING.getValue()); if (rewardRedeemDO.getStatus() != RewardRedeemStatusEnum.REDEEMING.getValue()) {
updateWrapper.set(RewardRedeemDO::getStatus, RewardRedeemStatusEnum.CANCELED.getValue()); throw exception(ErrorCodeConstants.REDEEM_CANCEL_STATUS_ERROR);
boolean updateSuccess = this.update(null, updateWrapper); }
if (!updateSuccess) { LambdaUpdateWrapper<RewardRedeemDO> updateWrapper = Wrappers.lambdaUpdate();
throw exception(ErrorCodeConstants.REDEEM_CANCEL_STATUS_ERROR); updateWrapper.eq(RewardRedeemDO::getId, id);
} updateWrapper.eq(RewardRedeemDO::getStatus, RewardRedeemStatusEnum.REDEEMING.getValue());
Map<String, Object> extParam = new HashMap<>(); updateWrapper.set(RewardRedeemDO::getStatus, RewardRedeemStatusEnum.CANCELED.getValue());
extParam.put("redeemId", reqVO.getId()); boolean updateSuccess = this.update(null, updateWrapper);
memberUserScoreApi.operateScore(MemberUserScoreOperateReqDTO.builder() if (!updateSuccess) {
.memberId(rewardRedeemDO.getMemberId()) throw exception(ErrorCodeConstants.REDEEM_CANCEL_STATUS_ERROR);
.sourceType(ScoreSourceTypeEnum.EXCHANGE_REWARD_CANCEL) }
.scoreCount(rewardRedeemDO.getScoreCount()) Map<String, Object> extParam = new HashMap<>();
.extParam(extParam) extParam.put("redeemId", id);
.releationId(String.valueOf(reqVO.getId())) memberUserScoreApi.operateScore(MemberUserScoreOperateReqDTO.builder()
.build()); .memberId(rewardRedeemDO.getMemberId())
.sourceType(ScoreSourceTypeEnum.EXCHANGE_REWARD_CANCEL)
.scoreCount(rewardRedeemDO.getScoreCount())
.extParam(extParam)
.releationId(String.valueOf(id))
.build());
});
return true; return true;
} }
@Override @Override
public RedeemCancelCheckRespVO cancelCheck(RewardRedeemUpdateReqVO reqVO) { public RedeemCancelCheckRespVO cancelCheck(List<Long> ids) {
if (reqVO.getId() == null) { if (CollectionUtils.isEmpty(ids)) {
throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST); throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST);
} }
RewardRedeemDO rewardRedeemDO = this.getById(reqVO.getId()); RewardRedeemDO rewardRedeemDO = this.getById(ids.get(0));
if (rewardRedeemDO == null) { if (rewardRedeemDO == null) {
throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST); throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST);
} }
...@@ -291,7 +295,7 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper, ...@@ -291,7 +295,7 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
throw exception(ErrorCodeConstants.REDEEM_CANCEL_STATUS_ERROR); throw exception(ErrorCodeConstants.REDEEM_CANCEL_STATUS_ERROR);
} }
List<ReleationScoreExpireInfoDTO> scoreExpireInfo = memberUserScoreApi List<ReleationScoreExpireInfoDTO> scoreExpireInfo = memberUserScoreApi
.getScoreExpireInfo(String.valueOf(reqVO.getId()), ScoreSourceTypeEnum.EXCHANGE_REWARD); .getScoreExpireInfo(String.valueOf(ids.get(0)), ScoreSourceTypeEnum.EXCHANGE_REWARD);
int totalExpireScore = scoreExpireInfo.stream().filter(e -> e.getExpireDate() != null && e.getExpireDate().compareTo(new Date()) < 0) int totalExpireScore = scoreExpireInfo.stream().filter(e -> e.getExpireDate() != null && e.getExpireDate().compareTo(new Date()) < 0)
.mapToInt(ReleationScoreExpireInfoDTO::getScoreCount).sum(); .mapToInt(ReleationScoreExpireInfoDTO::getScoreCount).sum();
return RedeemCancelCheckRespVO.builder().expireCount(totalExpireScore).build(); return RedeemCancelCheckRespVO.builder().expireCount(totalExpireScore).build();
......
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