Пример #1
0
        /// <summary>
        /// 根据第三方编号获取京东编号
        /// </summary>
        /// <returns></returns>
        public static string getJdDanhao(string thirdOrder)
        {
            string  jdPOrderId = null;
            string  token      = GetToken();
            string  data       = "token=" + token + "&thirdOrder=" + thirdOrder;
            string  url        = UrlBase + "order/selectJdOrderIdByThirdOrder";
            string  jsonstr    = WebRequestHelper.SendPostInfo(url, data);
            JObject objwlgs    = JObject.Parse(jsonstr);

            if (objwlgs["success"].ToString() == "True")
            {
                jdPOrderId = objwlgs["result"].ToString();
            }
            return(jdPOrderId);
        }
Пример #2
0
        /// <summary>
        /// 根据第三方编号判断是否是京东编号
        /// </summary>
        /// <returns></returns>
        public static bool IsCheckJdDanhao(string thirdOrder)
        {
            bool    flag    = false;
            string  token   = GetToken();
            string  data    = "token=" + token + "&thirdOrder=" + thirdOrder;
            string  url     = UrlBase + "order/selectJdOrderIdByThirdOrder";
            string  jsonstr = WebRequestHelper.SendPostInfo(url, data);
            JObject objwlgs = JObject.Parse(jsonstr);

            if (objwlgs["success"].ToString() == "True")
            {
                flag = true;
            }
            return(flag);
        }
Пример #3
0
        /// <summary>
        /// 京东取消未确认订单接口
        /// </summary>
        /// <returns></returns>
        public static bool OrderCancel(string jdOrderId)
        {
            bool    flag    = false;
            string  token   = GetToken();
            string  url     = UrlBase + "order/cancel";
            string  data    = "token=" + token + "&jdOrderId=" + jdOrderId;
            string  obj     = WebRequestHelper.SendPostInfo(url, data);
            JObject objwlgs = JObject.Parse(obj);

            if (objwlgs["result"].ToString() == "True")
            {
                flag = true;
            }
            return(flag);
        }
Пример #4
0
        /// <summary>
        /// 删除推送信息
        /// </summary>
        /// <returns></returns>
        public static bool DelMessage(string id)
        {
            bool    flag    = false;
            string  token   = GetToken();
            string  data    = "token=" + token + "&id=" + id;
            string  url     = UrlBase + "message/del";
            string  obj     = WebRequestHelper.SendPostInfo(url, data);
            JObject objwlgs = JObject.Parse(obj);

            if (objwlgs["success"].ToString() == "True")
            {
                flag = true;
            }
            return(flag);
        }
Пример #5
0
        /// <summary>
        /// 获取拆单的提示信息
        /// </summary>
        /// <returns></returns>
        public static string chidanMessage()
        {
            string  objson  = null;
            string  token   = GetToken();
            string  data    = "token=" + token + "&type=1";
            string  url     = UrlBase + "message/get";
            string  obj     = WebRequestHelper.SendPostInfo(url, data);
            JObject objwlgs = JObject.Parse(obj);

            if (objwlgs["success"].ToString() == "True")
            {
                objson = objwlgs["result"].ToString();
            }
            return(objson);
        }
Пример #6
0
        /// <summary>
        /// 确认预占库存接口
        /// </summary>
        /// <returns></returns>
        public static bool confirmOrder(string jdOrderId)
        {
            bool   flag    = false;
            string token   = GetToken();
            string url     = UrlBase + "order/confirmOrder";
            string data    = "token=" + token + "&jdOrderId=" + jdOrderId;
            string jsonstr = WebRequestHelper.SendPostInfo(url, data);

            LogHelper.Info("京东预占接口数据:" + jsonstr.ToString() + "");
            JObject objwlgs = JObject.Parse(jsonstr);

            if (objwlgs["result"].ToString() == "True")
            {
                flag = true;
            }
            return(flag);
        }
Пример #7
0
        /// <summary>
        /// 查询京东配送信息接口
        /// </summary>
        /// <param name="jdOrderId"></param>
        /// <returns></returns>
        public static string orderTrack(string jdOrderId)
        {
            string str   = null;
            string token = GetToken();
            string data  = "token=" + token + "&jdOrderId=" + jdOrderId;
            string url   = UrlBase + "order/orderTrack";

            if (!string.IsNullOrWhiteSpace(jdOrderId))
            {
                string  obj     = WebRequestHelper.SendPostInfo(url, data);
                JObject objwlgs = JObject.Parse(obj);
                if (objwlgs["success"].ToString() == "True")
                {
                    str = objwlgs["result"]["orderTrack"].ToString();
                }
            }
            return(str);
        }
Пример #8
0
        /// <summary>
        /// 获取商品价格
        /// </summary>
        /// <param name="skuId"></param>
        /// <returns></returns>
        public static string GetPrice(string skuId)
        {
            string objson = null;

            try
            {
                string  token    = JdHelper.GetToken();
                string  postData = "token=" + token + "&sku=" + skuId;
                string  jsonstr  = WebRequestHelper.SendPostInfo(UrlBase + "price/getPrice", postData);
                JObject objwlgs  = JObject.Parse(jsonstr);
                if (objwlgs["success"].ToString() == "True")
                {
                }
            }
            catch (Exception)
            {
                objson = null;
            }
            return(objson);
        }
Пример #9
0
        /// <summary>
        /// 获取京东token
        /// </summary>
        /// <returns></returns>
        public static string GetToken()
        {
            var token = (string)HttpRuntime.Cache.Get("JD_Token");

            if (string.IsNullOrEmpty(token))
            {
                string returnObj = string.Empty;
                try
                {
                    string username     = "******";
                    string password     = GetMd5("123456");
                    string timestamp    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    string clientSecret = "8MkhJOGQtFJ6586h2l8j";
                    string clientId     = "beijingzhongshihua";
                    string sign         = clientSecret + timestamp + clientId + username + password + "access_token" + clientSecret;
                    sign = GetMd5(sign).ToUpper();
                    string url  = "https://bizapi.jd.com/oauth2/access_token";
                    string data =
                        "grant_type=access_token" +
                        "&client_id=" + clientId +
                        "&username="******"&password="******"&timestamp=" + timestamp +
                        "&sign=" + sign;
                    returnObj = WebRequestHelper.SendPostInfo(url, data);
                    JObject objwlgs = JObject.Parse(returnObj);
                    if (objwlgs["success"].ToString() == "True")
                    {
                        JObject objson = JObject.Parse(objwlgs["result"].ToString());
                        token = objson["access_token"].ToString();
                        HttpRuntime.Cache.Insert("JD_Token", token, null, DateTime.Now.AddHours(10), TimeSpan.Zero);
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error("JdHelper.GetToken 异常,returnObj: " + returnObj, ex);
                    throw ex;
                }
            }
            return(token);
        }
Пример #10
0
        /// <summary>
        /// 判断是否存在skuId
        /// </summary>
        /// <param name="skuId"></param>
        /// <returns></returns>
        public static bool IscheckskuId(string skuId)
        {
            bool flag = false;

            try
            {
                string  token    = JdHelper.GetToken();
                string  postData = "token=" + token + "&sku=" + skuId;
                string  jsonstr  = WebRequestHelper.SendPostInfo(UrlBase + "price/getPrice", postData);
                JObject objwlgs  = JObject.Parse(jsonstr);
                if (objwlgs["success"].ToString() == "True")
                {
                    flag = true;
                }
            }
            catch (Exception)
            {
                flag = false;
            }
            return(flag);
        }
Пример #11
0
        /// <summary>
        /// 获取四级地址
        /// </summary>
        /// <returns></returns>
        public static string GetTown(string Code)
        {
            string objson = null;

            try
            {
                string  token   = GetToken();
                string  url     = "https://bizapi.jd.com/api/area/getTown";
                string  data    = "token=" + token + "&id=" + Code;
                string  obj     = WebRequestHelper.SendPostInfo(url, data);
                JObject objwlgs = JObject.Parse(obj);
                if (objwlgs["success"].ToString() == "True")
                {
                    objson = objwlgs["result"].ToString();
                }
            }
            catch (Exception ex)
            {
                objson = null;
            }
            return(objson);
        }
Пример #12
0
        /// <summary>
        /// 确人是否拆单获取订单编号
        /// </summary>
        /// <returns></returns>
        public static string getMessage()
        {
            string  jdOrderId = null;
            string  token     = GetToken();
            string  data      = "token=" + token + "&type=1";
            string  url       = UrlBase + "message/get";
            string  obj       = WebRequestHelper.SendPostInfo(url, data);
            JObject objwlgs   = JObject.Parse(obj);

            if (objwlgs["success"].ToString() == "True")
            {
                JArray objson = JArray.Parse(objwlgs["result"].ToString());
                foreach (var item in objson)
                {
                    if (item["type"].ToString() == "1")
                    {
                        JObject objjson = JObject.Parse(item["result"].ToString());
                        jdOrderId = objjson["pOrder"].ToString();
                    }
                }
            }
            return(jdOrderId);
        }
Пример #13
0
        /// <summary>
        /// 获取拆单后物流的推送信息
        /// </summary>
        /// <returns></returns>
        public static JdMessageDto JdMessage(int type)
        {
            string       token     = GetToken();
            string       data      = "token=" + token + "&type=" + type;
            string       url       = UrlBase + "message/get";
            string       objson    = WebRequestHelper.SendPostInfo(url, data);
            JObject      firstjson = JObject.Parse(objson);
            JdMessageDto exEntity  = new JdMessageDto();

            exEntity.success       = bool.Parse(firstjson["success"].ToString());
            exEntity.resultMessage = firstjson["resultMessage"].ToString();
            exEntity.resultCode    = firstjson["resultCode"].ToString();
            List <JdMessagefirst> result = new List <JdMessagefirst>();

            if (firstjson["success"].ToString() == "True")
            {
                JArray jarray = JArray.Parse(firstjson["result"].ToString());
                if (jarray.Count() > 0)
                {
                    foreach (var item in jarray)
                    {
                        JdMessagefirst jdmessagefirst = new JdMessagefirst();
                        jdmessagefirst.id = item["id"].ToString();
                        JdMessageSecond jdmessagesecond = new JdMessageSecond();
                        JObject         secondjson      = JObject.Parse(item["result"].ToString());
                        jdmessagesecond.orderId = secondjson["orderId"].ToString();
                        jdmessagesecond.state   = int.Parse(secondjson["state"].ToString());
                        jdmessagefirst.result   = jdmessagesecond;
                        jdmessagefirst.time     = DateTime.Parse(item["time"].ToString());
                        jdmessagefirst.type     = int.Parse(item["type"].ToString());
                        result.Add(jdmessagefirst);
                    }
                }
            }
            exEntity.result = result;
            return(exEntity);
        }
Пример #14
0
        /// <summary>
        ///  查询子订单信息
        /// </summary>
        /// <returns></returns>
        public static List <Suborders> SearchJdOrderlist(string jdOrderId)
        {
            List <Suborders> objlist = new List <Suborders>();

            try
            {
                string token = GetToken();
                string data  = "token=" + token + "&jdOrderId=" + jdOrderId;
                string url   = UrlBase + "order/selectJdOrder";
                if (!string.IsNullOrWhiteSpace(jdOrderId))
                {
                    string obj = WebRequestHelper.SendPostInfo(url, data);
                    if (!string.IsNullOrEmpty(obj))
                    {
                        JObject objwlgs = JObject.Parse(obj);
                        if (objwlgs["success"].ToString() == "True")
                        {
                            string    jsonstr   = objwlgs["result"]["cOrder"].ToString();
                            Suborders suborders = new Suborders();
                            if (!string.IsNullOrEmpty(jsonstr))
                            {
                                JArray array = JArray.Parse(jsonstr);
                                if (array.Count() > 0)
                                {
                                    foreach (var arr in array)
                                    {
                                        JObject firstObject = JObject.Parse(arr.ToString());
                                        suborders                 = new Suborders();
                                        suborders.pOrder          = firstObject["pOrder"].ToString();
                                        suborders.orderState      = int.Parse(firstObject["orderState"].ToString());
                                        suborders.jdOrderId       = firstObject["jdOrderId"].ToString();
                                        suborders.freight         = decimal.Parse(firstObject["freight"].ToString());
                                        suborders.state           = int.Parse(firstObject["state"].ToString());
                                        suborders.submitState     = int.Parse(firstObject["submitState"].ToString());
                                        suborders.orderPrice      = decimal.Parse(firstObject["orderPrice"].ToString());
                                        suborders.orderNakedPrice = decimal.Parse(firstObject["orderNakedPrice"].ToString());
                                        suborders.type            = int.Parse(firstObject["type"].ToString());
                                        suborders.orderTaxPrice   = decimal.Parse(firstObject["orderTaxPrice"].ToString());
                                        JArray secondObject = JArray.Parse(firstObject["sku"].ToString());
                                        if (secondObject.Count > 0)
                                        {
                                            List <goodssku> goodsskulist = new List <goodssku>();
                                            foreach (var item in secondObject)
                                            {
                                                goodssku model = new goodssku()
                                                {
                                                    category   = item["category"].ToString(),
                                                    num        = int.Parse(item["num"].ToString()),
                                                    price      = decimal.Parse(item["price"].ToString()),
                                                    tax        = decimal.Parse(item["tax"].ToString()),
                                                    oid        = int.Parse(item["oid"].ToString()),
                                                    taxPrice   = decimal.Parse(item["taxPrice"].ToString()),
                                                    skuId      = item["skuId"].ToString(),
                                                    nakedPrice = decimal.Parse(item["nakedPrice"].ToString()),
                                                    type       = int.Parse(item["type"].ToString())
                                                };
                                                goodsskulist.Add(model);
                                            }
                                            suborders.sku = goodsskulist;
                                        }
                                        objlist.Add(suborders);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(string.Format("查询京东SearchJdOrder异常信息:{0}", ex.Message), ex);
            }
            return(objlist);
        }