Example #1
0
        private StoerBalanceModel <Dictionary <string, object> > GetDataList(StoreBalanceQuery query)
        {
            StoerBalanceModel <Dictionary <string, object> > stoerBalanceModel = new StoerBalanceModel <Dictionary <string, object> >();
            DbQueryResult storeBalanceOverOrders = StoresHelper.GetStoreBalanceOverOrders(query);

            stoerBalanceModel.rows = DataHelper.DataTableToDictionary(storeBalanceOverOrders.Data);
            List <Dictionary <string, object> > rows = DataHelper.DataTableToDictionary(storeBalanceOverOrders.Data);
            int      storeId = query.StoreId;
            DateTime value   = query.StartDate.Value;
            DateTime?endDate = query.EndDate;
            decimal  num     = stoerBalanceModel.totalAmount = StoresHelper.GetStoreBalanceOrderTotal(storeId, value, endDate.Value, query.IsStoreCollect);

            stoerBalanceModel.rows  = rows;
            stoerBalanceModel.total = storeBalanceOverOrders.TotalRecords;
            return(stoerBalanceModel);
        }
Example #2
0
        private void ExportToExcel(HttpContext context)
        {
            StoreBalanceQuery query = this.GetQuery(context);

            query.PageIndex = 1;
            query.PageSize  = 2147483647;
            DbQueryResult storeBalanceOverOrders = StoresHelper.GetStoreBalanceOverOrders(query);
            decimal       storeBalanceOrderTotal = StoresHelper.GetStoreBalanceOrderTotal(query.StoreId, query.StartDate.Value, query.EndDate.Value, query.IsStoreCollect);
            StringBuilder stringBuilder          = new StringBuilder();

            stringBuilder.AppendLine("<table cellspacing=\"0\" cellpadding=\"5\" rules=\"all\" border=\"1\">");
            stringBuilder.AppendLine("<tr style=\"font-weight: bold; white-space: nowrap;\">");
            stringBuilder.AppendLine("<td>结算时间</td>");
            stringBuilder.AppendLine("<td>订单编号</td>");
            stringBuilder.AppendLine("<td>订单实付</td>");
            stringBuilder.AppendLine("<td>退款金额</td>");
            stringBuilder.AppendLine("<td>平台佣金</td>");
            stringBuilder.AppendLine("<td>结算金额</td>");
            stringBuilder.AppendLine("<td>收款方</td>");
            stringBuilder.AppendLine("<td>运费</td>");
            stringBuilder.AppendLine("<td>积分抵扣</td>");
            stringBuilder.AppendLine("<td>优惠券抵扣</td>");
            stringBuilder.AppendLine("</tr>");
            DataTable data = storeBalanceOverOrders.Data;
            DateTime  dateTime;

            foreach (DataRow row in data.Rows)
            {
                stringBuilder.AppendLine("<tr>");
                StringBuilder stringBuilder2 = stringBuilder;
                dateTime = row.Field <DateTime>("CreateTime");
                stringBuilder2.AppendLine("<td>" + dateTime.ToString("yyyy-MM-dd HH:mm:ss") + "</td>");
                stringBuilder.AppendLine("<td style=\"vnd.ms-excel.numberformat:@\">" + row.Field <string>("TradeNo") + "</td>");
                stringBuilder.AppendLine("<td>" + row["OrderTotal"].ToDecimal(0).F2ToString("f2") + "</td>");
                stringBuilder.AppendLine("<td>" + row["RefundAmount"].ToDecimal(0).F2ToString("f2") + "</td>");
                stringBuilder.AppendLine("<td>" + row["PlatCommission"].ToDecimal(0).F2ToString("f2") + "</td>");
                stringBuilder.AppendLine("<td>" + row["Income"].ToDecimal(0).F2ToString("f2") + "</td>");
                if (row["CollectByStore"].ToString() == "1")
                {
                    stringBuilder.AppendLine("<td>门店</td>");
                }
                else
                {
                    stringBuilder.AppendLine("<td>平台</td>");
                }
                stringBuilder.AppendLine("<td>" + row["Freight"].ToDecimal(0).F2ToString("f2") + "</td>");
                stringBuilder.AppendLine("<td>" + row["DeductionMoney"].ToDecimal(0).F2ToString("f2") + "</td>");
                stringBuilder.AppendLine("<td>" + row["CouponValue"].ToDecimal(0).F2ToString("f2") + "</td>");
                stringBuilder.AppendLine("</tr>");
            }
            stringBuilder.AppendLine("<tr>");
            stringBuilder.AppendLine("<td>总结算金额:" + storeBalanceOrderTotal.F2ToString("f2") + "</td>");
            stringBuilder.AppendLine("<td></td>");
            stringBuilder.AppendLine("</tr>");
            stringBuilder.AppendLine("</table>");
            context.Response.Clear();
            context.Response.Buffer  = false;
            context.Response.Charset = "GB2312";
            HttpResponse response = context.Response;

            dateTime = DateTime.Now;
            response.AppendHeader("Content-Disposition", "attachment;filename=StoreBalance_" + dateTime.ToString("yyyyMMddHHmmss") + ".xls");
            context.Response.ContentEncoding = Encoding.GetEncoding("GB2312");
            context.Response.ContentType     = "application/ms-excel";
            context.Response.Write(stringBuilder.ToString());
            context.Response.End();
        }