Commit 2bac45e2 by 泽锋 李

新增退款汇总报表

parent b07eca62
...@@ -40,8 +40,8 @@ where 1=1 "; ...@@ -40,8 +40,8 @@ where 1=1 ";
} }
if (search_data.start_date != null) if (search_data.start_date != null)
{ {
sql += " and t1.`date`>=@btime "; sql += " and t1.`create_date`>=@btime ";
countSql += " and t1.`date`>=@btime "; countSql += " and t1.`create_date`>=@btime ";
parameters.Add("btime", search_data.start_date); parameters.Add("btime", search_data.start_date);
} }
if (search_data.end_date != null) if (search_data.end_date != null)
......
...@@ -1894,6 +1894,66 @@ where t1.warehouse_code=@warehousecode and t1.bailun_sku=@sku and t2.create_time ...@@ -1894,6 +1894,66 @@ where t1.warehouse_code=@warehousecode and t1.bailun_sku=@sku and t2.create_time
_connection.Delete<dc_auto_purchase_advise_detailed>(id); _connection.Delete<dc_auto_purchase_advise_detailed>(id);
} }
/// <summary>
/// 退货汇总
/// </summary>
/// <param name="search_data"></param>
/// <param name="offset"></param>
/// <param name="limit"></param>
/// <param name="total"></param>
/// <returns></returns>
public static List<dc_aims_return_goods_dto> ReturnGoodsList(dc_aims_return_goods_search_dto search_data, int offset, int limit, ref int total)
{
var sql = @"select t1.*
from dc_aims_return_goods as t1
left join dc_base_warehouse as t3 on t1.warehouse_code = t3.warehouse_code
where 1=1 ";
var countSql = " select count(1) from dc_aims_return_goods as t1 left join dc_base_warehouse as t3 on t1.warehouse_code = t3.warehouse_code where 1=1 ";
DynamicParameters parameters = new DynamicParameters();
if (!string.IsNullOrWhiteSpace(search_data.warehousecode))
{
sql += " and t1.warehouse_code=@warehouse_code ";
countSql += " and t1.warehouse_code=@warehouse_code ";
parameters.Add("warehouse_code", search_data.warehousecode);
}
if (!string.IsNullOrWhiteSpace(search_data.warehousetype))
{
sql += " and t3.hq_type = @hq_type ";
countSql += " and t3.hq_type = @hq_type ";
parameters.Add("hq_type", search_data.warehousetype);
}
if (search_data.warehousearea > 0)
{
sql += " and t3.area_id = @area_id ";
countSql += " and t3.area_id = @area_id ";
parameters.Add("area_id", search_data.warehousearea);
}
if (search_data.start_date != null)
{
sql += " and t1.`date`>=@btime ";
countSql += " and t1.`date`>=@btime ";
parameters.Add("btime", search_data.start_date);
}
if (search_data.end_date != null)
{
sql += " and t1.`date`<=@etime ";
countSql += " and t1.`date`<=@etime ";
parameters.Add("etime", search_data.end_date);
}
if (!string.IsNullOrWhiteSpace(search_data.bailun_sku))
{
sql += " and t1.bailun_sku in @bailun_sku ";
countSql += " and t1.bailun_sku in @bailun_sku ";
parameters.Add("bailun_sku", search_data.bailun_sku.Split(','));
}
sql += " order by t1.id desc ";
total = _connection.QueryFirst<int>(countSql, parameters, commandTimeout: 0);
sql += " limit " + offset + "," + limit;
var obj = _connection.Query<dc_aims_return_goods_dto>(sql, parameters, buffered: false, commandTimeout: 0);
return obj.AsList();
}
} }
} }
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Text; using System.Text;
namespace AutoTurnOver.Models namespace AutoTurnOver.Models
...@@ -29,4 +30,26 @@ namespace AutoTurnOver.Models ...@@ -29,4 +30,26 @@ namespace AutoTurnOver.Models
public string return_addrs { get; set; } public string return_addrs { get; set; }
public decimal confirm_return_count { get; set; } public decimal confirm_return_count { get; set; }
} }
public class dc_aims_return_goods_dto: dc_aims_return_goods
{
}
public class dc_aims_return_goods_search_dto
{
[Description("sku")]
public string bailun_sku { get; set; }
[Description("开始时间")]
public DateTime? start_date { get; set; }
[Description("结束时间")]
public DateTime? end_date { get; set; }
[Description("仓库编码")]
public string warehousecode { get; set; }
[Description("仓库类型")]
public string warehousetype { get; set; }
[Description("仓库国家")]
public int? warehousearea { get; set; }
}
} }
...@@ -587,5 +587,61 @@ namespace AutoTurnOver.Services ...@@ -587,5 +587,61 @@ namespace AutoTurnOver.Services
var count = MyMySqlConnection._connection_read_only.QuerySingleOrDefault<int>("select count(1) from dc_auto_turnover where gmt_modified>=@time ",new { time = time }); var count = MyMySqlConnection._connection_read_only.QuerySingleOrDefault<int>("select count(1) from dc_auto_turnover where gmt_modified>=@time ",new { time = time });
ApiServices.QiYeJiQiRenMsPush(new QiYeJiQiRenMsDto { msgtype = "text", text = new QiYeJiQiRenMsDto.text_dto { content = $" 骆宾, 当前已更新的周转数 {count}" } }); ApiServices.QiYeJiQiRenMsPush(new QiYeJiQiRenMsDto { msgtype = "text", text = new QiYeJiQiRenMsDto.text_dto { content = $" 骆宾, 当前已更新的周转数 {count}" } });
} }
public List<dc_aims_return_goods_dto> ReturnGoodsList(dc_aims_return_goods_search_dto search_data, int offset, int limit, ref int total)
{
return DB.purchase_advise.ReturnGoodsList(search_data, offset, limit, ref total);
}
public string ExportReturnGoods(dc_aims_return_goods_search_dto searchData)
{
try
{
var fileName = AppContext.BaseDirectory + $@"退货汇总-{DateTime.Now.ToString("yyyyMMddHHmmss")}{Guid.NewGuid()}.csv";
int total = 0;
var list = ReturnGoodsList(searchData, 0, int.MaxValue, ref total);
DataTable table = new DataTable();
string[] cols = new string[] { "规则", "仓库", "sku", "库存", "采购员", "供应商", "采购价", "采购单号", "采购数量", "淘宝单号", "最后签收时间" };
foreach (var item in cols)
{
table.Columns.Add(item);
}
foreach (var itemData in list)
{
DataRow row = table.NewRow();
row["规则"] = itemData.rule_title;
row["仓库"] = itemData.warehouse_name;
row["sku"] = itemData.bailun_sku;
row["库存"] = itemData.stock;
row["采购员"] = itemData.buy_name;
row["供应商"] = itemData.suppliers_name;
row["采购价"] = itemData.unit_price;
row["采购单号"] = itemData.purchase_id;
row["采购数量"] = itemData.purchase_count;
row["淘宝单号"] = itemData.order_1688_no;
row["最后签收时间"] = itemData.sign_date;
table.Rows.Add(row);
}
CsvFileHelper.SaveCSV(table, fileName);
return fileName;
//var memory = new MemoryStream();
//using (var stream = new FileStream(fileName, FileMode.Open))
//{
// stream.CopyTo(memory);
//}
//memory.Position = 0;
//return memory;
}
catch (Exception)
{
throw;
}
}
} }
} }
...@@ -56,6 +56,9 @@ namespace AutoTurnOver.Services ...@@ -56,6 +56,9 @@ namespace AutoTurnOver.Services
case "采购建议": case "采购建议":
item.result_file_url = await DownloadPurchaseAdvise(item.parameter, item); item.result_file_url = await DownloadPurchaseAdvise(item.parameter, item);
break; break;
case "退货汇总":
item.result_file_url = await DownloadReturnGoods(item.parameter, item);
break;
default: throw new Exception("无法识别的任务"); default: throw new Exception("无法识别的任务");
} }
item.end_date = DateTime.Now; item.end_date = DateTime.Now;
...@@ -147,6 +150,20 @@ namespace AutoTurnOver.Services ...@@ -147,6 +150,20 @@ namespace AutoTurnOver.Services
return fileData; return fileData;
} }
/// <summary> /// <summary>
/// 下载采购建议
/// </summary>
public async Task<string> DownloadReturnGoods(string par_json, dc_task_download download_data)
{
dc_aims_return_goods_search_dto search_data = par_json.ToObject<dc_aims_return_goods_search_dto>();
Console.WriteLine("DownloadStock - 开始生成文件");
var memory = new PurchaseAdviseServices().ExportReturnGoods(search_data);
Console.WriteLine("DownloadStock - 开始生成上传文件");
var fileData = await AutoTurnOver.Utility.QiNiuCloudHelper.UploadSectioningAsync(memory);
Console.WriteLine("DownloadStock - 上传完毕");
return fileData;
}
/// <summary>
/// 下载库存 /// 下载库存
/// </summary> /// </summary>
public async Task<string> DownloadFbaStock(string par_json, dc_task_download download_data) public async Task<string> DownloadFbaStock(string par_json, dc_task_download download_data)
......
...@@ -63,8 +63,6 @@ namespace AutoTurnOver.Controllers ...@@ -63,8 +63,6 @@ namespace AutoTurnOver.Controllers
[HttpGet] [HttpGet]
public string DetailList([FromQuery] dc_auto_purchase_advise_detailed_search_dto m, [FromQuery]int limit, [FromQuery]int offset, [FromQuery] string sort, [FromQuery] string order) public string DetailList([FromQuery] dc_auto_purchase_advise_detailed_search_dto m, [FromQuery]int limit, [FromQuery]int offset, [FromQuery] string sort, [FromQuery] string order)
{ {
var total = 0; var total = 0;
var list = PurchaseAdviseServices.DetailList(m, offset, limit, ref total, order, sort); var list = PurchaseAdviseServices.DetailList(m, offset, limit, ref total, order, sort);
...@@ -282,5 +280,40 @@ namespace AutoTurnOver.Controllers ...@@ -282,5 +280,40 @@ namespace AutoTurnOver.Controllers
} }
} }
[HttpGet]
[BrowseLog("Bailun_aims", "触发【百伦自动下单系统】->【自动下单管理】->【退货汇总】->【查询】操作", 0)]
public string ReturnGoodsList([FromQuery] dc_aims_return_goods_search_dto m, [FromQuery]int limit, [FromQuery]int offset )
{
var total = 0;
var list = new PurchaseAdviseServices().ReturnGoodsList(m, offset, limit, ref total);
return new
{
rows = list,
total = total,
}.ToJson(false);
}
public JsonResult ExportReturnGoods([FromQuery] dc_auto_purchase_advise_detailed_search_dto m, [FromQuery]int limit, [FromQuery]int offset, [FromQuery] string sort, [FromQuery] string order)
{
try
{
var user = AutoUtility.GetUser();
dc_task_download_dao.PushData<dc_auto_purchase_advise_detailed_search_dto>(new dc_task_download
{
parameter = m.ToJson(),
task_name = "退货汇总"
}, user);
return new JsonResult(new { success = true });
}
catch (Exception ex)
{
return new JsonResult(new { success = false, message = ex.Message });
}
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment