Example #1
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));
        }
Example #2
0
        public JsonResult Manage(KanJia entity)
        {
            ModelState.Remove("ID");
            ModelState.Remove("CreatedTime");
            ModelState.Remove("UpdatedTime");
            ModelState.Remove("IsDelete");
            ModelState.Remove("IsNeedPay");
            ModelState.Remove("IsNeedReport");
            ModelState.Remove("UserID");
            if (ModelState.IsValid)
            {
                if (entity.OldPrice < entity.LessPrice + entity.OncePrice)
                {
                    return(DataErorrJResult());
                }
                if (entity.ID.IsNullOrEmpty())
                {
                    if (entity.EndTime < entity.StartTime)
                    {
                        return(JResult(Core.Code.ErrorCode.end_time_error, ""));
                    }
                    if (entity.StartTime < DateTime.Now)
                    {
                        return(JResult(Core.Code.ErrorCode.start_time_error, ""));
                    }
                    entity.IsNeedPay    = false;
                    entity.IsNeedReport = false;
                    entity.UserID       = LoginUser.ID;
                    entity.CountLimit   = entity.CountLimit;
                    entity.CreatedTime  = entity.UpdatedTime = DateTime.Now;
                    var guid = Guid.NewGuid().ToString("N");
                    entity.ID = guid;
                    if (IKanJiaService.Add(entity) > 0)
                    {
                        return(JResult(entity.ID.IsNullOrEmpty()?guid:entity.ID));
                    }
                    else
                    {
                        return(DataErorrJResult());
                    }
                }
                else
                {
                    if (entity.EndTime < entity.StartTime)
                    {
                        return(JResult(Core.Code.ErrorCode.end_time_error, ""));
                    }
                    var model = IKanJiaService.Find(entity.ID);
                    if (model == null || (model != null && model.IsDelete))
                    {
                        return(DataErorrJResult());
                    }
                    if (model.UserID != LoginUser.ID)
                    {
                        return(DataErorrJResult());
                    }
                    model.CountLimit     = entity.CountLimit;
                    model.Name           = entity.Name;
                    model.Picture        = entity.Picture;
                    model.StartTime      = entity.StartTime;
                    model.EndTime        = entity.EndTime;
                    model.Connact        = entity.Connact;
                    model.Rules          = entity.Rules;
                    model.MusicUrl       = entity.MusicUrl;
                    model.FunctionName   = entity.FunctionName;
                    model.OldPrice       = entity.OldPrice;
                    model.LessPrice      = entity.LessPrice;
                    model.OncePrice      = entity.OncePrice;
                    model.LimitHour      = entity.LimitHour;
                    model.PrizeCount     = entity.PrizeCount;
                    model.UsedCount      = entity.UsedCount;
                    model.GoodsItemsJson = entity.GoodsItemsJson;

                    model.IntroduceTxtJson      = entity.IntroduceTxtJson;
                    model.IntroducePicturesJson = entity.IntroducePicturesJson;
                    model.IntroduceVediosJson   = entity.IntroduceVediosJson;
                    model.Direction             = entity.Direction;
                    var result = IKanJiaService.Update(model);
                    return(JResult(result));
                }
            }
            else
            {
                return(ParamsErrorJResult(ModelState));
            }
        }