瀏覽代碼

订单权限修改

wangxiaoming 5 年之前
父節點
當前提交
7b1091d5cb

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

@@ -18,7 +18,7 @@ public class  OrderSyncLog  implements  Serializable {
     private Integer syncPlatId;
     //类型:1;拉取订单  2.发货
     private Integer syncLogType;
-    //更新模式 1:定时任务 2:手动同步
+    //更新模式 1:定时任务 2:手动同步 3:同步发货
     private Integer syncLogMode;
     //同步总数量
     private Integer syncLogRecentNum;

+ 42 - 2
watero-rst-service/src/main/java/com/iamberry/rst/service/order/OrderSyncLogServiceImpl.java

@@ -225,11 +225,16 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
             // 因此时间不会及时刷新,考虑到系统等问题,因为时间调整每晚12点刷新拉取时间
             Calendar endCreateTimeCalendar = Calendar.getInstance();
             endCreateTimeCalendar.setTime(orderSyncPlatform.getSyncOrderLastTime());
+            endCreateTimeCalendar.add(Calendar.DATE, 1);//增加一天
+
+            //当前时间
             Calendar newDateCalendar = Calendar.getInstance();
-            if(endCreateTimeCalendar.get(Calendar.DAY_OF_MONTH) != newDateCalendar.get(Calendar.DAY_OF_MONTH)){
+
+            if((endCreateTimeCalendar.get(Calendar.DAY_OF_MONTH)) != newDateCalendar.get(Calendar.DAY_OF_MONTH)){
                 newDateCalendar.set(Calendar.HOUR_OF_DAY,0);
                 newDateCalendar.set(Calendar.MINUTE,0);
                 newDateCalendar.set(Calendar.SECOND,0);
+                newDateCalendar.add(Calendar.DATE, -1);
                 endCreateTime = newDateCalendar.getTime();
                 orderSyncPlatform.setSyncOrderLastTime(endCreateTime);
 
@@ -499,6 +504,9 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
      */
     @Override
     public boolean syncXYTOrderShip(Integer[] salesOrderIds) {
+        Integer successNum = 0,errorNum = 0;
+        StringBuffer allSb = new StringBuffer();
+        StringBuffer errorSb = new StringBuffer();
         for (int m = 0; m < salesOrderIds.length; m++) {
             Integer salesOrderId = salesOrderIds[m];
             SalesOrder salesOrder = salesOrderService.getSalesOrderByIdConcise(salesOrderId);
@@ -539,6 +547,8 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
                 i++;
             }
 
+            allSb.append(salesOrder.getSalesDealCode());
+
             //删除因为拆单增加的订单后缀
             String orderId  = salesOrder.getSalesDealCode();
             if(orderId.indexOf("-")>-1){
@@ -566,8 +576,32 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
                 shipSalesOrder.setSalesIsShip(1);   //同步物流状态到第三方平台 1:是
                 shipSalesOrder.setSalesId(salesOrderId);
                 salesOrderService.update(shipSalesOrder);
+                successNum++;
+            }else{
+                errorSb.append("发货失败交易号:" + salesOrder.getSalesDealCode() + ",失败原因:"+shipResultJson+";");
+                errorNum++;
             }
         }
+
+        //防止日志过多,所以在此控制,没有必要的日志,没有必要录入
+        if(errorNum > 0){
+            OrderSyncPlatform orderSyncPlatform =  getXYTPlatform();
+            OrderSyncLog orderSyncLog = new OrderSyncLog();
+            orderSyncLog.setSyncPlatId(orderSyncPlatform.getSyncPlatId());
+            orderSyncLog.setSyncLogType(2);
+            orderSyncLog.setSyncLogMode(3);
+            orderSyncLog.setSyncLogRecentNum(successNum+errorNum); //同步总数量
+            orderSyncLog.setSyncLogErrorNum(errorNum); //同步失败数量
+            orderSyncLog.setSyncLogMsg("发货订单交易号:"+ allSb.toString());   //备注
+            if(!errorSb.toString().equals("")){
+                String newErrorMsg = errorSb.toString();
+                if(newErrorMsg.length() > 5000){
+                    newErrorMsg = newErrorMsg.substring(0,4999);
+                }
+                orderSyncLog.setSyncLogErrorMsg(newErrorMsg);  //失败信息
+            }
+            orderSyncLogMapper.save(orderSyncLog);
+        }
         return true;
     }
 
@@ -836,12 +870,18 @@ public class OrderSyncLogServiceImpl implements OrderSyncLogService {
                         String shopIdStr = String.valueOf(shopId);
                         switch (platformId){
                             case "TMALL":{
-                                salesOrder.setSalesStoreId(86);     //天猫爱贝源旗舰店
+                                //因为淘宝天猫有两个所以需要区分
+                                if("100239736885".equals(shopIdStr) ){  //爱贝源旗舰店
+                                    salesOrder.setSalesStoreId(86);     //天猫爱贝源旗舰店
+                                }else if("100239736886".equals(shopIdStr)){ //爱贝源直销店
+                                    salesOrder.setSalesStoreId(3);     //爱贝源母婴直销店
+                                }
                                 salesOrder.setSalesCompanyId(1);    //深圳爱贝源
                                 salesOrder.setSalesPayType(5);//付款方式5:支付宝支付
                                 break;
                             }
                             case "JD":{
+                                //JD店铺id:100206182446
                                 salesOrder.setSalesStoreId(40);     //天猫爱贝源旗舰店
                                 salesOrder.setSalesCompanyId(1);    //深圳爱贝源
                                 salesOrder.setSalesPayType(5);//付款方式5:支付宝支付