Bläddra i källkod

Merge branch 'master' of lvjian/ccnet-wx-mp3.0 into master

吕健 5 månader sedan
förälder
incheckning
bcfefb1444

+ 6 - 7
src/main/java/com/emato/ccnet/wx/biz/req/order/csp/Ceb311SendDateRequet.java

@@ -8,7 +8,6 @@ import com.emato.ccnet.wx.dao.entity.ccnet.CusOrderGoods;
 import com.emato.ccnet.wx.dao.entity.ccnet.CusOrderStatus;
 import com.emato.ccnet.wx.dto.ccnetdto.OrderDto;
 import com.emato.ccnet.wx.dto.ccnetdto.OrderRequest;
-import com.emato.ccnet.wx.manager.result.Result;
 import com.emato.ccnet.wx.service.CusOrderGoodsService;
 import com.emato.ccnet.wx.service.CusOrderService;
 import com.emato.ccnet.wx.service.CusOrderStatusService;
@@ -17,7 +16,6 @@ import com.emato.ccnet.wx.util.OkHttpUtils;
 import com.emato.ccnet.wx.util.jackson.JacksonUtil;
 import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
 import okhttp3.Request;
 import okhttp3.RequestBody;
 import org.slf4j.Logger;
@@ -59,7 +57,7 @@ public class Ceb311SendDateRequet implements CebReqSendDate {
         //查找当前ccnet中的所有电子订单
         List<CusOrder> cusOrders = cusOrderService.findAllCusOrder();
         if(cusOrders == null){
-            String info = "查找当前ccnet中的所有电子订单失败";
+            String info = "未查询到待发送 csp 的电子订单";
             LOGGER.error("--- {}", info);
             return ResponseMessage.failed(info);
         }
@@ -105,7 +103,8 @@ public class Ceb311SendDateRequet implements CebReqSendDate {
 
             //发送CSP系统请求并获取响应信息
             String response = requestSubmit(sPara);
-            LOGGER.info("CSP的响应报文:" + response);
+            LOGGER.info("请求 CSP 电子订单响应报文:" + response);
+
             if(response == null){
                 failedList.add(cusOrder.getOrderNo());
                 String info = "发送请求并获取响应信息失败";
@@ -113,8 +112,6 @@ public class Ceb311SendDateRequet implements CebReqSendDate {
                 continue;
             }
 
-            LOGGER.info("response date:"+response);
-
             //解析响应报文并处理本地业务逻辑
             ResponseMessage responseDis = ceb311SendDateResponse.addResponse(response,cusOrder.getOrderSn());
             if(!ResponseMessage.isSuccess(responseDis)){
@@ -147,12 +144,14 @@ public class Ceb311SendDateRequet implements CebReqSendDate {
         String url = cus.getOrder().get("order-url");
         Request request = OkHttpUtils.buildRequest(url,requestBody);
 
+        LOGGER.info("请求 CSP 电子订单 url => 【{}】, 请求参数 => {}", url, JacksonUtil.toJson(sPara));
+
         // 同步访问,返回结果字符串
         String response = null;
         try {
             response = OkHttpUtils.post(request);
         } catch (IOException e) {
-            e.printStackTrace();
+            LOGGER.error("请求 CSP 电子订单异常: ", e);
         }
 
         return response;

+ 11 - 12
src/main/java/com/emato/ccnet/wx/biz/req/play/wx/WxplaySendDateRequet.java

@@ -55,7 +55,7 @@ public class WxplaySendDateRequet implements CebReqSendDate {
         //查找当前wm_ccnet中的所有支付订单
         List<WxPayDoc> wxPayDocs = wxPayDocService.findAllWxPayDoc();
         if(wxPayDocs == null){
-            String info = "查找当前wm_ccnet中的所有支付订单失败";
+            String info = "未查询到待发送 cuspay 的支付单数据";
             LOGGER.error("--- {}", info);
             return ResponseMessage.failed(info);
         }
@@ -63,7 +63,7 @@ public class WxplaySendDateRequet implements CebReqSendDate {
         //发送给第三方的请求回调
         ResponseMessage wxPaySumbit = buildRequest(wxPayDocs);
         if(!ResponseMessage.isSuccess(wxPaySumbit)){
-            String info = "查找当前ccnet中的所有电子订单失败";
+            String info = "发送 cuspay 的支付单数据失败";
             LOGGER.error("--- {}", info);
             return ResponseMessage.failed(info);
         }
@@ -94,22 +94,22 @@ public class WxplaySendDateRequet implements CebReqSendDate {
             Map<String,String> sPara = null;
             try {
                 sPara = buildRequestDate(wxPayDoc);
-                if(sPara == null){
+                if(sPara.isEmpty()){
                     failedList.add(wxPayDoc.getSubOrderNo());
-                    String info = "数据组装失败";
+                    String info = "请求 cuspay 数据组装失败";
                     LOGGER.error("--- {}", info);
                     continue;
                 }
             } catch (Exception e) {
                 failedList.add(wxPayDoc.getSubOrderNo());
-                String info = "数据组装失败";
-                LOGGER.error("--- {}", info);
+                LOGGER.error("--- 请求 cuspay 数据组装失败:", e);
                 continue;
             }
 
             //发送CSP系统请求并获取响应信息
             String response = requestSubmit(sPara);
-            LOGGER.info("WxPlay的响应报文:" + response);
+            LOGGER.info("cuspay 响应报文:" + response);
+
             if(response == null){
                 failedList.add(wxPayDoc.getSubOrderNo());
                 String info = "发送请求并获取响应信息失败";
@@ -139,8 +139,8 @@ public class WxplaySendDateRequet implements CebReqSendDate {
             sucList.add(wxPayDoc.getSubOrderNo());
         }
 
-        LOGGER.info("--- 【WMPlay】【成功】订单数:{}, 订单: {}", sucList.size(), Joiner.on(",").skipNulls().join(sucList.toArray()));
-        LOGGER.info("--- 【WMPlay】【失败】订单数:{}, 订单: {}", failedList.size(), Joiner.on(",").skipNulls().join(failedList.toArray()));
+        LOGGER.info("--- 【WxPaySend】【成功】订单数:{}, 订单: {}", sucList.size(), Joiner.on(",").skipNulls().join(sucList.toArray()));
+        LOGGER.info("--- 【WxPaySend】【失败】订单数:{}, 订单: {}", failedList.size(), Joiner.on(",").skipNulls().join(failedList.toArray()));
 
         wxplaySendDateAfter.afterSend(sucList,failedList);
 
@@ -159,14 +159,14 @@ public class WxplaySendDateRequet implements CebReqSendDate {
         //构建Request
         String url = ((Map<String, Object>) cus.getPlay().get("wx")).get("play-url").toString();
         Request request = OkHttpUtils.buildRequest(url,requestBody);
+        LOGGER.info("请求 cuspay 地址 url => 【{}】, 请求参数 => {}", url, JacksonUtil.toJson(sPara));
 
         // 同步访问,返回结果字符串
         String response = null;
         try {
             response = OkHttpUtils.post(request);
         } catch (IOException e) {
-            String info = "同步访问,返回结果字符串错误";
-            LOGGER.error("--- {}", info);
+            LOGGER.error("--- 请求 cuspay 发生异常: ", e);
             return null;
         }
 
@@ -212,7 +212,6 @@ public class WxplaySendDateRequet implements CebReqSendDate {
         list.add(wxPayDto);
         String requestData = JacksonUtil.toJson(list);
         sPara.put("data", requestData);
-        LOGGER.info("request Data :" + requestData);
         return sPara;
 
     }

+ 11 - 14
src/main/java/com/emato/ccnet/wx/biz/req/waybill/oms/Ceb511SendDateRequest.java

@@ -1,6 +1,5 @@
 package com.emato.ccnet.wx.biz.req.waybill.oms;
 
-import com.alibaba.fastjson.JSONObject;
 import com.emato.ccnet.wx.biz.CebReqSendDate;
 import com.emato.ccnet.wx.config.Cus;
 import com.emato.ccnet.wx.contants.CcnetContants;
@@ -26,13 +25,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
 
 import java.beans.BeanInfo;
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
 import java.io.IOException;
 import java.lang.reflect.Method;
-import java.math.BigDecimal;
 import java.util.*;
 
 @Component
@@ -67,8 +66,8 @@ public class Ceb511SendDateRequest implements CebReqSendDate{
     public ResponseMessage sendDate() {
         //查找当前ccnet中的所有电子订单
         List<CusWaybill> cusWaybills = cusWaybillService.findAllCusWaybill();
-        if(cusWaybills == null){
-            String info = "查找当前ccnet中的所有运单失败";
+        if(cusWaybills.isEmpty()){
+            String info = "未查询到发送 OMS 的订单数据";
             LOGGER.error("--- {}", info);
             return ResponseMessage.failed(info);
         }
@@ -76,7 +75,7 @@ public class Ceb511SendDateRequest implements CebReqSendDate{
         //发送给第三方的请求回调
         int orderSumbit = buildRequest(cusWaybills);
         if(orderSumbit != 1){
-            String info = "发送请求响应失败";
+            String info = "发送 OMS 请求响应失败";
             LOGGER.error("--- {}", info);
             return ResponseMessage.failed(info);
         }
@@ -105,18 +104,17 @@ public class Ceb511SendDateRequest implements CebReqSendDate{
 
             //构造请求oms的参数数值
             Map<String, String> sPara = buildCusWaybillMap(cusWaybill);
-            if(sPara == null){
+            if(CollectionUtils.isEmpty(sPara)){
                 failedList.add(cusWaybill.getMerchOrderId());
-                String info = "构造请求oms的参数数值失败";
+                String info = "构造请求 oms 的参数数值失败";
                 LOGGER.error("--- {}", info);
                 continue;
             }
 
             //发送请求并获取响应信息
             String response = requestSubmit(sPara, cusWaybill.getWsFlag());
-            LOGGER.info("oms的响应报文:" + response);
+            LOGGER.info("OMS 的响应报文:{}", response);
 
-            LOGGER.info("response date:"+response);
             //解析响应信息并处理
             ResponseMessage addRespone = ceb511SendDateResponse.addResponse(response,cusWaybill.getCusWaybillSn());
             if(!ResponseMessage.isSuccess(addRespone)){
@@ -153,14 +151,16 @@ public class Ceb511SendDateRequest implements CebReqSendDate{
         } else if (CcnetContants.wsFlag.item_10.getItem().equals(wsFlag)) {
             url = cus.getWaybill().get("shop-url");
         }
+
         Request request = OkHttpUtils.buildRequest(url, JacksonUtil.toJson(sPara));
-        LOGGER.info("oms的请求报文:" + request);
+        LOGGER.info("请求 OMS 下单地址 => 【{}】, 请求报文 => {}", url, JacksonUtil.toJson(sPara));
+
         // 同步访问,返回结果字符串
         String response = null;
         try {
             response = OkHttpUtils.post(request);
         } catch (IOException e) {
-            e.printStackTrace();
+            LOGGER.error("--- 请求 OMS 发生异常: ", e);
         }
 
         return response;
@@ -197,13 +197,10 @@ public class Ceb511SendDateRequest implements CebReqSendDate{
         sParaTemp.put("data",bondedStockMerchantOrderJson);
         sParaTemp.put("timestamp", timestamp);
         //生成要请求给oms秘钥
-//        String sign = OmsSign.sign(sParaTemp,cus.getWaybill().get("secret-key"));
         LOGGER.info("md5混淆码参数:" + merchantSecret.getMd5Salt());
         String sign = OmsSign.sign(sParaTemp,merchantSecret.getMd5Salt());
         sParaTemp.put("sign", sign);
 
-
-        LOGGER.info("oms的请求报文:merchId参数:" + cusWaybill.getMerchSn()+"sign参数:"+sign+"data参数:"+bondedStockMerchantOrderJson+"timestamp参数:"+timestamp);
         return sParaTemp;
     }
 

+ 1 - 1
src/main/java/com/emato/ccnet/wx/service/impl/CusOrderServiceImpl.java

@@ -202,7 +202,7 @@ public class CusOrderServiceImpl implements CusOrderService {
             }
 
         }catch (Exception e){
-            e.printStackTrace();
+            logger.error("CusOrderServiceImpl.addCusOrder() 电子订单初始化异常 => ", e);
             return 0;
 
         }