提现策略改动
This commit is contained in:
@@ -110,14 +110,6 @@ public class AppCashController {
|
||||
if (!in) {
|
||||
return Result.error(StrUtil.format("提现时间为每天{}", info.getValue()));
|
||||
}
|
||||
double money = Double.parseDouble(commonInfoService.findOne(929).getValue());
|
||||
Double v = cashOutService.queryUserTodayCashAmount(userId);
|
||||
if (v == null) {
|
||||
v = 0.0d;
|
||||
}
|
||||
if ((v + amount) >= money) {
|
||||
return Result.error("今日提现金额已达上限");
|
||||
}
|
||||
Result ret = Result.error();
|
||||
try {
|
||||
ret = cashOutService.withdraw(userId, amount, null, false);
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -510,7 +511,7 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result withdraw(Long userId, Double money, String msg, boolean isSys) {
|
||||
if (money == null || money <= 0.00) {
|
||||
return Result.error("请不要输入小于0的数字,请输入正确的提现金额!");
|
||||
@@ -604,7 +605,8 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
||||
if (sysUserMoney.getMoney().doubleValue() < money) {
|
||||
return Result.success("可提现余额不足!");
|
||||
}
|
||||
if (wuyouPay.checkCanCash(userId, WithdrawTypeEnum.MANUAL, new BigDecimal(money.toString()))) {
|
||||
try {
|
||||
wuyouPay.checkCanCash(userId, WithdrawTypeEnum.MANUAL, new BigDecimal(money.toString()));
|
||||
cashOut.setStatus(4);
|
||||
BaseResp baseResp = wuyouPay.extractOrder(outOrderNo, cashOut.getUserId(), false, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName(), cashOut.getBankName());
|
||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
||||
@@ -612,15 +614,16 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
||||
cashOut.setState(1);
|
||||
cashOut.setOutAt(DateUtil.date().toString());
|
||||
}
|
||||
|
||||
if (baseResp.getErrorMsg() != null) {
|
||||
return Result.error(baseResp.getErrorMsg());
|
||||
}
|
||||
} else {
|
||||
}catch (SqxException e){
|
||||
return Result.error(e.getMsg());
|
||||
}catch (ValidateException v){
|
||||
sysUserMoneyDetails.setContent("提现:" + money);
|
||||
cashOut.setState(3);
|
||||
cashOut.setRelationId(v.getMessage());
|
||||
}
|
||||
|
||||
sysUserMoneyDetailsService.save(sysUserMoneyDetails);
|
||||
baseMapper.insert(cashOut);
|
||||
sysUserMoneyService.updateSysMoney(2, userId, money);
|
||||
@@ -648,7 +651,7 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
||||
cashOut.setState(3);
|
||||
cashOut.setRelationId("提现黑名单用户,请谨慎审核!");
|
||||
} else {
|
||||
if (wuyouPay.checkCanCash(userId, WithdrawTypeEnum.MANUAL, new BigDecimal(money.toString()))) {
|
||||
try {
|
||||
cashOut.setStatus(4);
|
||||
BaseResp baseResp = wuyouPay.extractOrder(outOrderNo, cashOut.getUserId(), true, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName(), cashOut.getBankName());
|
||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))) {
|
||||
@@ -656,13 +659,15 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
||||
cashOut.setState(1);
|
||||
cashOut.setOutAt(DateUtil.date().toString());
|
||||
}
|
||||
|
||||
if (baseResp.getErrorMsg() != null) {
|
||||
return Result.error(baseResp.getErrorMsg());
|
||||
}
|
||||
} else {
|
||||
}catch (SqxException e){
|
||||
return Result.error(e.getMsg());
|
||||
}catch (ValidateException v){
|
||||
userMoneyDetails.setContent("提现:" + money);
|
||||
cashOut.setState(3);
|
||||
cashOut.setRelationId(v.getMessage());
|
||||
}
|
||||
}
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.sqx.modules.pay.wuyou;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.pay.dao.CashOutDao;
|
||||
import com.sqx.modules.pay.entity.WithdrawTypeEnum;
|
||||
import com.sqx.modules.pay.service.CashOutService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -32,13 +35,15 @@ public class WuyouPay {
|
||||
|
||||
private final CashOutDao cashOutDao;
|
||||
private final CommonInfoService commonInfoService;
|
||||
private final CashOutService cashOutService;
|
||||
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(WuyouPay.class);
|
||||
|
||||
public WuyouPay(CashOutDao cashOutDao, CommonInfoService commonInfoService) {
|
||||
public WuyouPay(CashOutDao cashOutDao, CommonInfoService commonInfoService, CashOutService cashOutService) {
|
||||
this.cashOutDao = cashOutDao;
|
||||
this.commonInfoService = commonInfoService;
|
||||
this.cashOutService = cashOutService;
|
||||
}
|
||||
|
||||
public BaseResp payOrder(String orderNo, Long userId, String amount, String userAgent, String allId, String payType) {
|
||||
@@ -92,34 +97,60 @@ public class WuyouPay {
|
||||
return JSONObject.parseObject(body, BaseResp.class);
|
||||
}
|
||||
|
||||
public boolean checkCanCash(long userId, WithdrawTypeEnum type, BigDecimal money) {
|
||||
public void checkCanCash(long userId, WithdrawTypeEnum type, BigDecimal money) {
|
||||
if (WithdrawTypeEnum.MANUAL.equals(type)) {
|
||||
// 查询当日体现次数
|
||||
Integer successCashCount = cashOutDao.selectTodayCashCount(userId, 1, DateUtil.today() + " 00:00:00");
|
||||
CommonInfo cashLimit = commonInfoService.findOne(922);
|
||||
if (cashLimit == null || StrUtil.isBlank(cashLimit.getValue())) {
|
||||
logger.warn("提现必要参数未配置,请联系管理员");
|
||||
return false;
|
||||
throw new ValidateException("【922】每日体现次数上限未配置");
|
||||
}
|
||||
|
||||
if (successCashCount >= Integer.parseInt(cashLimit.getValue())) {
|
||||
logger.warn("体现次数超限,当前限制{}次, 已经体现{}次", cashLimit.getValue(), successCashCount);
|
||||
return false;
|
||||
|
||||
throw new SqxException(StrUtil.format("超过当日提现限制次数{}次,请明天再试!", cashLimit.getValue()));
|
||||
}
|
||||
return checkCanCashByLimit(money);
|
||||
checkCanCashByLimit(money);
|
||||
todayTotalLimit(userId, money.doubleValue());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean checkCanCashByLimit(BigDecimal money) {
|
||||
public void checkCanCashByLimit(BigDecimal money) {
|
||||
CommonInfo info = commonInfoService.findOne(923);
|
||||
if (info == null || StrUtil.isBlank(info.getValue())) {
|
||||
logger.warn("未配置提现限制,请联系管理员配置");
|
||||
return false;
|
||||
throw new ValidateException("【923】单次提现超额未配置");
|
||||
}
|
||||
|
||||
return money.compareTo(new BigDecimal(info.getValue())) <= 0;
|
||||
boolean ret = money.compareTo(new BigDecimal(info.getValue())) <= 0;
|
||||
if(!ret){
|
||||
throw new ValidateException("单次提现超额");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当日累计提现超过设定值时,需要人工审核
|
||||
*
|
||||
* @param userId
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
public void todayTotalLimit(long userId, double amount) {
|
||||
CommonInfo info = commonInfoService.findOne(929);
|
||||
if (info == null || StrUtil.isBlank(info.getValue())) {
|
||||
logger.warn("未配置提现限制,请联系管理员配置");
|
||||
throw new ValidateException("【929】当日累计提现额未配置");
|
||||
}
|
||||
double money = Double.parseDouble(commonInfoService.findOne(929).getValue());
|
||||
Double v = cashOutService.queryUserTodayCashAmount(userId);
|
||||
if (v == null) {
|
||||
v = 0.0d;
|
||||
}
|
||||
if ((v + amount) >= money) {
|
||||
logger.warn("当日累计提现超过设定值时,当日累计提现金额:¥{}, 提现金额:¥{},设定值:¥{}", (v + amount), amount, money);
|
||||
throw new ValidateException("当日累计提现超额");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +272,7 @@ public class WuyouPay {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
WuyouPay pay = new WuyouPay(null, null);
|
||||
WuyouPay pay = new WuyouPay(null, null, null);
|
||||
|
||||
Map<String, Object> params = pay.getBaseParams();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user