cxw #17
@ -47,6 +47,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1_007_007_003, "已经存在钱包退款");
|
ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1_007_007_003, "已经存在钱包退款");
|
||||||
ErrorCode WALLET_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1_007_007_004, "钱包冻结余额不足");
|
ErrorCode WALLET_FREEZE_PRICE_NOT_ENOUGH = new ErrorCode(1_007_007_004, "钱包冻结余额不足");
|
||||||
|
|
||||||
|
|
||||||
// ========== 钱包充值模块 1-007-008-000 ==========
|
// ========== 钱包充值模块 1-007-008-000 ==========
|
||||||
ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1_007_008_000, "钱包充值记录不存在");
|
ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1_007_008_000, "钱包充值记录不存在");
|
||||||
ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_008_001, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态");
|
ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1_007_008_001, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态");
|
||||||
@ -62,6 +63,8 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode WALLET_RECHARGE_PACKAGE_NOT_FOUND = new ErrorCode(1_007_008_011, "钱包充值套餐不存在");
|
ErrorCode WALLET_RECHARGE_PACKAGE_NOT_FOUND = new ErrorCode(1_007_008_011, "钱包充值套餐不存在");
|
||||||
ErrorCode WALLET_RECHARGE_PACKAGE_IS_DISABLE = new ErrorCode(1_007_008_012, "钱包充值套餐已禁用");
|
ErrorCode WALLET_RECHARGE_PACKAGE_IS_DISABLE = new ErrorCode(1_007_008_012, "钱包充值套餐已禁用");
|
||||||
ErrorCode WALLET_RECHARGE_PACKAGE_NAME_EXISTS = new ErrorCode(1_007_008_013, "钱包充值套餐名称已存在");
|
ErrorCode WALLET_RECHARGE_PACKAGE_NAME_EXISTS = new ErrorCode(1_007_008_013, "钱包充值套餐名称已存在");
|
||||||
|
ErrorCode WALLET_RECHARGE_RANGE_EXCEPTION = new ErrorCode(1_007_007_004, "充值后余额异常");
|
||||||
|
|
||||||
|
|
||||||
// ========== 转账模块 1-007-009-000 ==========
|
// ========== 转账模块 1-007-009-000 ==========
|
||||||
ErrorCode PAY_TRANSFER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_009_000, "发起转账报错,错误码:{},错误提示:{}");
|
ErrorCode PAY_TRANSFER_SUBMIT_CHANNEL_ERROR = new ErrorCode(1_007_009_000, "发起转账报错,错误码:{},错误提示:{}");
|
||||||
|
@ -18,7 +18,8 @@ public enum PayWalletBizTypeEnum implements IntArrayValuable {
|
|||||||
RECHARGE(1, "充值"),
|
RECHARGE(1, "充值"),
|
||||||
RECHARGE_REFUND(2, "充值退款"),
|
RECHARGE_REFUND(2, "充值退款"),
|
||||||
PAYMENT(3, "支付"),
|
PAYMENT(3, "支付"),
|
||||||
PAYMENT_REFUND(4, "支付退款");
|
PAYMENT_REFUND(4, "支付退款"),
|
||||||
|
ADMIN_MODIFY(5, "管理员修改");
|
||||||
|
|
||||||
// TODO 后续增加
|
// TODO 后续增加
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public class PayWalletController {
|
|||||||
|
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
@PreAuthorize("@ss.hasPermission('pay:wallet:update')")
|
@PreAuthorize("@ss.hasPermission('pay:wallet:update')")
|
||||||
@Operation(summary = "修改用户钱包余额")
|
@Operation(summary = "修改用户钱包余额(后台操作)")
|
||||||
public CommonResult<Boolean> updateWallet(@Valid @RequestBody PayWalletUserBalanceVo reqVo){
|
public CommonResult<Boolean> updateWallet(@Valid @RequestBody PayWalletUserBalanceVo reqVo){
|
||||||
payWalletService.updateWallet(reqVo);
|
payWalletService.updateWallet(reqVo);
|
||||||
return success(true);
|
return success(true);
|
||||||
|
@ -99,7 +99,7 @@ public interface PayWalletService {
|
|||||||
void unfreezePrice(Long id, Integer price);
|
void unfreezePrice(Long id, Integer price);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改钱包余额
|
* 修改钱包余额(后台操作)
|
||||||
* @param reqVo
|
* @param reqVo
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
@ -210,17 +210,35 @@ public class PayWalletServiceImpl implements PayWalletService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateWallet(PayWalletUserBalanceVo reqVo) {
|
public void updateWallet(PayWalletUserBalanceVo reqVo) {
|
||||||
if(reqVo.getBalance().compareTo(BigDecimal.ZERO) == 0){
|
// 如果
|
||||||
|
if (reqVo.getBalance().compareTo(BigDecimal.ZERO) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 把单位从元转为分
|
||||||
BigDecimal change = new BigDecimal("100");
|
BigDecimal change = new BigDecimal("100");
|
||||||
|
// 查出对应钱包信息
|
||||||
PayWalletDO walletDO = walletMapper.selectById(reqVo.getId());
|
PayWalletDO walletDO = walletMapper.selectById(reqVo.getId());
|
||||||
int changeBalance = (reqVo.getBalance().multiply(change)).intValue();
|
if (reqVo.getBalance().compareTo(new BigDecimal("21474836.47")) > 0) {
|
||||||
int totalBalance = walletDO.getBalance() + changeBalance;
|
throw exception(WALLET_RECHARGE_RANGE_EXCEPTION);
|
||||||
int totalRecharge = walletDO.getTotalRecharge() + changeBalance;
|
}
|
||||||
walletDO.setBalance(totalBalance);
|
// 总共改变的金额
|
||||||
walletDO.setTotalRecharge(totalRecharge);
|
long changeBalance = (reqVo.getBalance().multiply(change)).longValue();
|
||||||
|
// 总余额
|
||||||
|
long totalBalance = walletDO.getBalance() + changeBalance;
|
||||||
|
// 总充值
|
||||||
|
long totalRecharge = walletDO.getTotalRecharge() + changeBalance;
|
||||||
|
if (totalBalance > 2147483647 || totalRecharge > 2147483647 || totalBalance < 0 || totalRecharge < 0) {
|
||||||
|
throw exception(WALLET_RECHARGE_RANGE_EXCEPTION);
|
||||||
|
}
|
||||||
|
walletDO.setBalance((int) totalBalance);
|
||||||
|
walletDO.setTotalRecharge((int) totalRecharge);
|
||||||
walletMapper.updateById(walletDO);
|
walletMapper.updateById(walletDO);
|
||||||
|
String title = "后台操作给用户" + (totalBalance > 0 ? "增加" : "减少") + "余额" + Math.abs(changeBalance)/100.0 + "元";
|
||||||
|
WalletTransactionCreateReqBO transactionCreateReqBO = new WalletTransactionCreateReqBO()
|
||||||
|
.setWalletId(reqVo.getId()).setPrice((int) changeBalance).setBalance((int) totalBalance)
|
||||||
|
.setBizType(PayWalletBizTypeEnum.ADMIN_MODIFY.getType()).setBizId("0").setTitle(title);
|
||||||
|
walletTransactionService.createWalletTransaction(transactionCreateReqBO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user