示例#1
0
        public string MonthRewards(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 MonthRewardsRD();
            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.MonthRewards(rp.Parameters.UserOrRetailID, loggingSessionInfo.ClientID, year); //获取
            var VipRiseList = new List <MonthRewardInfo>();

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


            int currentMonth = DateTime.Now.Month;

            //判断账号是否存在
            rd.MonthRewardList = new List <MonthRewardInfo>();
            for (int i = 1; i <= currentMonth; i++)
            {
                MonthRewardInfo temp = VipRiseList.Where(p => p.Month == i).SingleOrDefault();//直接根据所需要的字段反序列化
                if (temp == null)
                {
                    temp                  = new MonthRewardInfo();
                    temp.Year             = year;
                    temp.Month            = i;
                    temp.MonthAmount      = 0;
                    temp.MonthVipAmount   = 0;
                    temp.MonthTradeAmount = 0;
                }
                rd.MonthRewardList.Add(temp);
            }

            rd.MonthRewardList.Reverse();//顺序反转
            return(rsp.ToJSON());
        }