Commit 8662d20e authored by zhaobiyan's avatar zhaobiyan

Merge branch 'feature_member_score' into dev

parents d5638121 87f219e9
...@@ -86,14 +86,14 @@ public class RedeemRewardController { ...@@ -86,14 +86,14 @@ public class RedeemRewardController {
@PostMapping("record/cancel/check") @PostMapping("record/cancel/check")
@ApiOperation("撤销检查") @ApiOperation("撤销检查")
public CommonResult<RedeemCancelCheckRespVO> cancelCheck(@Valid @RequestBody List<Long> ids) { public CommonResult<RedeemCancelCheckRespVO> cancelCheck(@Valid @RequestBody RewardRedeemIdReqVO req) {
return success(rewardRedeemService.cancelCheck(ids)); return success(rewardRedeemService.cancelCheck(req));
} }
@PostMapping("record/cancel") @PostMapping("record/cancel")
@ApiOperation("撤销") @ApiOperation("撤销")
public CommonResult<Boolean> cancel(@Valid @RequestBody List<Long> ids) { public CommonResult<Boolean> cancel(@Valid @RequestBody RewardRedeemIdReqVO req) {
return success(rewardRedeemService.cancel(ids)); return success(rewardRedeemService.cancel(req));
} }
@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(List<Long> ids); Boolean cancel(RewardRedeemIdReqVO req);
RedeemCancelCheckRespVO cancelCheck(List<Long> ids); RedeemCancelCheckRespVO cancelCheck(RewardRedeemIdReqVO req);
} }
...@@ -245,49 +245,41 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper, ...@@ -245,49 +245,41 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
} }
@Override @Override
public Boolean cancel(List<Long> ids) { public Boolean cancel(RewardRedeemIdReqVO req) {
if (CollectionUtils.isEmpty(ids)) { //取消兑换 状态改为已取消 回退扣减的积分 ,如果存在已过期的积分,则直接过期
if (req.getId() == null) {
throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST); throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST);
} }
ids.forEach(id -> { RewardRedeemDO rewardRedeemDO = this.getById(req.getId());
//取消兑换 状态改为已取消 回退扣减的积分 ,如果存在已过期的积分,则直接过期 if (rewardRedeemDO == null) {
if (id == null) { throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST);
throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST); }
} if (rewardRedeemDO.getStatus() != RewardRedeemStatusEnum.REDEEMING.getValue()) {
RewardRedeemDO rewardRedeemDO = this.getById(id); throw exception(ErrorCodeConstants.REDEEM_CANCEL_STATUS_ERROR);
if (rewardRedeemDO == null) { }
throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST); LambdaUpdateWrapper<RewardRedeemDO> updateWrapper = Wrappers.lambdaUpdate();
} updateWrapper.eq(RewardRedeemDO::getId, req.getId());
if (rewardRedeemDO.getStatus() != RewardRedeemStatusEnum.REDEEMING.getValue()) { updateWrapper.eq(RewardRedeemDO::getStatus, RewardRedeemStatusEnum.REDEEMING.getValue());
throw exception(ErrorCodeConstants.REDEEM_CANCEL_STATUS_ERROR); updateWrapper.set(RewardRedeemDO::getStatus, RewardRedeemStatusEnum.CANCELED.getValue());
} boolean updateSuccess = this.update(null, updateWrapper);
LambdaUpdateWrapper<RewardRedeemDO> updateWrapper = Wrappers.lambdaUpdate(); if (!updateSuccess) {
updateWrapper.eq(RewardRedeemDO::getId, id); throw exception(ErrorCodeConstants.REDEEM_CANCEL_STATUS_ERROR);
updateWrapper.eq(RewardRedeemDO::getStatus, RewardRedeemStatusEnum.REDEEMING.getValue()); }
updateWrapper.set(RewardRedeemDO::getStatus, RewardRedeemStatusEnum.CANCELED.getValue()); Map<String, Object> extParam = new HashMap<>();
boolean updateSuccess = this.update(null, updateWrapper); extParam.put("redeemId", req.getId());
if (!updateSuccess) { memberUserScoreApi.operateScore(MemberUserScoreOperateReqDTO.builder()
throw exception(ErrorCodeConstants.REDEEM_CANCEL_STATUS_ERROR); .memberId(rewardRedeemDO.getMemberId())
} .sourceType(ScoreSourceTypeEnum.EXCHANGE_REWARD_CANCEL)
Map<String, Object> extParam = new HashMap<>(); .scoreCount(rewardRedeemDO.getScoreCount())
extParam.put("redeemId", id); .extParam(extParam)
memberUserScoreApi.operateScore(MemberUserScoreOperateReqDTO.builder() .releationId(String.valueOf(req.getId()))
.memberId(rewardRedeemDO.getMemberId()) .build());
.sourceType(ScoreSourceTypeEnum.EXCHANGE_REWARD_CANCEL)
.scoreCount(rewardRedeemDO.getScoreCount())
.extParam(extParam)
.releationId(String.valueOf(id))
.build());
});
return true; return true;
} }
@Override @Override
public RedeemCancelCheckRespVO cancelCheck(List<Long> ids) { public RedeemCancelCheckRespVO cancelCheck(RewardRedeemIdReqVO req) {
if (CollectionUtils.isEmpty(ids)) { RewardRedeemDO rewardRedeemDO = this.getById(req.getId());
throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST);
}
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);
} }
...@@ -295,7 +287,7 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper, ...@@ -295,7 +287,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(ids.get(0)), ScoreSourceTypeEnum.EXCHANGE_REWARD); .getScoreExpireInfo(String.valueOf(req.getId()), 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();
......
package cn.iocoder.yudao.module.reward.vo.reward;
import lombok.Data;
@Data
public class RewardRedeemIdReqVO {
private Long id;
}
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