Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -4,7 +4,9 @@ import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.utils.ApiAccessLimitUtil;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.RedisKeys;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
@@ -34,6 +36,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -68,12 +71,13 @@ public class WuyouController {
|
||||
private final CashOutDao cashOutDao;
|
||||
private final CompletAwardService completAwardService;
|
||||
private final SysUserService sysUserService;
|
||||
private final ApplicationContext applicationContext;
|
||||
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(5);
|
||||
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
WuyouController(OrdersService ordersService, PayDetailsDao payDetailsDao, UserService userService, InviteService inviteService, CashOutDao cashOutDao,
|
||||
UserMoneyService userMoneyService, UserMoneyDetailsService userMoneyDetailsService, CommonInfoService commonRepository,
|
||||
InviteDao inviteDao,CompletAwardService completAwardService, SysUserService sysUserService) {
|
||||
InviteDao inviteDao, CompletAwardService completAwardService, SysUserService sysUserService, ApplicationContext applicationContext) {
|
||||
this.ordersService = ordersService;
|
||||
this.payDetailsDao = payDetailsDao;
|
||||
this.userService = userService;
|
||||
@@ -85,6 +89,7 @@ public class WuyouController {
|
||||
this.inviteDao = inviteDao;
|
||||
this.completAwardService = completAwardService;
|
||||
this.sysUserService = sysUserService;
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@Debounce(interval = 1000, value = "#orderId")
|
||||
@@ -335,7 +340,11 @@ public class WuyouController {
|
||||
ordersService.updateById(order);
|
||||
ordersService.insertOrders(order);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
activities(user, byUser);
|
||||
ApiAccessLimitUtil.runFunAndCheckKey(() -> {
|
||||
WuyouController proxy = applicationContext.getBean(WuyouController.class);
|
||||
proxy.activities(user, byUser);
|
||||
return null;
|
||||
}, RedisKeys.getLockKey("activaties", user.getUserId(), byUser.getUserId()), 15);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -486,15 +486,20 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
||||
return Result.success("可提现余额不足!");
|
||||
}
|
||||
|
||||
// BaseResp baseResp = WuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
||||
// if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))){
|
||||
// userMoneyDetails.setContent("成功提现:" + money);
|
||||
// cashOut.setState(1);
|
||||
// }
|
||||
//
|
||||
// if (baseResp.getErrorMsg() != null) {
|
||||
// return Result.error(baseResp.getErrorMsg());
|
||||
// }
|
||||
if (WuyouPay.checkCanCash(userId)) {
|
||||
BaseResp baseResp = WuyouPay.extractOrder(outOrderNo, cashOut.getMoney(), cashOut.getZhifubao(), cashOut.getZhifubaoName());
|
||||
if (baseResp.getStatus() != null && (baseResp.getStatus().equals(2) || baseResp.getStatus().equals(10000))){
|
||||
userMoneyDetails.setContent("成功提现:" + money);
|
||||
cashOut.setState(1);
|
||||
}
|
||||
|
||||
if (baseResp.getErrorMsg() != null) {
|
||||
return Result.error(baseResp.getErrorMsg());
|
||||
}
|
||||
}else {
|
||||
userMoneyDetails.setContent("成功提现:" + money);
|
||||
cashOut.setState(3);
|
||||
}
|
||||
|
||||
userMoneyDetailsService.save(userMoneyDetails);
|
||||
baseMapper.insert(cashOut);
|
||||
|
||||
@@ -82,30 +82,30 @@ public class WuyouPay {
|
||||
return JSONObject.parseObject(body, BaseResp.class);
|
||||
}
|
||||
|
||||
public static boolean checkCanCash(long userId) {
|
||||
// 查询当日体现次数
|
||||
Integer successCashCount = cashOutDao.selectTodayCashCount(userId, 1);
|
||||
CommonInfo cashLimit = commonInfoService.findOne(922);
|
||||
if (cashLimit == null || StrUtil.isBlank(cashLimit.getValue())) {
|
||||
logger.warn("提现必要参数未配置,请联系管理员");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (successCashCount >= Integer.parseInt(cashLimit.getValue())) {
|
||||
logger.warn("提现必要参数未配置,请联系管理员");
|
||||
return false;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现
|
||||
* @param account 支付宝账号
|
||||
* @param userName 支付宝名称
|
||||
* @return
|
||||
*/
|
||||
public static BaseResp extractOrder(long userId, String outOrderNo, String amount, String account, String userName) {
|
||||
|
||||
// 查询当日体现次数
|
||||
Integer successCashCount = cashOutDao.selectTodayCashCount(userId, 1);
|
||||
CommonInfo cashLimit = commonInfoService.findOne(922);
|
||||
if (cashLimit == null || StrUtil.isBlank(cashLimit.getValue())) {
|
||||
BaseResp baseResp = new BaseResp();
|
||||
baseResp.setStatus(0);
|
||||
baseResp.setErrorMsg("提现必要参数未配置,请联系管理员");
|
||||
return baseResp;
|
||||
}
|
||||
|
||||
if (successCashCount >= Integer.parseInt(cashLimit.getValue())) {
|
||||
BaseResp baseResp = new BaseResp();
|
||||
baseResp.setStatus(0);
|
||||
baseResp.setErrorMsg("每日提现次数限制" + cashLimit.getValue() + "次, 您已超过上限");
|
||||
return baseResp;
|
||||
}
|
||||
public static BaseResp extractOrder(String outOrderNo, String amount, String account, String userName) {
|
||||
|
||||
Map<String, Object> params = getBaseParams();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user