金额操作修改1

pull/2/head
shaowenhao 2023-10-29 11:33:40 +08:00
parent 9b942c105a
commit bdd434d826
3 changed files with 2 additions and 50 deletions

View File

@ -124,16 +124,7 @@ public class PurseController {
return purseService.purseWithdraw(bankId);
}
/**
*
* 100 == H
*
* id
*/
@PostMapping("/topUp")
public R<Integer> topUp(@RequestBody BankId bankId){
return purseService.topUp(bankId);
}

View File

@ -246,46 +246,7 @@ public class PurseServiceImpl implements PurseService {
}
/***
*
* @param bankId
* @return
*/
@Override
public R<Integer> topUp(BankId bankId) {
//获取到选择的银行卡 通过前台传来选择银行卡的id 进行查询对象
BankId bank = purseMapper.bankNumBank(bankId.getId());
//查询银行卡里面的金额 跟前台输入的金额做对比
if (bank.getNumBank() < bankId.getAmount()){
return R.fail("银行卡余额不足");
}else{
//获取到前台传来的金额
int amount = bankId.getAmount();
//调用当前用户的userId 查询到金额
PurseResponse show = purseMapper.show(bankId.getUserId());
//银行卡里面的金额(前台 输入的数据) * 100 加上原有的 钱包金额 进行给钱包金额赋值
PurseRequest purseRequest = new PurseRequest();
purseRequest.setBalanceFee((amount * 100) + show.getBalanceFee());
//修改H币 方法
Integer i = purseMapper.topUp(bankId);
// //更改银行卡里面的余额
// BankId bankId1 = new BankId();
// //查询银行卡的余额
// BankResponse b = purseMapper.selBankNumBank(bankId.getId());
// bankId1.setNumBank(b.getNumBank() - amount);
// purseMapper.updBankNumBank(bankRequest);
//添加充值记录表里面
MoneyWithdrawRequest moneyWithdraw = new MoneyWithdrawRequest();
//添加用户
moneyWithdraw.setUserId(bankId.getUserId());
//添加记录表
purseMapper.addMoneyWithdraw(moneyWithdraw);
return R.ok(i>0?200:500,i>0?"充值成功":"充值失败");
}
}
/***

View File

@ -29,7 +29,7 @@ public interface PurseService {
R<List<MoneyWithdrawResponse>> moneyWithdrawLog(@Param("userId") String userId);
R<Integer> topUp(BankId bankId);
R<List<InvitationRecordRequest>> in(InvitationRecordRequest invitationRecord);