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