public static bool CheckSystemParameters(string in_app_key, string in_timestamp, string in_sign, out string result)
        {
            result = string.Empty;
            SiteSettings siteSettings = HiContext.Current.SiteSettings;

            if (string.IsNullOrEmpty(DataHelper.CleanSearchString(in_app_key)))
            {
                result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Missing_App_Key, "app_key");
                return(false);
            }
            if (!siteSettings.AppKey.Equals(in_app_key))
            {
                result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Invalid_App_Key, "app_key");
                return(false);
            }
            if (string.IsNullOrEmpty(DataHelper.CleanSearchString(in_timestamp)))
            {
                result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Missing_Timestamp, "timestamp");
                return(false);
            }
            if (!OpenApiHelper.IsDate(in_timestamp) || !OpenApiSign.CheckTimeStamp(in_timestamp))
            {
                result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Invalid_Timestamp, "timestamp");
                return(false);
            }
            if (string.IsNullOrEmpty(DataHelper.CleanSearchString(in_sign)))
            {
                result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Missing_Signature, "sign");
                return(false);
            }
            return(true);
        }
        public HttpResponseMessage GetProduct()
        {
            int    num_iid = 0;
            string content = "";
            NameValueCollection nameValueCollection            = base.Request.RequestUri.ParseQueryString();
            SortedDictionary <string, string> sortedDictionary = new SortedDictionary <string, string>();

            string[] allKeys = nameValueCollection.AllKeys;
            foreach (string text in allKeys)
            {
                sortedDictionary.Add(text, nameValueCollection.Get(text));
            }
            if (this.CheckProductParameters(sortedDictionary, out num_iid, out content))
            {
                SiteSettings siteSettings = HiContext.Current.SiteSettings;
                if (OpenApiSign.CheckSign(sortedDictionary, siteSettings.CheckCode, ref content))
                {
                    content = this.GetProduct(num_iid);
                }
            }
            return(new HttpResponseMessage
            {
                Content = new StringContent(content, Encoding.UTF8, "application/json")
            });
        }
Exemple #3
0
 public static bool CheckSystemParameters(System.Collections.Generic.SortedDictionary <string, string> parameters, string app_key, out string result)
 {
     result = string.Empty;
     if (string.IsNullOrEmpty(DataHelper.CleanSearchString(parameters["app_key"])))
     {
         result = OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Missing_App_Key, "app_key");
         return(false);
     }
     if (app_key != parameters["app_key"])
     {
         result = OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Invalid_App_Key, "app_key");
         return(false);
     }
     if (!parameters.Keys.Contains("timestamp") || string.IsNullOrEmpty(DataHelper.CleanSearchString(parameters["timestamp"])))
     {
         result = OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Missing_Timestamp, "timestamp");
         return(false);
     }
     if (!OpenApiHelper.IsDate(parameters["timestamp"]) || !OpenApiSign.CheckTimeStamp(parameters["timestamp"]))
     {
         result = OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Invalid_Timestamp, "timestamp");
         return(false);
     }
     if (string.IsNullOrEmpty(DataHelper.CleanSearchString(parameters["sign"])))
     {
         result = OpenApiErrorMessage.ShowErrorMsg(OpenApiErrorCode.Missing_Signature, "sign");
         return(false);
     }
     return(true);
 }
Exemple #4
0
 public void GetTrade(SortedDictionary <string, string> parameters, ref string results)
 {
     if (this.CheckTradesParameters(parameters, ref results) && OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref results))
     {
         results = this.tradeApi.GetTrade(parameters["tid"]);
     }
 }
Exemple #5
0
 public void ChangLogistics(SortedDictionary <string, string> parameters, ref string result)
 {
     if (this.CheckChangLogisticsParameters(parameters, ref result) && OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
     {
         result = this.tradeApi.ChangLogistics(parameters["tid"], parameters["company_name"], parameters["out_sid"]);
     }
 }
Exemple #6
0
        public void GetProduct(SortedDictionary <string, string> parameters, ref string result)
        {
            int num = 0;

            if (this.CheckProductParameters(parameters, out num, out result) && OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
            {
                result = this.productApi.GetProduct(num);
            }
        }
Exemple #7
0
        /// <summary>
        /// 检测基础参数和参数签名
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static void CheckBaseParamsAndSign(SortedDictionary <string, string> data)
        {
            if (data == null)
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.System_Error, "no params");
            }
            if (data.Count < 1)
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.System_Error, "no params");
            }
            string app_key   = "";
            string timestamp = "";
            string sign      = "";

            #region 基础检测
            if (!data.TryGetValue("app_key", out app_key))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Missing_App_Key, "app_key");
            }
            if (string.IsNullOrWhiteSpace(app_key))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Missing_App_Key, "app_key");
            }
            if (!data.TryGetValue("timestamp", out timestamp))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Missing_Timestamp, "timestamp");
            }
            if (string.IsNullOrWhiteSpace(timestamp))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Missing_Timestamp, "timestamp");
            }
            if (!OpenApiSign.CheckTimeStamp(timestamp))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Invalid_Timestamp, "timestamp");
            }
            if (!data.TryGetValue("sign", out sign))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Missing_Signature, "sign");
            }
            if (string.IsNullOrWhiteSpace(sign))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Missing_Signature, "sign");
            }
            #endregion

            ShopHelper shobj = new ShopHelper(app_key);

            //验签
            string msg = "";
            if (!OpenApiSign.CheckSign(data, shobj.AppSecreate, ref msg))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Invalid_Signature, "sign");
            }
        }
        private string _updateProductApproveStatus(ProductApproveStatusParam data)
        {
            string result = "";

            if (this.CheckUpdateApproveStatusParameters(data, out result))
            {
                SiteSettings siteSettings = HiContext.Current.SiteSettings;
                string       text         = OpenApiSign.Sign(data.SignStr(siteSettings.CheckCode), "MD5", "utf-8");
                result = ((!text.Equals(data.sign)) ? OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Invalid_Signature, "sign") : this.lastUpdateProductApproveStatus(data.num_iid, data.approve_status));
            }
            return(result);
        }
Exemple #9
0
 public void SendLogistic(System.Collections.Generic.SortedDictionary <string, string> parameters, ref string result)
 {
     if (!this.CheckSendLogisticParameters(parameters, ref result))
     {
         return;
     }
     if (!OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
     {
         return;
     }
     result = this.tradeApi.SendLogistic(parameters["tid"], parameters["company_name"], parameters["out_sid"]);
 }
Exemple #10
0
 public void GetTrade(System.Collections.Generic.SortedDictionary <string, string> parameters, ref string results)
 {
     if (!this.CheckTradesParameters(parameters, ref results))
     {
         return;
     }
     if (!OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref results))
     {
         return;
     }
     results = this.tradeApi.GetTrade(parameters["tid"]);
 }
Exemple #11
0
        public void GetProduct(System.Collections.Generic.SortedDictionary <string, string> parameters, ref string result)
        {
            int num_iid = 0;

            if (!this.CheckProductParameters(parameters, out num_iid, out result))
            {
                return;
            }
            if (!OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
            {
                return;
            }
            result = this.productApi.GetProduct(num_iid);
        }
Exemple #12
0
        public void UpdateTradeMemo(System.Collections.Generic.SortedDictionary <string, string> parameters, ref string result)
        {
            int flag = 0;

            if (!this.CheckUpdateTradeMemoParameters(parameters, out flag, ref result))
            {
                return;
            }
            if (!OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
            {
                return;
            }
            result = this.tradeApi.UpdateTradeMemo(parameters["tid"], parameters["memo"], flag);
        }
Exemple #13
0
        public void UpdateProductApproveStatus(System.Collections.Generic.SortedDictionary <string, string> parameters, ref string result)
        {
            int    num_iid = 0;
            string empty   = string.Empty;

            if (!this.CheckUpdateApproveStatusParameters(parameters, out num_iid, out empty, out result))
            {
                return;
            }
            if (!OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
            {
                return;
            }
            result = this.productApi.UpdateProductApproveStatus(num_iid, empty);
        }
Exemple #14
0
        public void UpdateProductQuantity(System.Collections.Generic.SortedDictionary <string, string> parameters, ref string result)
        {
            int num_iid  = 0;
            int quantity = 0;
            int type     = 1;

            if (!this.CheckUpdateQuantityParameters(parameters, out num_iid, out quantity, out type, out result))
            {
                return;
            }
            if (!OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
            {
                return;
            }
            result = this.productApi.UpdateProductQuantity(num_iid, parameters["sku_id"], quantity, type);
        }
Exemple #15
0
        private void GetSoldTrades(System.Collections.Generic.SortedDictionary <string, string> parameters, ref string results)
        {
            System.DateTime?start_created = null;
            System.DateTime?end_created   = null;
            string          empty         = string.Empty;
            int             page_no       = 0;
            int             page_size     = 0;

            if (!this.CheckSoldTradesParameters(parameters, out start_created, out end_created, out empty, out page_no, out page_size, ref results))
            {
                return;
            }
            if (!OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref results))
            {
                return;
            }
            results = this.tradeApi.GetSoldTrades(start_created, end_created, empty, parameters["buyer_uname"], page_no, page_size);
        }
Exemple #16
0
        public void GetSoldProducts(System.Collections.Generic.SortedDictionary <string, string> parameters, ref string result)
        {
            System.DateTime?start_modified = null;
            System.DateTime?end_modified   = null;
            string          approve_status = "";
            int             page_no        = 0;
            int             page_size      = 0;

            if (!this.CheckSoldProductsParameters(parameters, out start_modified, out end_modified, out approve_status, out page_no, out page_size, out result))
            {
                return;
            }
            if (!OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
            {
                return;
            }
            result = this.productApi.GetSoldProducts(start_modified, end_modified, approve_status, parameters["q"], parameters["order_by"], page_no, page_size);
        }
        private string _addUser(UserParam data)
        {
            string result = default(string);

            if (this.CheckAddUserParameters(data, out result))
            {
                SiteSettings siteSettings = HiContext.Current.SiteSettings;
                string       text         = OpenApiSign.Sign(data.SignStr(siteSettings.CheckCode), "MD5", "utf-8");
                if (text.Equals(data.sign))
                {
                    result = this.lastAddUser(data);
                    return(result);
                }
                result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Invalid_Signature, "sign");
                return(result);
            }
            return(result);
        }
Exemple #18
0
        private void GetIncrementSoldTrades(System.Collections.Generic.SortedDictionary <string, string> parameters, ref string results)
        {
            string status    = "";
            int    page_no   = 0;
            int    page_size = 0;

            System.DateTime start_modified;
            System.DateTime end_modified;
            if (!this.CheckIncrementSoldTradesParameters(parameters, out start_modified, out end_modified, out status, out page_no, out page_size, ref results))
            {
                return;
            }
            if (!OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref results))
            {
                return;
            }
            results = this.tradeApi.GetIncrementSoldTrades(start_modified, end_modified, status, parameters["buyer_uname"], page_no, page_size);
        }
Exemple #19
0
        /// <summary>
        /// 检测参数完整性与合法性
        /// </summary>
        /// <returns></returns>
        public virtual bool CheckParameter()
        {
            bool result = false;

            if (string.IsNullOrWhiteSpace(app_key))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Missing_App_Key, "app_key");
            }
            if (string.IsNullOrWhiteSpace(timestamp))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Missing_Timestamp, "timestamp");
            }
            if (!OpenApiSign.CheckTimeStamp(timestamp))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Invalid_Timestamp, "timestamp");
            }
            if (string.IsNullOrWhiteSpace(sign))
            {
                throw new MallApiException(Hishop.Open.Api.OpenApiErrorCode.Missing_Signature, "sign");
            }
            return(result);
        }
        private string _updateProductQuantity(ProductQuantityParam data)
        {
            string result = "";

            if (this.CheckUpdateQuantityParameters(data, out result))
            {
                SiteSettings siteSettings = HiContext.Current.SiteSettings;
                string       text         = OpenApiSign.Sign(data.SignStr(siteSettings.CheckCode), "MD5", "utf-8");
                if (text.Equals(data.sign))
                {
                    if (data.type == 0)
                    {
                        data.type = 1;
                    }
                    result = this.lastUpdateProductQuantity(data);
                }
                else
                {
                    result = OpenApiErrorMessage.ShowErrorMsg((Enum)(object)OpenApiErrorCode.Invalid_Signature, "sign");
                }
            }
            return(result);
        }
        public HttpResponseMessage GetSoldProducts()
        {
            NameValueCollection nameValueCollection            = base.Request.RequestUri.ParseQueryString();
            SortedDictionary <string, string> sortedDictionary = new SortedDictionary <string, string>();

            string[] allKeys = nameValueCollection.AllKeys;
            foreach (string text in allKeys)
            {
                sortedDictionary.Add(text, nameValueCollection.Get(text));
            }
            DateTime?    start_modified = null;
            DateTime?    end_modified   = null;
            string       approve_status = "";
            string       content        = "";
            int          page_no        = 0;
            int          page_size      = 0;
            SiteSettings siteSettings   = HiContext.Current.SiteSettings;

            if (this.CheckSoldProductsParameters(sortedDictionary, out start_modified, out end_modified, out approve_status, out page_no, out page_size, out content) && OpenApiSign.CheckSign(sortedDictionary, siteSettings.CheckCode, ref content))
            {
                content = this.GetSoldProducts(start_modified, end_modified, approve_status, sortedDictionary["q"], sortedDictionary["order_by"], page_no, page_size);
            }
            return(new HttpResponseMessage
            {
                Content = new StringContent(content, Encoding.UTF8, "application/json")
            });
        }
Exemple #22
0
        public void UpdateProductQuantity(SortedDictionary <string, string> parameters, ref string result)
        {
            int num      = 0;
            int quantity = 0;
            int type     = 1;

            if (this.CheckUpdateQuantityParameters(parameters, out num, out quantity, out type, out result) && OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
            {
                result = this.productApi.UpdateProductQuantity(num, parameters["sku_id"], quantity, type);
            }
        }
Exemple #23
0
        public void UpdateProductApproveStatus(SortedDictionary <string, string> parameters, ref string result)
        {
            int    num    = 0;
            string status = string.Empty;

            if (this.CheckUpdateApproveStatusParameters(parameters, out num, out status, out result) && OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
            {
                result = this.productApi.UpdateProductApproveStatus(num, status);
            }
        }
Exemple #24
0
        public void GetSoldProducts(SortedDictionary <string, string> parameters, ref string result)
        {
            DateTime?nullable  = null;
            DateTime?nullable2 = null;
            string   status    = "";
            int      num       = 0;
            int      num2      = 0;

            if (this.CheckSoldProductsParameters(parameters, out nullable, out nullable2, out status, out num, out num2, out result) && OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
            {
                result = this.productApi.GetSoldProducts(nullable, nullable2, status, parameters["q"], parameters["order_by"], num, num2);
            }
        }
        public HttpResponseMessage GetUsers()
        {
            string content = "";
            NameValueCollection nameValueCollection            = base.Request.RequestUri.ParseQueryString();
            SortedDictionary <string, string> sortedDictionary = new SortedDictionary <string, string>();

            string[] allKeys = nameValueCollection.AllKeys;
            foreach (string text in allKeys)
            {
                sortedDictionary.Add(text, nameValueCollection.Get(text));
            }
            DateTime?    start_time   = null;
            DateTime?    end_time     = null;
            int          page_no      = 0;
            int          page_size    = 0;
            SiteSettings siteSettings = HiContext.Current.SiteSettings;

            if (this.CheckUsersParameters(sortedDictionary, out start_time, out end_time, out page_no, out page_size, out content) && OpenApiSign.CheckSign(sortedDictionary, siteSettings.CheckCode, ref content))
            {
                content = this.lastGetUsers(start_time, end_time, page_no, page_size);
            }
            return(new HttpResponseMessage
            {
                Content = new StringContent(content, Encoding.UTF8, "application/json")
            });
        }
Exemple #26
0
        private void GetSoldTrades(SortedDictionary <string, string> parameters, ref string results)
        {
            DateTime?nullable  = null;
            DateTime?nullable2 = null;
            string   status    = string.Empty;
            int      num       = 0;
            int      num2      = 0;

            if (this.CheckSoldTradesParameters(parameters, out nullable, out nullable2, out status, out num, out num2, ref results) && OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref results))
            {
                results = this.tradeApi.GetSoldTrades(nullable, nullable2, status, parameters["buyer_uname"], num, num2);
            }
        }
Exemple #27
0
        private void GetIncrementSoldTrades(SortedDictionary <string, string> parameters, ref string results)
        {
            DateTime time;
            DateTime time2;
            string   status = "";
            int      num    = 0;
            int      num2   = 0;

            if (this.CheckIncrementSoldTradesParameters(parameters, out time, out time2, out status, out num, out num2, ref results) && OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref results))
            {
                results = this.tradeApi.GetIncrementSoldTrades(time, time2, status, parameters["buyer_uname"], num, num2);
            }
        }
Exemple #28
0
        public void UpdateTradeMemo(SortedDictionary <string, string> parameters, ref string result)
        {
            int flag = 0;

            if (this.CheckUpdateTradeMemoParameters(parameters, out flag, ref result) && OpenApiSign.CheckSign(parameters, this.site.CheckCode, ref result))
            {
                result = this.tradeApi.UpdateTradeMemo(parameters["tid"], parameters["memo"], flag);
            }
        }