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