public JsonResult AddUserPoint(int id = 0, int points = 0, int taskType = 0, string pointDesc = "") { if (taskType > 0)//关联任务的 { UserTaskLogBll userTaskBll = new UserTaskLogBll(); int point = userTaskBll.UserTaskLogAdd(id, taskType, pointDesc); if (point > 0) { return(Json(new { code = 1, msg = "操作成功增加" + point + "分" })); } else { return(Json(new { code = -100, msg = "未知错误" })); } } else { if (points == 0) { return(Json(new { code = -1, msg = "改动积分不能为0" })); } if (string.IsNullOrEmpty(pointDesc)) { return(Json(new { code = -1, msg = "请添加积分备注" })); } int row = user.AddUserPoint(id, points, pointDesc); if (row > 0) { return(Json(new { code = 1, msg = "操作成功" })); } return(Json(new { code = -100, msg = "未知错误" })); } }
/// <summary> /// 获取每日任务状态 /// </summary> /// <param name="userId"></param> /// <param name="refresh">是否直接读库</param> /// <returns></returns> public static Dictionary <string, string> GetEveryDayTask(int userId, bool refresh = false) { string hashId = "HeziTasks_" + userId; //RedisHelper.ClearQueue(hashId); Dictionary <string, string> userTaskListDic = refresh ? new Dictionary <string, string>() : RedisHelper.GetAllEntriesFromHash(hashId); if (userTaskListDic.Count <= 0) { UserTaskLogBll userTaskBll = new UserTaskLogBll(); List <UserTaskModel> userTaskList = userTaskBll.GetUserTask_EveryDay(userId); if (userTaskList.IsNoNull()) { userTaskListDic = ResetEverydayTask(hashId, userTaskList); } } return(userTaskListDic); }
public virtual void DoTask(int uid, PointsEnum pointsEnum, out int points) { points = 0; UserTaskLogBll userTaskLog = new UserTaskLogBll(); Dictionary <string, string> userTaskInfo = TaskHelper.GetEveryDayTask(uid); int taskKey = (int)pointsEnum; if (userTaskInfo != null) { if (!userTaskInfo.ContainsKey(taskKey.ToString()))//没有任务状态 { userTaskInfo = TaskHelper.GetEveryDayTask(uid, true); } if (userTaskInfo != null && userTaskInfo.ContainsKey(taskKey.ToString()) && userTaskInfo[taskKey.ToString()] == "-1")//未做过 { userTaskLog.UserTaskLogAdd(uid, taskKey); TaskHelper.SetEveryDayTask(uid, taskKey, 0); } } }