Ejemplo n.º 1
0
        public IHttpActionResult GetList4CashAssociateCommissionReport([FromUri] CashAssociateCommissionStatisticsReportRequest request, [UserProfile] UserProfile userProfile)
        {
            IHttpActionResult httpActionResult;
            var result = CheckDataRoleAndArrangeParams(request, userProfile, out httpActionResult);

            if (!result)
            {
                return(httpActionResult);
            }

            var pagerRequest = request.PagerRequest;

            var associateIncomeRequestFilter = CashAssociateCommissionStatisticsReportFilter(request);
            var storeFilter   = StoreFilter(request.StoreId, request.DataRoleStores);
            var sectionFilter = SectionFilter(request.SectionCode);
            var userFilter    = UserFilter(request.MiniSilverNo, request.Contact);

            List <CashAssociateCommissionStatisticsReportDto> datas;
            int totalCount;

            using (var db = new YintaiHZhouContext())
            {
                var associateIncomeRequest = db.IMS_AssociateIncomeRequest.AsExpandable().Where(associateIncomeRequestFilter);
                var associates             = db.IMS_Associate;
                var stores   = db.Stores.AsExpandable().Where(storeFilter);
                var sections = db.Sections.AsExpandable().Where(sectionFilter);
                var users    = db.Users.AsExpandable().Where(userFilter);


                var sql = from air in associateIncomeRequest
                          join a in associates on air.UserId equals a.UserId
                          join store in stores on a.StoreId equals store.Id
                          join section in sections on a.SectionId equals section.Id
                          join user in users on a.UserId equals user.Id
                          where air.Status == CashStatus && a.Status == 1
                          select new CashAssociateCommissionStatisticsReportDto
                {
                    Id         = air.Id,
                    PickUpDate = air.CreateDate,
                    BankCardNo = air.BankNo,
                    BankName   = air.BankName,
                    //Fee = 1,
                    MiniSilverNo = user.Nickname,
                    PickUpAmount = air.Amount,
                    PickUpPerson = air.BankAccountName,
                    SectionCode  = section.SectionCode,
                    SectionId    = section.Id,
                    SectionName  = section.Name,
                    StoreId      = store.Id,
                    StoreName    = store.Name,
                    Contact      = user.Mobile
                                   //Taxes = null
                };



                totalCount = sql.Count();
                datas      = sql.OrderByDescending(v => v.PickUpDate).Skip(pagerRequest.SkipCount).Take(pagerRequest.PageSize).ToList();
            }


            var pager      = new PagerInfo <CashAssociateCommissionStatisticsReportDto>(pagerRequest, totalCount, datas);
            var execresult = new OkExectueResult <PagerInfo <CashAssociateCommissionStatisticsReportDto> >(pager);

            return(RetrunHttpActionResult4ExectueResult(execresult));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 礼品卡表 筛选
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        private static Expression <Func <IMS_AssociateIncomeRequest, bool> > CashAssociateCommissionStatisticsReportFilter(CashAssociateCommissionStatisticsReportRequest filter)
        {
            var query = PredicateBuilder.True <IMS_AssociateIncomeRequest>();

            if (!String.IsNullOrEmpty(filter.BankName))
            {
                query = PredicateBuilder.And(query, v => v.BankName == filter.BankName);
                return(query);
            }

            if (!String.IsNullOrEmpty(filter.BankCode))
            {
                query = PredicateBuilder.And(query, v => v.BankCode == filter.BankCode);
                return(query);
            }

            if (filter.PickUpStartDate != null)
            {
                query = PredicateBuilder.And(query, v => v.CreateDate >= filter.PickUpStartDate);
            }

            if (filter.PickUpEndDate != null)
            {
                query = PredicateBuilder.And(query, v => v.CreateDate < filter.PickUpEndDate);
            }

            return(query);
        }