refactor(pay): 提现校验

master
yang 2025-03-07 15:31:01 +08:00
parent 583d90f42d
commit 3f915a7ac8
1 changed files with 16 additions and 0 deletions

View File

@ -17,6 +17,8 @@ import com.mcwl.pay.domain.OrderTradeDto;
import com.mcwl.pay.domain.vo.PayVo;
import com.mcwl.pay.service.AliPayService;
import com.mcwl.pay.service.OrderTradeService;
import com.mcwl.system.domain.SysUserPayAccount;
import com.mcwl.system.service.ISysUserPayAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
@ -57,6 +59,9 @@ public class AliPayController extends BaseController {
@Autowired
private OrderTradeService orderTradeService;
@Autowired
private ISysUserPayAccountService sysUserPayAccountService;
@Autowired
private AliPayService aliPayService;
@ -175,6 +180,17 @@ public class AliPayController extends BaseController {
@NotNull(message = "提现金额不能为空")
@Pattern(regexp = "^(0|(?!0\\d)[1-9]\\d*)(\\.\\d{2})?$", message = "金额格式错误(必须保留两位小数)")
String amount) throws Exception {
SysUserPayAccount sysUserPayAccount = sysUserPayAccountService.lambdaQuery()
.eq(SysUserPayAccount::getUserId, SecurityUtils.getUserId())
.eq(SysUserPayAccount::getType, 0)
.one();
if (Objects.isNull(sysUserPayAccount)) {
return R.fail("请先绑定支付宝");
}
if (Double.parseDouble(amount) < 0.1) {
return R.fail("提现金额最小为0.1");
}