public string MonthDayRewards(string pRequest) { var rp = pRequest.DeserializeJSONTo <APIRequest <SellUserMainAchieveRP> >(); if (string.IsNullOrEmpty(rp.Parameters.UserOrRetailID)) { throw new APIException("缺少参数【UserOrRetailID】或参数值为空") { ErrorCode = 135 }; } var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1"); var bll = new RetailTraderBLL(loggingSessionInfo); var rd = new MonthDayRewardsRD(); var rsp = new SuccessResponse <IAPIResponseData>(rd); //获取分销商的信息,loggingSessionInfo.ClientID // int month = DateTime.Now.Month; int year = DateTime.Now.Year; //目前只取今年的 int month = DateTime.Now.Month; //目前只取今年的 var ds = bll.MonthDayRewards(rp.Parameters.UserOrRetailID, loggingSessionInfo.ClientID, year, month); //获取 var VipRiseList = new List <RewardsDayRiseTrand>(); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { var tempDt = ds.Tables[0]; VipRiseList = DataTableToObject.ConvertToList <RewardsDayRiseTrand>(tempDt);//直接根据所需要的字段反序列化 } int currentDay = DateTime.Now.Day; //判断账号是否存在 rd.MonthRewardList = new List <RewardsDayRiseTrand>(); for (int i = 1; i <= currentDay; i++) { RewardsDayRiseTrand temp = VipRiseList.Where(p => p.Day == i).SingleOrDefault();//直接根据所需要的字段反序列化 if (temp == null) { temp = new RewardsDayRiseTrand(); temp.Year = year; temp.Month = month; temp.Day = i; temp.formatDate = year + "-" + month + "-" + i; temp.DayAmount = 0; temp.DayVipAmount = 0; temp.DayTradeAmount = 0; } rd.MonthRewardList.Add(temp); } rd.MonthRewardList.Reverse();//按照日期倒序 return(rsp.ToJSON()); }