Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            DateTime startTime = DateTime.Now;  //开始进入时间
            var      appkey    = context.Request["appkey"];
            var      token     = context.Request["token"];
            var      method    = context.Request["method"];
            var      sign      = context.Request["sign"];

            //TODO:[DZY]记录参数日志,用于调试

            /*
             * string pa = "";
             * foreach (var item in context.Request.Form.AllKeys)
             * {
             *  pa += item + "=" + context.Request.Form[item] + "&";
             * }
             * Log.Debug("[PA]" + pa);
             * Log.Debug("[PAU]" + context.Request.RawUrl);
             */

            if (string.IsNullOrWhiteSpace(token))
            {
                ResponseError(context, 40000, "错误的接入码", "GSE.SYSTEM_ERROR", "错误的接入码:token");
                return;
            }
            if (string.IsNullOrWhiteSpace(method))
            {
                ResponseError(context, 40000, "错误的参数", "GSE.SYSTEM_ERROR", "错误的参数:method");
                return;
            }
            var    shopwdinfo = ShopApplication.GetshopWdgjInfoByCode(token);
            string appSecret  = "";

            if (shopwdinfo == null)
            {
                ResponseError(context, 40000, "错误的接入码", "GSE.SYSTEM_ERROR", "错误的接入码:token");
                return;
            }
            appSecret = shopwdinfo.uSign;
            CurShopId = shopwdinfo.ShopId;

            if (string.IsNullOrWhiteSpace(sign) || !CheckSign(context, appSecret, sign))
            {
                ResponseError(context, 40000, "签名错误", "GSE.SYSTEM_ERROR", "签名错误.");
                return;
            }
            try
            {
                switch (method)
                {
                case "Differ.JH.Business.GetOrder":    //订单下载
                    context.Response.Write(GetOrder(context));
                    return;

                case "Differ.JH.Business.CheckRefundStatus":    //退款检测
                    context.Response.Write(CheckRefundStatus(context));
                    return;

                case "Differ.JH.Business.Send":    //订单发货
                    context.Response.Write(Send(context));
                    return;

                case "Differ.JH.Business.DownloadProduct":    //商品下载
                    context.Response.Write(DownloadProduct(context));
                    return;

                case "Differ.JH.Business.SyncStock":    //商品库存同步
                    context.Response.Write(SyncStock(context));
                    return;

                case "Differ.JH.Business.Consume":
                    context.Response.Write(Consume(context));      //订单核销
                    return;

                case "Differ.JH.Business.GetWebSite":
                    context.Response.Write(GetStores(context));      //获取门店列表
                    return;
                }
            }
            catch (HimallApiException ex)
            {
                ResponseError(context, 40000, ex.Message, "GSE.SYSTEM_ERROR", ex.Message);
                return;
            }
            catch (HimallException ex)
            {
                ResponseError(context, 40000, ex.Message, "GSE.SYSTEM_ERROR", ex.Message);
                return;
            }
            catch
            {
                ResponseError(context, 40000, "系统异常", "GSE.SYSTEM_ERROR", "系统发生异常,请与管理员联系!");
                return;
            }
        }