Exemplo n.º 1
0
        public void ProcessRequest(System.Web.HttpContext context)
        {
            string text = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><trade_get_response>{0}</trade_get_response>";
            string str  = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";

            this.fomat = "json";
            SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);

            this.jsonformat = "{{\"Oid\": \"{0}\",\"SellerUid\": \"{1}\",\"BuyerNick\": \"{2}\",\"BuyerEmail\": \"{3}\",\"ReceiverName\": \"{4}\",\"ReceiverState\": \"{5}\",\"ReceiverCity\": \"{6}\",\"ReceiverDistrict\":\"{7}\",\"ReceiverAddress\":\"{8}\",\"ReceiverZip\": \"{9}\",\"ReceiverMobile\": \"{10}\",\"ReceiverPhone\":\"{11}\",\"BuyerMemo\": \"{12}\",\"OrderMark\":\"{13}\",\"SellerMemo\":\"{14}\",\"Nums\":\"{15}\",\"Price\": \"{16}\",\"Payment\":\"{17}\",\"PaymentType\": \"{18}\",\"PaymentTypeId\":\"{19}\",\"PaymentName\":\"{20}\",\"PostFee\": \"{21}\",\"DiscountFee\": \"{22}\",\"AdjustFee\": \"{23}\",\"PaymentTs\": \"{24}\",\"SentTs\":\"{25}\",\"RefundStatus\":\"{26}\",\"RefundAmount\":\"{27}\",\"RefundRemark\":\"{28}\",\"Status\": \"{29}\",\"ModeName\": \"{30}\",\"CreateTs\":\"{31}\",\"orders\": [{32}]}},";
            string field          = "action";
            string orderitemfomat = "{{\"Tid\": \"{0}\",\"Oid\": \"{1}\",\"GoodsIid\": \"{2}\",\"Title\": \"{3}\",\"OuterId\": \"{4}\",\"SkuId\":\"{5}\",\"SKUContent\": \"{6}\",\"Nums\": \"{7}\",\"Price\": \"{8}\",\"Payment\":\"{9}\",\"ThumUrl\":\"{10}\"}},";

            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
            this.ModelId   = context.Request.Form["action"].ToString();
            field          = "sign";
            this.key       = context.Request.Form["sign"];
            this.localcode = masterSettings.CheckCode;
            new System.Collections.Generic.Dictionary <string, string>();
            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            try
            {
                if (!string.IsNullOrEmpty(this.ModelId))
                {
                    string modelId;
                    if ((modelId = this.ModelId) != null)
                    {
                        if (!(modelId == "tradelist"))
                        {
                            if (!(modelId == "tradedetails"))
                            {
                                if (!(modelId == "send"))
                                {
                                    if (modelId == "mark")
                                    {
                                        string value = context.Request.Form["order_mark"].Trim();
                                        string text2 = context.Request.Form["seller_memo"].Trim();
                                        if (string.IsNullOrEmpty(context.Request.Form["tid"].Trim()) || string.IsNullOrEmpty(value) || string.IsNullOrEmpty(text2))
                                        {
                                            this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid or order_mark or seller_memo");
                                            goto IL_9F1;
                                        }
                                        if (System.Convert.ToInt32(value) <= 0 || System.Convert.ToInt32(value) >= 7)
                                        {
                                            this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "order_mark");
                                            goto IL_9F1;
                                        }
                                        string text3 = context.Request.Form["tid"].Trim();
                                        this.tmpParas.Add("tid", text3);
                                        this.tmpParas.Add("order_mark", value);
                                        this.tmpParas.Add("seller_memo", text2);
                                        this.tmpParas.Add("format", this.fomat);
                                        this.tmpParas.Add("action", this.ModelId);
                                        if (!APIHelper.CheckSign(this.tmpParas, this.localcode, this.key))
                                        {
                                            this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                            goto IL_9F1;
                                        }
                                        OrderInfo orderInfo = OrderHelper.GetOrderInfo(text3);
                                        orderInfo.ManagerMark   = new OrderMark?((OrderMark)System.Enum.Parse(typeof(OrderMark), value, true));
                                        orderInfo.ManagerRemark = Globals.HtmlEncode(text2);
                                        if (!OrderHelper.SaveRemark(orderInfo))
                                        {
                                            this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "save is failure ");
                                            goto IL_9F1;
                                        }
                                        if (this.fomat == "json")
                                        {
                                            text = string.Format("{{\"trade_get_response\":{{\"trade\":{0}}}}}", this.GetOrderDetails(this.jsonformat, orderitemfomat, orderInfo));
                                            goto IL_9F1;
                                        }
                                        goto IL_9F1;
                                    }
                                }
                                else
                                {
                                    string text4 = context.Request.Form["tid"].Trim();
                                    string text5 = context.Request.Form["out_sid"].Trim();
                                    string text6 = context.Request.Form["company_code"].Trim();
                                    if (string.IsNullOrEmpty(text4) || string.IsNullOrEmpty(text6) || string.IsNullOrEmpty(text5))
                                    {
                                        this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramters");
                                        goto IL_9F1;
                                    }
                                    this.tmpParas.Add("tid", text4);
                                    this.tmpParas.Add("out_sid", text5);
                                    this.tmpParas.Add("company_code", text6);
                                    this.tmpParas.Add("format", this.fomat);
                                    this.tmpParas.Add("action", this.ModelId);
                                    if (!APIHelper.CheckSign(this.tmpParas, this.localcode, this.key))
                                    {
                                        this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                        goto IL_9F1;
                                    }
                                    ExpressCompanyInfo expressCompanyInfo = ExpressHelper.FindNodeByCode(text6);
                                    if (string.IsNullOrEmpty(expressCompanyInfo.Name))
                                    {
                                        this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "company_code");
                                        goto IL_9F1;
                                    }
                                    ShippingModeInfo shippingModeByCompany = SalesHelper.GetShippingModeByCompany(expressCompanyInfo.Name);
                                    OrderInfo        orderInfo2            = OrderHelper.GetOrderInfo(text4);
                                    if (orderInfo2 == null)
                                    {
                                        this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.NoExists_Error, "tid");
                                        goto IL_9F1;
                                    }
                                    ApiErrorCode apiErrorCode = this.SendOrders(orderInfo2, shippingModeByCompany, text5, expressCompanyInfo);
                                    if (apiErrorCode != ApiErrorCode.Success)
                                    {
                                        this.erromsg = MessageInfo.ShowMessageInfo(apiErrorCode, "It");
                                        goto IL_9F1;
                                    }
                                    orderInfo2 = OrderHelper.GetOrderInfo(text4);
                                    if (this.fomat == "json")
                                    {
                                        text = string.Format("{{\"trade_get_response\":{{\"trade\":{0}}}}}", this.GetOrderDetails(this.jsonformat, orderitemfomat, orderInfo2));
                                        goto IL_9F1;
                                    }
                                    goto IL_9F1;
                                }
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(context.Request.Form["tid"].Trim()))
                                {
                                    this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "tid");
                                    goto IL_9F1;
                                }
                                string text3 = context.Request.Form["tid"].Trim();
                                this.tmpParas = new System.Collections.Generic.SortedDictionary <string, string>();
                                this.tmpParas.Add("tid", context.Request.Form["tid"]);
                                this.tmpParas.Add("format", this.fomat);
                                this.tmpParas.Add("action", this.ModelId);
                                if (!APIHelper.CheckSign(this.tmpParas, this.localcode, this.key))
                                {
                                    this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "signature");
                                    goto IL_9F1;
                                }
                                string text7 = context.Request.Form["tid"].Replace("\r\n", "\n");
                                if (string.IsNullOrEmpty(text7))
                                {
                                    this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "tid");
                                    goto IL_9F1;
                                }
                                text3 = text7;
                                OrderInfo orderInfo3 = TradeHelper.GetOrderInfo(text3);
                                if (this.fomat == "json")
                                {
                                    text = string.Format("{{\"trade_get_response\":{{\"trade\":{0}}}}}", this.GetOrderDetails(this.jsonformat, orderitemfomat, orderInfo3));
                                    goto IL_9F1;
                                }
                                goto IL_9F1;
                            }
                        }
                        else
                        {
                            OrderQuery orderQuery = new OrderQuery
                            {
                                PageSize = 100
                            };
                            int    num    = 0;
                            string text8  = context.Request.Form["status"].Trim();
                            string value2 = context.Request.Form["pagesize"].Trim();
                            string text9  = context.Request.Form["datatype"].Trim();
                            string text10 = context.Request.Form["buyernick"].Trim();
                            string value3 = context.Request.Form["pageindex"].Trim();
                            string value4 = context.Request.Form["starttime"].Trim();
                            string value5 = context.Request.Form["endtime"].Trim();
                            if (!string.IsNullOrEmpty(text8) && System.Convert.ToInt32(text8) >= 0 && text8 != "6")
                            {
                                orderQuery.Status = (OrderStatus)System.Enum.Parse(typeof(OrderStatus), text8, true);
                            }
                            else
                            {
                                if (text8 == "6")
                                {
                                    orderQuery.Status      = OrderStatus.All;
                                    orderQuery.RefundState = (RefundStatus)System.Enum.Parse(typeof(RefundStatus), text8, true);
                                }
                                else
                                {
                                    this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "status");
                                }
                            }
                            if (!string.IsNullOrEmpty(value3) && System.Convert.ToInt32(value3) > 0)
                            {
                                orderQuery.PageIndex = System.Convert.ToInt32(value3);
                            }
                            else
                            {
                                this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "pageindex");
                            }
                            if (!string.IsNullOrEmpty(value2) && System.Convert.ToInt32(value2) > 0)
                            {
                                orderQuery.PageSize = (int)System.Convert.ToInt16(value2);
                            }
                            if (!string.IsNullOrEmpty(text9) && System.Convert.ToInt32(text9) > 0)
                            {
                                orderQuery.DataType = int.Parse(text9);
                            }
                            if (!string.IsNullOrEmpty(this.erromsg))
                            {
                                this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramter");
                                goto IL_9F1;
                            }
                            this.tmpParas.Add("status", text8);
                            this.tmpParas.Add("datatype", text9);
                            this.tmpParas.Add("buyernick", text10);
                            this.tmpParas.Add("pageindex", value3);
                            this.tmpParas.Add("pagesize", value2);
                            this.tmpParas.Add("starttime", value4);
                            this.tmpParas.Add("endtime", value5);
                            this.tmpParas.Add("format", this.fomat);
                            this.tmpParas.Add("action", this.ModelId);
                            if (!APIHelper.CheckSign(this.tmpParas, this.localcode, this.key))
                            {
                                this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                goto IL_9F1;
                            }
                            if (!string.IsNullOrEmpty(text10))
                            {
                                orderQuery.UserName = text10;
                            }
                            if (!string.IsNullOrEmpty(value4))
                            {
                                orderQuery.StartDate = new System.DateTime?(System.Convert.ToDateTime(value4));
                            }
                            if (!string.IsNullOrEmpty(value5))
                            {
                                orderQuery.EndDate = new System.DateTime?(System.Convert.ToDateTime(value5));
                            }
                            string arg = stringBuilder.Append(this.GetOrderList(orderQuery, this.jsonformat, orderitemfomat, out num).ToString()).ToString();
                            if (this.fomat == "json")
                            {
                                text = string.Format("{{\"trade_get_response\":{{\"trade\":[{0}],\"total\":{1}}}}}", arg, num);
                                goto IL_9F1;
                            }
                            goto IL_9F1;
                        }
                    }
                    this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "paramters");
                }
                else
                {
                    this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "sign");
                }
                IL_9F1 :;
            }
            catch (System.Exception)
            {
                this.erromsg = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, field);
            }
            if (!string.IsNullOrEmpty(this.erromsg))
            {
                text = str + this.erromsg;
                if (this.fomat == "json")
                {
                    text = text.Replace("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>", "");
                    xmlDocument.Load(new System.IO.MemoryStream(System.Text.Encoding.GetEncoding("UTF-8").GetBytes(text)));
                    text = JsonConvert.SerializeXmlNode(xmlDocument);
                }
            }
            context.Response.ContentType = "text/json";
            context.Response.Write(text);
        }
Exemplo n.º 2
0
        public void ProcessRequest(System.Web.HttpContext context)
        {
            string content = "";
            string message = "";
            string action  = context.Request.Form["action"].Trim();
            string sign    = context.Request.Form["sign"].Trim();

            this.siteSettings = SettingsManager.GetMasterSettings(false);
            string checkCode = this.siteSettings.CheckCode;
            SortedDictionary <string, string> sortedDictionary = new SortedDictionary <string, string>();

            string skuContentFormat = "{{\"lid\":\"{0}\",\"OuterId\":\"{1}\",\"SkuId\":\"{2}\",\"SKUContent\":\"{3}\",\"Nums\":\"{4}\",\"Price\":{5},\"CostPrice\":{6}}}";
            string productFormat    = "{{\"lid\":\"{0}\",\"OuterId\":\"{1}\",\"Title\":\"{2}\",\"PicUrl\":\"{3}\",\"Url\":\"{4}\",\"MarketPrice\":{5},\"Price\":{6},\"CostPrice\":{7},\"Weight\":{8},\"Status\":{9},\"SaleCounts\":{10},\"ShortDescription:\":\"{11}\",\"Stock\":{12},\"AddedDate\":\"{13}\",\"Description\":\"{14}\",\"RankPrice\":{15},\"List\":\"{16}\",\"BrandId\":\"{17}\",\"SkuItems\":[{18}],\"Unit\":\"{19}\"}}";

            string arg_A3_0 = context.Request.Form["format"];

            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();

            try
            {
                if (!string.IsNullOrEmpty(action))
                {
                    string hostPath = HiContext.Current.HostPath;
                    string a;
                    if ((a = action) != null)
                    {
                        if (!(a == "productview"))
                        {
                            if (!(a == "stockview"))
                            {
                                if (!(a == "quantity"))
                                {
                                    if (a == "statue")
                                    {
                                        string state     = context.Request.Form["state"].Trim();
                                        string productId = context.Request.Form["productId"].Trim();
                                        if (string.IsNullOrEmpty(state) || string.IsNullOrEmpty(productId))
                                        {
                                            message = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "state or productId");
                                            goto IL_78C;
                                        }
                                        ProductSaleStatus productSaleStatus = (ProductSaleStatus)System.Enum.Parse(typeof(ProductSaleStatus), state, true);
                                        int num = System.Convert.ToInt32(productId);
                                        if (num <= 0)
                                        {
                                            message = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "productId");
                                            goto IL_78C;
                                        }
                                        sortedDictionary.Add("productid", productId);
                                        sortedDictionary.Add("state", state);
                                        sortedDictionary.Add("format", "json");
                                        if (!APIHelper.CheckSign(sortedDictionary, checkCode, sign))
                                        {
                                            message = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                            goto IL_78C;
                                        }
                                        bool flag = false;
                                        if (productSaleStatus == ProductSaleStatus.OnSale)
                                        {
                                            if (ProductHelper.UpShelfAPI(num.ToString()) > 0)
                                            {
                                                flag = true;
                                            }
                                            else
                                            {
                                                message = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "productId");
                                            }
                                        }
                                        else
                                        {
                                            if (productSaleStatus == ProductSaleStatus.UnSale)
                                            {
                                                if (ProductHelper.OffShelfAPI(num.ToString()) > 0)
                                                {
                                                    flag = true;
                                                }
                                                else
                                                {
                                                    message = MessageInfo.ShowMessageInfo(ApiErrorCode.Format_Eroor, "productId");
                                                }
                                            }
                                        }
                                        if (flag)
                                        {
                                            content = string.Concat(new string[]
                                            {
                                                "{\"item_update_statue_response\":\"item\":{\"num_iid\":\"",
                                                productId,
                                                "\",\"modified\":\"",
                                                DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                                                "\"}}"
                                            });
                                            goto IL_78C;
                                        }
                                        message = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, "update");
                                        goto IL_78C;
                                    }
                                }
                                else
                                {
                                    if (string.IsNullOrEmpty(context.Request.Form["productId"].Trim()) || string.IsNullOrEmpty(context.Request.Form["quantity"].Trim()))
                                    {
                                        message = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "paramters");
                                        goto IL_78C;
                                    }
                                    string text6 = context.Request.Form["productId"];
                                    string text7 = "";
                                    string text8 = "";
                                    int    type  = 1;
                                    int    stock = System.Convert.ToInt32(context.Request.Form["quantity"].Trim());
                                    if (!string.IsNullOrEmpty(context.Request.Form["sku_id"].Trim()))
                                    {
                                        text7 = context.Request.Form["sku_id"];
                                    }
                                    if (!string.IsNullOrEmpty(context.Request.Form["outer_id"].Trim()))
                                    {
                                        text8 = context.Request.Form["outer_id"];
                                    }
                                    if (!string.IsNullOrEmpty(context.Request.Form["type"]))
                                    {
                                        type = System.Convert.ToInt32(context.Request.Form["type"]);
                                    }
                                    sortedDictionary.Add("productId", text6.ToString());
                                    sortedDictionary.Add("quantity", stock.ToString());
                                    sortedDictionary.Add("sku_id", text7);
                                    sortedDictionary.Add("outer_id", text8);
                                    sortedDictionary.Add("type", type.ToString());
                                    sortedDictionary.Add("format", "json");
                                    sortedDictionary.Add("action", action);
                                    if (!APIHelper.CheckSign(sortedDictionary, checkCode, sign))
                                    {
                                        message = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                        goto IL_78C;
                                    }
                                    ApiErrorCode apiErrorCode = ProductHelper.UpdateProductStock(System.Convert.ToInt32(text6), text7, text8, type, stock);
                                    if (ApiErrorCode.Success == apiErrorCode)
                                    {
                                        string format = "{{\"trade_get_response\":{{\"product\":{{{0}}}}}}}";
                                        content = string.Format(format, this.GetProductDetailsView(System.Convert.ToInt32(text6), 0, hostPath, productFormat, skuContentFormat).ToString());
                                        goto IL_78C;
                                    }
                                    message = MessageInfo.ShowMessageInfo(apiErrorCode, "paramters");
                                    goto IL_78C;
                                }
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(context.Request.Form["productId"].Trim()) || System.Convert.ToInt32(context.Request.Form["productId"].Trim()) <= 0)
                                {
                                    message = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "productId");
                                    goto IL_78C;
                                }
                                int    num   = System.Convert.ToInt32(context.Request.Form["productId"].Trim());
                                string text9 = "0";
                                if (!string.IsNullOrEmpty(context.Request.Form["gradeId"].Trim()) && System.Convert.ToInt16(context.Request.Form["gradeId"].Trim()) > 0)
                                {
                                    text9 = context.Request.Form["gradeId"].Trim();
                                }
                                sortedDictionary.Add("productid", num.ToString());
                                sortedDictionary.Add("action", "stockview");
                                sortedDictionary.Add("format", "json");
                                sortedDictionary.Add("gradeId", text9);
                                if (APIHelper.CheckSign(sortedDictionary, checkCode, sign))
                                {
                                    string format2 = "{{\"trade_get_response\":{{\"product\":{{{0}}}}}}}";
                                    content = string.Format(format2, this.GetProductDetailsView(num, int.Parse(text9), hostPath, productFormat, skuContentFormat).ToString());
                                    goto IL_78C;
                                }
                                message = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                                goto IL_78C;
                            }
                        }
                        else
                        {
                            string       value2       = context.Request.Form["parma"].Trim();
                            string       text9        = context.Request.Form["gradeId"].Trim();
                            ProductQuery productQuery = new ProductQuery();
                            if (!string.IsNullOrEmpty(value2))
                            {
                                productQuery = JsonConvert.DeserializeObject <ProductQuery>(value2);
                            }
                            message = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "sign");
                            if (string.IsNullOrEmpty(sign))
                            {
                                goto IL_78C;
                            }
                            sortedDictionary.Add("parma", context.Request.Form["parma"]);
                            sortedDictionary.Add("format", "json");
                            sortedDictionary.Add("action", "productview");
                            sortedDictionary.Add("gradeId", text9.ToString());
                            message = MessageInfo.ShowMessageInfo(ApiErrorCode.Signature_Error, "sign");
                            if (APIHelper.CheckSign(sortedDictionary, checkCode, sign))
                            {
                                Globals.EntityCoding(productQuery, true);
                                int    num2    = 0;
                                string format3 = "{{\"trade_get_response\":{{\"product\":[{0}],\"totalrecord\":\"{1}\"}}}}";
                                content = string.Format(format3, this.GetProductView(productQuery, int.Parse(text9), hostPath, productFormat, skuContentFormat, out num2).ToString(), num2.ToString());
                                goto IL_78C;
                            }
                            goto IL_78C;
                        }
                    }
                    message = MessageInfo.ShowMessageInfo(ApiErrorCode.Paramter_Error, "paramters");
                }
                else
                {
                    message = MessageInfo.ShowMessageInfo(ApiErrorCode.Empty_Error, "modeId");
                }
                IL_78C :;
            }
            catch (System.Exception ex)
            {
                message = MessageInfo.ShowMessageInfo(ApiErrorCode.Unknown_Error, ex.Message);
            }

            if (string.IsNullOrEmpty(content))
            {
                content = message;
                xmlDocument.Load(new System.IO.MemoryStream(Encoding.GetEncoding("UTF-8").GetBytes(content)));
                content = JsonConvert.SerializeXmlNode(xmlDocument);
            }

            context.Response.ContentType = "text/json";
            context.Response.Write(content);
        }