using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Common.Model;
using CoreEntity.Entity;
using CoreEntity.ESEntity;
using JCSoft.WX.Framework.Api;
using MemberWeb.Commonss;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using NPOI.HSSF.UserModel;
using PublicLibrary.Model;
using SupplierWeb.Commonss;
using ZcPeng.PublicLibrary;
using Num = CoreEntity.ESEntity.Num;
namespace SupplierWeb.Controllers
{
[Route("web/memingorder")]
public class mem_OrdersController : BaseController
{
private readonly IHostingEnvironment _hostingEnvironment;
public mem_OrdersController(IHostingEnvironment hostingEnvironmen,IMemoryCache cache, IApiClient client) : base(cache, client)
{
_hostingEnvironment = hostingEnvironmen;
}
public IActionResult Index()
{
return View();
}
///
/// 订单列表
///
///
///
///
[HttpPost]
[Route("allOrderList")]
public ActionResult allOrderList(QueryFilter[] filters, Int32 pageIndex, Int32 pageSize,
string sortField, Int32 sortDirection, string[] sumFields, [FromBody]dynamic data)
{
if (data != null)
{
filters = data.filters.ToObject();
pageIndex = data.pageIndex;
pageSize = data.pageSize;
sortField = data.sortField;
sortDirection = data.sortDirection;
sumFields = data.sumFields.ToObject();
}
DataTable dt = new DataTable();
string result;
IList permss = new List(0);
List parameters = new List();
string filterstr = QueryFilter.getFilterSqlParam(filters, out parameters, new Mem_Orders(), "A.");
string direct = " desc ";
if (sortDirection != 1)
{
direct = " asc";
}
if (sortField==null|| sortField=="") {
sortField = "A.OrderTime ";
}
int start = (pageIndex - 1) * pageSize;
int end = (start + 1 + pageSize);
string commandText0 = "select * from ";
string commandText1 = "( SELECT A.*,row_number() over( order by A." + sortField + direct + " ) as rownum FROM (" +
"SELECT o.*,p.Integral,p.payPirce,p.Is_Pay,p.PayType,p.PostagePrice,d.ProductName,d.Manufacturer,d.Amount,d.MarketPrice,d.MarketIng,d.ProductObject from mem_ingOrders o LEFT JOIN mem_ingOrdersPay p ON o. OrdersCode=p.OrdersCode LEFT JOIN mem_ingProduct d ON d.ProductCode=o.ProductCode where 1=1 " +
") as A where 1=1 " +filterstr+" )AAA ";
string commandText2 = " where AAA.rownum > "+ start + " and AAA.rownum < "+ end + " ORDER BY AAA.LastModified desc ";
string commandText3 = commandText0 + commandText1+commandText2;
bool success = DataAccess.GetValues(commandText3, ref dt, parameters.ToArray(), out result);
if (dt != null && dt.Rows.Count > 0)
{
// 把DataTable转换为IList
permss = ModelConvertHelper.ConvertToModel(dt);
}
string result1;
long totalcount = DataAccess.GetRowCountDefine("select count(1) from " + commandText1, parameters.ToArray(), out result1);
IsoDateTimeConverter timejson = new IsoDateTimeConverter
{
DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"
};
//IList