Commit 4f031428 authored by zhaobiyan's avatar zhaobiyan

核销回退接口

parents a9a99391 75a26330
......@@ -27,5 +27,6 @@ public interface ErrorCodeConstants {
ErrorCode REWARD_REDEEM_STATUS_ERROR = new ErrorCode(1001011019, "reward.redeem.status.error");
ErrorCode REWARD_REDEEM_VERIFY_NO_PARAM = new ErrorCode(1001011020, "reward.redeem.verify.no.param");
ErrorCode REWARD_REDEEM_BATCH_VERIFY_ERROR = new ErrorCode(1001011021, "reward.redeem.batch.verify.error");
ErrorCode REWARD_REDEEM_VERIFY_BACK_STATUS = new ErrorCode(1001011021, "reward.redeem.verify.back.status");
}
......@@ -26,7 +26,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
@RestController
@Api(tags = "管理后台 - 礼品管理")
@Api(tags = "管理后台 - 兑换记录管理")
@RequestMapping("/reward/redeem")
public class RedeemRewardController {
......@@ -37,35 +37,41 @@ public class RedeemRewardController {
private RewardRedeemService rewardRedeemService;
@PostMapping("record/page")
@ApiOperation("兑换记录列表")
@ApiOperation("列表")
public CommonResult<PageResult<RewardRedeemPageRespVO>> pageInfo(@Valid @RequestBody RewardRedeemPageReqVO reqVO) {
return success(rewardRedeemService.pageInfo(reqVO));
}
@PostMapping("record/detail")
@ApiOperation("兑换记录详情")
@ApiOperation("详情")
public CommonResult<RewardRedeemPageRespVO> detail(@Valid @RequestBody RewardRedeemBaseVO request) {
return success(rewardRedeemService.detail(request.getId()));
}
@PostMapping("record/update")
@ApiOperation("兑换记录更新")
@ApiOperation("更新")
public CommonResult<Boolean> update(@Valid @RequestBody RewardRedeemUpdateReqVO request) {
return success(rewardRedeemService.updateRecord(request));
}
@PostMapping("record/verify")
@ApiOperation("兑换记录核销")
@ApiOperation("核销")
public CommonResult<Boolean> verify(@Valid @RequestBody RewardRedeemVerifyReqVO request) {
return success(rewardRedeemService.verify(request));
}
@PostMapping("record/batch/verify")
@ApiOperation("兑换记录核销")
@ApiOperation("批量核销")
public CommonResult<Boolean> batchVerify(@Valid @RequestBody RewardRedeemBatchVerifyReqVO request) {
return success(rewardRedeemService.batchVerify(request));
}
@PostMapping("record/verify-back")
@ApiOperation("核销回退")
public CommonResult<Boolean> verifyBack(@Valid @RequestBody List<Long> redeemIds) {
return success(rewardRedeemService.verifyBack(redeemIds));
}
@PostMapping("/single")
@ApiOperation("兑换礼品")
......
......@@ -23,4 +23,6 @@ public interface RewardRedeemService extends IService<RewardRedeemDO> {
Boolean verify(RewardRedeemVerifyReqVO request);
Boolean batchVerify(RewardRedeemBatchVerifyReqVO request);
Boolean verifyBack(List<Long> redeemIds);
}
......@@ -22,7 +22,6 @@ import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -86,7 +85,7 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
@Override
public Boolean verify(RewardRedeemVerifyReqVO request) {
if (!checkVerifyParam(request)){
throw exception(ErrorCodeConstants.REWARD_REDEEM_STATUS_ERROR);
throw exception(ErrorCodeConstants.REWARD_REDEEM_VERIFY_NO_PARAM);
}
LambdaUpdateWrapper<RewardRedeemDO> wrapper = Wrappers.lambdaUpdate();
wrapper.eq(RewardRedeemDO::getId, request.getId());
......@@ -126,6 +125,33 @@ public class RewardRedeemServiceImpl extends AbstractService<RewardRedeemMapper,
return true;
}
@Override
public Boolean verifyBack(List<Long> redeemIds) {
if (CollectionUtils.isEmpty(redeemIds)) {
throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST);
}
LambdaUpdateWrapper<RewardRedeemDO> wrapper = Wrappers.lambdaUpdate();
wrapper.in(RewardRedeemDO::getId, redeemIds);
List<RewardRedeemDO> list = this.list(wrapper);
if (CollectionUtils.isEmpty(list)) {
throw exception(ErrorCodeConstants.REWARD_REDEEM_NOT_EXIST);
}
List<RewardRedeemDO> statusErrorList = list.stream().filter(item -> item.getStatus() != RewardRedeemStatusEnum.REDEEMED.getValue())
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(statusErrorList)) {
throw exception(ErrorCodeConstants.REWARD_REDEEM_VERIFY_BACK_STATUS);
}
LambdaUpdateWrapper<RewardRedeemDO> updateWrapper = Wrappers.lambdaUpdate();
updateWrapper.in(RewardRedeemDO::getId, redeemIds);
updateWrapper.set(RewardRedeemDO::getStatus, RewardRedeemStatusEnum.REDEEMING.getValue());
updateWrapper.set(RewardRedeemDO::getVerifyUser, null);
updateWrapper.set(RewardRedeemDO::getVerifyTime, null);
updateWrapper.set(RewardRedeemDO::getUpdater, SecurityFrameworkUtils.getLoginUserId());
updateWrapper.set(RewardRedeemDO::getUpdateTime, new Date());
this.update(null, updateWrapper);
return true;
}
private List<Long> checkBatchVerifyParam(RewardRedeemBatchVerifyReqVO request) {
LambdaUpdateWrapper<RewardRedeemDO> wrapper = Wrappers.lambdaUpdate();
wrapper.in(RewardRedeemDO::getId, request.getIds());
......
......@@ -1015,3 +1015,4 @@ reward.redeem.not.exist = reward redeem record does not exist
reward.redeem.status.error = reward redeem record that is redeeming can edit or verify
reward.redeem.verify.no.param = In addition to collect at home, the delivery company/delivery number/delivery time/delivery sender/recipient address must be filled in
reward.redeem.batch.verify.error = reward redeem record verify failed, please check record data : {}
reward.redeem.verify.back.status = record status must be redeemed
\ No newline at end of file
......@@ -1019,3 +1019,4 @@ reward.redeem.not.exist = \u793C\u54C1\u5151\u6362\u8BB0\u5F55\u4E0D\u5B58\u5728
reward.redeem.status.error = \u53EA\u6709\u5151\u6362\u4E2D\u72B6\u6001\u7684\u8BB0\u5F55\u624D\u5141\u8BB8\u7F16\u8F91\u6216\u6838\u9500
reward.redeem.verify.no.param = \u9664\u4E0A\u95E8\u9886\u53D6\u5916\uFF0C\u5FEB\u9012\u516C\u53F8/\u5FEB\u9012\u5355\u53F7/\u5FEB\u9012\u65F6\u95F4/\u5FEB\u9012\u53D1\u9001\u4EBA/\u6536\u4EF6\u4EBA\u5730\u5740\uFF0C\u5FC5\u987B\u586B\u5199
reward.redeem.batch.verify.error = \u793C\u54C1\u8BB0\u5F55\u6279\u91CF\u6838\u9500\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u6570\u636E\u662F\u5426\u6B63\u786E:{}
reward.redeem.verify.back.status = \u56DE\u9000\u8BB0\u5F55\u72B6\u6001\u5FC5\u987B\u4E3A\u5DF2\u5151\u6362
\ No newline at end of file
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