补贴相关接口功能新增

This commit is contained in:
liux 2025-12-09 13:16:45 +08:00
parent 3481119859
commit e050c9a70c
2 changed files with 23 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Data
public class AccSubsidyClearParam extends BaseEntity {
@ -13,6 +14,9 @@ public class AccSubsidyClearParam extends BaseEntity {
message = "用户编号不能为空"
) Long userId;
@ApiModelProperty("操作金额")
private BigDecimal operateAmount;
@ApiModelProperty("清空类型 清空-1 清空至-2")
private Integer clearType = 1;
}

View File

@ -130,8 +130,26 @@ public class AccSubServiceImpl implements AccSubService {
if (Objects.isNull(walletInfo)) {
throw new ServiceException("补贴钱包不存在");
}
BigDecimal operateAmount = BigDecimal.ZERO;
if(param.getClearType()==1){
//按余额清空
operateAmount = walletInfo.getWalletBal();
}else{
if(Objects.isNull(param.getOperateAmount()) || param.getOperateAmount().compareTo(BigDecimal.ZERO)<=0){
throw new ServiceException("按金额清空时清空金额必须大于0元");
}else{
if(param.getOperateAmount().compareTo(walletInfo.getWalletBal()) >= 0){
throw new ServiceException("按金额清空时,清空金额需小于补贴钱包余额,钱包剩余:"+walletInfo.getWalletBal().movePointLeft(2)+"");
}else {
operateAmount = walletInfo.getWalletBal().subtract(param.getOperateAmount());
log.info("钱包 :"+walletInfo.getWalletBal());
log.info("输入 :"+param.getOperateAmount());
log.info("扣款 :"+operateAmount);
}
}
}
WalletUpdateDTO walletUpdateDTO = new WalletUpdateDTO();
walletUpdateDTO.setAmount(walletInfo.getWalletBal());
walletUpdateDTO.setAmount(operateAmount);
walletUpdateDTO.setUserId(param.getUserId());
walletUpdateDTO.setAccWalletTypeEnum(AccWalletTypeEnum.SUBSIDY);
walletUpdateDTO.setAccTradeTypeEnum(AccTradeTypeEnum.CLEAR);