Beispiel #1
0
 public ViewResult Manage(string id)
 {
     if (id.IsNullOrEmpty())
     {
         return(View(new MiaoSha()));
     }
     else
     {
         return(View(IMiaoShaService.Find(id)));
     }
 }
Beispiel #2
0
 /// <summary>
 /// 分享
 /// </summary>
 /// <param name="id"></param>
 /// <param name="code"></param>
 /// <returns></returns>
 public ActionResult AddShare(string id, TargetCode code)
 {
     if (code == TargetCode.Kanjia)
     {
         var kanjia = IKanJiaService.Find(id);
         if (kanjia == null || kanjia.IsDelete)
         {
             return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
         }
         kanjia.ShareCount++;
         return(JResult(IKanJiaService.Update(kanjia)));
     }
     else if (code == TargetCode.Pintuan)
     {
         var pintuan = IPinTuanService.Find(id);
         if (pintuan == null || pintuan.IsDelete)
         {
             return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
         }
         pintuan.ShareCount++;
         return(JResult(IPinTuanService.Update(pintuan)));
     }
     else if (code == TargetCode.Miaosha)
     {
         var miaosha = IMiaoShaService.Find(id);
         if (miaosha == null || miaosha.IsDelete)
         {
             return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
         }
         miaosha.ShareCount++;
         return(JResult(IMiaoShaService.Update(miaosha)));
     }
     else if (code == TargetCode.Pintu)
     {
         var pintu = IPinTuService.Find(id);
         if (pintu == null || pintu.IsDelete)
         {
             return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
         }
         pintu.ShareCount++;
         return(JResult(IPinTuService.Update(pintu)));
     }
     return(DataErorrJResult());
 }
Beispiel #3
0
 /// <summary>
 /// 查找
 /// </summary>
 /// <returns></returns>
 public ActionResult Find(string id)
 {
     return(JResult(IMiaoShaService.Find(id)));
 }
Beispiel #4
0
        /// <summary>
        ///核销
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public ActionResult ToUsed(string id)
        {
            var userActivityModel = IUserActivityService.Find(x => x.ID == id);

            if (userActivityModel == null || userActivityModel.IsDelete || userActivityModel.ShopUserID != LoginUser.ID || !userActivityModel.IsPrize)
            {
                return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
            }
            userActivityModel.IsUsedOnLine = true;
            if (userActivityModel.Code == TargetCode.Pintuan)
            {
                var model = IPinTuanService.Find(x => x.ID == userActivityModel.TargetID);
                if (model == null || model.IsDelete || userActivityModel.Code != TargetCode.Pintuan)
                {
                    return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
                }
                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;
                    }
                }
                userActivityModel.Amount       = price;
                userActivityModel.IsUsedOnLine = true;
                userActivityModel.UsedTime     = DateTime.Now;
            }
            else if (userActivityModel.Code == TargetCode.Kanjia)
            {
                var model = IKanJiaService.Find(x => x.ID == userActivityModel.TargetID);
                if (model == null || model.IsDelete || userActivityModel.Code != TargetCode.Kanjia || userActivityModel.TargetUserID.IsNullOrEmpty())
                {
                    return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
                }
                userActivityModel.IsUsedOnLine = true;
                userActivityModel.UsedTime     = DateTime.Now;
            }
            else if (userActivityModel.Code == TargetCode.Miaosha)
            {
                var model = IMiaoShaService.Find(x => x.ID == userActivityModel.TargetID);
                if (model == null || model.IsDelete || userActivityModel.Code != TargetCode.Miaosha)
                {
                    return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
                }
                userActivityModel.IsUsedOnLine = true;
                userActivityModel.UsedTime     = DateTime.Now;
            }
            else if (userActivityModel.Code == TargetCode.Miaosha)
            {
                var model = IMiaoShaService.Find(x => x.ID == userActivityModel.TargetID);
                if (model == null || model.IsDelete || userActivityModel.Code != TargetCode.Pintu || userActivityModel.TargetUserID.IsNullOrEmpty())
                {
                    return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
                }
                userActivityModel.IsUsedOnLine = true;
                userActivityModel.UsedTime     = DateTime.Now;
            }
            return(JResult(IUserActivityService.Update(userActivityModel)));
        }