zhuyiyi 9 months ago
parent
commit
54343112ed
3 changed files with 54 additions and 13 deletions
  1. 17 5
      SiteCore/Handler/sync.order.cs
  2. 3 5
      SiteCore/taobao/commonHelper.cs
  3. 34 3
      SiteCore/taobao/dataHelper.cs

+ 17 - 5
SiteCore/Handler/sync.order.cs

@@ -53,7 +53,6 @@ namespace SiteCore.Handler
 
             string poscode = CurrentUser.UserPost.Post.Code;
             DataStruct dStruct = GetPostStruct();
-
             //apiHelper.Api_SyncOrderByTime("598825");
             //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
             //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
@@ -676,6 +675,7 @@ namespace SiteCore.Handler
                     entity.IsSample = 0;
                     entity.IsXianHuo = 0;
                     entity.isDianziOrder = 0;
+                    entity.DispatchSort = 0;
                     entity.FinishPlaceTime = null;
 
                     entity.Update();
@@ -3834,12 +3834,20 @@ namespace SiteCore.Handler
                         returnTag = 1;
                     }
 
-
+                    int toType = GetPostInt("totype");
+                    string fromType = "3";
+                    if (entity.OrderState < 5)
+                    {
+                        fromType = "3";
+                    }
+                    else
+                    {
+                        fromType = "4";
+                    }
                     if (entity.IsXianHuo == 0)
                     {
                         if (returnTag == 2)
                         {
-                            int toType = GetPostInt("totype");
                             if (toType == 1)
                             {
                                 entity.OrderState = 0;
@@ -3884,6 +3892,11 @@ namespace SiteCore.Handler
                         apiVo.orderRemarks = entity.ReturnReason;
                         designHelper.API_WorkCore(apiVo);//rebutDesign
                     }
+                    CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
+                    if (ceErpTradeCellExtend.orderFrom == 30)
+                    {
+                        dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
+                    }
                     CeErpSukuraData.createInfo(entity.ctid, 5);
                     apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
                     LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
@@ -6913,7 +6926,7 @@ namespace SiteCore.Handler
                     entity.AfterSaleMemoType = GetPostString("MemoType");
                     if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
                     {
-                        entity.AfterSaleSupplierState = 2;
+                        //entity.AfterSaleSupplierState = 2;
                     }
                     string df = GetPostString("DeductFee");
                     if (df == "")
@@ -7553,7 +7566,6 @@ namespace SiteCore.Handler
                 {
                     entity.AfterSaleSupplierState = st;
                     entity.AfterSaleSupplierMemo = afmemo;
-                    entity.AfterSaleSupplierState = st;
 
                     if (st == 1)
                     {

+ 3 - 5
SiteCore/taobao/commonHelper.cs

@@ -117,10 +117,8 @@ namespace SiteCore
                             {
                                 entity.AfterSaleState = 4;
                                 entity.FinishAfterSaleTime = DateTime.Now;
-                                if (entity.AfterSaleResSupId > 0)
-                                {
-                                    entity.AfterSaleSupplierState = 1;
-                                }
+
+                                entity.AfterSaleSupplierState = 1;
                                 entity.Update();
                                 ApiVo apiVo = new ApiVo();
                                 apiVo.orderNumber = entity.ctid;
@@ -271,7 +269,7 @@ namespace SiteCore
                     //用昵称找之前的订单
                     string name = ceErpTrade.buyer_nick;
                     StringBuilder CeErpTradeSql = new StringBuilder();
-                    CeErpTradeSql.AppendFormat("select top 1 * from ce_erptrade where buyer_nick='{0}' and tid <> '{1}' order by created desc;", name, trade.tid);
+                    CeErpTradeSql.AppendFormat("select top 1 * from ce_erptrade o left join CE_ErpTradeCell c on c.tid=o.tid where o.buyer_nick='{0}' and o.tid <> '{1}' and c.SupplierId <> 35 order by created desc;", name, trade.tid);
                     DataSet data = DbHelper.DbConn.ExecuteDataset(CeErpTradeSql.ToString());
                     DataTable datatable = data.Tables[0];
 

+ 34 - 3
SiteCore/taobao/dataHelper.cs

@@ -30,6 +30,7 @@ using System.Security.Principal;
 using System.Text;
 using System.Threading.Tasks;
 using System.Web;
+using System.Web.Routing;
 using Utils.Serialization;
 using static SiteCore.taoObj.dataShopResponseVo;
 using static SiteCore.taoObj.dataSpuInfoResponseVo;
@@ -366,7 +367,7 @@ namespace SiteCore.Handler
             string post_url = "http://api.presales.lingtao8.com/open/order/generateSplitOrderUniqueNos/1";
             try
             {
-                string remoteInfo = httpSaleContent(post_url, "");
+                string remoteInfo = httpSaleContent(HttpMethod.Get, post_url, new Dictionary<string, string>());
                 saleOrderResponse dataTokenBean = JsonConvert.DeserializeObject<saleOrderResponse>(remoteInfo);
                 if ("200".Equals(dataTokenBean.code))
                 {
@@ -379,6 +380,32 @@ namespace SiteCore.Handler
             return orderSn;
         }
 
+        public static void api_orderBack(string orderNumber, string state, string content)
+        {
+            string post_url = "http://api.presales.lingtao8.com/open/order/orderProcessReturn";
+            //string post_url = "http://admin.lingtao.zmht888.com/prod-api/open/order/orderProcessReturn";
+            string remoteInfo = "";
+            string param = JsonConvert.SerializeObject(new
+            {
+                orderSplitNo = orderNumber,
+                errorStatus = state,
+                reason = content
+            });
+            Dictionary<string, string> map = new Dictionary<string, string>();
+            map.Add("orderSplitNo", orderNumber);
+            map.Add("errorStatus", state);
+            map.Add("reason", content);
+            try
+            {
+                remoteInfo = httpSaleContent(HttpMethod.Post, post_url, map);
+            }
+            catch (Exception ex)
+            {
+                XLog.SaveLog(0, "api_orderBack:" + ex.Message);
+            }
+        }
+
+
         public static string getToken()
         {
             //return "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiYXBpIl0sInNjb3BlIjpbInJlYWQiLCJ3cml0ZSJdLCJleHAiOjE3MzU5NjU0ODAsImF1dGhvcml0aWVzIjpbIm9wZW5hcGkiXSwianRpIjoiYjY4NTRhZjctZjNmMy00OTU0LTk4ZmUtZDRlZTE4ZDllNzQyIiwiY2xpZW50X2lkIjoieGNsaWVudCJ9.E6U0NVMZPcUypl4P7L5718J1X8UxSJg9R7vZX_oMkuEJ-yelNXuYwu7-eAi1JTgIJ0GuuviQu-KEAH-W7sHb7t-JJJc-wLPMsLKmpwQDG2EpiRK5hW5ZmyUgL8rPuTUawKVP5k8SGrN60sVyXA2zKm4ztEQ39EGudXnam1Lld2w";
@@ -943,17 +970,21 @@ namespace SiteCore.Handler
 
         static HttpClient client = new HttpClient();
 
-        private static string httpSaleContent(string post_url, string content)
+        private static string httpSaleContent(HttpMethod httpMethod, string post_url, Dictionary<string, string> map)
         {
             var request = new HttpRequestMessage
             {
-                Method = HttpMethod.Get,
+                Method = httpMethod,
                 RequestUri = new Uri(post_url),
                 Headers =
                 {
                     { "token", "Zk2ncXqH8hFyA6Rj"},
                 }
             };
+            if (map.Keys.Count > 0)
+            {
+                request.Content = new FormUrlEncodedContent(map);
+            }
 
             var task = Task.Run(() =>
             {