/// <summary> /// 快递信息 /// </summary> /// <param name="serverUrl">登录URL</param> /// <param name="txtParams">参数</param> /// <returns>返回</returns> /// <remarks>2017-6-13 罗勤尧 创建</remarks> public HaiDaiResultKuaiDi KuaiDiDetail(string serverUrl, IDictionary <string, string> txtParams) { if (!txtParams.ContainsKey("timestamp")) { txtParams.Add("timestamp", this.GetTime()); } if (!txtParams.ContainsKey("appkey")) { txtParams.Add("appkey", this.appkey); } if (serverUrl.Contains("?")) { serverUrl = serverUrl.Substring(0, serverUrl.IndexOf('?') + 1); } Uri uri = new Uri(serverUrl); string absolutePath = uri.AbsolutePath; string encoding = "utf-8"; string sign = this.GetSign(this.method, absolutePath, txtParams, encoding); if (!txtParams.ContainsKey("topSign")) { txtParams.Add("topSign", sign); } string text = string.Empty; text = this.webUtils.DoPost(serverUrl, txtParams); return(JsonSerializationHelper.JsonToObject <HaiDaiResultKuaiDi>(text)); }
//string postData = ""; /// <summary> /// 利嘉查询商品分类 /// </summary> /// <param name="info">商品分类</param> /// <returns>结果对象</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static ResultLiJia SeachLiJiaProductCategory(LiJiaMemberSearch info) { //创建查询请求参数 string searchjosn = JsonHelper.ToJson(info); //查询接口 string searchpath = "category.search"; string postData = ""; bool Result = false; ResultLiJia resultList = new ResultLiJia(); try { string responseAddDsDealer = MainHttp(host, searchpath, methodTs, Token, postData, searchjosn); if (!string.IsNullOrEmpty(responseAddDsDealer)) { var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Assreturn.Success) { resultList = Assreturn; } else { //记录失败日志 Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(searchjosn, "LiJia"); Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia"); } } } catch (Exception ex) { return(resultList); } return(resultList); }
/// <summary> ///获取第三方支持的快递 /// </summary> /// <param name="auth">授权参数</param> /// <returns>2018-03-25 罗勤尧</returns> public Result <UpGradeExpress> GetExpress(AuthorizationParameters auth) { var result = new Result <UpGradeExpress>() { Status = true }; var _param = new Dictionary <string, string>(); //海外购订单发货 GeGeJiaDeliverGoods req = new GeGeJiaDeliverGoods(); //订单类型,0:渠道订单,1:格格家订单,2:格格团订单,3:格格团全球购订单,4:环球捕手订单,5:燕网订单,6:b2b订单,7:手q,8:云店 string parm = "{\"params\":{},\"partner\":\"" + auth.DealerApp.AppSecret + "\",\"timestamp\":\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\"}"; //MD5加密签名 string sign = MD5Encrypt(auth.DealerApp.AppKey + parm + auth.DealerApp.AppKey).ToUpper(); var response = PostJson("http://openapi.gegejia.com:8902/api/express/names", parm, sign); var Assreturn = JsonSerializationHelper.JsonToObject <UpGradeExpress>(response); var _response = JObject.Parse(response.ToString()); //var names = _response.Property("names"); if (_response.Property("errMsg") != null) { result.Status = false; result.Message = _response.Property("errMsg").ToString(); result.errCode = _response.Property("errCode").ToString(); } else { result.Data = Assreturn; result.Message = "获取成功"; } return(result); }
//string postData = ""; /// <summary> /// 利嘉查询商品品牌 /// </summary> /// <param name="info">商品品牌查询参数</param> /// <returns>结果对象</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static ResultLiJia SeachLiJiaBrand(LiJiaMemberSearch info) { //创建查询请求参数 string searchjosn = JsonHelper.ToJson(info); //查询接口 string searchpath = "brand.search"; string postData = ""; bool Result = false; ResultLiJia resultList = new ResultLiJia(); try { string responseAddDsDealer = MainHttp(host, searchpath, methodTs, Token, postData, searchjosn); if (!string.IsNullOrEmpty(responseAddDsDealer)) { var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Assreturn.Success) { resultList = Assreturn; } } } catch (Exception ex) { return(resultList); } return(resultList); }
//string postData = ""; /// <summary> /// 利嘉修改会员信息 /// </summary> /// <param name="info">会员信息</param> /// <returns>是否修改成</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static bool UpdateLiJiaMemerber(DsDealerLiJiaEdit info) { //创建新增分销商请求参数 string UpdateJson = JsonHelper.ToJson(info); //修改分销商接口 string pathUpdateDsDealer = "member.update"; string postData = ""; bool Result = false; try { string responseAddDsDealer = MainHttpT(host, pathUpdateDsDealer, methodTs, Token, postData, UpdateJson); if (!string.IsNullOrEmpty(responseAddDsDealer)) { var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Assreturn.Success) { Result = true; } } } catch (Exception ex) { return(Result); } return(Result); }
/// <summary> /// 利嘉新增仓库 /// </summary> /// <param name="info">仓库信息</param> /// <returns>利嘉仓库系统编号</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static string AddLiJiaStore(LiJiaStoreAdd info) { //创建新增仓库请求参数 string addds = JsonHelper.ToJson(info); //新增仓库接口 string pathAddPdCa = "store.add"; string postData = ""; string StoreCode = ""; try { string responseAddDsDealer = MainHttpT(host, pathAddPdCa, methodTs, Token, postData, addds); if (!string.IsNullOrEmpty(responseAddDsDealer)) { var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Assreturn.Success) { StoreCode = Assreturn.StoreCode; } else { //记录失败日志 Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addds, "LiJia"); Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia"); } } } catch (Exception ex) { return(StoreCode); } return(StoreCode); }
/// <summary> /// 利嘉新增商品品牌 /// </summary> /// <param name="info">商品品牌信息</param> /// <returns>利嘉商品品牌系统编号</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static int AddLiJiaBrand(LiJiaBrandAdd info) { //创建新增商品品牌请求参数 string addds = JsonHelper.ToJson(info); //新增商品品牌接口 string pathAdd = "brand.add"; string postData = ""; int id = 0; string BraCode = ""; try { string responseAddDsDealer = MainHttpT(host, pathAdd, methodTs, Token, postData, addds); if (!string.IsNullOrEmpty(responseAddDsDealer)) { var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Assreturn.Success) { id = Assreturn.BrandId; BraCode = Assreturn.BrandCode; } else { //记录失败日志 Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addds, "LiJia"); Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia"); } } } catch (Exception ex) { return(id); } return(id); }
/// <summary> /// 利嘉采购入库单 /// </summary> /// <param name="info">采购入库单信息</param> /// <returns>利嘉采购入库单系统编号</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static string AddLiJiaPurchaseInfo(LiJiaPurchaseInfo Info) { //创建新增采购入库单请求参数 string addds = JsonHelper.ToJson(Info); //新增采购入库单接口 string pathAddPdCa = "purchaseInfo.add"; string postData = ""; string Code = ""; try { string responseAddDsDealer = MainHttpT(host, pathAddPdCa, methodTs, Token, postData, addds); if (!string.IsNullOrEmpty(responseAddDsDealer)) { var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Assreturn.Success) { Code = Assreturn.PurchaseInboundOrderNo; } else { //记录失败日志 Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addds, "LiJia"); Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia"); } } } catch (Exception ex) { return(Code); } return(Code); }
/// <summary> /// 利嘉订单出库发货接口 /// </summary> /// <param name="info">出库信息</param> /// <returns>是否成功</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static bool LiJiaOrderInfoTracking(OrderInfoTracking Info) { //创建出库发货请求参数 string addds = JsonHelper.ToJson(Info); //出库发货接口 string pathAddPdCa = "orderInfo.tracking"; string postData = ""; string Code = ""; bool Result = false; try { string responseAddDsDealer = MainHttpT(host, pathAddPdCa, methodTs, Token, postData, addds); if (!string.IsNullOrEmpty(responseAddDsDealer)) { var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Assreturn.Success) { Result = true; } else { //记录失败日志 Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addds, "LiJia"); Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia"); } } } catch (Exception ex) { return(Result); } return(Result); }
//string postData = ""; /// <summary> /// 利嘉修改商品分类 /// </summary> /// <param name="info">商品分类信息</param> /// <returns>是否修改成</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static bool UpdateLiJiaProductCategory(CategoryLiJiaEdit info) { //创建修改商品分类请求参数 string UpdateJson = JsonHelper.ToJson(info); //修改商品分类接口 string pathUpdateDsDealer = "category.update"; string postData = ""; bool Result = false; try { string responseAddDsDealer = MainHttpT(host, pathUpdateDsDealer, methodTs, Token, postData, UpdateJson); if (!string.IsNullOrEmpty(responseAddDsDealer)) { var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Assreturn.Success) { Result = true; } else { //记录失败日志 Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(UpdateJson, "LiJia"); Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia"); } } } catch (Exception ex) { return(Result); } return(Result); }
/// <summary> /// 利嘉新增商品分类 /// </summary> /// <param name="info">商品分类信息</param> /// <returns>利嘉商品分类系统编号</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static int AddLiJiaProductCategory(ProductCategoryLiJia info) { //创建新增商品分类请求参数 string addds = JsonHelper.ToJson(info); //新增新增商品分类接口 string pathAddPdCa = "category.add"; string postData = ""; int id = 0; try { string responseAddDsDealer = MainHttpT(host, pathAddPdCa, methodTs, Token, postData, addds); if (!string.IsNullOrEmpty(responseAddDsDealer)) { var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Assreturn.Success) { id = Assreturn.CategoryId; } else { //记录失败日志 Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addds, "LiJia"); Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia"); } } } catch (Exception ex) { return(id); } return(id); }
/// <summary> /// 利嘉取消订单 /// </summary> /// <param name="info">订单编号</param> /// <returns>是否成功</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static bool CancelLiJiaOrder(LiJiaOrderCancel info) { //创建新增分销商请求参数 string addorderstr = JsonHelper.ToJson(info); //新增订单接口 //Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addorderstr, "LiJia"); string addorderpath = "orderInfo.cancel"; string postData = ""; bool Result = false; try { string responseAddDsDealer = MainHttpT(host, addorderpath, methodTs, Token, postData, addorderstr); if (!string.IsNullOrEmpty(responseAddDsDealer)) { // Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia"); var Assreturn = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Assreturn.Success) { Result = true; } else { //记录失败日志 Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addorderstr, "LiJia"); Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia"); } } } catch (Exception ex) { return(Result); } return(Result); }
/// <summary> /// 订单详情 /// </summary> /// <param name="serverUrl">登录URL</param> /// <param name="txtParams">参数</param> /// <returns>返回</returns> /// <remarks>2017-6-13 罗勤尧 创建</remarks> public Result <DataDetail> OrderDetail(string serverUrl, IDictionary <string, string> txtParams) { var result = new Result <DataDetail>() { Status = false }; if (!txtParams.ContainsKey("timestamp")) { txtParams.Add("timestamp", this.GetTime()); } if (!txtParams.ContainsKey("appkey")) { txtParams.Add("appkey", this.appkey); } if (serverUrl.Contains("?")) { serverUrl = serverUrl.Substring(0, serverUrl.IndexOf('?') + 1); } var uri = new Uri(serverUrl); string absolutePath = uri.AbsolutePath; string encoding = "utf-8"; string sign = this.GetSign(this.method, absolutePath, txtParams, encoding); if (!txtParams.ContainsKey("topSign")) { txtParams.Add("topSign", sign); } var responseStr = this.webUtils.DoPost(serverUrl, txtParams); var response = JObject.Parse(responseStr); if (response["result"].ToString() == "1") { result.Status = true; result.Data = JsonSerializationHelper.JsonToObject <DataDetail>(response["data"].ToString()); return(result); } result.Message = response["data"].ToString(); return(result); }
/// <summary> /// 登录获取token /// </summary> /// <param name="serverUrl">登录URL</param> /// <returns>返回</returns> /// <remarks>2017-6-13 罗勤尧 创建</remarks> public HaiDaiResultLogin LoginApi(string serverUrl) { HaiDaiResultLogin login = new HaiDaiResultLogin(); IDictionary <string, string> txtParams = new Dictionary <string, string>(); if (!txtParams.ContainsKey("timestamp")) { txtParams.Add("timestamp", this.GetTime()); } if (!txtParams.ContainsKey("username")) { txtParams.Add("username", this.username.ToString()); } if (!txtParams.ContainsKey("password")) { txtParams.Add("password", EncryptWithMd5(this.password)); } if (!txtParams.ContainsKey("appkey")) { txtParams.Add("appkey", this.appkey); } if (serverUrl.Contains("?")) { serverUrl = serverUrl.Substring(0, serverUrl.IndexOf('?') + 1); } Uri uri = new Uri(serverUrl); string absolutePath = uri.AbsolutePath; string encoding = "utf-8"; //txtParams.TryGetValue("charset", out encoding); string sign = this.GetSign(this.method, absolutePath, txtParams, encoding); if (!txtParams.ContainsKey("topSign")) { txtParams.Add("topSign", sign); } string text = string.Empty; text = this.webUtils.DoPost(serverUrl, txtParams); login = JsonSerializationHelper.JsonToObject <HaiDaiResultLogin>(text); return(login); }
//string postData = ""; #region 会员接口 /// <summary> /// 利嘉新增会员 /// </summary> /// <param name="info">会员信息</param> /// <returns>利嘉会员系统编号</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static ResultLiJia AddLiJiaMemerber(DsDealerLiJia info) { //创建新增分销商请求参数 string addds = JsonHelper.ToJson(info); //新增分销商接口 string pathAddDsDealer = "member.add"; string postData = ""; int id = 0; ResultLiJia Result = null; try { string responseAddDsDealer = MainHttpT(host, pathAddDsDealer, methodTs, Token, postData, addds); if (!string.IsNullOrEmpty(responseAddDsDealer)) { Result = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Result.Success) { return(Result); } else { //记录失败日志 Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addds, "LiJia"); Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia"); } } } catch (Exception ex) { return(Result = new ResultLiJia() { Success = false, Message = ex.ToString() }); } return(Result); }
//string postData = ""; #region 订单接口 /// <summary> /// 利嘉新增订单 /// </summary> /// <param name="info">订单编号</param> /// <returns>是否添加成功</returns> /// <remarks>2017-05-18 罗勤尧 创建</remarks> public static ResultLiJia AddLiJiaOrder(LiJiaOrderModel info) { //创建新增分销商请求参数 string addorderstr = JsonHelper.ToJson(info); //新增订单接口 //Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addorderstr, "LiJia"); string addorderpath = "orderInfo.add"; string postData = ""; //bool Result = false; ResultLiJia Result = null; try { string responseAddDsDealer = MainHttpT(host, addorderpath, methodTs, Token, postData, addorderstr); if (!string.IsNullOrEmpty(responseAddDsDealer)) { Result = JsonSerializationHelper.JsonToObject <ResultLiJia>(responseAddDsDealer); if (Result.Success) { return(Result); } else { //记录失败日志 Hyt.BLL.Log.LocalLogBo.Instance.WriteTo(addorderstr, "LiJia"); Hyt.BLL.Log.LocalLogBo.Instance.WriteReturn(responseAddDsDealer, "LiJia"); } } } catch (Exception ex) { return(Result = new ResultLiJia() { Success = false, Message = ex.ToString() }); } return(Result); }
/// <summary> /// Performs the HTTP request. /// </summary> /// <returns>The server response string(UTF8 decoded).</returns> public virtual string Request() { HttpWebRequest req = HttpWebRequest.Create(ConstructUri()) as HttpWebRequest; AppendHeaders(req.Headers); if (!string.IsNullOrEmpty(Method)) { req.Method = Method; } if (!string.IsNullOrEmpty(ContentType)) { req.ContentType = ContentType; } PrepareRequest(req); // Calls GetRequestStream with a "GET" method, an exception is thrown "Cannot send a content-body with this verb-type." if (req.Method == HttpMethod.Post) { using (var reqStream = req.GetRequestStream()) { WriteBody(reqStream); } // ContentLength is automatically calculated. } WebResponse resp = null; try { resp = req.GetResponse(); } catch (WebException wex) { ErrorResponse errorResp; var webResp = wex.Response as HttpWebResponse; if (null == webResp) { throw new AMicroblogException(LocalErrorCode.NetworkUnavailable); } try { var responseContent = RetrieveResponse(webResp); if (!string.IsNullOrEmpty(responseContent) && responseContent.StartsWith(Constants.JsonHeader, StringComparison.InvariantCultureIgnoreCase)) { errorResp = JsonSerializationHelper.JsonToObject <ErrorResponse>(responseContent); //TODO: 21327 token expired } else { // Handle other cases errorResp = new ErrorResponse() { ErrorCode = (int)webResp.StatusCode, ErrorMessage = webResp.StatusDescription }; } } catch (Exception exx) { throw new AMicroblogException(LocalErrorCode.ProcessResponseErrorHandlingFailed, exx); } var aex = new AMicroblogException(errorResp.ErrorMessage, wex) { IsRemoteError = true, ErrorCode = errorResp.ErrorCode }; var e = new ResponseErrorEventArgs(req.RequestUri.AbsoluteUri, aex, req.Method, req.ContentType); Environment.NotifyResponseError(e); aex.IsHandled = e.IsHandled; throw aex; } return(RetrieveResponse(resp)); }