|
|
@@ -34,6 +34,7 @@ import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.request.ApplyMoneyReq;
|
|
|
import com.cyksj.model.request.TransferAccountsReq;
|
|
|
import com.cyksj.model.request.YhShopApplyMoneyReq;
|
|
|
+import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.pay.TransferFuncService;
|
|
|
import com.cyksj.service.user.UserBenefitsService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@@ -74,10 +75,22 @@ public class TransferFuncServiceImpl implements TransferFuncService {
|
|
|
|
|
|
private final DistributeMoneyApplyMapper distributeMoneyApplyMapper;
|
|
|
|
|
|
+ private final RedisService redisService;
|
|
|
+
|
|
|
@Override
|
|
|
public Result distributeApply(ApplyMoneyReq applyMoneyReq) throws Exception {
|
|
|
applyMoneyReq.setMType(DistributeMoneyApply.MType.ds);
|
|
|
- return commonApplyMoney(applyMoneyReq);
|
|
|
+ String key = String.format(RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getName(), DateTime.now().toDateStr(), applyMoneyReq.getMType(), applyMoneyReq.getUserId());
|
|
|
+ if (!redisService.setNx(key, applyMoneyReq.getUserId(), RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getTimeout())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("每天仅可提现一次");
|
|
|
+ }
|
|
|
+ Result result = commonApplyMoney(applyMoneyReq);
|
|
|
+ if (result.isFlag()) {
|
|
|
+ redisService.set(key, applyMoneyReq.getUserId(), RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getTimeout());
|
|
|
+ } else {
|
|
|
+ redisService.del(key);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -209,7 +222,17 @@ public class TransferFuncServiceImpl implements TransferFuncService {
|
|
|
@Override
|
|
|
public Result<String> subApplyMoney(ApplyMoneyReq applyMoneyReq) throws Exception {
|
|
|
applyMoneyReq.setMType(DistributeMoneyApply.MType.sub);
|
|
|
- return commonApplyMoney(applyMoneyReq);
|
|
|
+ String key = String.format(RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getName(), DateTime.now().toDateStr(), applyMoneyReq.getMType(), applyMoneyReq.getUserId());
|
|
|
+ if (!redisService.setNx(key, applyMoneyReq.getUserId(), RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getTimeout())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("每天仅可提现一次");
|
|
|
+ }
|
|
|
+ Result result = commonApplyMoney(applyMoneyReq);
|
|
|
+ if (result.isFlag()) {
|
|
|
+ redisService.set(key, applyMoneyReq.getUserId(), RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getTimeout());
|
|
|
+ } else {
|
|
|
+ redisService.del(key);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
private AlipayRequest aliPayTransferAccountsRequest(String donNo, String account, String name, BigDecimal money, String remark) {
|