Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var        requestPath   = context.Request.PathInfo.Replace("/", "");
            var        RequestParams = GetRequestStringList(context.Request);
            var        result        = "";
            string     openid        = System.Web.HttpContext.Current.Session["FromUserName"] == null ? "" : System.Web.HttpContext.Current.Session["FromUserName"].ToString();
            HttpCookie cookie        = context.Request.Cookies["XYH_COUPON"];

            if (openid == "" && cookie != null && !string.IsNullOrWhiteSpace(cookie["FromUserName"]))
            {
                openid = cookie["FromUserName"].ToString();
            }
            // openid = "oDRuD1DSi1yyDx9x4_Ttpf_0haB0";
            if (string.IsNullOrWhiteSpace(openid) &&
                requestPath != "HXCoupon" &&
                requestPath != "GetCardDetail")   //核销不需要openid
            {
                response.Status  = -5;
                response.Message = "重新授权";
                result           = JsonHelper.ToJSON(response);
                context.Response.Write(result);
                return;
            }


            DateTime StartDate = string.IsNullOrWhiteSpace(AppConfig.ActivityStartDate) ? DateTime.MinValue : DateTime.Parse(AppConfig.ActivityStartDate);
            DateTime EndDate   = string.IsNullOrWhiteSpace(AppConfig.ActivityEndDate) ? DateTime.MaxValue : DateTime.Parse(AppConfig.ActivityEndDate);

            //活动结束只能领券,核销,分享

            if (EndDate < DateTime.Now)
            {
                response.Status  = -6;
                response.Message = "活动已结束";
                result           = JsonHelper.ToJSON(response);
                context.Response.Write(result);
                return;
            }


            switch (requestPath)
            {
            case "AddPVData":
                //WriteTxt("新增pv数据-开始" + openid);
                try
                {
                    PVData pv = new PVData();
                    pv.DOMAIN   = context.Request.Params[1];
                    pv.URL      = "商业集团领券活动";
                    pv.TITLE    = context.Request.Params[3];
                    pv.REFERRER = context.Request.Params[4];
                    pv.SH       = context.Request.Params[5];
                    pv.SW       = context.Request.Params[6];
                    pv.CD       = context.Request.Params[7];
                    pv.ACCOUNT  = context.Request.Params[9];
                    pv.LTIME    = context.Request.Params[10];
                    pv.openid   = openid;
                    mss.InsertPVData(pv);
                    //WriteTxt("新增pv数据-结束" + openid);
                }
                catch (Exception ex) { WriteTxt("新增pv数据-异常" + ex.Message); }
                result = "";
                break;

            case "GetCardDetail": result = GetCardDetail(RequestParams["code"], RequestParams["card_id"]); break;

            case "HXCoupon": result = HXCoupon(RequestParams["code"], RequestParams["card_id"]); break;

            case "SendMsg": result = SendMsg(RequestParams["mobile"]); break;

            case "IsMember": result = IsMember(RequestParams["mobile"], openid); break;

            case "WXShare": result = WXShare(openid, int.Parse(RequestParams["type"])); break;

            case "VerificaMobile": result = VerificaMobile(RequestParams["mobile"]); break;

            case "VerificaOpenId": result = VerificaOpenId(openid); break;

            case "LQCoupon": result = LQCoupon(openid); break;
            }
            context.Response.Write(result);
        }