Exemplo n.º 1
0
        public ApiResult <ListOutput> Bill([FromQuery] ListInput parameter)
        {
            var moneyTypes   = Resolve <IAutoConfigService>().MoneyTypes();
            var billApiInput = new BillApiInput
            {
                UserId    = parameter.LoginUserId,
                PageIndex = parameter.PageIndex,
                PageSize  = parameter.PageSize
            };

            var billList = Resolve <IFinanceAdminService>().GetApiBillPageList(billApiInput, out var count);
            var result   = new ListOutput
            {
                StyleType = 1, //采用第一种样式
                TotalSize = count / parameter.PageSize
            };

            foreach (var item in billList.ToList())
            {
                var index   = new Random().Next(1, 8);
                var apiData = new ListItem
                {
                    Id    = item.Id,
                    Intro = $"账后{item.AfterAmount} 时间{item.CreateTime.ToString("yyyy-MM-dd hh:ss")}",
                    Title =
                        $"{moneyTypes.FirstOrDefault(e => e.Id == item.MoneyTypeId)?.Name}-{item.Type.GetDisplayName()}",
                    Image = Resolve <IApiService>().ApiImageUrl($"/assets/mobile/images/icon/demo{index}.png"),
                    Url   = $"/finance/bill/view?id={item.Id}".ToClientUrl(ClientType.WapH5),
                    Extra = item.Amount.ToStr()
                };
                result.ApiDataList.Add(apiData);
            }

            return(ApiResult.Success(result));
        }
Exemplo n.º 2
0
        public IList <Bill> GetApiBillList(BillApiInput billApiInput, out long count)
        {
            if (billApiInput.PageIndex < 0)
            {
                throw new ArgumentNullException("pageIndex", "pageindex has to be greater than 1");
            }

            if (billApiInput.PageSize > 100)
            {
                billApiInput.PageSize = 100;
            }

            var sqlWhere = string.Empty;

            if (billApiInput.Flow.HasValue)
            {
                sqlWhere = $"{sqlWhere} AND Flow={(int)billApiInput.Flow}";
            }

            if (!billApiInput.MoneyTypeId.IsGuidNullOrEmpty())
            {
                sqlWhere = $"{sqlWhere} AND MoneyTypeId= '{billApiInput.MoneyTypeId}' ";
            }

            if (billApiInput.UserId > 0)
            {
                sqlWhere = $"{sqlWhere} AND UserId='{billApiInput.UserId}' ";
            }

            var sqlCount = $"SELECT COUNT(Id) [Count] FROM [Asset_Bill] where 1=1 {sqlWhere}";

            count = RepositoryContext.ExecuteScalar(sqlCount)?.ConvertToLong() ?? 0;

            var result = new List <Bill>();
            var sql    = $@"SELECT TOP {billApiInput.PageSize} * FROM (
                        SELECT  ROW_NUMBER() OVER (ORDER BY id desc) AS RowNumber,[Id]  ,[Type],[Flow],AfterAmount,[MoneyTypeId],[Amount],[CreateTime] FROM [Asset_Bill] where 1=1 {
                    sqlWhere
                }
                               ) as A
                        WHERE RowNumber > {billApiInput.PageSize}*({billApiInput.PageIndex}-1)  ";

            using (var dr = RepositoryContext.ExecuteDataReader(sql))
            {
                while (dr.Read())
                {
                    var item = new Bill
                    {
                        Id          = dr.Read <long>("Id"),
                        Amount      = dr.Read <decimal>("Amount"),
                        AfterAmount = dr.Read <decimal>("AfterAmount"),
                        Type        = (BillActionType)dr["Type"].ToInt16(),
                        Flow        = (AccountFlow)dr["Flow"].ToInt16(),
                        CreateTime  = dr.Read <DateTime>("CreateTime"),
                        MoneyTypeId = dr.Read <Guid>("MoneyTypeId")
                    };
                    result.Add(item);
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="FinanceAdminService" /> class.
        /// </summary>
        /// <summary>
        ///     获取s the API bill 分页 list.
        /// </summary>
        /// <param name="billApiInput">The bill API input.</param>
        /// <param name="count">The count.</param>
        public IList <Bill> GetApiBillPageList(BillApiInput billApiInput, out long count)
        {
            var billList = _billRepository.GetApiBillList(billApiInput, out count);

            return(billList);
        }