Commit 95a08bcd authored by liwenbin's avatar liwenbin

通知业务流系统订单状态增加下次操作时间

parent 7e0f8ccc
......@@ -71,13 +71,14 @@ public class ConsumerConfig implements RabbitListenerConfigurer {
JSONObject jo = JSONObject.parseObject(ms);
String noticeType = jo.getString("noticeType");
if(FundingResult.REJECT.getCode().equals(noticeType)
// || FundingResult.HANG_UP.getCode().equals(noticeType)
|| FundingResult.HANG_UP.getCode().equals(noticeType)
|| FundingResult.CANCEL_LOAN.getCode().equals(noticeType)
|| FundingResult.FUAD_ASSIGN_SUCC.getCode().equals(noticeType)){
log.info("资金路由有效MQ消息接收, 消息内容 : {} ",ms);
String applyNo = jo.getJSONObject("data").getString("applyNo");
String nextOperateDate = getNextOperateDate(jo, noticeType);
iAidFundRouteRecordService.fundingResultNotity(applyNo,FundingResult.fromCode(noticeType));
distributeService.receiveFundingResult(applyNo, FundingResult.fromCode(noticeType));
distributeService.receiveFundingResult(applyNo, FundingResult.fromCode(noticeType), nextOperateDate);
log.info("资金路由有效MQ消息处理结束, bizNo : {} ,noticeType : {} , 耗时 : {} ",applyNo,noticeType,stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
}
// 采用手动应答模式, 手动确认应答更为安全稳定
......@@ -95,9 +96,21 @@ public class ConsumerConfig implements RabbitListenerConfigurer {
}
/**
* 获取下次可操作之间, 只有拒绝才有
* @param jo
* @return
*/
private String getNextOperateDate(JSONObject jo, String noticeType) {
try {
if (FundingResult.REJECT.getCode().equals(noticeType)) {
return jo.getJSONObject("extraData").getString("nextOperateDate");
}
return null;
} catch (Exception e) {
log.error("资金路由结果消息解析下次可操作时间异常!", e);
return null;
}
}
}
......@@ -27,5 +27,5 @@ public interface IAssetDistributeService {
* @param bizNo
* @param fundingResult
*/
public void receiveFundingResult(String bizNo, FundingResult fundingResult);
public void receiveFundingResult(String bizNo, FundingResult fundingResult, String nextOperateDate);
}
......@@ -206,13 +206,13 @@ public class AssetDistributeServiceImpl implements IAssetDistributeService{
* 接收fundingResult消息
*/
@Override
public void receiveFundingResult(String bizNo, FundingResult fundingResult) {
public void receiveFundingResult(String bizNo, FundingResult fundingResult, String nextOperateDate) {
try {
Stopwatch stopwatch = Stopwatch.createStarted();
// 1、更改分配记录状态
assetDistributeRecordService.updateAssetDistributeStatus(bizNo, fundingResult == FundingResult.FUAD_ASSIGN_SUCC ? StatusConstants.SUCCESS : StatusConstants.FAIL);
// 2、通知业务流系统
notifyService.notifyBusinessFlow(bizNo, fundingResult == FundingResult.FUAD_ASSIGN_SUCC ? StatusConstants.SUCCESS : StatusConstants.FAIL);
notifyService.notifyBusinessFlow(bizNo, fundingResult, nextOperateDate);
// 3、重新进行分发, 目前还没有,等接了助贷资金路由以后再增加
log.info("资产分发接收资金结果处理结束, bizNo : {}, fundingResult : {}, 耗时 : {}", bizNo, fundingResult.getCode(), stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
} catch (QGException qe) {
......
......@@ -2,6 +2,7 @@ package com.quantgroup.asset.distribution.service.notify;
import java.util.Map;
import com.quantgroup.asset.distribution.enums.funding.FundingResult;
import com.quantgroup.asset.distribution.model.form.AssetForm;
/**
......@@ -20,5 +21,5 @@ public interface INotifyService {
/**
* 通知业务流系统
*/
public void notifyBusinessFlow(String bizNo, Integer status);
public void notifyBusinessFlow(String bizNo, FundingResult fundResult, String nextOperateDate);
}
......@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.quantgroup.asset.distribution.enums.funding.FundingResult;
import com.quantgroup.asset.distribution.exception.QGException;
import com.quantgroup.asset.distribution.exception.QGExceptionType;
import com.quantgroup.asset.distribution.model.form.AssetForm;
......@@ -50,26 +51,45 @@ public class NotifyServiceImpl implements INotifyService{
}
@Override
public void notifyBusinessFlow(String bizNo, Integer status) {
public void notifyBusinessFlow(String bizNo, FundingResult fundingResult, String nextOperateDate) {
try {
if (isDebug) { return; }
log.info("通知业务流系统订单终态开始, bizNo : {}, status : {}", bizNo, status);
log.info("通知业务流系统订单终态开始, bizNo : {}, fundingResult : {}, nextOperateDate : {}", bizNo, fundingResult.name(), nextOperateDate);
String response = httpService.post(businessFlowURL + "/ex/inner/accept_info", new HashMap<String, String>(){{
put("applyNo", bizNo);
put("status", status + "");
put("status", getNotifyBusinessFlowStatusByFundingResult(fundingResult) + "");
put("type", "5");
put("auditValidTime", nextOperateDate);
}});
log.info("通知业务流系统订单终态结束, bizNo : {}, status : {}, response : {}", bizNo, status, response);
log.info("通知业务流系统订单终态结束, bizNo : {}, fundingResult : {}, nextOperateDate, response : {}", bizNo, fundingResult.name(), nextOperateDate, response);
JSONObject data = null;
if (StringUtils.isEmpty(response) || (data = JSON.parseObject(response)).getInteger("code") != 0) {
throw new QGException(QGExceptionType.NOTIFY_BUSINESS_FLOW_ERROR, bizNo, status);
throw new QGException(QGExceptionType.NOTIFY_BUSINESS_FLOW_ERROR, bizNo, fundingResult.name());
}
} catch (QGException qe) {
log.error("资产分发订单终态通知业务流系统出现错误, 错误信息 : {}, bizNo : {}, status : {}", qe.qgExceptionType.code + "->" + qe.detail, bizNo, status);
alarmService.dingtalkAlarm("Warn", "通知业务流系统订单终态出现错误", "错误信息 : " + qe.qgExceptionType.code + "->" + qe.detail + " , bizNo : " + bizNo + " , " + "status : " + status);
log.error("资产分发订单终态通知业务流系统出现错误, 错误信息 : {}, bizNo : {}, fundingResult : {}", qe.qgExceptionType.code + "->" + qe.detail, bizNo, fundingResult.name());
alarmService.dingtalkAlarm("Warn", "通知业务流系统订单终态出现错误", "错误信息 : " + qe.qgExceptionType.code + "->" + qe.detail + " , bizNo : " + bizNo + " , " + "status : " + fundingResult.name());
} catch (Exception e) {
log.error("资产分发订单终态通知业务流系统异常, bizNo : {}, status : {}", bizNo, status);
alarmService.dingtalkAlarm("Warn", "通知业务流系统订单终态异常", "bizNo : " + bizNo + " , " + "status : " + status);
log.error("资产分发订单终态通知业务流系统异常, bizNo : {}, fundingResult : {}", bizNo, fundingResult.name());
alarmService.dingtalkAlarm("Warn", "通知业务流系统订单终态异常", "bizNo : " + bizNo + " , " + "status : " + fundingResult.name());
}
}
/**
* @return
* @param fundingResult
*/
private int getNotifyBusinessFlowStatusByFundingResult(FundingResult fundingResult) {
if (fundingResult == FundingResult.FUAD_ASSIGN_SUCC) {
return 1;
} else if (fundingResult == FundingResult.REJECT) {
return 0;
} else if (fundingResult == FundingResult.CANCEL_LOAN) {
return 2;
} else if (fundingResult == FundingResult.HANG_UP) {
return 3;
} else {
return -1;
}
}
}
......@@ -19,6 +19,7 @@ import com.quantgroup.asset.distribution.AssetDistributionBootstrap;
import com.quantgroup.asset.distribution.constant.StatusConstants;
import com.quantgroup.asset.distribution.enums.funding.FundingResult;
import com.quantgroup.asset.distribution.model.entity.DistributeRecord;
import com.quantgroup.asset.distribution.service.asset.IAssetAttributeExtendConfigService;
import com.quantgroup.asset.distribution.service.distribute.IAssetDistributeRecordService;
import com.quantgroup.asset.distribution.service.distribute.IAssetDistributeService;
import com.quantgroup.asset.distribution.service.httpclient.IHttpService;
......@@ -37,6 +38,8 @@ public class DistributeTest {
private IHttpService httpService;
@Autowired
private IAssetDistributeService distributeService;
@Autowired
private IAssetAttributeExtendConfigService service;
@Test
public void testEn() {
......@@ -63,14 +66,15 @@ public class DistributeTest {
@Test
public void testHttp() {
String result = httpService.post("http://localhost:9050" + "/feature/get", new HashMap<String, String>(){{
put("uuid", "123213");
put("bizChannel", "123213");
put("bizNo", "1232131");
put("bizType", "123213131");
put("keys", "12321321");
put("method", "0");
}});
// String result = httpService.post("http://localhost:9050" + "/feature/get", new HashMap<String, String>(){{
// put("uuid", "123213");
// put("bizChannel", "123213");
// put("bizNo", "1232131");
// put("bizType", "123213131");
// put("keys", "12321321");
// put("method", "0");
// }});
service.clearAllExtendConfigCache();
}
@Test
......@@ -78,7 +82,7 @@ public class DistributeTest {
// AssetDistributeRecord record = assetDistributeRecordRepository.findByBizNoOrderByCreatedAtDescLimitOne("1231231231231");
// record.setAssetDistributeStatus(StatusConstants.SUCCESS);
// assetDistributeRecordRepository.save(record);
distributeService.receiveFundingResult("SP499997499085250626417877", FundingResult.FUAD_ASSIGN_SUCC);
distributeService.receiveFundingResult("SP499997499085250626417877", FundingResult.FUAD_ASSIGN_SUCC, System.currentTimeMillis() + "");
}
public static void main(String[] args) {
......
......@@ -7,6 +7,8 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import com.quantgroup.asset.distribution.AssetDistributionBootstrap;
import com.quantgroup.asset.distribution.enums.funding.FundingResult;
import com.quantgroup.asset.distribution.service.httpclient.IHttpService;
import com.quantgroup.asset.distribution.service.notify.INotifyService;
@RunWith(SpringRunner.class)
......@@ -15,9 +17,23 @@ public class NotifyTest {
@Autowired
private INotifyService notifyService;
@Autowired
private IHttpService httpService;
@Test
public void testBusinessFlow() {
notifyService.notifyBusinessFlow("SP527400898415178843596841", 0);
notifyService.notifyBusinessFlow("SP527400898415178843596841", FundingResult.REJECT, System.currentTimeMillis() + "");
}
@Test
public void test() {
httpService.get("https://www.baidu.com");
}
public static void main(String[] args) {
String a = "2019-11-12 01:20:30";
String b = "2019-11-12 01:20:30";
System.out.println(a.length());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment