Commit 33c625ef by 王世昌

Merge branch 'feature/20210616-记录三方调用结果-wsc' into qa

# Conflicts:
#	order-application-service/src/main/java/cn/freemud/service/coupon/impl/PlatformCouponRelationServiceImpl.java
parents c6404fe7 5f07845b
...@@ -44,6 +44,7 @@ import com.freemud.sdk.api.assortment.order.response.order.QueryOrderByIdRespons ...@@ -44,6 +44,7 @@ import com.freemud.sdk.api.assortment.order.response.order.QueryOrderByIdRespons
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -70,6 +71,9 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService ...@@ -70,6 +71,9 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
private static final String ORDER_RESOURCE_PUSH_LOG_EXCHANGE = "order-resource-push-log-exchange"; private static final String ORDER_RESOURCE_PUSH_LOG_EXCHANGE = "order-resource-push-log-exchange";
private static final String ORDER_RESOURCE_PUSH_LOG_ROUTING_KEY = "order-resource-push-log-routing-key"; private static final String ORDER_RESOURCE_PUSH_LOG_ROUTING_KEY = "order-resource-push-log-routing-key";
@Value("${baffleOpen.verification.coupon:false}")
private Boolean baffleOpen=false;
@Override @Override
public BaseResponse verificationCoupon(List<QueryOrdersResponseDto.DataBean.OrderBean.AccountBean> accountList, QueryOrdersResponseDto.DataBean.OrderBean orderBean, CouponReqType couponReqType) { public BaseResponse verificationCoupon(List<QueryOrdersResponseDto.DataBean.OrderBean.AccountBean> accountList, QueryOrdersResponseDto.DataBean.OrderBean orderBean, CouponReqType couponReqType) {
if (accountList.size() > 1) { if (accountList.size() > 1) {
...@@ -157,28 +161,33 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService ...@@ -157,28 +161,33 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
//只 传递一次, 防止后续开发 多张优惠券使用情况 //只 传递一次, 防止后续开发 多张优惠券使用情况
couponCodeVerificationTransDto = null; couponCodeVerificationTransDto = null;
} }
boolean ok = false;
Exception lastException = null;
CouponCodeResponseDto couponCodeResponseDto = null;
try { try {
//71.券核销 //71.券核销
// todo 这循环有啥用-.-
for (int i = 2; i >= 0; i--) { for (int i = 2; i >= 0; i--) {
LogUtil.info("核销券码开始==", JSON.toJSONString(couponCodeVerificationDto), null); LogUtil.info("核销券码开始==", JSON.toJSONString(couponCodeVerificationDto), null);
CouponCodeResponseDto couponCodeResponseDto = couponOfflineClient.verification(couponCodeVerificationDto); couponCodeResponseDto = couponOfflineClient.verification(couponCodeVerificationDto);
LogUtil.info("核销券码返回==", JSON.toJSONString(couponCodeVerificationDto), couponCodeResponseDto); LogUtil.info("核销券码返回==", JSON.toJSONString(couponCodeVerificationDto), couponCodeResponseDto);
ThirdPartyLog.infoConvertJson(System.currentTimeMillis(), System.currentTimeMillis(), "/api", couponCodeVerificationDto, couponCodeResponseDto); ThirdPartyLog.infoConvertJson(System.currentTimeMillis(), System.currentTimeMillis(), "/api", couponCodeVerificationDto, couponCodeResponseDto);
if (Objects.equals(couponCodeResponseDto.getStatusCode(), ResponseResult.SUCCESS.getCode())) { if (Objects.nonNull(couponCodeResponseDto) && Objects.equals(couponCodeResponseDto.getStatusCode(), ResponseResult.SUCCESS.getCode())) {
ok = true;
LogUtil.info("CouponReverseServiceImpl", JSON.toJSONString(couponCodeVerificationDto), JSON.toJSONString(couponCodeResponseDto)); LogUtil.info("CouponReverseServiceImpl", JSON.toJSONString(couponCodeVerificationDto), JSON.toJSONString(couponCodeResponseDto));
break;
}
if (!Objects.equals(couponCodeResponseDto.getStatusCode(), ResponseResult.SUCCESS.getCode())) {
sendMessage(orderBean, LogThreadLocal.getTrackingNo(), couponCodeVerificationDto, couponCodeResponseDto);
emailAlertService.sendEmailAlert("核销券码失败", String.format("request:%s \r\nresponse:%s", JSONObject.toJSONString(couponCodeVerificationDto), JSONObject.toJSONString(couponCodeResponseDto)));
return ResponseUtil.error(ResponseResult.COUPON_VERIFICATION_FAIL);
} }
break;
} }
} catch (Exception ex) { } catch (Exception ex) {
sendMessage(orderBean, LogThreadLocal.getTrackingNo(), couponCodeVerificationDto, ex); lastException = ex;
emailAlertService.sendEmailAlert("核销券码异常", String.format("request:%s \r\nexception:%s", JSONObject.toJSONString(couponCodeVerificationDto), Throwables.getStackTraceAsString(ex)));
ErrorLog.printErrorLog("verification_error", "/api", couponCodeVerificationDto, ex); ErrorLog.printErrorLog("verification_error", "/api", couponCodeVerificationDto, ex);
}
if (!ok || Objects.equals(baffleOpen,true)){
sendMessage(orderBean, LogThreadLocal.getTrackingNo(), couponCodeVerificationDto, Objects.equals(baffleOpen, true) ? "模拟券核销失败" : couponCodeResponseDto);
}
if (!ok){
emailAlertService.sendEmailAlert("核销券码失败", String.format("request:%s \r\nresponse:%s", JSONObject.toJSONString(couponCodeVerificationDto), JSONObject.toJSONString(lastException == null ? couponCodeResponseDto : lastException)));
return ResponseUtil.error(ResponseResult.COUPON_VERIFICATION_FAIL); return ResponseUtil.error(ResponseResult.COUPON_VERIFICATION_FAIL);
} }
} }
...@@ -192,7 +201,7 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService ...@@ -192,7 +201,7 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
* *
* @param orderBean * @param orderBean
*/ */
private void sendMessage(QueryOrdersResponseDto.DataBean.OrderBean orderBean, String trackingNo, CouponCodeVerificationDto req, Object failObject) { private void sendMessage(QueryOrdersResponseDto.DataBean.OrderBean orderBean, String trackingNo, Object req, Object failObject) {
OrderResourcePushLogMsgDto dto = new OrderResourcePushLogMsgDto(); OrderResourcePushLogMsgDto dto = new OrderResourcePushLogMsgDto();
try { try {
String failureReasons; String failureReasons;
...@@ -220,7 +229,7 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService ...@@ -220,7 +229,7 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
MQMessage<OrderResourcePushLogMsgDto> message = new MQMessage<>(header, dto); MQMessage<OrderResourcePushLogMsgDto> message = new MQMessage<>(header, dto);
mqService.convertAndSend(ORDER_RESOURCE_PUSH_LOG_EXCHANGE, ORDER_RESOURCE_PUSH_LOG_ROUTING_KEY, message); mqService.convertAndSend(ORDER_RESOURCE_PUSH_LOG_EXCHANGE, ORDER_RESOURCE_PUSH_LOG_ROUTING_KEY, message);
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(trackingNo, "sendMessage error!!! routingKey = order-resource-push-log-routing-key", JSONObject.toJSONString(dto), null, e); LogUtil.error(trackingNo, "sendMessage COUPON_VERIFICATION error!!! routingKey = order-resource-push-log-routing-key", JSONObject.toJSONString(dto), null, e);
} }
} }
} }
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