Пример #1
0
        public JsonResult PostLike(UserStore data)
        {
            PaginationInfo paging = new PaginationInfo();
            IList <Like>   likes  = ilike.Get(null, data.Bady.ID.ToString(), UserName, 3, 1, 1, 0, null, out paging);

            if (likes != null && likes.Count > 0)
            {
                Like like = likes[0];
                like.Likednum   = data.needliked;
                like.Commentnum = data.needcommment;
                like.Recordnum  = data.needrecord;
                like.Likenum    = data.needlike;
                like.Supernum   = data.needsuper;
                like.Comment    = data.msg;

                decimal totalpoint = 0;
                IList <SettingGroup> groupsetting = isetting.GetSystemSetting();
                string  likeprice         = GetSettingVal(groupsetting, "65AD5D23-2619-480E-B6A9-84C58AD07DCB");
                string  commentprice      = GetSettingVal(groupsetting, "4D2E7311-BA9F-468B-BC3B-3F938C9CC3EA");
                string  likedprice        = GetSettingVal(groupsetting, "FB8E6B56-DEA6-4D70-9C52-E451E7423F55");
                string  recordprice       = GetSettingVal(groupsetting, "88841710-5B5F-4581-9557-85103CD65534");
                string  supperrecordprice = GetSettingVal(groupsetting, "6FF927CF-5676-43B2-A9B4-F72C346E22DE");
                decimal alivepoint        = GetAlivePoint();

                totalpoint += data.needlike * decimal.Parse(likeprice);
                totalpoint += data.needrecord * decimal.Parse(recordprice);
                totalpoint += data.needliked * decimal.Parse(likedprice);
                totalpoint += data.needcommment * decimal.Parse(commentprice);
                totalpoint += data.needsuper * decimal.Parse(supperrecordprice);

                if (alivepoint >= totalpoint)
                {
                    like.Statues = 0;
                    bool isupdate = ilike.Update(like);
                    if (isupdate)
                    {
                        like.ID         = Guid.NewGuid();
                        like.Statues    = 1;
                        like.Runstatues = 0;
                        Guid iscreate = ilike.Create(like);
                        if (iscreate == like.ID)
                        {
                            WriteLog(UserName + "分派了首页直达任务 编号为" + like.ID.ToString());
                            ResultMsg msg = new ResultMsg {
                                Msg = "开始成功", Result = true
                            };
                            ReduceUserPoint(totalpoint, "发布首页直达任务,冻结积分:" + ((int)totalpoint).ToString());
                            return(Json(msg, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            ResultMsg msg = new ResultMsg {
                                Msg = "开始失败", Result = false
                            };
                            return(Json(false, JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        ResultMsg msg = new ResultMsg {
                            Msg = "开始失败", Result = false
                        };
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    ResultMsg msg = new ResultMsg {
                        Msg = "可用积分不足", Result = false
                    };
                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                decimal totalpoint = 0;
                IList <SettingGroup> groupsetting = isetting.GetSystemSetting();
                string likeprice         = GetSettingVal(groupsetting, "65AD5D23-2619-480E-B6A9-84C58AD07DCB");
                string commentprice      = GetSettingVal(groupsetting, "4D2E7311-BA9F-468B-BC3B-3F938C9CC3EA");
                string likedprice        = GetSettingVal(groupsetting, "FB8E6B56-DEA6-4D70-9C52-E451E7423F55");
                string recordprice       = GetSettingVal(groupsetting, "88841710-5B5F-4581-9557-85103CD65534");
                string supperrecordprice = GetSettingVal(groupsetting, "6FF927CF-5676-43B2-A9B4-F72C346E22DE");

                decimal alivepoint = GetAlivePoint();

                totalpoint += data.needlike * decimal.Parse(likeprice);
                totalpoint += data.needrecord * decimal.Parse(recordprice);
                totalpoint += data.needliked * decimal.Parse(likedprice);
                totalpoint += data.needcommment * decimal.Parse(commentprice);
                totalpoint += data.needsuper * decimal.Parse(supperrecordprice);
                //totalpoint += like.Supernum * decimal.Parse(superrecordprice);
                if (alivepoint >= totalpoint)
                {
                    Like like = new Like
                    {
                        ID         = Guid.NewGuid(),
                        Likednum   = data.needliked,
                        Commentnum = data.needcommment,
                        Recordnum  = data.needrecord,
                        Likenum    = data.needlike,
                        Bady       = new Bady {
                            ID = data.Bady.ID
                        },

                        Type       = 1,
                        Comment    = data.msg,
                        Runstatues = 0,
                        Statues    = 1,
                        Supernum   = data.needsuper,
                        Username   = UserName
                    };

                    Guid id = ilike.Create(like);
                    WriteLog(UserName + "分派了首页直达任务 编号为" + like.ID.ToString());
                    if (id == like.ID)
                    {
                        ResultMsg msg = new ResultMsg {
                            Msg = "开始成功", Result = true
                        };
                        ReduceUserPoint(totalpoint, "发布首页直达任务,冻结积分:" + ((int)totalpoint).ToString());
                        return(Json(msg, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        ResultMsg msg = new ResultMsg {
                            Msg = "开始失败", Result = false
                        };
                        return(Json(false, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    ResultMsg msg = new ResultMsg {
                        Msg = "可用积分不足", Result = false
                    };
                    return(Json(msg, JsonRequestBehavior.AllowGet));
                }
            }
        }
Пример #2
0
        public JsonResult StopLiking(List <Like> data)
        {
            PaginationInfo paging = new PaginationInfo();

            //IList<Share> shares = ishare.Get(null, UserName, null, null, null, null, null, 1, 0, null, out paging);
            //Share share = shares[0];
            //bool isdelete = ishare.Delete(share);
            try
            {
                IList <SettingGroup> systemsettings = isetting.GetSystemSetting();
                var likedprice       = decimal.Parse(GetSettingVal(systemsettings, "FB8E6B56-DEA6-4D70-9C52-E451E7423F55"));
                var likeprice        = decimal.Parse(GetSettingVal(systemsettings, "65AD5D23-2619-480E-B6A9-84C58AD07DCB"));
                var commentprice     = decimal.Parse(GetSettingVal(systemsettings, "4D2E7311-BA9F-468B-BC3B-3F938C9CC3EA"));
                var recordprice      = decimal.Parse(GetSettingVal(systemsettings, "88841710-5B5F-4581-9557-85103CD65534"));
                var superrecordprice = decimal.Parse(GetSettingVal(systemsettings, "6FF927CF-5676-43B2-A9B4-F72C346E22DE"));

                foreach (Like s in data)
                {
                    Like like = ilike.Get(s.ID);
                    like.Runstatues = 3;
                    bool isupdate = ilike.Update(like);

                    decimal totalpoint    = likeprice * like.Likenum + likedprice * like.Likednum + commentprice * like.Commentnum + recordprice * like.Recordnum + superrecordprice * like.Supernum;
                    decimal completepoint = 0;

                    IList <Task> starttasks = itask.Get(null, null, like.ID, null, null, null, null, 1, 0, null, out paging);

                    var likecompletenum        = starttasks.Where(m => m.TaskType == "like" && m.Runstatues == 2).Count();
                    var likedcompletenum       = starttasks.Where(m => m.TaskType == "liked" && m.Runstatues == 2).Count();
                    var commentcompletenum     = starttasks.Where(m => m.TaskType == "commment" && m.Runstatues == 2).Count();
                    var recordcompletenum      = starttasks.Where(m => m.TaskType == "record" && m.Runstatues == 2).Count();
                    var superrecordcompletenum = starttasks.Where(m => m.TaskType == "superrecord" && m.Runstatues == 2).Count();
                    completepoint = likeprice * likecompletenum + likedprice * likedcompletenum + commentprice * commentcompletenum + recordprice * recordcompletenum + superrecordprice * superrecordcompletenum;
                    foreach (Task t in starttasks)
                    {
                        if (t.Runstatues != 2)
                        {
                            t.Runstatues = 3;
                            t.Statues    = 0;
                            itask.Update(t);
                        }
                    }


                    if (isupdate)
                    {
                        WriteLog(UserName + "停止喜欢任务 编号为" + like.ID.ToString());
                        if (totalpoint - completepoint == 0)
                        {
                            AddUserPoint(totalpoint - completepoint, "停止喜欢任务,但是该任务已经被人完成,编号为" + like.ID.ToString() + ",返回积分:" + (totalpoint - completepoint).ToString());
                        }
                        else
                        {
                            AddUserPoint(totalpoint - completepoint, "停止喜欢任务,编号为" + like.ID.ToString() + ",返回积分:" + (totalpoint - completepoint).ToString());
                        }
                    }
                }

                return(Json(new ResultMsg {
                    Msg = "停止成功", Result = true
                }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new ResultMsg {
                    Msg = "停止失败", Result = false
                }, JsonRequestBehavior.AllowGet));
            }
        }