Ejemplo n.º 1
0
        public async Task OnGetAsync(int id = 0)
        {
            Merchant = (await merchantService.GetModelAsync(m => m.id == id)).data;

            if (await HttpContext.IsSystem())
            {
                CmsAgents = (await agentService.GetListAsync()).data;
            }
            else
            {
                var guid = await HttpContext.LoginUserId();

                CmsAgents = (await agentService.GetListAsync(t => t.Admin_Guid == guid, t => t.Create_Time, Common.DbOrderEnum.Asc)).data;
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> TradeExport(string q)
        {
            var req = JsonConvert.DeserializeObject <QueryOrderListRequest>(q);

            if (req.start_time == null)
            {
                req.start_time = DateTime.Now.Date;
            }
            if (req.end_time == null)
            {
                req.end_time = DateTime.Now.AddDays(1).Date;
            }

            req.order_type = OrderType.支付订单;

            var mch = await merchantService.GetModelAsync(p => p.out_sub_mch_id == req.out_sub_mch_id);

            if (mch == null || mch.data == null || mch.data.id == 0)
            {
                return(Content("请选择导出商户"));
            }

            req.AuthenKey = mch.data.authen_key;

            req.page_size = 50;

            var list = new List <TradeOrder>();

            for (req.page_num = 1; ; req.page_num++)
            {
                var d = await wx.QueryAsync(req);

                if (d.Status > 0 || d.Data == null || d.Data.order_details == null || d.Data.order_details.Length == 0)
                {
                    break;
                }

                list.AddRange(d.Data.order_details.Where(p => p.order != null).Select(p => p.order));
            }

            if (list.Count == 0)
            {
                return(Content("没有数据"));
            }

            var data = await list.ExcelBuilder()
                       .Col("支付渠道", p => p.sub_pay_platform)
                       .Col("流水单号", p => p.out_trade_no)
                       .Col("商户名称", p => mch.data.name)
                       .Col("门店名称", p => p.shop_name)
                       .Col("订单金额", p => p.total_fee / 100M, "¥#,##0.00", FuncType.SUM)
                       .Col("支付类型", p => p.trade_type)
                       .Col("支付状态", p => p.trade_state)
                       .Col("交易时间", p => p.time_end.ToLocalTime(), "yyyy年MM月dd日 HH:mm:ss")
                       .Col("设备号", p => p.device_id)
                       .Col("店员名称", p => p.staff_name)
                       .Col("手续费", p => p.poundage / 100M, "¥#,##0.00", FuncType.SUM)
                       .Write("交易订单");

            return(File(
                       data,
                       "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                       $"(交易订单){mch.data.name}{req.start_time:yyyyMMddHHmmss}-{req.end_time:yyyyMMddHHmmss}.xlsx"));
        }