Ejemplo n.º 1
0
        public string GetVipDayRiseList(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <SellUserMainAchieveRP> >();

            if (string.IsNullOrEmpty(rp.Parameters.RetailTraderID))
            {
                throw new APIException("缺少参数【RetailTraderID】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
            var bll = new RetailTraderBLL(loggingSessionInfo);
            var rd  = new GetVipDayRiseListRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);
            //获取分销商的信息,loggingSessionInfo.ClientID
            // int month = DateTime.Now.Month;
            //int year = DateTime.Now.Year;//目前只取今年的
            //int month = DateTime.Now.Month;//目前只取今年的
            DateTime nowDay      = Convert.ToDateTime(DateTime.Now.ToShortDateString());                                                                                    //RetailTraderID
            var      ds          = bll.GetVipDayRiseList(rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID, nowDay.AddDays(-14), nowDay.AddDays(1).AddSeconds(-1)); //获取今天和前面14天的数据
            var      VipRiseList = new List <VipDayRiseTrand>();

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                var tempDt = ds.Tables[0];
                VipRiseList = DataTableToObject.ConvertToList <VipDayRiseTrand>(tempDt);//直接根据所需要的字段反序列化
            }
            int currentDay = DateTime.Now.Day;

            //判断账号是否存在
            rd.VipDayRiseList = new List <VipDayRiseTrand>();
            for (DateTime i = nowDay.AddDays(-14); i <= nowDay; i = i.AddDays(1))
            {
                VipDayRiseTrand temp = VipRiseList.Where(p => p.formatDate == i.ToString("yyyy-MM-dd")).SingleOrDefault();//直接根据所需要的字段反序列化
                if (temp == null)
                {
                    temp            = new VipDayRiseTrand();
                    temp.Year       = i.Year;
                    temp.Month      = i.Month;
                    temp.Day        = i.Day;
                    temp.formatDate = temp.Year + "-" + temp.Month + "-" + temp.Day;

                    temp.vipCount = 0;
                }
                temp.myDate = temp.Month + "/" + temp.Day;
                rd.VipDayRiseList.Add(temp);
            }
            return(rsp.ToJSON());
        }