فهرست منبع

小亚通接口调用

wangxiaoming 5 سال پیش
والد
کامیت
2853650c58
23فایلهای تغییر یافته به همراه971 افزوده شده و 226 حذف شده
  1. 1 1
      watero-rst-core/src/main/java/com.iamberry.rst.core/cm/SalesOrder.java
  2. 39 42
      watero-rst-core/src/main/java/com.iamberry.rst.core/order/OrderSyncLog.java
  3. 63 43
      watero-rst-core/src/main/java/com.iamberry.rst.core/order/OrderSyncPlatform.java
  4. 10 0
      watero-rst-core/src/main/java/com.iamberry.rst.core/order/ProductColor.java
  5. 33 0
      watero-rst-interface/src/main/java/com/iamberry/rst/faces/order/OrderSyncLogService.java
  6. 0 6
      watero-rst-interface/src/main/java/com/iamberry/rst/faces/order/OrderSyncPlatformService.java
  7. 632 3
      watero-rst-service/src/main/java/com/iamberry/rst/service/order/OrderSyncLogServiceImpl.java
  8. 4 9
      watero-rst-service/src/main/java/com/iamberry/rst/service/order/OrderSyncPlatformServiceImpl.java
  9. 7 0
      watero-rst-service/src/main/java/com/iamberry/rst/service/order/mapper/OrderSyncLogMapper.java
  10. 0 6
      watero-rst-service/src/main/java/com/iamberry/rst/service/order/mapper/OrderSyncPlatformMapper.java
  11. 53 36
      watero-rst-service/src/main/java/com/iamberry/rst/service/order/mapper/orderSyncLogMapper.xml
  12. 62 70
      watero-rst-service/src/main/java/com/iamberry/rst/service/order/mapper/orderSyncPlatformMapper.xml
  13. 3 1
      watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productColorMapper.xml
  14. 12 1
      watero-rst-web/src/main/java/com/iamberry/rst/utils/GenerateKeyUtil.java
  15. 1 0
      watero-rst-web/src/main/java/com/iamberry/rst/controllers/cm/AdminCustomerController.java
  16. 1 1
      watero-rst-web/src/main/java/com/iamberry/rst/controllers/cm/AdminDetectController.java
  17. 1 0
      watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AdminOrderController.java
  18. 37 0
      watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AdminOrderPlatformController.java
  19. 1 1
      watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AdminSalesOrderController.java
  20. 1 5
      watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AdminSalesOrderStatController.java
  21. 1 1
      watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/MallOrderController.java
  22. 1 0
      watero-rst-web/src/main/java/com/iamberry/rst/controllers/scm/AdminScmOrderController.java
  23. 8 0
      watero-rst-web/src/main/resources/watero-rst-orm.xml

+ 1 - 1
watero-rst-core/src/main/java/com.iamberry.rst.core/cm/SalesOrder.java

@@ -111,7 +111,7 @@ public class SalesOrder implements Serializable {
     private String salesBatchId;            //批次编号
     private Date batchCreateTime;           //批次创建时间
 
-    private Integer salesAddType;           //增加订单方式 1:手动增加 2:Excel导入 3:客诉增加订单
+    private Integer salesAddType;           //增加订单方式 1:手动增加 2:Excel导入 3:客诉增加订单 4.小亚通拉取订单
     private Integer salesAdminId;           //录入人id
     private String salesAdminName;           //录入人名称
 

+ 39 - 42
watero-rst-core/src/main/java/com.iamberry.rst.core/order/OrderSyncLog.java

@@ -1,19 +1,22 @@
 package com.iamberry.rst.core.order;
 
-import  java.util.Date;
-import  java.io.Serializable;
+import org.springframework.format.annotation.DateTimeFormat;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
 /**
- *  同步记录
- * @author Administrator
- * @Date 2019-12-17
+ * 订单同步日志
+ * Created by Administration on 2020-02-17
  */
-public class OrderSyncLog implements  Serializable{
-    private static final long serialVersionUID = 1819602099624248902L;
+public class  OrderSyncLog  implements  Serializable {
+    private static final long serialVersionUID = -5606308411189028751L;
     //同步时间id
     private Integer syncLogId;
     //
     private Integer syncPlatId;
-    //类型:1;拉取订单
+    //类型:1;拉取订单  2.发货
     private Integer syncLogType;
     //更新模式 1:定时任务 2:手动同步
     private Integer syncLogMode;
@@ -21,72 +24,66 @@ public class OrderSyncLog implements  Serializable{
     private Integer syncLogRecentNum;
     //同步失败数量
     private Integer syncLogErrorNum;
+    //备注
+    private String syncLogMsg;
     //错误信息
     private String syncLogErrorMsg;
-    //创建时间-同步时间'
+    //创建时间-同步时间
+    @DateTimeFormat( pattern = "yyyy-MM-dd HH:mm:ss" )
+    @JsonFormat ( pattern = "yyyy-MM-dd", timezone = "GMT+8" )
     private Date syncLogCreateDate;
-
     public Integer getSyncLogId(){
         return syncLogId;
     }
-
-    public void setSyncLogId(Integer  syncLogId){
-        this.syncLogId=syncLogId;
+    public void setSyncLogId(Integer syncLogId){
+        this.syncLogId = syncLogId;
     }
-
     public Integer getSyncPlatId(){
         return syncPlatId;
     }
-
-    public void setSyncPlatId(Integer  syncPlatId){
-        this.syncPlatId=syncPlatId;
+    public void setSyncPlatId(Integer syncPlatId){
+        this.syncPlatId = syncPlatId;
     }
-
     public Integer getSyncLogType(){
         return syncLogType;
     }
-
-    public void setSyncLogType(Integer  syncLogType){
-        this.syncLogType=syncLogType;
+    public void setSyncLogType(Integer syncLogType){
+        this.syncLogType = syncLogType;
     }
-
     public Integer getSyncLogMode(){
         return syncLogMode;
     }
-
-    public void setSyncLogMode(Integer  syncLogMode){
-        this.syncLogMode=syncLogMode;
+    public void setSyncLogMode(Integer syncLogMode){
+        this.syncLogMode = syncLogMode;
     }
-
     public Integer getSyncLogRecentNum(){
         return syncLogRecentNum;
     }
-
-    public void setSyncLogRecentNum(Integer  syncLogRecentNum){
-        this.syncLogRecentNum=syncLogRecentNum;
+    public void setSyncLogRecentNum(Integer syncLogRecentNum){
+        this.syncLogRecentNum = syncLogRecentNum;
     }
-
     public Integer getSyncLogErrorNum(){
         return syncLogErrorNum;
     }
-
-    public void setSyncLogErrorNum(Integer  syncLogErrorNum){
-        this.syncLogErrorNum=syncLogErrorNum;
+    public void setSyncLogErrorNum(Integer syncLogErrorNum){
+        this.syncLogErrorNum = syncLogErrorNum;
+    }
+    public String getSyncLogMsg(){
+        return syncLogMsg;
+    }
+    public void setSyncLogMsg(String syncLogMsg){
+        this.syncLogMsg = syncLogMsg;
     }
-
     public String getSyncLogErrorMsg(){
         return syncLogErrorMsg;
     }
-
-    public void setSyncLogErrorMsg(String  syncLogErrorMsg){
-        this.syncLogErrorMsg=syncLogErrorMsg;
+    public void setSyncLogErrorMsg(String syncLogErrorMsg){
+        this.syncLogErrorMsg = syncLogErrorMsg;
     }
-
     public Date getSyncLogCreateDate(){
         return syncLogCreateDate;
     }
-
-    public void setSyncLogCreateDate(Date  syncLogCreateDate){
-        this.syncLogCreateDate=syncLogCreateDate;
+    public void setSyncLogCreateDate(Date syncLogCreateDate){
+        this.syncLogCreateDate = syncLogCreateDate;
     }
-}
+}

+ 63 - 43
watero-rst-core/src/main/java/com.iamberry.rst.core/order/OrderSyncPlatform.java

@@ -1,19 +1,22 @@
 package com.iamberry.rst.core.order;
 
-import  java.util.Date;
-import  java.io.Serializable;
+import org.springframework.format.annotation.DateTimeFormat;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
 /**
- *  订单同步表类
- * @author Administrator
- * @Date 2019-12-17
+ * 订单同步
+ * Created by Administration on 2020-02-17
  */
-public class OrderSyncPlatform implements  Serializable{
-    private static final long serialVersionUID = 301138434190468157L;
+public class  OrderSyncPlatform  implements  Serializable {
+    private static final long serialVersionUID = 7012865196696151591L;
     //平台id
     private Integer syncPlatId;
     //平台名称
     private String syncPlatName;
-    //类型 1.自营其他平台商城 2.天猫
+    //类型 1:小亚通  2:微信商城
     private Integer syncPlatType;
     //AppKey
     private String syncPlatAppKey;
@@ -22,81 +25,98 @@ public class OrderSyncPlatform implements  Serializable{
     //access_token
     private String syncPlatAccessToken;
     //token_date
+    @DateTimeFormat( pattern = "yyyy-MM-dd HH:mm:ss" )
+    @JsonFormat ( pattern = "yyyy-MM-dd", timezone = "GMT+8" )
     private Date syncPlatTokenDate;
+    //最新一次拉取订单的时间
+    @DateTimeFormat( pattern = "yyyy-MM-dd HH:mm:ss" )
+    @JsonFormat ( pattern = "yyyy-MM-dd", timezone = "GMT+8" )
+    private Date syncOrderLastTime;
+    //其他字段 json格式(Map)
+    private String syncPlatOtherField;
+    //API接口
+    private String syncPlatApi;
     //状态 1:使用中 2:未使用
     private Integer syncPlatStatus;
-    //创建时间'
+    //创建时间
+    @DateTimeFormat ( pattern = "yyyy-MM-dd HH:mm:ss" )
+    @JsonFormat ( pattern = "yyyy-MM-dd", timezone = "GMT+8" )
     private Date syncPlatCreateDate;
-
     public Integer getSyncPlatId(){
         return syncPlatId;
     }
-
-    public void setSyncPlatId(Integer  syncPlatId){
-        this.syncPlatId=syncPlatId;
+    public void setSyncPlatId(Integer syncPlatId){
+        this.syncPlatId = syncPlatId;
     }
-
     public String getSyncPlatName(){
         return syncPlatName;
     }
-
-    public void setSyncPlatName(String  syncPlatName){
-        this.syncPlatName=syncPlatName;
+    public void setSyncPlatName(String syncPlatName){
+        this.syncPlatName = syncPlatName;
     }
-
     public Integer getSyncPlatType(){
         return syncPlatType;
     }
-
-    public void setSyncPlatType(Integer  syncPlatType){
-        this.syncPlatType=syncPlatType;
+    public void setSyncPlatType(Integer syncPlatType){
+        this.syncPlatType = syncPlatType;
     }
-
     public String getSyncPlatAppKey(){
         return syncPlatAppKey;
     }
-
-    public void setSyncPlatAppKey(String  syncPlatAppKey){
-        this.syncPlatAppKey=syncPlatAppKey;
+    public void setSyncPlatAppKey(String syncPlatAppKey){
+        this.syncPlatAppKey = syncPlatAppKey;
     }
-
     public String getSyncPlatAppSecret(){
         return syncPlatAppSecret;
     }
 
-    public void setSyncPlatAppSecret(String  syncPlatAppSecret){
-        this.syncPlatAppSecret=syncPlatAppSecret;
+    public String getSyncPlatOtherField() {
+        return syncPlatOtherField;
+    }
+
+    public void setSyncPlatOtherField(String syncPlatOtherField) {
+        this.syncPlatOtherField = syncPlatOtherField;
     }
 
+    public void setSyncPlatAppSecret(String syncPlatAppSecret){
+        this.syncPlatAppSecret = syncPlatAppSecret;
+    }
     public String getSyncPlatAccessToken(){
         return syncPlatAccessToken;
     }
-
-    public void setSyncPlatAccessToken(String  syncPlatAccessToken){
-        this.syncPlatAccessToken=syncPlatAccessToken;
+    public void setSyncPlatAccessToken(String syncPlatAccessToken){
+        this.syncPlatAccessToken = syncPlatAccessToken;
     }
-
     public Date getSyncPlatTokenDate(){
         return syncPlatTokenDate;
     }
-
-    public void setSyncPlatTokenDate(Date  syncPlatTokenDate){
-        this.syncPlatTokenDate=syncPlatTokenDate;
+    public void setSyncPlatTokenDate(Date syncPlatTokenDate){
+        this.syncPlatTokenDate = syncPlatTokenDate;
+    }
+    public String getSyncPlatApi(){
+        return syncPlatApi;
+    }
+    public void setSyncPlatApi(String syncPlatApi){
+        this.syncPlatApi = syncPlatApi;
     }
-
     public Integer getSyncPlatStatus(){
         return syncPlatStatus;
     }
-
-    public void setSyncPlatStatus(Integer  syncPlatStatus){
-        this.syncPlatStatus=syncPlatStatus;
+    public void setSyncPlatStatus(Integer syncPlatStatus){
+        this.syncPlatStatus = syncPlatStatus;
     }
-
     public Date getSyncPlatCreateDate(){
         return syncPlatCreateDate;
     }
+    public void setSyncPlatCreateDate(Date syncPlatCreateDate){
+        this.syncPlatCreateDate = syncPlatCreateDate;
+    }
+
+    public Date getSyncOrderLastTime() {
+        return syncOrderLastTime;
+    }
 
-    public void setSyncPlatCreateDate(Date  syncPlatCreateDate){
-        this.syncPlatCreateDate=syncPlatCreateDate;
+    public void setSyncOrderLastTime(Date syncOrderLastTime) {
+        this.syncOrderLastTime = syncOrderLastTime;
     }
-}
+}

+ 10 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/order/ProductColor.java

@@ -38,6 +38,7 @@ public class ProductColor implements Serializable {
     private Date colorUpdateTime;   //修改时间
 
     private String productName;     //产品名称
+    private String productAbbreviation;     //产品简称
 
     private Integer productType;    //产品类型
 
@@ -262,6 +263,15 @@ public class ProductColor implements Serializable {
         this.inventoryGoodProductNum = inventoryGoodProductNum;
     }
 
+
+    public String getProductAbbreviation() {
+        return productAbbreviation;
+    }
+
+    public void setProductAbbreviation(String productAbbreviation) {
+        this.productAbbreviation = productAbbreviation;
+    }
+
     @Override
     public String toString() {
         return "ProductColor{" +

+ 33 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/order/OrderSyncLogService.java

@@ -2,6 +2,7 @@ package com.iamberry.rst.faces.order;
 
 import com.iamberry.rst.core.order.OrderSyncLog;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -28,4 +29,36 @@ public interface OrderSyncLogService {
      * @return Integer
      */
     Integer  save(OrderSyncLog orderSyncLog);
+
+    /**
+     * 小亚通 - 拉取订单
+     * @param type
+     * @return Integer
+     */
+    Integer syncXYTOrder(Integer type,Date creatTime);
+
+    /**
+     * 小亚通 - 拉取订单
+     * @param type
+     * @return Integer
+     */
+    Integer syncXYTOrderOne(Integer type,String orderId);
+
+    /**
+     * 小亚通 - 发货判断,检测是否退货或者其他异常状态
+     * @param
+     * @return Integer
+     */
+    boolean syncXYTOrderShipInspec(String orderId);
+
+
+    /**
+     * 小亚通 - 发货判断,检测是否退货或者其他异常状态
+     * @param
+     * @return Integer
+     */
+    boolean syncXYTOrderShip(String orderId);
+
+
+
 }

+ 0 - 6
watero-rst-interface/src/main/java/com/iamberry/rst/faces/order/OrderSyncPlatformService.java

@@ -23,12 +23,6 @@ public interface OrderSyncPlatformService {
      */
     OrderSyncPlatform getSyncPlatformById(Integer  id);
     /**
-     * 增加数据
-     * @param  orderSyncPlatform
-     * @return Integer
-     */
-    Integer  save(OrderSyncPlatform orderSyncPlatform);
-    /**
      * 修改数据
      * @param  orderSyncPlatform
      * @return Integer

+ 632 - 3
watero-rst-service/src/main/java/com/iamberry/rst/service/order/OrderSyncLogServiceImpl.java

@@ -1,12 +1,32 @@
 package com.iamberry.rst.service.order;
 
-import com.alibaba.dubbo.config.annotation.Service;
-import com.iamberry.rst.core.order.OrderSyncLog;
+import com.iamberry.app.tool.util.MD5;
+import com.iamberry.rst.core.cm.SalesOrder;
+import com.iamberry.rst.core.cm.SalesOrderItem;
+import com.iamberry.rst.core.order.*;
+import com.iamberry.rst.faces.cm.SalesOrderService;
+import com.iamberry.rst.faces.order.OrderBatchService;
 import com.iamberry.rst.faces.order.OrderSyncLogService;
 import com.iamberry.rst.service.order.mapper.OrderSyncLogMapper;
+import com.iamberry.rst.service.order.mapper.OrderSyncPlatformMapper;
+import com.iamberry.rst.service.product.mapper.ProductColorMapper;
+import com.iamberry.rst.util.GenerateKeyUtil;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
-import java.util.List;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  *  同步记录
@@ -15,8 +35,31 @@ import java.util.List;
  */
 @Service
 public class OrderSyncLogServiceImpl implements OrderSyncLogService {
+    private static Logger logger = LoggerFactory.getLogger(OrderSyncLogServiceImpl.class);
     @Autowired
     private OrderSyncLogMapper orderSyncLogMapper;
+    @Autowired
+    private OrderBatchService orderBatchService;
+    @Autowired
+    private ProductColorMapper productColorMapper;
+    @Autowired
+    private SalesOrderService salesOrderService;
+    @Autowired
+    private OrderSyncPlatformMapper orderSyncPlatformMapper;
+    @Autowired
+    private GenerateKeyUtil generateKeyUtil ;
+
+    private static final SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD HH:MM:SS");
+    private static final int XYT_ID = 1;    //小亚通,平台id
+    private static OrderSyncPlatform XYT_PLATFORM = null;    //小亚通平台信息
+
+    private OrderSyncPlatform getXYTPlatform(){
+        if(XYT_PLATFORM == null){
+            XYT_PLATFORM = orderSyncPlatformMapper.getSyncPlatformById(XYT_ID);
+        }
+        return XYT_PLATFORM;
+    }
+
     /**
      * 获取集合
      * @param  orderSyncLog
@@ -26,6 +69,7 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
     public List<OrderSyncLog> getSyncLogList(OrderSyncLog orderSyncLog){
         return  orderSyncLogMapper.getSyncLogList(orderSyncLog);
     }
+
     /**
      * 查询单条数据
      * @param  id
@@ -35,6 +79,7 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
     public OrderSyncLog getSyncLogById(Integer  id){
         return  orderSyncLogMapper.getSyncLogById(id);
     }
+
     /**
      * 增加数据
      * @param  orderSyncLog
@@ -44,4 +89,588 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
     public  Integer  save(OrderSyncLog orderSyncLog){
         return  orderSyncLogMapper.save(orderSyncLog);
     }
+
+    /**
+     * 增加所有的订单
+     *  1:定时任务 2:手动同步
+     * @return
+     */
+    @Override
+    public Integer syncXYTOrder(Integer type,Date creatTime) {
+        OrderSyncPlatform orderSyncPlatform =  getXYTPlatform();
+        Map<String,Object> map = new HashMap<>();
+        if(creatTime == null){
+//            OrderSyncLog orderSyncLog = orderSyncLogMapper.getSyncLogLast(orderSyncPlatform.getSyncPlatId());
+//            if(orderSyncLog == null){
+//                logger.info("XYT拉取订单-调用接口失败-缺少开始时间");
+//                return 0;
+//            }
+            map.put("beginCreateTime", sdf.format(orderSyncPlatform.getSyncOrderLastTime()));//生成开始时间
+        }else{
+            map.put("beginCreateTime", sdf.format(creatTime));//生成开始时间
+        }
+        map.put("endCreateTime",sdf.format(new Date()));//生成结束时间
+//        map.put("receiverName","");//收件人姓名
+//        map.put("receiverMobile","");//收件人手机号码
+//        map.put("outOrderId","");//原始订单号
+//        map.put("orderId","");//系统订单号
+        String json = this.syncXYT("IOrderServce.query",map);
+
+        //添加订单
+        this.saveOrder(1,json);
+
+        return 1;
+    }
+
+    /**
+     * 单个订单拉取
+     * @param type
+     * @param orderId  小亚通订单账号
+     * @return
+     */
+    @Override
+    public Integer syncXYTOrderOne(Integer type, String orderId) {
+        String json = syncOrderOnce(orderId);
+        this.saveOrder(2,json);
+        return null;
+    }
+
+    /**
+     * 检测发货
+     * @param orderId
+     * @return
+     */
+    @Override
+    public boolean syncXYTOrderShipInspec(String orderId) {
+        String json = syncOrderOnce(orderId);
+        JSONObject jsonObj = new JSONObject(json);//转化为json格式
+        String resultMsg = jsonObj.getString("result_msg");
+        if(resultMsg.equals("success")){
+            //
+            return true;
+        }else{
+            logger.info("小亚通调用检测发货接口失败-拉取订单详情-失败原因:"+json);
+            return false;
+        }
+    }
+
+    /**
+     * 发货接口-小亚通
+     * @param orderId
+     * @return
+     */
+    @Override
+    public boolean syncXYTOrderShip(String orderId) {
+        //查询订单
+
+        Map<String,Object> map = new HashMap<>();
+        map.put("orderId",orderId);//原始订单号
+        map.put("itemIds","");//订单项ID,如果为null 表示整个订单只有1 个包裹,否则只是部分订单项
+        map.put("companyCode","");//物流公司编码
+        map.put("deliveryNo","");//物流单号
+        map.put("deliveryTime","");//发货时间
+        String shipResultJson = this.syncXYT("IOrderServce.query",map);
+        JSONObject jsonObj = new JSONObject(shipResultJson);//转化为json格式
+        String resultMsg = jsonObj.getString("result_msg");
+        if(resultMsg.equals("success")){
+            //
+            return true;
+        }else{
+            logger.info("小亚通调用发货接口失败-失败原因:"+shipResultJson);
+            return false;
+        }
+    }
+
+    /**
+     * 1:定时任务 2:手动同步
+     * @return
+     */
+    private boolean saveOrder(Integer type,String json){
+        OrderSyncPlatform orderSyncPlatform =  getXYTPlatform();
+        String batchId = "";    //批次编号
+//        JSONObject jsonObj = new JSONObject(json);//转化为json格式
+        JSONObject jsonObj = new JSONObject(Alljson);//转化为json格式
+        String resultMsg = jsonObj.getString("result_msg");
+        if(resultMsg.equals("success")){
+
+            // 用户新建批次,系统自动新建
+            if("".equals(batchId)){
+                batchId = generateKeyUtil.getSalesBatchIdSX();
+                OrderBatch ob = new OrderBatch();
+                ob.setBatchId(batchId);
+                ob.setBatchStatus(1);
+                if(orderBatchService.save(ob) < 1){
+                    throw new RuntimeException("XYT拉取订单-创建订单批次失败");
+                }
+            }
+
+            JSONObject dataObj = jsonObj.getJSONObject("data");    //数据
+            JSONArray beanListArray = dataObj.getJSONArray("beanList");
+            for(int i=0;i<beanListArray.length();i++){
+                JSONObject job = beanListArray.getJSONObject(i);
+                try{
+                    JSONObject consigneeObj = job.getJSONObject("consignee");   //用户信息
+                    JSONObject infoObj = job.getJSONObject("info");   //订单基本信息
+                    JSONArray itemsArray = job.getJSONArray("items");   //订单项基本信息
+                    JSONObject memoObj = job.getJSONObject("memo");   //备注信息
+
+                    //订单项状态:0 待支付;10 待成团;20 待发货;30 预售中;40 待审批;50 仓库代发货;60 已发货;70 已签收;80 已拒收;999 已作废
+                    Integer itemStatus = infoObj.getInt("itemStatus");
+                    if(itemStatus != 20){   //20 待发货
+                        continue;
+                    }
+
+                    SalesOrder salesOrder = new SalesOrder();
+                    salesOrder.setSalesOrderId(infoObj.getString("orderId"));  //小亚通订单编号
+                    salesOrder.setSalesDealCode(infoObj.getString("orderId"));  //小亚通订单编号
+
+                    //收货人信息
+                    salesOrder.setSalesAddressPostcode(consigneeObj.getString("receiverZip"));//收件人邮政编码
+                    salesOrder.setSalesAddressName(consigneeObj.getString("receiverName"));//收件人姓名
+                    salesOrder.setSalesAddressTel(consigneeObj.getString("receiverMobile"));//收件人电话
+                    //salesOrder.setSalesAddressDesc(consigneeObj.getString(""));//地址详情
+                    String receiverState = consigneeObj.getString("receiverState");//省
+                    String receiverCity = consigneeObj.getString("receiverCity");//市
+                    String receiverDistrict = consigneeObj.getString("receiverDistrict");//区
+                    String receiverAddress = consigneeObj.getString("receiverAddress");//地址
+                    salesOrder.setSalesAddressInfo(receiverState+" "+receiverCity+" "+receiverDistrict+" "+receiverAddress);//详细地址
+
+                    //平台
+                    String platformId = infoObj.getString("platformId");    //SELF- 自身  TMALL- 天猫  KDT- 有赞 LJSW-生活作风
+                    switch (platformId){
+                        case "SELF":{
+                            break;
+                        }
+                        case "TMALL":{
+                            salesOrder.setSalesStoreId(86);     //天猫爱贝源旗舰店
+                            salesOrder.setSalesCompanyId(1);    //深圳爱贝源
+                            salesOrder.setSalesPayType(5);//付款方式5:支付宝支付
+                            break;
+                        }
+                        case "KDT":{
+                            break;
+                        }
+                        case "LJSW":{
+                            break;
+                        }
+                        default:
+                            break;
+                    }
+
+                    //支付金额
+                    Double totalFee = infoObj.getDouble("totalFee");
+                    totalFee = totalFee*100;
+                    Integer amount = totalFee.intValue();
+                    salesOrder.setSalesLastMoney(amount);//本次支付金额
+                    salesOrder.setSalesPayMoney(amount);//已付金额-支付金额/折扣价
+                    salesOrder.setSalesAmount(amount);//订单总金额
+
+                    //优惠金额
+                    Double discountFee = infoObj.getDouble("discountFee");
+                    discountFee = discountFee*100;
+                    Integer discountFeeInt = discountFee.intValue();
+                    salesOrder.setSalesDiscountMoney(discountFeeInt);//优惠金额
+
+                    //支付时间
+                    String createTime = infoObj.getString("createTime");//创建时间
+                    salesOrder.setSalesSalesTime(sdf.parse(createTime));//订购时间
+                    salesOrder.setSalesPayTime(sdf.parse(createTime));//支付时间
+
+                    //备注
+                    String orderMemo = memoObj.getString("orderMemo"); //备注
+                    String buyerMemo = memoObj.getString("buyerMemo"); //买方备注
+                    String sellerMemo = memoObj.getString("sellerMemo"); //卖方备注
+                    salesOrder.setSalesUserRemark(orderMemo+"-"+buyerMemo);//用户备注
+                    salesOrder.setSalesAdminRemark(sellerMemo);//后台的备注--卖家备注
+
+                    //邮费
+                    Double postFee = memoObj.getDouble("postFee"); //邮费
+                    postFee = postFee*100;
+                    Integer postFeeInt = postFee.intValue();
+                    salesOrder.setSalesPostageCost(postFeeInt);//邮费成本
+                    salesOrder.setSalesShippingFee(postFeeInt);//邮费
+
+                    //批次
+                    salesOrder.setSalesBatchId(batchId);
+
+                    //默认
+                    salesOrder.setSalesWaitMoney(0);//待付金额
+                    salesOrder.setSalesType(1);//订单类型1:购买2:租赁
+                    salesOrder.setSalesOrderStatus(1);
+                    salesOrder.setSalesPayStatus(2);
+                    salesOrder.setIsSalesCustomerId(1);//是否绑定客诉(是否为售后订单)1:不是2:是
+                    salesOrder.setSalesAddType(4);//增加订单方式1:手动增加2:Excel导入3:客诉增加订单
+                    salesOrder.setSalesPledgeMoney(0);//押金金额
+                    salesOrder.setSalesRemainDeposit(0);
+                    salesOrder.setSalesWaitMoney(0);//待付金额
+
+                    //状态信息
+                    salesOrder.setSalesIsSend(0);//是否通知配货0:否1:是
+                    salesOrder.setSalesIsLocked(0);//是否锁定0:否1:是
+                    salesOrder.setSalesIsSeparate(0);//是否缺货0:否1:是
+                    salesOrder.setSalesStatus(0);  //确认状态0(未确认)
+                    salesOrder.setSalesShippingStatus(0);////发货状态0(未发货)1(已发货,即已扫描出库)3(备货中)4(收货)11(已通知配货,后加)
+                    salesOrder.setSalesDeliver(1);  //出库状态1:未出库2:已出库
+                    salesOrder.setSalesAdminId(1);   //录入人id
+
+                    List<SalesOrderItem> salesOrderItemList = new ArrayList<SalesOrderItem>();
+                    for(int j=0;j<itemsArray.length();j++){
+                        JSONObject item = itemsArray.getJSONObject(j);
+
+                        SalesOrderItem salesOrderItem = new SalesOrderItem();
+
+                        String extSkuId = memoObj.getString("extSkuId"); //sku - 69码
+
+                        ProductColor productColor = productColorMapper.getProductColorByBar(extSkuId);
+
+                        Integer num = memoObj.getInt("num"); //数量
+                        Double itemDiscountFee = memoObj.getDouble("discountFee"); //折扣费
+                        itemDiscountFee = itemDiscountFee*100;
+                        Integer itemDiscountFeeInt = itemDiscountFee.intValue();
+                        Integer itemTotal = itemDiscountFeeInt*num;
+
+                        salesOrderItem.setItemProductPrice(itemDiscountFeeInt); //产品市场价
+                        salesOrderItem.setItemProductDiscount(itemDiscountFeeInt); //产品折扣价
+                        salesOrderItem.setItemTotal(itemTotal);//小结
+
+                        //itemCost;//单个成本  itemCostTotal;//成本小结  确认操作计算
+
+                        salesOrderItem.setItemNum(num);    //产品数量
+                        salesOrderItem.setItemColorBar(productColor.getColorBar());   //colorBar
+                        salesOrderItem.setItemProductId(productColor.getColorProductId());//产品id
+                        salesOrderItem.setItemColorId(productColor.getColorId());
+                        salesOrderItem.setItemProductType(productColor.getProductType());
+                        salesOrderItem.setItemProductName(productColor.getProductName());
+                        salesOrderItem.setItemProductColor(productColor.getColorName());  //产品颜色
+                        salesOrderItem.setProductAbbreviation(productColor.getProductAbbreviation());   //商品简称
+                        salesOrderItem.setColorAbbreviation(productColor.getColorAbbreviation()); //所属产品简称
+                        salesOrderItem.setColorIsWeight(productColor.getColorIsWeight());//重量
+                        salesOrderItem.setColorIsMachine(productColor.getColorIsMachine());//是否是水机 1:水机 2;其它产品
+                        salesOrderItem.setItemIsSource(1);//产品来源 1:产品颜色表,2:配件表
+                        salesOrderItemList.add(salesOrderItem);
+                    }
+                    salesOrder.setSalesOrderItemList(salesOrderItemList);
+                    String[] detectIds = {};
+                    salesOrderService.addRstOrderinfo(salesOrder,new ArrayList<SalesOrder>(),detectIds);
+
+                    //添加操作跟踪记录
+                    OrderTracking orderTracking = new OrderTracking();
+                    orderTracking.setAdminId(1);    //默认用户爱贝源自动拉取订单
+                    orderTracking.setSalesDealCode(salesOrder.getSalesDealCode());
+                    orderTracking.setTrackingDesc("创建订单(小亚通拉取订单)");
+                    salesOrderService.addTracking(orderTracking);
+                }catch (Exception e){
+                    e.printStackTrace();
+                    logger.info("XYT拉取订单-添加订单错误-错误信息:"+e.getMessage());
+                }
+            }
+        }else{
+            OrderSyncLog osl = new OrderSyncLog();
+            osl.setSyncPlatId(orderSyncPlatform.getSyncPlatId());
+            osl.setSyncLogType(1);
+            osl.setSyncLogMode(type); //更新模式 1:定时任务 2:手动同步
+            osl.setSyncLogRecentNum(0); //同步总数量
+            osl.setSyncLogErrorNum(0); //同步失败数量
+            osl.setSyncLogErrorMsg(resultMsg);  //错误信息
+            osl.setSyncLogMsg("小亚通拉取订单失败");
+            orderSyncLogMapper.save(osl);
+            logger.info("XYT拉取订单-调用小亚通业务错误-错误信息:"+json);
+        }
+        return true;
+    }
+
+    /**
+     * 拉取单个订单,但是调用请走验证发货验证或者保存接口,此方法不公开
+     * @param orderId
+     * @return
+     */
+    private String syncOrderOnce(String orderId) {
+        Map<String,Object> map = new HashMap<>();
+        map.put("orderId",orderId);//原始订单号
+        String json = this.syncXYT("IOrderServce.query",map);
+        return json;
+    }
+
+    /**
+     * 分开组装小亚通api接口
+     * @param type
+     * @param map
+     * @return
+     */
+    private String syncXYT(String type, Map<String,Object> map) {
+        Map<String,Object> paramsMap = new HashMap<>();
+        String methodName = "";
+        switch (type){
+            case "allOrder":{ //订单查询
+                List<Map<String,Object>> conditionTypeList = new ArrayList<>();
+                for(String key:map.keySet()){//keySet获取map集合key的集合  然后在遍历key即可
+                    Map<String,Object> conditionTypeMap = new HashMap<>();
+                    conditionTypeMap.put(key,map.get(key).toString());
+                    conditionTypeList.add(conditionTypeMap);
+                }
+
+                Map<String,Object> condMap = new HashMap<>();
+                condMap.put("pageNumber",1);
+                condMap.put("pageSize",20);
+                condMap.put("conditionType",conditionTypeList);
+
+                paramsMap.put("cond","");
+                paramsMap.put("fullMode",false);   //fullMode Boolean 是 是否查询全部信息
+                paramsMap.put("includeArchive",false); //includeArchive Boolean 是 是否查询三个月前历史订单
+                methodName = "IOrderServce.query";
+                break;
+            }
+            case "oneOrder":{ //单个查询
+                List<Map<String,Object>> conditionTypeList = new ArrayList<>();
+                for(String key:map.keySet()){//keySet获取map集合key的集合  然后在遍历key即可
+                    Map<String,Object> conditionTypeMap = new HashMap<>();
+                    conditionTypeMap.put(key,map.get(key).toString());
+                    conditionTypeList.add(conditionTypeMap);
+                }
+
+                Map<String,Object> condMap = new HashMap<>();
+                condMap.put("pageNumber",1);
+                condMap.put("pageSize",20);
+                condMap.put("conditionType",conditionTypeList);
+
+
+                paramsMap.put("cond","");
+                paramsMap.put("fullMode",false);   //fullMode Boolean 是 是否查询全部信息
+                paramsMap.put("includeArchive",false); //includeArchive Boolean 是 是否查询三个月前历史订单
+                methodName = "IOrderServce.query";
+                break;
+            }
+            case "delivery":{   //订单发货
+
+                methodName = "delivery";
+                break;
+            }
+//            case "IConvertService.submitOrder":{   //提交订单
+//                break;
+//            }
+            default:{
+                return "";
+            }
+        }
+        OrderSyncPlatform orderSyncPlatform = getXYTPlatform();
+        JSONObject jsonObject = this.syncXYTFormat(methodName,paramsMap,orderSyncPlatform);
+        String rspJson = doPost(jsonObject,orderSyncPlatform.getSyncPlatApi());
+        return rspJson;
+    }
+
+    /**
+     *  组装api接口
+     * @return
+     */
+    private JSONObject syncXYTFormat(String apiCode, Map<String,Object> paramsMap, OrderSyncPlatform orderSyncPlatform){
+        JSONObject jsonObj = new JSONObject(paramsMap);//转化为json格式
+
+        String otherField = orderSyncPlatform.getSyncPlatOtherField();  //syncPlatOtherField
+        JSONObject jsonObject = new JSONObject(otherField);
+        String opId = (String) jsonObject.get("opId");
+
+        String timeStamp = sdf.format(new Date());    //-09-0522:22:32
+        String sign = String.format("%sapiCode%sappId%sopId%sparams%stimeStamp%s%s",
+                orderSyncPlatform.getSyncPlatAppSecret(),
+                apiCode,
+                orderSyncPlatform.getSyncPlatAppKey(),
+                opId,
+                jsonObj.toString(),
+                timeStamp,
+                orderSyncPlatform.getSyncPlatAppSecret()
+        );
+        sign = MD5.md5(sign);
+
+        JSONObject postData = new JSONObject();
+        postData.put("opId",opId);
+        postData.put("appId",orderSyncPlatform.getSyncPlatAppKey());
+        postData.put("sign",sign);
+        postData.put("apiCode",apiCode);
+        postData.put("timeStamp",timeStamp);
+        postData.put("params",paramsMap);
+        return postData;
+    }
+
+    /**
+     * post请求
+     *
+     * @param date
+     * @return
+     */
+    private static String doPost(JSONObject date,String url) {
+
+		HttpClient client = HttpClients.createDefault();
+//        DefaultHttpClient client = new DefaultHttpClient();
+
+        // 将接口地址和接口方法拼接起来
+        HttpPost post = new HttpPost(url);
+        JSONObject response = null;
+        String rsp= "";
+        try {
+            post.setEntity(new StringEntity(date.toString(),"UTF-8"));
+//			post.addHeader("Accept", "application/json, text/plain, */*");
+//			post.addHeader("Origin", "https://porder.shop.jd.com");
+//			post.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36");
+            post.addHeader("Content-Type", "application/json;charset=UTF-8");
+
+//			Cookie cookie = new Cookie("shshshfpa", "d9423d99-3936-1656-ce39-c4630942dec5-1544663920");
+//			cookie.setPath("/" + NameUtils.getConfig("ROOT_PATH"));
+//			cookie.setHttpOnly(true);
+//			cookie.setDomain(NameUtils.getConfig(".jd.com"));
+
+            HttpResponse res = client.execute(post);
+            if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                rsp = EntityUtils.toString(res.getEntity());
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return rsp;
+    }
+
+
+    static String Alljson = "{\n" +
+            "  \"result_msg\": \"success\",\n" +
+            "  \"data\": {\n" +
+            "    \"amount\": 302,\n" +
+            "    \"beanList\": [\n" +
+            "      {\n" +
+            "        \"consignee\": {\n" +
+            "          \"consigneeId\": 100004219907,\n" +
+            "          \"createOp\": 100000000001,\n" +
+            "          \"createTime\": \"2017-10-31 10:10:31\",\n" +
+            "          \"doneTime\": \"2017-10-31 10:11:04\",\n" +
+            "          \"orderId\": 100004540881,\n" +
+            "          \"receiverAddress\": \"A\",\n" +
+            "          \"receiverCity\": \"市辖区\",\n" +
+            "          \"receiverDistrict\": \"和平区\",\n" +
+            "          \"receiverMobile\": \"15757160000\",\n" +
+            "          \"receiverName\": \"CG\",\n" +
+            "          \"receiverPhone\": \"15757160000\",\n" +
+            "          \"receiverState\": \"天津市\",\n" +
+            "          \"receiverTown\": \"和平区\",\n" +
+            "          \"receiverZip\": \"\",\n" +
+            "          \"tenantId\": 100000000001\n" +
+            "        },\n" +
+            "        \"coupons\": [\n" +
+            "          \n" +
+            "        ],\n" +
+            "        \"info\": {\n" +
+            "          \"adjustFee\": 0,\n" +
+            "          \"buyerId\": \"74\",\n" +
+            "          \"buyerNick\": \"CG\",\n" +
+            "          \"createOp\": 100000000001,\n" +
+            "          \"createTime\": \"2017-10-31 10:10:31\",\n" +
+            "          \"discountFee\": 0,\n" +
+            "          \"doneTime\": \"2017-10-31 10:11:04\",\n" +
+            "          \"doneVersion\": 1,\n" +
+            "          \"extOrderId\": \"150941583170874\",\n" +
+            "          \"orderId\": 100004540881,\n" +
+            "          \"orderKind\": 0,\n" +
+            "          \"orderStatus\": 20,\n" +
+            "          \"orderStatusReason\": 0,\n" +
+            "          \"paidFee\": 1,\n" +
+            "          \"paidPoints\": 0,\n" +
+            "          \"payTime\": \"2017-10-31 10:10:41\",\n" +
+            "          \"payType\": \"N/A\",\n" +
+            "          \"platformId\": \"IMEIHAO\",\n" +
+            "          \"postFee\": 0,\n" +
+            "          \"revokeStatus\": 0,\n" +
+            "          \"shippingType\": \"express\",\n" +
+            "          \"shopId\": 100000041343,\n" +
+            "          \"skuBrief\": \"博冠丨 Just Fit V2 云智能健康秤\",\n" +
+            "          \"skuNum\": 1,\n" +
+            "          \"supplierTenantId\": 100000000001,\n" +
+            "          \"syncTime\": \"2017-10-31 10:00:29\",\n" +
+            "          \"tenantId\": 100000000001,\n" +
+            "          \"totalFee\": 16900,\n" +
+            "          \"updateTime\": \"2017-10-31 10:10:41\",\n" +
+            "          \"warrantyStatus\": 0\n" +
+            "        },\n" +
+            "        \"items\": [\n" +
+            "          {\n" +
+            "            \"adjustFee\": 0,\n" +
+            "            \"catalogNature\": 0,\n" +
+            "            \"createTime\": \"2017-10-31 10:10:31\",\n" +
+            "            \"discountFee\": 0,\n" +
+            "            \"doneTime\": \"2017-10-31 10:11:04\",\n" +
+            "            \"doneVersion\": 1,\n" +
+            "            \"extItemId\": \"15094158317087400\",\n" +
+            "            \"extNumIid\": \"107617669\",\n" +
+            "            \"extOrderId\": \"150941583170874\",\n" +
+            "            \"extSkuId\": \"MDMJ20170515ZNJKC\",\n" +
+            "            \"extSkuTitle\": \"博冠丨 Just Fit V2 云智能健康秤\",\n" +
+            "            \"imageUrl\": \"https://cdn.imeihao.shop/mall-imeihao/product/main-1507617610718spQCphtyyi_750_750.jpg\",\n" +
+            "            \"isSplit\": 0,\n" +
+            "            \"itemStatus\": 20,\n" +
+            "            \"num\": 1,\n" +
+            "            \"orderId\": 100004540881,\n" +
+            "            \"orderItemId\": 100005685925,\n" +
+            "            \"outerId\": \"A4939978A1DBB8D2CB1DC3495DA820E3\",\n" +
+            "            \"paidFee\": 1,\n" +
+            "            \"paidPoints\": 0,\n" +
+            "            \"platformId\": \"IMEIHAO\",\n" +
+            "            \"postFee\": 0,\n" +
+            "            \"price\": 1,\n" +
+            "            \"refundFee\": 0,\n" +
+            "            \"skuId\": 100001278198,\n" +
+            "            \"skuPoints\": 0,\n" +
+            "            \"skuSpecChars\": \"智能健康秤\",\n" +
+            "            \"skuTitle\": \"博冠丨 Just Fit V2 云智能健康秤\",\n" +
+            "            \"tenantId\": 100000000001,\n" +
+            "            \"totalFee\": 16900,\n" +
+            "            \"warrantyStatus\": 0\n" +
+            "          }\n" +
+            "        ],\n" +
+            "        \"logistics\": [\n" +
+            "          {\n" +
+            "            \"companyCode\": \"\",\n" +
+            "            \"companyName\": \"\",\n" +
+            "            \"createOp\": 100000000001,\n" +
+            "            \"createTime\": \"2017-10-31 10:10:31\",\n" +
+            "            \"deliveryNo\": \"\",\n" +
+            "            \"deliveryStatus\": 0,\n" +
+            "            \"deliveryTime\": \"2017-10-31 10:10:31\",\n" +
+            "            \"doneTime\": \"2017-10-31 10:11:04\",\n" +
+            "            \"logisticsId\": 100002780406,\n" +
+            "            \"orderId\": 100004540881,\n" +
+            "            \"tenantId\": 100000000001\n" +
+            "          }\n" +
+            "        ],\n" +
+            "        \"logisticsTrackings\": [\n" +
+            "          \n" +
+            "        ],\n" +
+            "        \"logs\": [\n" +
+            "          \n" +
+            "        ],\n" +
+            "        \"memo\": {\n" +
+            "          \"buyerMessage\": \"\",\n" +
+            "          \"createOp\": 100000000001,\n" +
+            "          \"createTime\": \"2017-10-31 10:10:31\",\n" +
+            "          \"doneTime\": \"2017-10-31 10:11:04\",\n" +
+            "          \"memoId\": 100004220937,\n" +
+            "          \"orderId\": 100004540881,\n" +
+            "          \"tenantId\": 100000000001\n" +
+            "        },\n" +
+            "        \"prints\": [\n" +
+            "          \n" +
+            "        ],\n" +
+            "        \"promotions\": [\n" +
+            "          \n" +
+            "        ],\n" +
+            "        \"specChar\": [\n" +
+            "          {\n" +
+            "            \"attributeValue\": \"智能健康秤\",\n" +
+            "            \"orderCharId\": 100006152526,\n" +
+            "            \"orderId\": 100004540881,\n" +
+            "            \"specId\": 0,\n" +
+            "            \"specName\": \"款式\",\n" +
+            "            \"tenantId\": 100000000001\n" +
+            "          }\n" +
+            "        ]\n" +
+            "      }\n" +
+            "    ]\n" +
+            "  },\n" +
+            "  \"result_code\": \"0\"\n" +
+            "}";
 }

+ 4 - 9
watero-rst-service/src/main/java/com/iamberry/rst/service/order/OrderSyncPlatformServiceImpl.java

@@ -15,8 +15,10 @@ import java.util.List;
  */
 @Service
 public class OrderSyncPlatformServiceImpl implements OrderSyncPlatformService {
+
     @Autowired
     private OrderSyncPlatformMapper orderSyncPlatformMapper;
+
     /**
      * 获取集合
      * @param  orderSyncPlatform
@@ -26,6 +28,7 @@ public class OrderSyncPlatformServiceImpl implements OrderSyncPlatformService {
     public List<OrderSyncPlatform> getSyncPlatformList(OrderSyncPlatform orderSyncPlatform){
         return  orderSyncPlatformMapper.getSyncPlatformList(orderSyncPlatform);
     }
+
     /**
      * 查询单条数据
      * @param  id
@@ -35,15 +38,7 @@ public class OrderSyncPlatformServiceImpl implements OrderSyncPlatformService {
     public OrderSyncPlatform getSyncPlatformById(Integer  id){
         return  orderSyncPlatformMapper.getSyncPlatformById(id);
     }
-    /**
-     * 增加数据
-     * @param  orderSyncPlatform
-     * @return Integer
-     */
-    @Override
-    public  Integer  save(OrderSyncPlatform orderSyncPlatform){
-        return  orderSyncPlatformMapper.save(orderSyncPlatform);
-    }
+
     /**
      * 修改数据
      * @param  orderSyncPlatform

+ 7 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/order/mapper/OrderSyncLogMapper.java

@@ -16,6 +16,13 @@ public interface OrderSyncLogMapper {
      * @return List
      */
     List<OrderSyncLog> getSyncLogList(OrderSyncLog orderSyncLog);
+
+    /**
+     * 获取集合- 最后一次拉取记录
+     * @return List
+     */
+    OrderSyncLog getSyncLogLast(Integer platId);
+
     /**
      * 查询单条数据
      * @param  id

+ 0 - 6
watero-rst-service/src/main/java/com/iamberry/rst/service/order/mapper/OrderSyncPlatformMapper.java

@@ -23,12 +23,6 @@ public interface OrderSyncPlatformMapper {
      */
     OrderSyncPlatform getSyncPlatformById(Integer  id);
     /**
-     * 增加数据
-     * @param  orderSyncPlatform
-     * @return Integer
-     */
-    Integer  save(OrderSyncPlatform orderSyncPlatform);
-    /**
      * 修改数据
      * @param  orderSyncPlatform
      * @return Integer

+ 53 - 36
watero-rst-service/src/main/java/com/iamberry/rst/service/order/mapper/orderSyncLogMapper.xml

@@ -1,23 +1,25 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.iamberry.rst.service.order.mapper.OrderSyncLogMapper">
-    <resultMap  id="BaseResultMap" type="OrderSyncLog" >
-        <result    column="sync_log_id"    property="syncLogId" />
-        <result    column="sync_plat_id"    property="syncPlatId" />
-        <result    column="sync_log_type"    property="syncLogType" />
-        <result    column="sync_log_mode"    property="syncLogMode" />
-        <result    column="sync_log_recent_num"    property="syncLogRecentNum" />
-        <result    column="sync_log_error_num"    property="syncLogErrorNum" />
-        <result    column="sync_log_error_msg"    property="syncLogErrorMsg" />
-        <result    column="sync_log_create_date"    property="syncLogCreateDate" />
+    <resultMap id="BaseResultMap" type="OrderSyncLog">
+        <result column="sync_log_id" property="syncLogId" />
+        <result column="sync_plat_id" property="syncPlatId" />
+        <result column="sync_log_type" property="syncLogType" />
+        <result column="sync_log_mode" property="syncLogMode" />
+        <result column="sync_log_recent_num" property="syncLogRecentNum" />
+        <result column="sync_log_error_num" property="syncLogErrorNum" />
+        <result column="sync_log_msg" property="syncLogMsg" />
+        <result column="sync_log_error_msg" property="syncLogErrorMsg" />
+        <result column="sync_log_create_date" property="syncLogCreateDate" />
     </resultMap>
-    <sql    id="Base_List" >
+    <sql id="Base_List">
         t.sync_log_id,
         t.sync_plat_id,
         t.sync_log_type,
         t.sync_log_mode,
         t.sync_log_recent_num,
         t.sync_log_error_num,
+        t.sync_log_msg,
         t.sync_log_error_msg,
         t.sync_log_create_date
     </sql>
@@ -26,45 +28,60 @@
         <include refid="Base_List" />
         from tb_rst_order_sync_log t
         <where>
-            <if test="syncLogId != null ">
+            <if test="syncLogId!= null ">
                 AND t.sync_log_id = #{syncLogId}
-            </if >
-            <if test="syncPlatId != null ">
+            </if>
+            <if test="syncPlatId!= null ">
                 AND t.sync_plat_id = #{syncPlatId}
-            </if >
-            <if test="syncLogType != null ">
+            </if>
+            <if test="syncLogType!= null ">
                 AND t.sync_log_type = #{syncLogType}
-            </if >
-            <if test="syncLogMode != null ">
+            </if>
+            <if test="syncLogMode!= null ">
                 AND t.sync_log_mode = #{syncLogMode}
-            </if >
+            </if>
         </where>
     </select>
-    <select id="getOrderSyncLogById" resultMap="BaseResultMap" parameterType="Integer" >
+    <select id="getSyncLogLast" resultMap="BaseResultMap" parameterType="Integer" >
         select
-        <include refid="Base_List" />
+          <include refid="Base_List" />
+        from tb_rst_order_sync_log t
+        where
+        t.sync_plat_id = #{syncPlatId}
+        ORDER BY t.sync_log_id DESC
+    </select>
+    <select id="getSyncLogById" resultMap="BaseResultMap" parameterType="OrderSyncLog" >
+        select
+          <include refid="Base_List" />
         from tb_rst_order_sync_log t
-        where t.sync_log_id= #{syncLogId}
+        where
+          t.sync_log_id = #{syncLogId}
     </select>
     <insert id="save" parameterType="OrderSyncLog" >
-        insert into
+      insert into
         tb_rst_order_sync_log
         (
-        sync_plat_id,
-        sync_log_type,
-        sync_log_mode,
-        sync_log_recent_num,
-        sync_log_error_num,
-        sync_log_error_msg
+            sync_log_id,
+            sync_plat_id,
+            sync_log_type,
+            sync_log_mode,
+            sync_log_recent_num,
+            sync_log_error_num,
+            sync_log_msg,
+            sync_log_error_msg,
+            sync_log_create_date
         )
-        values
+      values
         (
-        #{syncPlatId},
-        #{syncLogType},
-        #{syncLogMode},
-        #{syncLogRecentNum},
-        #{syncLogErrorNum},
-        #{syncLogErrorMsg}
+            #{syncLogId},
+            #{syncPlatId},
+            #{syncLogType},
+            #{syncLogMode},
+            #{syncLogRecentNum},
+            #{syncLogErrorNum},
+            #{syncLogMsg},
+            #{syncLogErrorMsg},
+            #{syncLogCreateDate}
         )
     </insert>
-</mapper>
+</mapper>

+ 62 - 70
watero-rst-service/src/main/java/com/iamberry/rst/service/order/mapper/orderSyncPlatformMapper.xml

@@ -1,18 +1,21 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.iamberry.rst.service.order.mapper.OrderSyncPlatformMapper">
-    <resultMap  id="BaseResultMap" type="OrderSyncPlatform" >
-        <result    column="sync_plat_id"    property="syncPlatId" />
-        <result    column="sync_plat_name"    property="syncPlatName" />
-        <result    column="sync_plat_type"    property="syncPlatType" />
-        <result    column="sync_plat_app_key"    property="syncPlatAppKey" />
-        <result    column="sync_plat_app_secret"    property="syncPlatAppSecret" />
-        <result    column="sync_plat_access_token"    property="syncPlatAccessToken" />
-        <result    column="sync_plat_token_date"    property="syncPlatTokenDate" />
-        <result    column="sync_plat_status"    property="syncPlatStatus" />
-        <result    column="sync_plat_create_date"    property="syncPlatCreateDate" />
+    <resultMap id="BaseResultMap" type="OrderSyncPlatform">
+        <result column="sync_plat_id" property="syncPlatId" />
+        <result column="sync_plat_name" property="syncPlatName" />
+        <result column="sync_plat_type" property="syncPlatType" />
+        <result column="sync_plat_app_key" property="syncPlatAppKey" />
+        <result column="sync_plat_app_secret" property="syncPlatAppSecret" />
+        <result column="sync_plat_access_token" property="syncPlatAccessToken" />
+        <result column="sync_plat_token_date" property="syncPlatTokenDate" />
+        <result column="sync_order_last_time" property="syncOrderLastTime" />
+        <result column="sync_plat_other_field" property="syncPlatOtherField" />
+        <result column="sync_plat_api" property="syncPlatApi" />
+        <result column="sync_plat_status" property="syncPlatStatus" />
+        <result column="sync_plat_create_date" property="syncPlatCreateDate" />
     </resultMap>
-    <sql    id="Base_List" >
+    <sql id="Base_List">
         t.sync_plat_id,
         t.sync_plat_name,
         t.sync_plat_type,
@@ -20,6 +23,9 @@
         t.sync_plat_app_secret,
         t.sync_plat_access_token,
         t.sync_plat_token_date,
+        t.sync_order_last_time,
+        t.sync_plat_other_field,
+        t.sync_plat_api,
         t.sync_plat_status,
         t.sync_plat_create_date
     </sql>
@@ -28,84 +34,70 @@
         <include refid="Base_List" />
         from tb_rst_order_sync_platform t
         <where>
-            <if test="syncPlatId != null ">
+            <if test="syncPlatId!= null ">
                 AND t.sync_plat_id = #{syncPlatId}
-            </if >
+            </if>
             <if test="syncPlatName != null and syncPlatName != ''">
-                AND t.sync_plat_name  like  CONCAT ('%',#{syncPlatName},'%')
-            </if >
-            <if test="syncPlatType != null ">
+                AND t.sync_plat_name like CONCAT ('%',#{syncPlatName},'%')
+            </if>
+            <if test="syncPlatType!= null ">
                 AND t.sync_plat_type = #{syncPlatType}
-            </if >
-            <if test="syncPlatAppKey != null and syncPlatAppKey != ''">
-                AND t.sync_plat_app_key = #{syncPlatAppKey}
-            </if >
-            <if test="syncPlatAppSecret != null and syncPlatAppSecret != ''">
-                AND t.sync_plat_app_secret = #{syncPlatAppSecret}
-            </if >
-            <if test="syncPlatAccessToken != null and syncPlatAccessToken != ''">
-                AND t.sync_plat_access_token = #{syncPlatAccessToken}
-            </if >
-            <if test="syncPlatStatus != null ">
+            </if>
+            <if test="syncPlatStatus!= null ">
                 AND t.sync_plat_status = #{syncPlatStatus}
-            </if >
+            </if>
         </where>
     </select>
-    <select id="getOrderSyncPlatformById" resultMap="BaseResultMap" parameterType="Integer" >
+    <select id="getSyncPlatformById" resultMap="BaseResultMap" parameterType="OrderSyncPlatform" >
         select
         <include refid="Base_List" />
         from tb_rst_order_sync_platform t
-        where t.sync_plat_id= #{syncPlatId}
+        where
+            t.sync_plat_id = #{syncPlatId}
     </select>
-    <insert id="save" parameterType="OrderSyncPlatform" >
-        insert into
-        tb_rst_order_sync_platform
-        (
-        sync_plat_name,
-        sync_plat_type,
-        sync_plat_app_key,
-        sync_plat_app_secret,
-        sync_plat_access_token,
-        sync_plat_token_date,
-        sync_plat_status
-        )
-        values
-        (
-        #{syncPlatName},
-        #{syncPlatType},
-        #{syncPlatAppKey},
-        #{syncPlatAppSecret},
-        #{syncPlatAccessToken},
-        #{syncPlatTokenDate},
-        #{syncPlatStatus}
-        )
-    </insert>
+
     <update id="update" parameterType="OrderSyncPlatform" >
         update
         tb_rst_order_sync_platform
-        <set >
-            <if test="syncPlatName != null and syncPlatName != ''">
+        <set>
+            <if test="syncPlatId != null">
+                sync_plat_id = #{syncPlatId},
+            </if>
+            <if test="syncPlatName != null and billItemProductName != ''">
                 sync_plat_name = #{syncPlatName},
-            </if >
-            <if test="syncPlatType != null ">
+            </if>
+            <if test="syncPlatType != null">
                 sync_plat_type = #{syncPlatType},
-            </if >
-            <if test="syncPlatAppKey != null and syncPlatAppKey != ''">
+            </if>
+            <if test="syncPlatAppKey != null and billItemProductName != ''">
                 sync_plat_app_key = #{syncPlatAppKey},
-            </if >
-            <if test="syncPlatAppSecret != null and syncPlatAppSecret != ''">
+            </if>
+            <if test="syncPlatAppSecret != null and billItemProductName != ''">
                 sync_plat_app_secret = #{syncPlatAppSecret},
-            </if >
-            <if test="syncPlatAccessToken != null and syncPlatAccessToken != ''">
+            </if>
+            <if test="syncPlatAccessToken != null and billItemProductName != ''">
                 sync_plat_access_token = #{syncPlatAccessToken},
-            </if >
-            <if test="syncPlatTokenDate != null and syncPlatTokenDate != ''">
+            </if>
+            <if test="syncPlatTokenDate != null and billItemProductName != ''">
                 sync_plat_token_date = #{syncPlatTokenDate},
-            </if >
-            <if test="syncPlatStatus != null ">
+            </if>
+            <if test="syncOrderLastTime != null and syncOrderLastTime != ''">
+                sync_order_last_time = #{syncOrderLastTime},
+            </if>
+            <if test="syncPlatOtherField != null and billItemProductName != ''">
+                sync_plat_other_field = #{syncPlatOtherField},
+            </if>
+            <if test="syncPlatApi != null and billItemProductName != ''">
+                sync_plat_api = #{syncPlatApi},
+            </if>
+            <if test="syncPlatStatus != null">
                 sync_plat_status = #{syncPlatStatus},
-            </if >
-        </set >
-        where sync_plat_id= #{syncPlatId}
+            </if>
+            <if test="syncPlatCreateDate != null and billItemProductName != ''">
+                sync_plat_create_date = #{syncPlatCreateDate}
+            </if>
+        </set>
+        where
+        sync_plat_id = #{syncPlatId}
     </update>
 </mapper>

+ 3 - 1
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productColorMapper.xml

@@ -70,8 +70,10 @@
     </select>
     <select id="getProductColorByBar" resultMap="BaseResultMap" parameterType="String" >
         select
-        <include refid="Base_List" />
+            <include refid="Base_List" />,
+            pi.product_abbreviation
         from tb_rst_product_color t
+        LEFT JOIN tb_rst_product_info pi ON t.color_product_id = pi.product_id
         where t.color_bar= #{colorBar}
     </select>
     <insert id="save" parameterType="ProductColor"  useGeneratedKeys="true"  keyProperty="colorId" >

+ 12 - 1
watero-rst-web/src/main/java/com/iamberry/rst/utils/GenerateKeyUtil.java

@@ -1,4 +1,4 @@
-package com.iamberry.rst.utils;
+package com.iamberry.rst.util;
 
 import com.iamberry.redis.RedisUtils;
 import com.iamberry.rst.core.cm.SalesOrder;
@@ -61,6 +61,8 @@ public class GenerateKeyUtil {
     private final static String SD_BATCH = "D";
     /*批量添加批次编号*/
     private final static String SC_BATCH = "C";
+    /*小亚通添加批次编号*/
+    private final static String SX_BATCH = "X";
     /*获取redis编号前缀*/
     private final static String SC_DETECT = "detect_";
 
@@ -138,6 +140,15 @@ public class GenerateKeyUtil {
     }
 
     /**
+     * 获取批次号 setSalesBatchId -- 小亚通添加
+     * @return
+     */
+    public String getSalesBatchIdSX(){
+        Integer number = getBatch();
+        return ("S"+ SX_BATCH + SDF_BATCH.format(new Date()) + String.format("%08d", number));
+    }
+
+    /**
      * 获取批次号 setSalesBatchId -- 批量导入
      * @return
      */

+ 1 - 0
watero-rst-web/src/main/java/com/iamberry/rst/controllers/cm/AdminCustomerController.java

@@ -23,6 +23,7 @@ import com.iamberry.rst.faces.order.LogisticsInfoService;
 import com.iamberry.rst.faces.product.ProductService;
 import com.iamberry.rst.faces.sms.SmsService;
 import com.iamberry.rst.faces.sys.SysService;
+import com.iamberry.rst.util.GenerateKeyUtil;
 import com.iamberry.rst.util.SmsConfig;
 import com.iamberry.rst.utils.*;
 import com.iamberry.wechat.tools.NameUtils;

+ 1 - 1
watero-rst-web/src/main/java/com/iamberry/rst/controllers/cm/AdminDetectController.java

@@ -20,7 +20,7 @@ import com.iamberry.rst.faces.product.ProductService;
 import com.iamberry.rst.service.cm.mapper.ComplaintQuestionInfoMapper;
 import com.iamberry.rst.service.sys.mapper.SysMapper;
 import com.iamberry.rst.utils.AdminUtils;
-import com.iamberry.rst.utils.GenerateKeyUtil;
+import com.iamberry.rst.util.GenerateKeyUtil;
 import com.iamberry.rst.utils.StitchAttrUtil;
 import com.iamberry.wechat.tools.ResponseJson;
 import org.apache.poi.hssf.usermodel.*;

+ 1 - 0
watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AdminOrderController.java

@@ -34,6 +34,7 @@ import com.iamberry.rst.faces.product.ProductService;
 import com.iamberry.rst.faces.sms.MessageService;
 import com.iamberry.rst.faces.sms.SmsService;
 import com.iamberry.rst.faces.sys.SysService;
+import com.iamberry.rst.util.GenerateKeyUtil;
 import com.iamberry.rst.utils.*;
 import com.iamberry.wechat.tools.DateTimeUtil;
 import com.iamberry.wechat.tools.ObjectExcelView;

+ 37 - 0
watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AdminOrderPlatformController.java

@@ -0,0 +1,37 @@
+package com.iamberry.rst.controllers.order;
+
+
+import com.iamberry.rst.faces.order.OrderSyncLogService;
+import com.iamberry.rst.faces.order.OrderSyncPlatformService;
+import com.iamberry.wechat.tools.ResponseJson;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * 同步订单
+ * Created by Administrator
+ */
+@Controller
+@RequestMapping("/admin/sync_order")
+public class AdminOrderPlatformController {
+    private static Logger logger = LoggerFactory.getLogger(AdminOrderPlatformController.class);
+
+    @Autowired
+    private OrderSyncPlatformService orderSyncPlatformService;
+    @Autowired
+    private OrderSyncLogService orderSyncLogService;
+
+    @ResponseBody
+    @RequestMapping("/pull")
+    public ResponseJson addOrder(HttpServletRequest request){
+        orderSyncLogService.syncXYTOrder(2,null);
+        return  new ResponseJson();
+    }
+
+}

+ 1 - 1
watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AdminSalesOrderController.java

@@ -27,7 +27,7 @@ import com.iamberry.rst.faces.product.ProductService;
 import com.iamberry.rst.faces.sms.SmsService;
 import com.iamberry.rst.utils.AdminUtils;
 import com.iamberry.rst.utils.ExcelUtil;
-import com.iamberry.rst.utils.GenerateKeyUtil;
+import com.iamberry.rst.util.GenerateKeyUtil;
 import com.iamberry.rst.utils.StitchAttrUtil;
 import com.iamberry.wechat.tools.DateTimeUtil;
 import com.iamberry.wechat.tools.ResponseJson;

+ 1 - 5
watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AdminSalesOrderStatController.java

@@ -3,16 +3,14 @@ package com.iamberry.rst.controllers.order;
 import com.iamberry.rst.core.cm.CompanyInfo;
 import com.iamberry.rst.core.cm.ProcMethod;
 import com.iamberry.rst.core.cm.SalesOrder;
-import com.iamberry.rst.core.cm.SalesOrderItem;
 import com.iamberry.rst.faces.cm.CompanyInfoService;
 import com.iamberry.rst.faces.cm.ProcMethodService;
 import com.iamberry.rst.faces.cm.SalesOrderService;
 import com.iamberry.rst.faces.cm.StoreInfoService;
-import com.iamberry.rst.faces.order.EfastOrderService;
 import com.iamberry.rst.faces.order.LogisticsInfoService;
 import com.iamberry.rst.faces.order.OrderBatchService;
 import com.iamberry.rst.faces.product.ProductService;
-import com.iamberry.rst.utils.GenerateKeyUtil;
+import com.iamberry.rst.util.GenerateKeyUtil;
 import com.iamberry.wechat.tools.ResponseJson;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.slf4j.Logger;
@@ -25,9 +23,7 @@ import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  * 订单信息统计

+ 1 - 1
watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/MallOrderController.java

@@ -9,7 +9,7 @@ import com.iamberry.rst.core.order.ProductColor;
 import com.iamberry.rst.faces.cm.SalesOrderService;
 import com.iamberry.rst.faces.cm.StoreInfoService;
 import com.iamberry.rst.faces.product.ProductService;
-import com.iamberry.rst.utils.GenerateKeyUtil;
+import com.iamberry.rst.util.GenerateKeyUtil;
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 import org.slf4j.Logger;

+ 1 - 0
watero-rst-web/src/main/java/com/iamberry/rst/controllers/scm/AdminScmOrderController.java

@@ -9,6 +9,7 @@ import com.iamberry.rst.core.scm.ScmOrderInfo;
 import com.iamberry.rst.core.scm.ScmOrderItem;
 import com.iamberry.rst.core.sys.Admin;
 import com.iamberry.rst.core.tools.LogisticsInfo;
+import com.iamberry.rst.util.GenerateKeyUtil;
 import com.iamberry.rst.utils.OrderUtils;
 import com.iamberry.rst.faces.cm.StoreShipService;
 import com.iamberry.rst.faces.order.LogisticsInfoService;

+ 8 - 0
watero-rst-web/src/main/resources/watero-rst-orm.xml

@@ -231,6 +231,11 @@
 		<!--订单新增-->
 		<typeAlias type="com.iamberry.rst.core.order.CargoInfo" alias="CargoInfo"/>
 		<typeAlias type="com.iamberry.rst.core.order.OrderStatisticsInfo" alias="OrderStatisticsInfo"/>
+
+		<!--订单拉取平台-->
+		<typeAlias type="com.iamberry.rst.core.order.OrderSyncLog" alias="OrderSyncLog"/>
+		<typeAlias type="com.iamberry.rst.core.order.OrderSyncPlatform" alias="OrderSyncPlatform"/>
+
 		<!-- 客诉新增-->
 		<typeAlias type="com.iamberry.rst.core.cm.TagInfo" alias="TagInfo"/>
 		<!-- 生成计划-->
@@ -316,6 +321,9 @@
 		<mapper resource="com/iamberry/rst/service/order/mapper/logisticsInfoMapper.xml"/>
 		<mapper resource="com/iamberry/rst/service/order/mapper/provincesLogisticsMapper.xml"/>
 		<mapper resource="com/iamberry/rst/service/order/mapper/orderWarehouseMapper.xml"/>
+		<!--订单拉取平台-->
+		<mapper resource="com/iamberry/rst/service/order/mapper/orderSyncLogMapper.xml"/>
+		<mapper resource="com/iamberry/rst/service/order/mapper/orderSyncPlatformMapper.xml"/>
 
 		<mapper resource="com/iamberry/rst/service/approval/mapper/applyPickItemMapper.xml"/>
 		<mapper resource="com/iamberry/rst/service/approval/mapper/applyPickMapper.xml"/>