后台-修改余额功能
This commit is contained in:
parent
3909ce665e
commit
cc63700872
@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
@Schema(description = "管理后台 - 用户修改余额 Request VO")
|
||||
@ -12,5 +13,5 @@ public class PayWalletUserBalanceVo {
|
||||
@Schema(description = "钱包编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
@Schema(description = "余额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Integer balance;
|
||||
private BigDecimal balance;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -209,12 +210,14 @@ public class PayWalletServiceImpl implements PayWalletService {
|
||||
|
||||
@Override
|
||||
public void updateWallet(PayWalletUserBalanceVo reqVo) {
|
||||
if(reqVo.getBalance() == 0){
|
||||
if(reqVo.getBalance().compareTo(BigDecimal.ZERO) == 0){
|
||||
return;
|
||||
}
|
||||
BigDecimal change = new BigDecimal("100");
|
||||
PayWalletDO walletDO = walletMapper.selectById(reqVo.getId());
|
||||
int totalBalance = walletDO.getBalance() + reqVo.getBalance();
|
||||
int totalRecharge = walletDO.getTotalRecharge() + reqVo.getBalance();
|
||||
int changeBalance = (reqVo.getBalance().multiply(change)).intValue();
|
||||
int totalBalance = walletDO.getBalance() + changeBalance;
|
||||
int totalRecharge = walletDO.getTotalRecharge() + changeBalance;
|
||||
walletDO.setBalance(totalBalance);
|
||||
walletDO.setTotalRecharge(totalRecharge);
|
||||
walletMapper.updateById(walletDO);
|
||||
|
Loading…
Reference in New Issue
Block a user