feat: 回调超过次数后停止,整理代码
This commit is contained in:
parent
d456bfe4ff
commit
d1bcc7225f
@ -56,10 +56,6 @@ public class AccountController extends DefaultBaseController {
|
||||
private IAccountBankService iAccountBankService;
|
||||
@Autowired
|
||||
private IAccountRechargeService iAccountRechargeService;
|
||||
@Autowired
|
||||
private SysCallbackService sysCallbackService;
|
||||
@Autowired
|
||||
private SystemApiPathProperties systemApiPathProperties;
|
||||
|
||||
@ApiOperation(value = "支付宝支付成功后回调", notes = "支付宝支付成功后回调")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@ -92,15 +88,6 @@ public class AccountController extends DefaultBaseController {
|
||||
PayResultDTO payResultDTO = WXPay.queryPay(rechargeId);
|
||||
if (payResultDTO.getOrderStatus().equals("1") && payResultDTO.getMoney().equals(PayUtil.buiderMoney(dto.getRechargeMoney()))) {
|
||||
iAccountRechargeService.saveConfirmOnline(dto.getAccountRechargeId(), payResultDTO.getOrderId(), payResultDTO.getOrderSuccessTime());
|
||||
try {
|
||||
JSONObject selfData = JSON.parseObject(dto.getSelfData());
|
||||
if (selfData.containsKey("type") && StringUtils.equals("PROJ_PKG", selfData.getString("type"))) {
|
||||
LOG.debug("通知付打包款成功");
|
||||
sysCallbackService.save("项目打包付款成功", systemApiPathProperties.getCopyright() + "api/pay/pkg-pay-success/proj-id/" + selfData.getString("projId"), null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONObject json = new JSONObject();
|
||||
|
@ -3,6 +3,7 @@ package cn.com.tenlion.operator.enums;
|
||||
public enum SysCallbackStatusEnum {
|
||||
|
||||
SUCCESS,
|
||||
UN_SUCCESS
|
||||
UN_SUCCESS,
|
||||
STOP
|
||||
|
||||
}
|
||||
|
@ -13,12 +13,15 @@ import cn.com.tenlion.operator.service.account.IAccountService;
|
||||
import cn.com.tenlion.operator.service.accountbank.IAccountBankService;
|
||||
import cn.com.tenlion.operator.service.accountitem.IAccountItemService;
|
||||
import cn.com.tenlion.operator.service.remote.IRemoteWangGengInvoiceService;
|
||||
import cn.com.tenlion.operator.service.sys.callback.SysCallbackService;
|
||||
import cn.com.tenlion.operator.util.UserUtil;
|
||||
import cn.com.tenlion.operator.util.pay.ALiPay;
|
||||
import cn.com.tenlion.operator.util.pay.PayResultDTO;
|
||||
import cn.com.tenlion.operator.util.pay.PayUtil;
|
||||
import cn.com.tenlion.operator.util.pay.WXPay;
|
||||
import cn.com.tenlion.projectconfig.util.ProjectConfigUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
@ -72,6 +75,10 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA
|
||||
private IAccountItemService iAccountItemService;
|
||||
@Autowired
|
||||
private SystemApiPathProperties apiPathProperties;
|
||||
@Autowired
|
||||
private SysCallbackService sysCallbackService;
|
||||
@Autowired
|
||||
private SystemApiPathProperties systemApiPathProperties;
|
||||
|
||||
@Override
|
||||
public void save(AccountRechargeVO accountRechargeVO) {
|
||||
@ -561,8 +568,20 @@ public class AccountRechargeServiceImpl extends DefaultBaseService implements IA
|
||||
String accountItemId = iAccountItemService.saveReturnId(vo);
|
||||
// 2. 修改状态为2
|
||||
updateCheck(dto.getAccountRechargeId(), RechargeCheckEnum.RECHARGE_SUCCESS, "线上充值", accountItemId, orderId, successTime);
|
||||
if (!StringUtils.isBlank(dto.getSelfData())) {
|
||||
try {
|
||||
JSONObject selfData = JSON.parseObject(dto.getSelfData());
|
||||
if (selfData.containsKey("type") && StringUtils.equals("PROJ_PKG", selfData.getString("type"))) {
|
||||
LOG.debug("通知付打包款成功");
|
||||
sysCallbackService.save("项目打包付款成功", systemApiPathProperties.getCopyright() + "api/pay/pkg-pay-success/proj-id/" + selfData.getString("projId"), null);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
// 3. 调用第三方接口, 告知充值到账
|
||||
remoteWangGengInvoiceSerivceImpl.paySuccess(dto.getAccountId());
|
||||
sysCallbackService.save("项目充值到账", systemApiPathProperties.getCopyright() + "api/pay/recharge-success/user-id/" + dto.getAccountId(), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,14 @@ public class SysCallbackTask implements Job {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("回调异常: {}", e.getMessage(), e);
|
||||
sysCallbackService.update(sysCallbackPO.getCallbackId(), SysCallbackStatusEnum.UN_SUCCESS, sysCallbackPO.getFailCount() + 1);
|
||||
sysTaskService.runCallbackTask(sysCallbackPO.getCallbackId());
|
||||
int failCount = sysCallbackPO.getFailCount() + 1;
|
||||
// 失败次数超过20次,停止回调
|
||||
if (failCount < 20) {
|
||||
sysCallbackService.update(sysCallbackPO.getCallbackId(), SysCallbackStatusEnum.UN_SUCCESS, failCount);
|
||||
sysTaskService.runCallbackTask(sysCallbackPO.getCallbackId());
|
||||
} else {
|
||||
sysCallbackService.update(sysCallbackPO.getCallbackId(), SysCallbackStatusEnum.STOP, failCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user