فهرست منبع

新增chy修改物流

zhuyiyi 2 ماه پیش
والد
کامیت
0c9346aae6
4فایلهای تغییر یافته به همراه254 افزوده شده و 7 حذف شده
  1. 27 6
      SiteCore/Handler/sync.order.cs
  2. 15 0
      SiteCore/taoObj/ChyTokenResponse.cs
  3. 5 1
      SiteCore/taobao/apiCaiYingTong.cs
  4. 207 0
      SiteCore/taobao/apichyHelper.cs

+ 27 - 6
SiteCore/Handler/sync.order.cs

@@ -63,7 +63,6 @@ namespace SiteCore.Handler
 
             string poscode = CurrentUser.UserPost.Post.Code;
             DataStruct dStruct = GetPostStruct();
-
             //string a = SecurityHelper.DecryptSymmetric("YDaPXIhsKgw=");
             //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\领淘文件名命名规范.xls");
             //apiHelper.Api_SyncOrderByTime("598825");
@@ -1199,7 +1198,29 @@ namespace SiteCore.Handler
                         entity.IsSF = 2;
                         sfTagMSg = "顺丰到付";
                     }
+                    if (entity.SupplierId == 19 && entity.OrderState == 6)
+                    {
+                        string deliveryWayName = "";
+                        if (sfTagstr == "撤销顺丰")
+                        {
+                            sfTagstr = "普通快递";
+                        }
+                        if (sfTagstr == "顺丰寄付")
+                        {
+                            sfTagstr = "顺丰特快寄付";
 
+                        }
+                        if (sfTagstr == "顺丰到付")
+                        {
+                            sfTagstr = "顺丰特快到付";
+                        }
+                        string result = apichyHelper.updateExpressMark(entity.OrderSn, sfTagstr);
+                        if ("修改失败".Equals(result))
+                        {
+                            returnErrorMsg("修改失败");
+                            return;
+                        }
+                    }
                     entity.Update();
                     apiVo = new ApiVo();
                     apiVo.orderNumber = entity.ctid;
@@ -5275,7 +5296,7 @@ namespace SiteCore.Handler
                         commonHelper.UpdateRelationOrder(entity.ctid);
                         commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
                         CeErpSukuraData.createInfo(entity.ctid, 4);
-                        if (entity.SupplierId == 64 || entity.SupplierId == 80)
+                        if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
                         {
                             commonHelper.sendCytExpress(exinfo);
                         }
@@ -6286,7 +6307,7 @@ namespace SiteCore.Handler
                                     commonHelper.UpdateRelationOrder(entity.ctid);
                                     CeErpSukuraData.createInfo(ctid, 4);
                                     commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
-                                    if (entity.SupplierId == 64 || entity.SupplierId == 80)
+                                    if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
                                     {
                                         commonHelper.sendCytExpress(exinfo);
                                     }
@@ -6326,7 +6347,7 @@ namespace SiteCore.Handler
                                 exinfo.Create();
                                 commonHelper.UpdateRelationOrder(entity.ctid);
                                 CeErpSukuraData.createInfo(entity.ctid, 4);
-                                if (entity.SupplierId == 64 || entity.SupplierId == 80)
+                                if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
                                 {
                                     commonHelper.sendCytExpress(exinfo);
                                 }
@@ -6437,7 +6458,7 @@ namespace SiteCore.Handler
                                     commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
                                     CeErpSukuraData.createInfo(ctid, 4);
                                     commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
-                                    if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
+                                    if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80 || entity.SupplierId == 126)
                                     {
                                         commonHelper.sendCytExpress(exinfo);
                                     }
@@ -6545,7 +6566,7 @@ namespace SiteCore.Handler
                     exinfo.print_time = DateTime.Now;
                     exinfo.printUser = CurrentUser.UserName;
                     exinfo.Create();
-                    if (entity.SupplierId == 64 || entity.SupplierId == 80)
+                    if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
                     {
                         commonHelper.sendCytExpress(exinfo);
                     }

+ 15 - 0
SiteCore/taoObj/ChyTokenResponse.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SiteCore.taoObj
+{
+    public class ChyTokenResponse
+    {
+        public string accessToken { get; set; }
+
+        public int expiresIn { get; set; }
+    }
+}

+ 5 - 1
SiteCore/taobao/apiCaiYingTong.cs

@@ -517,6 +517,10 @@ namespace SiteCore.Handler
             {
                 ceErpTradeResponsible = CeErpTradeResponsible.GetByUserId(entity.ctid, 80, 1, 0);
             }
+            if (ceErpTradeResponsible == null)
+            {
+                ceErpTradeResponsible = CeErpTradeResponsible.GetByUserId(entity.ctid, 126, 1, 0);
+            }
             if (ceErpTradeResponsible != null)
             {
                 id = ceErpTradeResponsible.ID.ToString();
@@ -613,7 +617,7 @@ namespace SiteCore.Handler
                 returnErrorMsg("查无订单!");
                 return;
             }
-            if (ceErpTradeCell.SupplierId != 64)
+            if (ceErpTradeCell.SupplierId != 64 && ceErpTradeCell.SupplierId != 80 && ceErpTradeCell.SupplierId != 126)
             {
                 returnErrorMsg("查无订单!");
                 return;

+ 207 - 0
SiteCore/taobao/apichyHelper.cs

@@ -0,0 +1,207 @@
+using BizCom;
+using Microsoft.SqlServer.Server;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using NHibernate.Cache;
+using SiteCore.Handler;
+using SiteCore.taoObj;
+using SiteCore.taoObj.WebApi;
+using SQLData;
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Data;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http.Headers;
+using System.Net.Http;
+using System.Reflection;
+using System.Security.Cryptography.Xml;
+using System.Security.Policy;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web;
+using static SiteCore.taoObj.Api_trade_info;
+using System.Text.RegularExpressions;
+using NPOI.OpenXmlFormats.Shared;
+
+namespace SiteCore.Handler
+{
+    public class apichyHelper : BaseHandler, IHttpHandler
+    {
+        public void ProcessRequest(HttpContext context)
+        {
+            if (UrlParmsCheck("t"))
+            {
+                String tname = GetString("t");
+                MethodInfo method;
+                Type type = this.GetType();
+                method = type.GetMethod(tname);
+                con = context;
+                if (method == null)
+                {
+                    conError("找不到对应方法,服务器返回错误");
+                    return;
+                }
+                successFlag = false;
+                context.Response.ContentType = "application/json";
+                context.Response.Headers.Set("Access-Control-Allow-Origin", "*");
+                try
+                {
+                    method.Invoke(this, null);
+                }
+                catch (Exception ex)
+                {
+                    conError("处理接口错误,服务器返回错误");
+                }
+                finally
+                {
+                    //AfterInvoke(methodName);
+                }
+                //if (!successFlag) returnErrorMsg("服务器返回错误");
+            }
+        }
+        /*        static string pUrl = "http://tst.ds.gw.chenghuiyin.com/ordering";
+                static string userName = "001008";
+                static string password = "123234";*/
+        static string pUrl = "http://ds.gw.chenghuiyin.com/ordering";
+        static string userName = "001008";
+        static string password = "lt666888";
+
+
+
+        public static string getToken()
+        {
+            //return "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsiYXBpIl0sInNjb3BlIjpbInJlYWQiLCJ3cml0ZSJdLCJleHAiOjE3MzU5NjU0ODAsImF1dGhvcml0aWVzIjpbIm9wZW5hcGkiXSwianRpIjoiYjY4NTRhZjctZjNmMy00OTU0LTk4ZmUtZDRlZTE4ZDllNzQyIiwiY2xpZW50X2lkIjoieGNsaWVudCJ9.E6U0NVMZPcUypl4P7L5718J1X8UxSJg9R7vZX_oMkuEJ-yelNXuYwu7-eAi1JTgIJ0GuuviQu-KEAH-W7sHb7t-JJJc-wLPMsLKmpwQDG2EpiRK5hW5ZmyUgL8rPuTUawKVP5k8SGrN60sVyXA2zKm4ztEQ39EGudXnam1Lld2w";
+            string token = "";
+            if (RedisHelper.HasKey("chy_token"))
+            {
+                token = RedisHelper.StringGet("chy_token").ToString();
+                {
+                    return token;
+                }
+            }
+            string post_url = pUrl + "/api/User/GetToken";
+            string remoteInfo = "";
+            try
+            {
+                remoteInfo = httpGetTokenContent(post_url, JsonConvert.SerializeObject(new { userName, password }));
+                if (!string.IsNullOrEmpty(remoteInfo))
+                {
+                    ChyTokenResponse chyToken = JsonConvert.DeserializeObject<ChyTokenResponse>(remoteInfo);
+                    token = chyToken.accessToken;
+                    TimeSpan timeSpan = TimeSpan.FromSeconds(chyToken.expiresIn - 5);
+                    RedisHelper.StringSet("chy_token", token, timeSpan);
+                }
+            }
+            catch (Exception ex)
+            {
+                XLog.SaveLog(0, ex.Message);
+            }
+            return token;
+        }
+
+        public static string updateExpressMark(string customerOrderId, string deliveryWayName)
+        {
+            string post_url = pUrl + "/api/ExpressAddress/UpdateExpressMark";
+            string remoteInfo = "";
+            string result = "修改成功";
+
+            try
+            {
+                remoteInfo = httpContent(post_url, JsonConvert.SerializeObject(new { customerOrderId, deliveryWayName }));
+                if (!string.IsNullOrEmpty(remoteInfo))
+                {
+                    result = "修改失败";
+                }
+            }
+            catch (Exception ex)
+            {
+                result = "修改失败";
+            }
+            return result;
+
+        }
+        static HttpClient client = new HttpClient();
+
+        private static string httpContent(string post_url, string content)
+        {
+            string token = getToken();
+            var request = new HttpRequestMessage
+            {
+                Method = HttpMethod.Post,
+                RequestUri = new Uri(post_url),
+                Headers =
+                {
+                    { "Authorization", "bearer " + token },
+                    { "ContentType", "application/json" },
+                },
+                Content = new StringContent(content)
+                {
+                    Headers =
+                    {
+                        ContentType = new MediaTypeHeaderValue("application/json")
+                    }
+                }
+            };
+            var task = Task.Run(() =>
+            {
+                try
+                {
+                    var response = client.SendAsync(request).Result;
+                    response.EnsureSuccessStatusCode();
+                    return response.Content.ReadAsStringAsync().Result;
+                }
+                catch (Exception e)
+                {
+                    XLog.SaveLog(0, "chyhttpContent:" + e.Message);
+                    return "找不到商品或已发货";
+                }
+
+
+            });
+
+            return task.Result;
+        }
+        private static string httpGetTokenContent(string post_url, string content)
+        {
+            var request = new HttpRequestMessage
+            {
+                Method = HttpMethod.Post,
+                RequestUri = new Uri(post_url),
+                Headers =
+                {
+                    { "ContentType", "application/json" },
+                },
+                Content = new StringContent(content)
+                {
+                    Headers =
+                    {
+                        ContentType = new MediaTypeHeaderValue("application/json")
+                    }
+                }
+            };
+            var task = Task.Run(() =>
+            {
+                try
+                {
+                    var response = client.SendAsync(request).Result;
+                    response.EnsureSuccessStatusCode();
+                    return response.Content.ReadAsStringAsync().Result;
+                }
+                catch (Exception e)
+                {
+                    XLog.SaveLog(0, "chyhttpContent:" + e.Message);
+                    return "";
+                }
+
+
+            });
+
+            return task.Result;
+        }
+
+    }
+}