Beispiel #1
0
        /// <summary>
        /// 获取优惠券列表
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="wid"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public CouponListDTO GetCouponList(int wid, string openid)
        {
            CouponListDTO result = new CouponListDTO();

            if (openid != null)
            {
                string str = string.Empty;

                //no use
                str = string.Format(
                    " openid='{0}'  and hasLingQu=0  and actId IN (SELECT id FROM wx_dzpActionInfo WHERE wid={1}) and a.createDate BETWEEN b.beginDate AND b.endDate ", openid, wid);

                result.UnExpiredCoupons = GetList(str);

                //expired
                str = string.Format(" openid='{0}'  and hasLingQu=0  and actId IN (SELECT id FROM wx_dzpActionInfo WHERE wid={1})  and a.createDate > b.endDate", openid, wid);

                result.ExpiredCoupons = GetList(str);

                //used
                str = string.Format(" openid='{0}'  and hasLingQu=1  and actId IN (SELECT id FROM wx_dzpActionInfo WHERE wid={1}) ", openid, wid);

                result.UsedCoupons = GetList(str);
            }
            return(result);
        }
Beispiel #2
0
        public void GetCouponList(string code, int wid, string url)
        {
            string openid = string.Empty;

            try
            {
                var service = new CouponService();

                if (Session["openid"] == null)
                {
                    BLL.wx_userweixin   bll     = new BLL.wx_userweixin();
                    Model.wx_userweixin wxModel = bll.GetModel(wid);
                    openid = OAuth2BaseProc(wxModel, "coupon", code, url);
                    if (!string.IsNullOrEmpty(openid))
                    {
                        Session["openid"] = openid;
                    }
                }
                else
                {
                    openid = Session["openid"] as string;
                }
                CouponListDTO dto = service.GetCouponList(wid, openid);
                if (dto != null)
                {
                    var data = new
                    {
                        lists  = dto,
                        openid = openid
                    };
                    Context.Response.Write(AjaxResult.Success(data));
                }
                else
                {
                    throw new Exception("参数异常");
                }
            }
            catch (UnAuthException jsEx)
            {
                Context.Response.Write(AjaxResult.Error(jsEx.RedirectUrl, jsEx.Code));
            }
            catch (Exception ex)
            {
                var s = "";
                if (ex.InnerException != null)
                {
                    s = ex.InnerException.Message;
                }
                Context.Response.Write(AjaxResult.Error(s));
            }
        }