public HttpResponseMessage ExportFlightOrderList([FromUri] QueryFltOrderListRequestViewModel request) { request.Cid = this.GetCid(); //导出 request.IsExport = 1; QueryFltOrderListResponseViewModel responseViewModel = _queryFlightOrderListApplication.QueryFltOrderList(request); var file = ExcelStream(responseViewModel.OrderDataList); //string csv = _service.GetData(model); HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); result.Content = new StreamContent(file); //a text file is actually an octet-stream (pdf, etc) //result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.ms-excel"); //we used attachment to force download result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); result.Content.Headers.ContentDisposition.FileName = "国内机票订单.xls"; return(result); //ResponseBaseViewModel<QueryFltOrderListResponseViewModel> v = // new ResponseBaseViewModel<QueryFltOrderListResponseViewModel> // { // Flag = new ResponseCodeViewModel() { Code = 0, MojoryToken = this.GetToken() }, // Data = responseViewModel // }; //return v; }
public QueryFltOrderListResponseViewModel QueryFltOrderList(QueryFltOrderListRequestViewModel request) { //1.查询机场信息 SearchCityAportModel aportModel = _getCityForFlightServiceBll.SearchAirport(new List <string>() { "N" }); //2.根据Cid查询客户信息 CustomerModel customerModel = _getCustomerServiceBll.GetCustomerByCid(request.Cid); //3.查询机票订单 QueryFlightOrderListDataQueryModel query = Mapper.Map <QueryFltOrderListRequestViewModel, QueryFlightOrderListDataQueryModel>(request); query.AportInfo = aportModel; query.CorpId = customerModel.CorpID; query.Customer = customerModel; //判断是否显示全部订单 if ((query.IsShowAllOrder ?? 0) == 1) { //判断客户是否有查看全部订单权限 if ((customerModel.IsShowAllOrder ?? 0) == 1) { query.Cid = null; } } //3.1判断是否是administrator帐号,如果是则获取当前公司下所有订单 //administrator administator if (customerModel.UserID.ToLower() == "administrator") { query.Cid = null; } if (!string.IsNullOrEmpty(customerModel.CorpID)) { query.CorpCustomerList = _getCustomerServiceBll.GetCustomerByCorpId(customerModel.CorpID); } QueryFlightOrderListModel result = _queryFlightOrderListServiceBll.QueryFlightOrderList(query); if (result.OrderDataList != null && result.OrderDataList.Count > 0) { foreach (var order in result.OrderDataList) { List <CorpAduitOrderInfoModel> corpAduitOrderInfoModels = _getCorpAduitOrderServiceBll.GetAduitOrderInfoByOrderId(order.OrderId); if (corpAduitOrderInfoModels != null && corpAduitOrderInfoModels.Count > 0) { order.AduitOrderStatus = corpAduitOrderInfoModels[0].Status; if (!string.IsNullOrEmpty(corpAduitOrderInfoModels[0].NextAduitName)) { order.AuditStatus = string.Format("待{0}审批", corpAduitOrderInfoModels[0].NextAduitName); } } } } QueryFltOrderListResponseViewModel viewModel = Mapper.Map <QueryFlightOrderListModel, QueryFltOrderListResponseViewModel>(result); SortedList <int, string> fltOrderStatusSortedList = EnumConvert.QueryEnum <FltOrderListOrderStatusEnum>(); viewModel.QueryOrderStatusList = (from status in fltOrderStatusSortedList select new SortedListViewModel() { Key = status.Key, Value = status.Value }).ToList(); return(viewModel); }
public ResponseBaseViewModel <QueryFltOrderListResponseViewModel> QueryFlightOrderList(QueryFltOrderListRequestViewModel request) { request.Cid = this.GetCid(); QueryFltOrderListResponseViewModel responseViewModel = _queryFlightOrderListApplication.QueryFltOrderList(request); ResponseBaseViewModel <QueryFltOrderListResponseViewModel> v = new ResponseBaseViewModel <QueryFltOrderListResponseViewModel> { Flag = new ResponseCodeViewModel() { Code = 0, MojoryToken = this.GetToken() }, Data = responseViewModel }; return(v); }