예제 #1
0
        public string RetailCoupon(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <GetRetailVipInfosRP> >();

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

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
            var bll           = new RetailTraderBLL(loggingSessionInfo);
            var rd            = new RetailCouponRD();
            var rsp           = new SuccessResponse <IAPIResponseData>(rd);
            var CouponTypeBll = new CouponTypeBLL(loggingSessionInfo);


            //优惠券状态为1代表已经使用,为0
            //已核销优惠券列表
            var ds3 = bll.GetRetailCoupon(rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID, 1, pageIndex ?? 1, pageSize ?? 15, rp.Parameters.OrderBy, rp.Parameters.OrderType);   //获取

            if (ds3 != null && ds3.Tables.Count > 0 && ds3.Tables[0].Rows.Count > 0)
            {
                rd.WriteOffCouponCount = Convert.ToInt32(ds3.Tables[0].Rows[0]["TotalCount"].ToString());
                rd.WriteOffCouponList  = DataTableToObject.ConvertToList <RetailCouponInfo>(ds3.Tables[1]);
            }



            //未核销优惠券列表
            var ds4 = bll.GetRetailCoupon(rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID, 0, pageIndex ?? 1, pageSize ?? 15, rp.Parameters.OrderBy, rp.Parameters.OrderType);   //获取

            if (ds4 != null && ds4.Tables.Count > 0 && ds4.Tables[0].Rows.Count > 0)
            {
                rd.NoWriteOffCouponCount = Convert.ToInt32(ds4.Tables[0].Rows[0]["TotalCount"].ToString());
                rd.NoWriteOffCouponList  = DataTableToObject.ConvertToList <RetailCouponInfo>(ds4.Tables[1]);
            }

            rd.AllCouponCouponCount = rd.WriteOffCouponCount + rd.NoWriteOffCouponCount;

            #region 获取适用所有门店的券
            var CouponTypeList = CouponTypeBll.QueryByEntity(new CouponTypeEntity()
            {
                SuitableForStore = 3, CustomerId = loggingSessionInfo.ClientID
            }, null).ToList();
            if (CouponTypeList.Count > 0)
            {
                foreach (var item in CouponTypeList)
                {
                    int Count = CouponTypeBll.GetCouponCount(item.CouponTypeID.ToString());
                    rd.AllCouponCouponCount += Count;
                }
            }
            #endregion

            return(rsp.ToJSON());
        }
예제 #2
0
        public string RetailTraderMain(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <GetRetailVipInfosRP> >();

            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 RetailTraderMainRD();
            var rsp           = new SuccessResponse <IAPIResponseData>(rd);
            var CouponTypeBll = new CouponTypeBLL(loggingSessionInfo);
            //  BringVipCount//我为兰博士带多少会员
            //  RewardAmount//奖励多少钱
            //累计会员数量
            var ds3 = bll.GetRetailVipInfos(rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID, -1, -1, -1);   //获取

            if (ds3 != null && ds3.Tables.Count > 0 && ds3.Tables[0].Rows.Count > 0)
            {
                var tempDt = ds3.Tables[0];
                rd.BringVipCount = tempDt.Rows.Count;
            }
            //累积奖励
            decimal TotalRewards = bll.RetailRewardByAmountSource(rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID, -1, -1, -1, "17")
                                   + bll.RetailRewardByAmountSource(rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID, -1, -1, -1, "14")
                                   + bll.RetailRewardByAmountSource(rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID, -1, -1, -1, "15");    //获取

            rd.RewardAmount = TotalRewards;

            int?pageIndex = 1;
            int?pageSize  = 10000;
            //未核销优惠券列表
            int NoWriteOffCouponCount = 0;
            var ds4 = bll.GetRetailCoupon(rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID, 0, pageIndex ?? 1, pageSize ?? 15, rp.Parameters.OrderBy, rp.Parameters.OrderType);   //获取

            if (ds4 != null && ds4.Tables.Count > 0 && ds4.Tables[0].Rows.Count > 0)
            {
                //var tempDt = ds4.Tables[0];
                NoWriteOffCouponCount = Convert.ToInt32(ds4.Tables[0].Rows[0]["TotalCount"].ToString());//tempDt.Rows.Count;
                //  rd.WriteOffCouponList = DataTableToObject.ConvertToList<RetailCouponInfo>(ds4.Tables[1]);
            }

            var ds5 = bll.GetRetailCoupon(rp.Parameters.RetailTraderID, loggingSessionInfo.ClientID, 1, pageIndex ?? 1, pageSize ?? 15, rp.Parameters.OrderBy, rp.Parameters.OrderType);   //获取

            if (ds5 != null && ds5.Tables.Count > 0 && ds5.Tables[0].Rows.Count > 0)
            {
                //var tempDt = ds5.Tables[0];
                rd.UsedCoupon = Convert.ToInt32(ds5.Tables[0].Rows[0]["TotalCount"].ToString());
                //  rd.WriteOffCouponList = DataTableToObject.ConvertToList<RetailCouponInfo>(ds3.Tables[1]);
            }


            //    rd.AllCouponCouponCount = rd.WriteOffCouponCount + rd.NoWriteOffCouponCount;


            rd.SendCouponCount = rd.UsedCoupon + NoWriteOffCouponCount;//	兰博士为我发券数量

            #region 获取适用所有门店的券
            var CouponTypeList = CouponTypeBll.QueryByEntity(new CouponTypeEntity()
            {
                SuitableForStore = 3, CustomerId = loggingSessionInfo.ClientID
            }, null).ToList();
            if (CouponTypeList.Count > 0)
            {
                foreach (var item in CouponTypeList)
                {
                    int Count = CouponTypeBll.GetCouponCount(item.CouponTypeID.ToString());
                    rd.SendCouponCount += Count;
                }
            }
            #endregion


            return(rsp.ToJSON());
        }