|
@@ -1,11 +1,13 @@
|
|
|
package com.fire.customer.callback.service.impl;
|
|
|
|
|
|
|
|
|
+import com.fire.common.exception.BaseException;
|
|
|
import com.fire.customer.callback.data.DataPool;
|
|
|
import com.fire.customer.callback.dto.CallbackRequestContent;
|
|
|
import com.fire.customer.callback.dto.CallbackRequestMsgBody;
|
|
|
import com.fire.customer.callback.dto.CallbackRequestParam;
|
|
|
import com.fire.customer.callback.service.CallbackCustomerService;
|
|
|
+import com.fire.customer.callback.service.OrderUpdateService;
|
|
|
import com.fire.dto.FlowAppInfo;
|
|
|
import com.fire.dto.FlowOrderInfo;
|
|
|
import com.fire.param.HeaderDto;
|
|
@@ -17,6 +19,11 @@ import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
+import static com.fire.common.constants.RocketTags.CALLBACK_TAG;
|
|
|
+import static com.fire.dto.enums.OrderStatus.ORDER_FAIL;
|
|
|
+import static com.fire.dto.enums.OrderStatus.ORDER_SUCCESS;
|
|
|
|
|
|
/**
|
|
|
* 向客户回调
|
|
@@ -29,6 +36,8 @@ public class CallbackCustomerServiceImpl implements CallbackCustomerService {
|
|
|
|
|
|
@Resource
|
|
|
private RestTemplate restTemplate;
|
|
|
+ @Resource
|
|
|
+ private OrderUpdateService orderUpdateService;
|
|
|
|
|
|
@Override
|
|
|
public void callbackCustomer(FlowOrderInfo orderInfo) {
|
|
@@ -65,7 +74,18 @@ public class CallbackCustomerServiceImpl implements CallbackCustomerService {
|
|
|
String secretKey = DigestUtils.md5DigestAsHex(secretStr.getBytes(StandardCharsets.UTF_8));
|
|
|
header.setSecretKey(secretKey);
|
|
|
|
|
|
- restTemplate.postForObject(flowAppInfo.getCallbackUrl(), requestParam, String.class);
|
|
|
+ orderInfo.setCallbackTime(new Date());
|
|
|
+ try {
|
|
|
+ restTemplate.postForObject(flowAppInfo.getCallbackUrl(), requestParam, String.class);
|
|
|
+ orderInfo.setCallbackStatus(ORDER_SUCCESS.status());
|
|
|
+ orderUpdateService.updateOrder(orderInfo,CALLBACK_TAG);
|
|
|
+ } catch (Exception e) {
|
|
|
+ orderInfo.setCallbackStatus(ORDER_FAIL.status());
|
|
|
+ orderUpdateService.updateOrder(orderInfo,CALLBACK_TAG);
|
|
|
+ log.error("回调客户失败:", e);
|
|
|
+ throw new BaseException("回调失败");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|