Пример #1
0
        /// <summary>
        /// 砍价活动页面
        /// </summary>
        /// <param name="id"></param>
        /// <param name="userActId"></param>
        /// <returns></returns>
        public ActionResult PinTu(string id)
        {
            var model = IPinTuService.Find(id);

            if (model == null)
            {
                return(Forbidden());
            }
            model.ClickCount++;
            IPinTuService.Update(model);
            var itemList = model.PinTuItemJson.DeserializeJson <List <PinTuItem> >();
            var count    = IUserActivityService.GetCount(x => x.TargetID == id && x.JoinUserID == LoginUser.ID && !string.IsNullOrEmpty(x.TargetUserID) && x.TargetUserID == LoginUser.ID);

            //if (count >= itemList.Count)
            //{
            //    return JResult(Core.Code.ErrorCode.pintu_count_limit_error, "");
            //}
            ViewBag.NowCount = count;
            ViewBag.IsReport = IUserActivityService.IsExits(x => x.TargetID == id && x.JoinUserID == LoginUser.ID);
            ViewBag.ItemList = itemList;
            ViewBag.AppId    = Params.WeixinAppId;
            string cacheToken = WxPayApi.GetCacheToken(Params.WeixinAppId, Params.WeixinAppSecret);

            ViewBag.TimeStamp = WxPayApi.GenerateTimeStamp();
            ViewBag.NonceStr  = WxPayApi.GenerateNonceStr();
            ViewBag.Signature = WxPayApi.GetSignature(Request.Url.ToString().Split('#')[0], cacheToken, ViewBag.TimeStamp, ViewBag.NonceStr);
            return(View(model));
        }
Пример #2
0
        }                                               //H5调起JS API参数


        public ActionResult Pay(string orderId, string fee)
        {
            ViewBag.AppId = Params.WeixinAppId;
            string cacheToken = WxPayApi.GetCacheToken(Params.WeixinAppId, Params.WeixinAppSecret);

            ViewBag.TimeStamp    = WxPayApi.GenerateTimeStamp();
            ViewBag.NonceStr     = WxPayApi.GenerateNonceStr();
            ViewBag.Signature    = WxPayApi.GetSignature(Params.SiteUrl, cacheToken, ViewBag.TimeStamp, ViewBag.NonceStr);
            ViewBag.isShowFooter = false;
            return(View());
        }
Пример #3
0
        /// <summary>
        /// 拼团页面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Pintuan(string id)
        {
            var model = IPinTuanService.Find(id);

            if (model == null)
            {
                return(Forbidden());
            }
            model.ClickCount++;
            IPinTuanService.Update(model);
            var priceList = model.PinTuanItemJson.DeserializeJson <List <PinTuanItem> >().OrderBy(x => x.Count).ToList();
            var countList = priceList.Select(x => x.Count).ToList();
            var price     = 0M;

            for (var index = 1; index <= countList.Count; index++)
            {
                if (index < countList.Count)
                {
                    if (model.JoinCount < countList[index - 1])
                    {
                        price = model.OldPrice;
                        break;
                    }
                    if (model.JoinCount == countList[index - 1])
                    {
                        price = priceList[index - 1].Amount;
                        break;
                    }
                    if (model.JoinCount > countList[index - 1] && model.JoinCount < countList[index])
                    {
                        price = priceList[index - 1].Amount;
                        break;
                    }
                }
                else
                {
                    price = priceList[index - 1].Amount;
                }
            }
            ViewBag.IsReport = IUserActivityService.IsExits(x => x.TargetID == id && x.JoinUserID == LoginUser.ID);
            ViewBag.Price    = price;
            ViewBag.AppId    = Params.WeixinAppId;
            string cacheToken = WxPayApi.GetCacheToken(Params.WeixinAppId, Params.WeixinAppSecret);

            ViewBag.TimeStamp = WxPayApi.GenerateTimeStamp();
            ViewBag.NonceStr  = WxPayApi.GenerateNonceStr();
            ViewBag.Signature = WxPayApi.GetSignature(Request.Url.ToString().Split('#')[0], cacheToken, ViewBag.TimeStamp, ViewBag.NonceStr);
            return(View(model));
        }
Пример #4
0
        /// <summary>
        /// 商家活动
        /// </summary>
        /// <returns></returns>
        public ActionResult ActList()
        {
            var model = new List <Tuple <string, string, string, DateTime, DateTime, bool, TargetCode> >();

            var kanjiaList = IKanJiaService.GetList(x => x.UserID == LoginUser.ID).Select(x =>
            {
                return(new Tuple <string, string, string, DateTime, DateTime, bool, TargetCode>(x.Name, x.Picture, x.ID, x.StartTime, x.EndTime, x.IsDelete, TargetCode.Kanjia));
            }).ToList();

            if (kanjiaList != null && kanjiaList.Count > 0)
            {
                model.AddRange(kanjiaList);
            }
            var pintuanList = IPinTuanService.GetList(x => x.UserID == LoginUser.ID);

            pintuanList.ForEach(x =>
            {
                model.Add(new Tuple <string, string, string, DateTime, DateTime, bool, TargetCode>(x.Name, x.Picture, x.ID, x.StartTime, x.EndTime, x.IsDelete, TargetCode.Pintuan));
            });

            var miaoshaList = IMiaoShaService.GetList(x => x.UserID == LoginUser.ID);

            miaoshaList.ForEach(x =>
            {
                model.Add(new Tuple <string, string, string, DateTime, DateTime, bool, TargetCode>(x.Name, x.Picture, x.ID, x.StartTime, x.EndTime, x.IsDelete, TargetCode.Miaosha));
            });

            var pintuList = IPinTuService.GetList(x => x.UserID == LoginUser.ID);

            pintuList.ForEach(x =>
            {
                model.Add(new Tuple <string, string, string, DateTime, DateTime, bool, TargetCode>(x.Name, x.Picture, x.ID, x.StartTime, x.EndTime, x.IsDelete, TargetCode.Pintu));
            });

            ViewBag.AppId = Params.WeixinAppId;
            string cacheToken = WxPayApi.GetCacheToken(Params.WeixinAppId, Params.WeixinAppSecret);

            ViewBag.TimeStamp = WxPayApi.GenerateTimeStamp();
            ViewBag.NonceStr  = WxPayApi.GenerateNonceStr();
            ViewBag.Signature = WxPayApi.GetSignature(Request.Url.ToString().Split('#')[0], cacheToken, ViewBag.TimeStamp, ViewBag.NonceStr);

            ViewBag.List = model.OrderByDescending(x => x.Item4).ToList();
            return(View());
        }
Пример #5
0
        /// <summary>
        /// 秒杀页面
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult MiaoSha(string id)
        {
            var model = IMiaoShaService.Find(id);

            if (model == null)
            {
                return(Forbidden());
            }
            model.ClickCount++;
            IMiaoShaService.Update(model);
            ViewBag.AppId = Params.WeixinAppId;
            string cacheToken = WxPayApi.GetCacheToken(Params.WeixinAppId, Params.WeixinAppSecret);

            ViewBag.TimeStamp = WxPayApi.GenerateTimeStamp();
            ViewBag.NonceStr  = WxPayApi.GenerateNonceStr();
            ViewBag.Signature = WxPayApi.GetSignature(Request.Url.ToString().Split('#')[0], cacheToken, ViewBag.TimeStamp, ViewBag.NonceStr);
            ViewBag.IsReport  = IUserActivityService.IsExits(x => x.TargetID == id && x.JoinUserID == LoginUser.ID);
            return(View(model));
        }
Пример #6
0
        // GET: User
        public ActionResult BuyTime()
        {
            if (LoginUser == null)
            {
                return(Redirect("/login/index?redirect_uri=" + this.Request.Url.ToString()));
            }
            var user = IUserService.Find(LoginUser.ID);

            if (user.Password.IsNullOrEmpty())
            {
                return(RedirectToAction("PersonData", "user"));
            }
            ViewBag.AppId = Params.WeixinAppId;
            string cacheToken = WxPayApi.GetCacheToken(Params.WeixinAppId, Params.WeixinAppSecret);

            ViewBag.TimeStamp = WxPayApi.GenerateTimeStamp();
            ViewBag.NonceStr  = WxPayApi.GenerateNonceStr();
            ViewBag.Signature = WxPayApi.GetSignature(Params.SiteUrl, cacheToken, ViewBag.TimeStamp, ViewBag.NonceStr);
            return(View(IRechargePlanService.GetList()));
        }
Пример #7
0
        /// <summary>
        /// 砍价活动页面
        /// </summary>
        /// <param name="id"></param>
        /// <param name="userActId"></param>
        /// <returns></returns>
        public ActionResult KanJia(string id, string userActId)
        {
            var model = new KanJia();

            if (userActId.IsNotNullOrEmpty())
            {
                var userAct = IUserActivityService.Find(x => x.ID == userActId);
                if (userAct == null)
                {
                    return(Forbidden());
                }
                model = IKanJiaService.Find(userAct.TargetID);
                //帮砍价人列表
                ViewBag.KanJiaList = IUserActivityService.GetList(x => x.TargetID == userAct.TargetID && !string.IsNullOrEmpty(x.TargetUserID) && x.TargetUserID == userAct.JoinUserID);
                ViewBag.Price      = userAct.Amount;
                ViewBag.JoinUserID = userAct.JoinUserID;
                id = userAct.TargetID;
            }
            else
            {
                var userActModel = IUserActivityService.Find(x => x.TargetID == id && string.IsNullOrEmpty(x.TargetUserID) && x.JoinUserID == LoginUser.ID && x.IsDelete);
                if (userActModel != null)
                {
                    var userAct = IUserActivityService.Find(x => x.ID == userActId);
                    if (userAct == null || userAct.IsDelete)
                    {
                        return(Forbidden());
                    }
                    model = IKanJiaService.Find(userAct.TargetID);
                    //帮砍价人列表
                    ViewBag.KanJiaList = IUserActivityService.GetList(x => x.TargetID == userAct.TargetID && !string.IsNullOrEmpty(x.TargetUserID) && x.TargetUserID == userAct.JoinUserID);
                    ViewBag.Price      = userAct.Amount;
                    ViewBag.JoinUserID = userAct.JoinUserID;
                    id = userActModel.TargetID;
                }
                else
                {
                    model = IKanJiaService.Find(id);
                    //帮砍价人列表
                    ViewBag.KanJiaList = new List <UserActivity>();
                    ViewBag.Price      = model.OldPrice;
                    ViewBag.JoinUserID = "";

                    if (model == null)
                    {
                        return(Forbidden());
                    }
                    model.ClickCount++;
                    IKanJiaService.Update(model);
                }
            }

            ViewBag.IsReport = IUserActivityService.IsExits(x => x.TargetID == id && x.JoinUserID == LoginUser.ID && string.IsNullOrEmpty(x.TargetUserID));
            ViewBag.AppId    = Params.WeixinAppId;
            string cacheToken = WxPayApi.GetCacheToken(Params.WeixinAppId, Params.WeixinAppSecret);

            ViewBag.TimeStamp = WxPayApi.GenerateTimeStamp();
            ViewBag.NonceStr  = WxPayApi.GenerateNonceStr();
            ViewBag.Signature = WxPayApi.GetSignature(Request.Url.ToString().Split('#')[0], cacheToken, ViewBag.TimeStamp, ViewBag.NonceStr);
            // LogHelper.WriteDebug($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm")} appid={ViewBag.AppId},TimeStamp={ViewBag.TimeStamp},NonceStr={ViewBag.NonceStr},Signature={ViewBag.Signature}");
            return(View(model));
        }