Esempio n. 1
0
        public JsonResult UserTaskDraw(int taskId)
        {
            PublicUserModel loginUser = this.GetLoginUser();
            int             result    = userTaskBll.UserTaskLogDraw(loginUser.UserID, taskId);
            string          msg       = string.Empty;

            if (result <= 0)
            {
                switch (result)
                {
                case -1:
                    msg = "任务不存在";
                    break;

                case -2:
                case -3:
                    msg = "已经签到";
                    break;

                default:
                    msg = "未知错误";
                    break;
                }
            }
            else
            {
                msg = "领取成功+" + result + "积分";
            }
            return(Json(new { status = result, msg = msg }));
        }
Esempio n. 2
0
        public ApiResponse DaySign()
        {
            int      userId        = GetCurrentUserId();
            int      result        = 0;
            int      gainPoints    = 0;
            string   gainPointsMsg = "";
            int      taskKey       = 0;
            int      timeOut       = 4;//四小时时间
            DateTime nowTime       = DateTime.Now;

            #region 判断时间
            if (nowTime.Hour >= 8 && nowTime.Hour < 8 + timeOut)
            {
                taskKey = (int)PointsEnum.EveryDay_Sign_8;
            }
            else if (nowTime.Hour >= 15 && nowTime.Hour < 15 + timeOut)
            {
                taskKey = (int)PointsEnum.EveryDay_Sign_16;
            }
            #endregion


            if (taskKey > 0)
            {
                int addResult = 0;
                Dictionary <string, string> userTaskInfo = TaskHelper.GetEveryDayTask(userId);
                if (userTaskInfo != null)
                {
                    if (!userTaskInfo.ContainsKey(taskKey.ToString()))//没有任务状态
                    {
                        userTaskInfo = TaskHelper.GetEveryDayTask(userId, true);
                    }
                    if (userTaskInfo != null)
                    {
                        if (userTaskInfo.ContainsKey(taskKey.ToString()) && userTaskInfo[taskKey.ToString()] == "-1")//未做过
                        {
                            addResult = userTaskLog.UserTaskLogAdd(userId, taskKey);
                            TaskHelper.SetEveryDayTask(userId, taskKey, 0);
                        }
                    }
                }
                if (addResult > 0)
                {
                    result = userTaskLog.UserTaskLogDraw(userId, taskKey);
                    #region 结果
                    if (result <= 0)
                    {
                        switch (result)
                        {
                        case -1:
                            return(new ApiResponse(Metas.Task_Null));

                        case -2:
                        case -3:
                            return(new ApiResponse(Metas.Sign_EXISTS));

                        default:
                            return(new ApiResponse(Metas.Sign_EXISTS));
                        }
                    }
                    else
                    {
                        gainPoints    = result;
                        gainPointsMsg = "成功领取+" + result + "积分";
                    }
                    #endregion
                }
                else
                {
                    #region 结果

                    switch (addResult)
                    {
                    case -1:
                        return(new ApiResponse(Metas.Task_Null));

                    case -2:
                    case -3:
                        return(new ApiResponse(Metas.Sign_EXISTS));

                    default:
                        return(new ApiResponse(Metas.Sign_EXISTS));
                    }
                    #endregion
                }
            }
            else
            {
                return(new ApiResponse(Metas.Appointed_Time));

                gainPointsMsg = "";
            }
            var response = new
            {
                GainPoints    = gainPoints,
                GainPointsMsg = gainPointsMsg
            };
            return(new ApiResponse(Metas.SUCCESS, response));
        }