100 lines
3.9 KiB
C#
100 lines
3.9 KiB
C#
|
|
using Hncore.Infrastructure.WebApi;
|
|||
|
|
using Hncore.Pass.Sells.Domain;
|
|||
|
|
using Hncore.Pass.Sells.Request.RedeemCode;
|
|||
|
|
using Hncore.Pass.Sells.Service;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
using System;
|
|||
|
|
using System.Linq.Expressions;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using Hncore.Infrastructure.Extension;
|
|||
|
|
using Hncore.Infrastructure.EntitiesExtension;
|
|||
|
|
using Microsoft.EntityFrameworkCore;
|
|||
|
|
using Hncore.Infrastructure.Common;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
|
|||
|
|
namespace Hncore.Pass.Live.Controllers
|
|||
|
|
{
|
|||
|
|
[ApiVersion("1.0")]
|
|||
|
|
[Route("api/sells/v{version:apiVersion}/taobao/[action]")]
|
|||
|
|
public class TaoBaoController : HncoreControllerBase
|
|||
|
|
{
|
|||
|
|
SellerTaoBaoService m_SellerTaoBaoService;
|
|||
|
|
|
|||
|
|
public TaoBaoController(SellerTaoBaoService _SellerTaoBaoService)
|
|||
|
|
{
|
|||
|
|
m_SellerTaoBaoService = _SellerTaoBaoService;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public async Task<ApiResult> Get([FromQuery] int id)
|
|||
|
|
{
|
|||
|
|
var ret = await m_SellerTaoBaoService.GetById(id);
|
|||
|
|
return Success(ret);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ѯ
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="request"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public async Task<ApiResult> Page([FromQuery]TaoBaoRequest request)
|
|||
|
|
{
|
|||
|
|
Expression<Func<TaoBaoOrderEntity, bool>> expr = m => 1 == 1;
|
|||
|
|
|
|||
|
|
if (request.KeyWord.Has())
|
|||
|
|
{
|
|||
|
|
expr = expr.And(m => m.Phone.Contains(request.KeyWord));
|
|||
|
|
expr = expr.Or(m => m.Tid.Contains(request.KeyWord));
|
|||
|
|
expr = expr.Or(m => m.BuyerNick.Contains(request.KeyWord));
|
|||
|
|
}
|
|||
|
|
if (request.BTime.HasValue && request.ETime.HasValue)
|
|||
|
|
{
|
|||
|
|
expr = expr.And(m => m.Created >= request.BTime && m.Created <= request.ETime);
|
|||
|
|
}
|
|||
|
|
var ret = await m_SellerTaoBaoService.PageDesc(request.PageIndex, request.PageSize, expr,true,m=>m.Id);
|
|||
|
|
|
|||
|
|
var data = ret.ToApiResult();
|
|||
|
|
return data;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[HttpGet]
|
|||
|
|
public async Task<IActionResult> Export([FromQuery]TaoBaoRequest request)
|
|||
|
|
{
|
|||
|
|
Expression<Func<TaoBaoOrderEntity, bool>> expr = m => 1 == 1;
|
|||
|
|
if (request.BTime.HasValue && request.ETime.HasValue)
|
|||
|
|
{
|
|||
|
|
expr = expr.And(m => m.CreateDate >= request.BTime && m.CreateDate <= request.ETime);
|
|||
|
|
}
|
|||
|
|
var ret = await m_SellerTaoBaoService.Query(expr).ToListAsync();
|
|||
|
|
|
|||
|
|
|
|||
|
|
var data = new ExcelData<TaoBaoOrderEntity>
|
|||
|
|
{
|
|||
|
|
SheetName = DateTime.Now.ToString("yyyy-MM-dd"),
|
|||
|
|
Data = ret
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
var title = new List<ExcelTitle>(){
|
|||
|
|
new ExcelTitle { Property = "Created", Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" ,Format=(val)=>((DateTime) val).ToString("yyyy-MM-dd hh:mm:ss")},
|
|||
|
|
new ExcelTitle { Property = "Tid", Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" },
|
|||
|
|
new ExcelTitle { Property = "SellerNick", Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" },
|
|||
|
|
new ExcelTitle { Property = "BuyerNick", Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" },
|
|||
|
|
new ExcelTitle { Property = "Phone", Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>" },
|
|||
|
|
new ExcelTitle { Property = "Price", Title = "<22><><EFBFBD><EFBFBD>" },
|
|||
|
|
new ExcelTitle { Property = "Num", Title = "<22><><EFBFBD><EFBFBD>" },
|
|||
|
|
new ExcelTitle { Property = "TotalFee", Title = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" },
|
|||
|
|
new ExcelTitle { Property = "Payment", Title = "ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" }
|
|||
|
|
};
|
|||
|
|
var fileBytes = ExcelHelper.ExportListToExcel(data, title);
|
|||
|
|
|
|||
|
|
var fileName = $"{DateTime.Now.ToString("yyyyMMdd")}<7D>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ.xlsx";
|
|||
|
|
Response.Headers.Add("X-Suggested-Filename", fileName.UrlEncode());
|
|||
|
|
return File(fileBytes, "application/octet-stream", fileName);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|