Ejemplo n.º 1
0
        public async Task <TakeCashSearchResult> GetModelListAsync(long?userId, long?stateId, string keyword, DateTime?startTime, DateTime?endTime, int pageIndex, int pageSize)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                TakeCashSearchResult result = new TakeCashSearchResult();
                var entities = dbc.GetAll <TakeCashEntity>();
                if (userId != null)
                {
                    entities = entities.Where(a => a.UserId == userId);
                }
                if (stateId != null)
                {
                    entities = entities.Where(a => a.StateId == stateId);
                }
                if (!string.IsNullOrEmpty(keyword))
                {
                    entities = entities.Where(g => g.User.Mobile.Contains(keyword) || g.User.NickName.Contains(keyword));
                }
                if (startTime != null)
                {
                    entities = entities.Where(a => a.CreateTime >= startTime);
                }
                if (endTime != null)
                {
                    entities = entities.Where(a => SqlFunctions.DateDiff("day", endTime, a.CreateTime) <= 0);
                }
                result.PageCount = (int)Math.Ceiling((await entities.LongCountAsync()) * 1.0f / pageSize);
                var takeCashResult = await entities.OrderByDescending(a => a.CreateTime).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToListAsync();

                result.TakeCashes = takeCashResult.Select(a => ToDTO(a, ToDTO(dbc.GetAll <PayCodeEntity>().SingleOrDefault(p => p.UserId == a.UserId)), ToDTO(dbc.GetAll <BankAccountEntity>().SingleOrDefault(b => b.UserId == a.UserId)))).ToArray();
                return(result);
            }
        }
Ejemplo n.º 2
0
        public async Task <TakeCashSearchResult> GetModelListAsync(long?userId, long?stateId, string keyword, DateTime?startTime, DateTime?endTime, int pageIndex, int pageSize)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                TakeCashSearchResult result = new TakeCashSearchResult();
                var entities = dbc.GetAll <TakeCashEntity>();
                if (userId != null)
                {
                    entities = entities.Where(a => a.UserId == userId);
                }
                if (stateId != null)
                {
                    entities = entities.Where(a => a.StateId == stateId);
                }
                if (!string.IsNullOrEmpty(keyword))
                {
                    entities = entities.Where(g => g.User.Mobile.Contains(keyword) || g.User.NickName.Contains(keyword));
                }
                if (startTime != null)
                {
                    entities = entities.Where(a => a.CreateTime >= startTime);
                }
                if (endTime != null)
                {
                    entities = entities.Where(a => a.CreateTime <= endTime);
                }
                result.PageCount = (int)Math.Ceiling((await entities.LongCountAsync()) * 1.0f / pageSize);
                var res = await entities.OrderByDescending(a => a.CreateTime).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToListAsync();

                result.List = res.Select(a => ToDTO(a)).ToArray();
                return(result);
            }
        }
Ejemplo n.º 3
0
 public TakeCashSearchResult GetPageList(string name, string mobile, DateTime?startTime, DateTime?endTime, int pageIndex, int pageSize)
 {
     using (MyDbContext dbc = new MyDbContext())
     {
         TakeCashSearchResult           result = new TakeCashSearchResult();
         CommonService <TakeCashEntity> cs     = new CommonService <TakeCashEntity>(dbc);
         var takeCashs = cs.GetAll();
         if (!string.IsNullOrEmpty(name))
         {
             takeCashs = takeCashs.Where(t => t.Holder.Name.Contains(name));
         }
         if (!string.IsNullOrEmpty(mobile))
         {
             takeCashs = takeCashs.Where(t => t.Holder.Mobile.Contains(mobile));
         }
         if (startTime != null)
         {
             takeCashs = takeCashs.Where(t => t.CreateTime >= startTime);
         }
         if (endTime != null)
         {
             takeCashs = takeCashs.Where(t => t.CreateTime <= endTime);
         }
         result.TotalCount = takeCashs.LongCount();
         result.TakeCashs  = takeCashs.OrderByDescending(t => t.CreateTime).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList().Select(t => ToDTO(t)).ToArray();
         return(result);
     }
 }
Ejemplo n.º 4
0
        public async Task <ActionResult> List(long?stateId, string keyword, DateTime?startTime, DateTime?endTime, int pageIndex = 1)
        {
            TakeCashSearchResult result = await takeCashService.GetModelListAsync(null, stateId, keyword, startTime, endTime, pageIndex, pageSize);

            TakeCashListViewModel model = new TakeCashListViewModel();

            model.TakeCashes = result.TakeCashes.Select(t => new TakeCashModel {
                AdminMobile = t.AdminMobile,
                Amount      = t.Amount,
                Code        = t.Code,
                CreateTime  = t.CreateTime,
                Description = t.Description,
                Id          = t.Id,
                Mobile      = t.Mobile,
                Name        = t.Name,
                PayTypeInfo = userService.GetPayInfo(t.UserId, t.TypeName),
                StateId     = t.StateId,
                StateName   = t.StateName,
                TypeId      = t.TypeId,
                TypeName    = t.TypeName,
                UserId      = t.UserId
            }).ToArray();
            model.PageCount = result.PageCount;
            model.States    = await idNameService.GetByTypeNameAsync("提现状态");

            return(Json(new AjaxResult {
                Status = 1, Data = model
            }));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> List(int pageIndex = 1)
        {
            long stateId = await idNameService.GetIdByNameAsync("已结款");

            TakeCashSearchResult result = await takeCashService.GetModelListAsync(userId, stateId, null, null, null, pageIndex, pageSize);

            return(Json(new AjaxResult {
                Status = 1, Data = result
            }));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> List(long?stateId, string keyword, DateTime?startTime, DateTime?endTime, int pageIndex = 1)
        {
            TakeCashSearchResult result = await takeCashService.GetModelListAsync(null, stateId, keyword, startTime, endTime, pageIndex, pageSize);

            TakeCashListViewModel model = new TakeCashListViewModel();

            model.TakeCashes = result.TakeCashes;
            model.PageCount  = result.PageCount;
            model.States     = MyEnumHelper.GetEnumList <TakeCashStateEnum>();
            return(Json(new AjaxResult {
                Status = 1, Data = model
            }));
        }
Ejemplo n.º 7
0
        public async Task <ApiResult> List(TakeCashListModel model)
        {
            User user = JwtHelper.JwtDecrypt <User>(ControllerContext);
            TakeCashSearchResult res = await takeCashService.GetModelListAsync(user.Id, null, null, null, null, model.PageIndex, model.PageSize);

            TakeCashListApiModel result = new TakeCashListApiModel();

            result.takeCashes = res.TakeCashes.Select(t => new TakeCash {
                createTime = t.CreateTime, amount = t.Amount, description = t.Description, payTypeName = t.PayTypeName, stateName = t.StateName, bankAccount = t.BankAccount.BankAccount
            });
            result.pageCount = res.PageCount;
            return(new ApiResult {
                status = 1, data = result
            });
        }
Ejemplo n.º 8
0
        public async Task <ActionResult> List(long?stateId, string mobile, DateTime?startTime, DateTime?endTime, int pageIndex = 1)
        {
            //long? typeId = await journalTypeService.GetIdByDescAsync("赠送");
            TakeCashSearchResult result = await takeCashService.GetModelListAsync(stateId, mobile, startTime, endTime, pageIndex, pageSize);

            ListViewModel model = new ListViewModel();

            model.TakeCashes = result.TakeCashes;
            model.States     = await stateService.GetModelListAsync();

            if (result.GivingIntegralCount == null)
            {
                result.GivingIntegralCount = 0;
            }
            if (result.UseIntegralCount == null)
            {
                result.UseIntegralCount = 0;
            }
            model.GivingIntegralCount = result.GivingIntegralCount;
            model.UseIntegralCount    = result.UseIntegralCount;

            Pagination pager = new Pagination();

            pager.PageIndex  = pageIndex;
            pager.PageSize   = pageSize;
            pager.TotalCount = result.TotalCount;

            if (result.TotalCount <= pageSize)
            {
                model.PageHtml = "test";
            }
            else
            {
                model.PageHtml = pager.GetPagerHtml();
            }
            model.Pages     = pager.Pages;
            model.PageCount = pager.PageCount;
            return(Json(new AjaxResult {
                Status = 1, Data = model
            }));
            //return View(model);
        }
Ejemplo n.º 9
0
        public async Task <TakeCashSearchResult> GetModelListAsync(long?stateId, string mobile, DateTime?startTime, DateTime?endTime, int pageIndex, int pageSize)
        {
            using (MyDbContext dbc = new MyDbContext())
            {
                TakeCashSearchResult result = new TakeCashSearchResult();
                var entities = dbc.GetAll <TakeCashEntity>();
                if (stateId != null)
                {
                    entities = entities.Where(t => t.StateId == stateId);
                }
                if (!string.IsNullOrEmpty(mobile))
                {
                    entities = entities.Where(t => t.PlatformUser.Mobile.Contains(mobile));
                }
                if (startTime != null)
                {
                    entities = entities.Where(t => t.CreateTime >= startTime);
                }
                if (endTime != null)
                {
                    entities = entities.Where(a => a.CreateTime.Year <= endTime.Value.Year && a.CreateTime.Month <= endTime.Value.Month && a.CreateTime.Day <= endTime.Value.Day);
                }
                long givingIntegralId = dbc.GetAll <IntegralTypeEntity>().SingleOrDefault(i => i.Name == "商家积分").Id;
                long useIntegralId    = dbc.GetAll <IntegralTypeEntity>().SingleOrDefault(i => i.Name == "消费积分").Id;
                long sId = dbc.GetAll <StateEntity>().SingleOrDefault(s => s.Name == "已转账").Id;
                result.TotalCount = await entities.LongCountAsync();

                result.GivingIntegralCount = await entities.Where(t => t.IntegralTypeId == givingIntegralId && t.StateId == sId).SumAsync(t => t.Integral);

                result.UseIntegralCount = await entities.Where(t => t.IntegralTypeId == useIntegralId && t.StateId == sId).SumAsync(t => t.Integral);

                var res = await entities.OrderByDescending(t => t.CreateTime).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToListAsync();

                result.TakeCashes = res.Select(t => ToDTO(t)).ToArray();
                return(result);
            }
        }
Ejemplo n.º 10
0
        public PartialViewResult ApplyGetPage(string name, string mobile, DateTime?startTime, DateTime?endTime, int pageIndex = 1)
        {
            TakeCashViewModel    model  = new TakeCashViewModel();
            TakeCashSearchResult result = takeCashService.GetPageList(name, mobile, startTime, endTime, pageIndex, pageSize);

            model.TakeCashes = result.TakeCashs;

            //分页
            Pagination pager = new Pagination();

            pager.PageIndex  = pageIndex;
            pager.PageSize   = pageSize;
            pager.TotalCount = result.TotalCount;

            if (result.TotalCount <= pageSize)
            {
                model.Page = "";
            }
            else
            {
                model.Page = pager.GetPagerHtml();
            }
            return(PartialView("TakeCashApplyPaging", model));
        }