public void Query(InvoiceQueryVM queryVM, int pageSize, int pageIndex, string sortField, Action<InvoiceQueryResultVM> callback) { InvoiceQueryFilter filter = queryVM.ConvertVM<InvoiceQueryVM, InvoiceQueryFilter>(); filter.PagingInfo = new PagingInfo() { PageIndex = pageIndex, PageSize = pageSize, SortBy = sortField }; string relativeUrl = "/InvoiceService/Invoice/Query"; restClient.QueryDynamicData(relativeUrl, filter, (obj, args) => { if (args.FaultsHandle()) { return; } InvoiceQueryResultVM result = new InvoiceQueryResultVM(); if (args.Result[0] != null && args.Result[0].Rows != null) { result.ResultList = DynamicConverter<InvoiceVM>.ConvertToVMList(args.Result[0].Rows); result.TotalCount = args.Result[0].TotalCount; } if (args.Result[1] != null && args.Result[1].Rows != null && !(args.Result[1].Rows is DynamicXml.EmptyList)) { result.InvoiceAmt = DynamicConverter<InvoiceAmtVM>.ConvertToVM(args.Result[1].Rows[0]); } callback(result); }); }
private void CalcStatisticInfo(InvoiceQueryResultVM queryResult) { decimal totalInvoiceAmtForSOOnly = 0M; decimal totalInvoiceAmt = 0M; decimal totalPrepayAmt = 0M; decimal totalIncomeAmt = 0M; decimal totalGiftCardPayAmt = 0M; decimal totalUnionAmt = 0M; decimal totalSOTotalAmt = 0M; decimal cInvoiceAmtForSOOnly = 0M; decimal cInvoiceAmt = 0M; decimal cPrepayAmt = 0M; decimal cIncomeAmt = 0M; decimal cGiftCardPayAmt = 0M; decimal cUnionAmt = 0M; decimal cSOTotalAmt = 0M; bool includeSO = false; if (queryResult.ResultList.Count > 0) { queryResult.ResultList.ForEach(p => { cInvoiceAmt += p.InvoiceAmt ?? 0M; cPrepayAmt += p.PrepayAmt ?? 0M; cIncomeAmt += p.IncomeAmt ?? 0M; cUnionAmt += p.UnionAmt ?? 0M; cSOTotalAmt += p.SOTotalAmt.HasValue ? p.SOTotalAmt.Value : 0M; if (p.OrderType == SOIncomeOrderType.SO) { cGiftCardPayAmt += p.GiftCardPayAmt ?? 0M; cInvoiceAmtForSOOnly += p.InvoiceAmt ?? 0M; } }); if (!queryVM.OrderType.HasValue || queryVM.OrderType == SOIncomeOrderType.SO) { includeSO = true; totalInvoiceAmt = queryResult.InvoiceAmt.TotalAmt; totalPrepayAmt = queryResult.InvoiceAmt.PrepayAmt; totalIncomeAmt = queryResult.InvoiceAmt.IncomeAmt; totalGiftCardPayAmt = queryResult.InvoiceAmt.GiftCardPayAmt; totalInvoiceAmtForSOOnly = queryResult.InvoiceAmt.TotalAmtForSOOnly; totalUnionAmt = queryResult.InvoiceAmt.UnionAmt; totalSOTotalAmt = queryResult.InvoiceAmt.TSOTotalAmt.HasValue ? queryResult.InvoiceAmt.TSOTotalAmt.Value : 0M; } else { totalInvoiceAmt = queryResult.InvoiceAmt.TotalAmt; totalInvoiceAmtForSOOnly = queryResult.InvoiceAmt.TotalAmtForSOOnly; totalUnionAmt = queryResult.InvoiceAmt.UnionAmt; totalSOTotalAmt = queryResult.InvoiceAmt.TSOTotalAmt.HasValue ? queryResult.InvoiceAmt.TSOTotalAmt.Value : 0M; } } // 税后=税前/1.17,税金=税前-税后 decimal taxRateBase = ConstValue.Invoice_TaxRateBase; queryResult.Statistic.Add(new InvoiceQueryStatisticVM() { StatisticType = StatisticType.Total, InvoiceAmt = totalInvoiceAmt, InvoiceAmtWithTax = totalInvoiceAmtForSOOnly / taxRateBase, InvoiceTax = (includeSO) ? (totalInvoiceAmtForSOOnly - (totalInvoiceAmtForSOOnly / taxRateBase)) : 0.00M, PrepayAmt = totalPrepayAmt, IncomeAmt = totalIncomeAmt, GiftCardPayAmt = totalGiftCardPayAmt, GiftCardPayAmtWithTax = totalGiftCardPayAmt / taxRateBase, UnionAmt = totalUnionAmt, SOTotalAmt = totalSOTotalAmt, }); queryResult.Statistic.Add(new InvoiceQueryStatisticVM() { StatisticType = StatisticType.Page, InvoiceAmt = cInvoiceAmt, InvoiceAmtWithTax = cInvoiceAmtForSOOnly / taxRateBase, InvoiceTax = (includeSO) ? cInvoiceAmtForSOOnly - (cInvoiceAmtForSOOnly / taxRateBase) : 0M, PrepayAmt = cPrepayAmt, IncomeAmt = cIncomeAmt, GiftCardPayAmt = cGiftCardPayAmt, GiftCardPayAmtWithTax = cGiftCardPayAmt / taxRateBase, UnionAmt = cUnionAmt, SOTotalAmt = cSOTotalAmt }); this.svStatisticInfo.Visibility = Visibility.Visible; this.tbStatisticInfo.Text = queryResult.Statistic.ToStatisticText(); }