feat:恢复充值金额

This commit is contained in:
dzc committed 2025-01-23 17:00:47 +08:00
1 parent 9d2cf0f5d2
commit 4ba65bfad8
4 files changed
+47 -3

No files matched your search

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity;
@@ -39,6 +40,13 @@ public class WalletRechargeImportController {
private final WalletRechargeImportService walletRechargeImportService;
@Operation(summary = "恢复", description = "恢复")
@Idempotent(expireTime = 5, info = "正在处理中,请勿重复操作")
@GetMapping("/recover")
public R<Boolean> recover(@RequestParam Long id) {
return R.ok(walletRechargeImportService.recover(id));
}
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeImport_view')")
@@ -17,4 +17,6 @@ public interface WalletRechargeImportService extends IService<WalletRechargeImpo
List<WalletRechargeImportVo> listJoin(WalletRechargeImportDto dto);
Page<WalletRechargeImportVo> scopePageList(Page page, WalletRechargeImportDto dto, DataScope dataScope);
Boolean recover(Long id);
}
@@ -312,7 +312,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
);
if (ObjectUtil.isEmpty(detail)) return;
if (!ObjectUtil.equals(detail.getProcessStatus(), TaskCheckStatusEnum.PADDING.getCode())) {
log.error("|{}|重复的回调,dto:|{}|", TAG);
log.error("|{}|重复的回调,dto:|{}|", TAG, JSON.toJSONString(dto));
return;
}
try {
@@ -1,6 +1,7 @@
package com.bsd.pjcloud.wallet.service.impl.recharge;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.dto.UserDTO;
@@ -12,20 +13,26 @@ import com.bsd.pjcloud.admin.api.vo.UserVO;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.wallet.api.constant.WalletBizEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo;
import com.bsd.pjcloud.wallet.mapper.WalletTypeMapper;
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeImportMapper;
import com.bsd.pjcloud.wallet.service.WalletRechargeImportService;
import com.bsd.pjcloud.wallet.service.WalletTypeService;
import com.bsd.pjcloud.wallet.service.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.ArrayList;
@@ -43,6 +50,11 @@ import java.util.List;
@Service
public class WalletRechargeImportServiceImpl extends ServiceImpl<WalletRechargeImportMapper, WalletRechargeImportEntity> implements WalletRechargeImportService {
@Lazy
private final WalletRechargeApplyService walletRechargeApplyService;
private final WalletTransactionService walletTransactionService;
private final WalletManageService walletManageService;
private final WalletTypeMapper walletTypeMapper;
private final RemoteUserService userService;
@@ -104,4 +116,26 @@ public class WalletRechargeImportServiceImpl extends ServiceImpl<WalletRechargeI
}
return list;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean recover(Long id) {
WalletRechargeImportEntity rechargeImport = baseMapper.selectById(id);
if (ObjectUtil.isEmpty(rechargeImport)) throw new RuntimeException("充值记录不存在");
WalletRechargeApplyEntity rechargeApply = walletRechargeApplyService.getById(rechargeImport.getApplyId());
if (ObjectUtil.isEmpty(rechargeApply)) throw new RuntimeException("充值申请不存在");
WalletTypeEntity walletType = walletTypeMapper.selectById(rechargeApply.getWalletTypeId());
WalletTypeEnum walletTypeEnum = WalletTypeEnum.valueOfByCode(walletType.getUniqueCode());
if (ObjectUtil.isEmpty(walletType) || ObjectUtil.isEmpty(walletTypeEnum)) {
throw new RuntimeException("钱包类型错误");
}
WalletTransactionEntity walletTransaction = walletTransactionService.getOne(new LambdaQueryWrapper<WalletTransactionEntity>()
.eq(WalletTransactionEntity::getBizId, String.valueOf(rechargeImport.getId()))
);
if (ObjectUtil.isNotEmpty(walletTransaction)) throw new RuntimeException("钱包已经充值过");
WalletManageEntity wallet = walletManageService.getOrCreateWallet(rechargeImport.getUserId(), walletTypeEnum);
if (ObjectUtil.isEmpty(wallet)) throw new RuntimeException("钱包错误");
walletTransactionService.addWalletBalance(wallet.getId(), rechargeImport.getPrice(), String.valueOf(rechargeImport.getId()), WalletBizEnum.BATCH);
return true;
}
}