|
|
@@ -19,6 +19,7 @@ import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.snowflake.Sequence;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.common.util.SmsUtil;
|
|
|
+import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.config.zfb.AliPayClientFactory;
|
|
|
import com.cyksj.config.zfb.ZfbProductCode;
|
|
|
import com.cyksj.dto.Result;
|
|
|
@@ -36,6 +37,7 @@ 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.sys.SysConfigService;
|
|
|
import com.cyksj.service.user.UserBenefitsService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -77,6 +79,8 @@ public class TransferFuncServiceImpl implements TransferFuncService {
|
|
|
|
|
|
private final RedisService redisService;
|
|
|
|
|
|
+ private final SysConfigService sysConfigService;
|
|
|
+
|
|
|
@Override
|
|
|
public Result distributeApply(ApplyMoneyReq applyMoneyReq) throws Exception {
|
|
|
applyMoneyReq.setMType(DistributeMoneyApply.MType.ds);
|
|
|
@@ -84,13 +88,18 @@ public class TransferFuncServiceImpl implements TransferFuncService {
|
|
|
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 {
|
|
|
+ try {
|
|
|
+ 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;
|
|
|
+ } catch (Exception e) {
|
|
|
redisService.del(key);
|
|
|
+ throw BusinessRuntimeException.getInstance(StringUtil.getErrorMsg(e));
|
|
|
}
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -100,13 +109,18 @@ public class TransferFuncServiceImpl implements TransferFuncService {
|
|
|
if (!redisService.setNx(key, applyMoneyReq.getUserId(), RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getTimeout())) {
|
|
|
throw BusinessRuntimeException.getInstance("每天仅可提现一次");
|
|
|
}
|
|
|
- Result result = yhShopApplyMoney(applyMoneyReq);
|
|
|
- if (result.isFlag()) {
|
|
|
- redisService.set(key, applyMoneyReq.getUserId(), RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getTimeout());
|
|
|
- } else {
|
|
|
+ try {
|
|
|
+ Result result = yhShopApplyMoney(applyMoneyReq);
|
|
|
+ if (result.isFlag()) {
|
|
|
+ redisService.set(key, applyMoneyReq.getUserId(), RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getTimeout());
|
|
|
+ } else {
|
|
|
+ redisService.del(key);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ } catch (Exception e) {
|
|
|
redisService.del(key);
|
|
|
+ throw BusinessRuntimeException.getInstance(StringUtil.getErrorMsg(e));
|
|
|
}
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -128,7 +142,7 @@ public class TransferFuncServiceImpl implements TransferFuncService {
|
|
|
name += "xx";
|
|
|
}
|
|
|
Integer scope = transferAccountsReq.getScope();
|
|
|
- AlipayClient alipayClient = AliPayClientFactory.getAlipayClient(ShopConfig.DISTRIBUTE_ZFB_DEFAULT_APP_ID);
|
|
|
+ AlipayClient alipayClient = AliPayClientFactory.getAlipayClient(sysConfigService.getDefaultShopConfigByType("zfb"));
|
|
|
|
|
|
AlipayRequest alipayRequest = aliPayTransferAccountsRequest(donNo, account, name, money, remark);
|
|
|
|