[HttpGet, Produces(typeof(ResponseDto))]//, AllowAnonymous public async Task <IActionResult> CheckInSendIntergral(string userID, UserType userType = UserType.Consumer) { if (string.IsNullOrWhiteSpace(userID)) { userID = UserID; } var scoreBiz = new ScoreExBiz(); if (scoreBiz.CheckInSendIntergral(UserID, userType.ToString())) { return(Failed(ErrorCode.SystemException, "今日已签到")); } var theRightIntergral = 0; //连续签到 判断 一个月为期,首日签到1积分,连续签到递增1积分, //连续签到上限为7积分,连续签到8,9,10天均为7个积分,若中断则重新计算,一个月最多得189分 var recordModel = await scoreBiz.GetCheckInSendIntergralRecord(UserID, SendIntergralEnum.连续签到送积分.ToString(), userType); if (recordModel != null && (DateTime.Now.Date - recordModel.CreationDate.Date).Days.Equals(1)) { //满勤的情况 var modelList = await scoreBiz.GetModelListByCondition(UserID, userType.ToString(), 30); theRightIntergral = recordModel.Variation < 7 ? recordModel.Variation + 1 : modelList.Where(a => a.Variation.Equals(7)).ToList().Count > 23 && modelList.Where(a => a.Variation.Equals(1)).ToList().Count == 1 && modelList[modelList.Count - 1].Variation == 1 ? 1 : 7; } else { theRightIntergral = 1; } var isSucc = InsertIntergral(theRightIntergral, SendIntergralEnum.连续签到送积分, userType); return(isSucc ? Success() : Failed(ErrorCode.DataBaseError, "签到积分插入错误")); }
[HttpGet, Produces(typeof(ResponseDto <GetUserSignInDataCurrentMonthResponse>))]//,AllowAnonymous public async Task <IActionResult> GetUserSignInDataCurrentMonthAsync(GetUserSignInDataCurrentMonthRequest request) { if (string.IsNullOrWhiteSpace(request.UserID)) { request.UserID = UserID; } var scoreBiz = new ScoreExBiz(); GetUserSignInDataCurrentMonthResponse response = new GetUserSignInDataCurrentMonthResponse(); var recordModel = await scoreBiz.GetCheckInSendIntergralRecord(request.UserID, SendIntergralEnum.连续签到送积分.ToString(), request.UserType); if (recordModel != null) { TimeSpan interval = DateTime.Now.Date - recordModel.CreationDate.Date; if (interval.Days.Equals(1) || interval.Days.Equals(0)) { var checkInInfoList = new List <GetUserSignInDataCurrentMonthResponse.CheckInInfo>(); if (recordModel.Variation < 7) { var modelListLessThan7 = await scoreBiz.GetModelListByCondition(request.UserID, request.UserType.ToString(), recordModel.Variation); return(Success(GetResponseData(modelListLessThan7))); } var modelList = await scoreBiz.GetModelListByCondition(request.UserID, request.UserType.ToString(), 30); var conditionModel = modelList.Take(7).Where(a => a.Variation.Equals(6)).ToList().Count == 0 ? modelList.Take(14).Where(a => a.Variation.Equals(6)).ToList().Count == 0 ? modelList.Take(21).Where(a => a.Variation.Equals(6)).ToList().Count == 0 ? modelList.Take(28).Where(a => a.Variation.Equals(6)).ToList().Count == 0 ? modelList.Where(a => a.Variation.Equals(6)).ToList() : modelList.Take(28).Where(a => a.Variation.Equals(6)).ToList() : modelList.Take(21).Where(a => a.Variation.Equals(6)).ToList() : modelList.Take(14).Where(a => a.Variation.Equals(6)).ToList() : modelList.Take(7).Where(a => a.Variation.Equals(6)).ToList(); if (conditionModel.Count != 1) { return(Failed(ErrorCode.DataBaseError, "数据有误,请联系管理员!")); } var dataIndex = modelList.FindIndex(a => a.ScoreGuid.Equals(conditionModel[0].ScoreGuid)); var realModelList = modelList.Take(dataIndex + 6).ToList(); return(Success(GetResponseData(realModelList))); } } //重新签到 var newModelList = new List <ScoreModel>(); return(Success(GetResponseData(newModelList))); }