Commit 3c8a65d7 by zhoujinhui

新增存货计价方式

parent 221987cc
namespace Bailun.DC.Models.Dtos.Stock
{
/// <summary>
/// 获取存货计价数据返回参数信息
/// </summary>
public class GetMonthStockWeightingOutputDto
{
/// <summary>
/// 数据集合
/// </summary>
public dynamic Data { get; set; }
/// <summary>
/// 前端Vue表头
/// </summary>
public string ColumnText { get; set; }
}
}
using Bailun.DC.Models.Stock;
using System;
namespace Bailun.DC.Models.Dtos.Stock
{
/// <summary>
/// 获取WMS库存流水返回参数
/// </summary>
public class ProductStockFlowApiResponseDto
{
/// <summary>
/// 系统交易流水号
/// </summary>
public string SysSerialNumber { get; set; }
/// <summary>
/// 产品sku
/// </summary>
public string Sku { get; set; }
/// <summary>
/// 变更数量
/// </summary>
public int ChangeQuantity { get; set; }
/// <summary>
/// 仓库编码
/// </summary>
public string WarehouseCode { get; set; }
/// <summary>
/// 仓库名称
/// </summary>
public string WarehouseName { get; set; }
/// <summary>
/// 第三方系统交易单号
/// </summary>
public string ThirdSysOrderNo { get; set; }
/// <summary>
/// 第三方交易单类型
/// </summary>
public ThirdSysOrderType ThirdSysOrderType { get; set; }
/// <summary>
/// 库存流水数据来源系统
/// </summary>
public StockFlowSystemSource SystemSource { get; set; }
/// <summary>
/// 收货仓库编码
/// </summary>
public string TargetWareNo { get; set; }
/// <summary>
/// 收货仓库名称
/// </summary>
public string TargetWareName { get; set; }
/// <summary>
/// 可用库存
/// </summary>
public int AvailabelStock { get; set; }
/// <summary>
/// 现有库存量
/// </summary>
public int OnHandStock { get; set; }
/// <summary>
/// 在途库存
/// </summary>
public int InboundStock { get; set; }
/// <summary>
/// 创建人姓名
/// </summary>
public string CreateUserName { get; set; }
/// <summary>
/// 第三方单创建时间
/// </summary>
public DateTime OrderCreationTime { get; set; }
/// <summary>
/// WMS流水创建时间
/// </summary>
public DateTime CreationTime { get; set; }
}
}
using Bailun.DC.Models.Dtos.Stock;
using System;
using System.ComponentModel;
namespace Bailun.DC.Models.Stock
{
/// <summary>
/// wms库存流水记录
/// </summary>
public class dc_base_wms_stock_flow
{
/// <summary>
/// id
/// </summary>
public int id { get; set; }
/// <summary>
/// 系统交易单号
/// </summary>
public string sys_serial_number { get; set; }
/// <summary>
/// 百伦SKU
/// </summary>
public string bailun_sku { get; set; }
/// <summary>
/// 变更数量
/// </summary>
public int change_quantity { get; set; }
/// <summary>
/// 仓库编码
/// </summary>
public string warehouse_code { get; set; }
/// <summary>
/// 仓库名称
/// </summary>
public string warehouse_name { get; set; }
/// <summary>
/// 第三方单号类型
/// </summary>
public string third_sys_order_no { get; set; }
/// <summary>
/// 第三方单号类型
/// </summary>
public ThirdSysOrderType third_sys_order_type { get; set; }
/// <summary>
/// 数据来源
/// </summary>
public StockFlowSystemSource system_source { get; set; }
/// <summary>
/// 目的仓库编码
/// </summary>
public string target_ware_no { get; set; }
/// <summary>
/// 目的仓库名称
/// </summary>
public string target_ware_name { get; set; }
/// <summary>
/// 可用库存
/// </summary>
public int availabel_stock { get; set; }
/// <summary>
/// 现有库存量
/// </summary>
public int on_hand_stock { get; set; }
/// <summary>
/// 在途库存数
/// </summary>
public int in_bound_stock { get; set; }
/// <summary>
/// 第三方单号创建时间
/// </summary>
public DateTime order_creation_time { get; set; }
/// <summary>
/// 创建人姓名
/// </summary>
public string create_user_name { get; set; }
/// <summary>
/// wms库存流水创建时间
/// </summary>
public DateTime wms_creation_time { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime create_time { get; set; }
/// <summary>
///
/// </summary>
/// <param name="productStockFlow"></param>
public void WmsRepsonseToModel(ProductStockFlowApiResponseDto productStockFlow)
{
sys_serial_number = productStockFlow.SysSerialNumber;
bailun_sku = productStockFlow.Sku;
change_quantity = productStockFlow.ChangeQuantity;
warehouse_code = productStockFlow.WarehouseCode;
warehouse_name = productStockFlow.WarehouseName;
third_sys_order_no = productStockFlow.ThirdSysOrderNo;
third_sys_order_type = productStockFlow.ThirdSysOrderType;
system_source = productStockFlow.SystemSource;
target_ware_no = productStockFlow.TargetWareNo;
target_ware_name = productStockFlow.TargetWareName;
availabel_stock = productStockFlow.AvailabelStock;
on_hand_stock = productStockFlow.OnHandStock;
in_bound_stock = productStockFlow.InboundStock;
order_creation_time = productStockFlow.OrderCreationTime;
create_user_name = productStockFlow.CreateUserName;
wms_creation_time = productStockFlow.CreationTime;
create_time = DateTime.Now;
}
}
/// <summary>
/// 库存交易流水第三方单号类型
/// </summary>
public enum ThirdSysOrderType
{
/// <summary>
/// FBA调拨单出库
/// </summary>
[Description("FBA调拨单出库")]
AllotFbaOut = 1,
/// <summary>
/// FBA调拨单入库
/// </summary>
[Description("FBA调拨单入库")]
AllotFbaPut = 2,
/// <summary>
/// 普通调拨单出库
/// </summary>
[Description("普通调拨单出库")]
AllotOrdinaryOut = 3,
/// <summary>
/// 普通调拨单入库
/// </summary>
[Description("普通调拨单入库")]
AllotOrdinaryPut = 4,
/// <summary>
/// 调拨单退货
/// </summary>
[Description("调拨单退货")]
AllotIntercept = 5,
/// <summary>
///采购入库
/// </summary>
[Description("采购入库")]
Purchase = 6,
/// <summary>
/// OMS配货单
/// </summary>
[Description("OMS配货单")]
OMS = 7,
/// <summary>
/// 盘亏
/// </summary>
[Description("盘亏")]
InventoryLoss = 8,
/// <summary>
/// 盘盈
/// </summary>
[Description("盘盈")]
InventorySurplus = 9,
/// <summary>
/// OMS退货单
/// </summary>
[Description("OMS退货单")]
OMSReturnOrder = 10,
/// <summary>
/// WFS调拨单出库
/// </summary>
[Description("WFS调拨单出库")]
AllotWfsOut = 11,
/// <summary>
/// WFS调拨单入库
/// </summary>
[Description("WFS调拨单入库")]
AllotWfsPut = 12,
}
/// <summary>
/// 库存流水数据来源系统
/// </summary>
public enum StockFlowSystemSource
{
/// <summary>
/// 调拨系统
/// </summary>
[Description("调拨系统")]
Allot = 1,
/// <summary>
/// OMS系统
/// </summary>
[Description("OMS系统")]
OMS = 2,
[Description("采购系统")]
Purchase = 3,
/// <summary>
/// WMS系统
/// </summary>
[Description("WMS系统")]
WMS = 4
}
}
using System;
namespace Bailun.DC.Models.Stock
{
/// <summary>
/// 存货计价
/// </summary>
public class dc_month_stock_weighting
{
/// <summary>
/// id
/// </summary>
public int id { get; set; }
/// <summary>
/// 百伦sku
/// </summary>
public string bailun_sku { get; set; }
/// <summary>
/// 加权计价月份
/// </summary>
public string weighted_month { get; set; }
/// <summary>
/// 加权价格
/// </summary>
public decimal weighted_average_price { get; set; }
/// <summary>
/// 月初库存数
/// </summary>
public int month_beginning_stock { get; set; }
/// <summary>
/// 采购单价
/// </summary>
public decimal purchase_unit_price { get; set; }
/// <summary>
/// 计算公式
/// </summary>
public string computing_formula { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime create_time { get; set; }
}
}
......@@ -4,6 +4,7 @@ using Bailun.DC.Models;
using Bailun.DC.Models.Common;
using Bailun.DC.Models.Common.Page;
using Bailun.DC.Models.Dtos.Finance;
using Bailun.DC.Models.Dtos.Stock;
using Bailun.DC.Models.WebApiModels;
using Dapper;
using MySql.Data.MySqlClient;
......@@ -468,7 +469,7 @@ and s1.management_cost_name = @managementcostname";
/// <param name="isCost">统计成本</param>
/// <param name="falg"></param>
/// <returns></returns>
public List<PlatformTypeMonthlyStatisticsDto> GetPlatformTypeMonthlyStatistics(string month, string financecategory,bool isCost = false,bool falg = false)
public List<PlatformTypeMonthlyStatisticsDto> GetPlatformTypeMonthlyStatistics(string month, string financecategory, bool isCost = false, bool falg = false)
{
StringBuilder sql = new StringBuilder();
if (isCost)
......@@ -720,7 +721,7 @@ SUM(t1.amount_sales * t1.seller_order_exchange_rate * t1.quantity_shipped) AS to
public CommonApiResponseDto<List<FinanceDetailsDto>> GetMonthProfitFeeManagementCostDetail(string month, string feeName)
{
month = month.Replace("月份", "");
var start =Convert.ToDateTime(month).Date;
var start = Convert.ToDateTime(month).Date;
var end = start.AddMonths(1).Date;
var sql = BuildMonthProfitFeeManagementCostDetailSql(start, end, feeName, out DynamicParameters parameters);
......@@ -756,7 +757,7 @@ SUM(t1.amount_sales * t1.seller_order_exchange_rate * t1.quantity_shipped) AS to
});
return new CommonApiResponseDto<List<FinanceDetailsDto>> { Data = data };
}
public string BuildMonthProfitFeeManagementCostDetailSql(DateTime start,DateTime end,string feeName,out DynamicParameters parameters)
public string BuildMonthProfitFeeManagementCostDetailSql(DateTime start, DateTime end, string feeName, out DynamicParameters parameters)
{
parameters = new DynamicParameters();
StringBuilder sql = new StringBuilder();
......@@ -772,7 +773,7 @@ or (is_lend=2 and cost_form=1)) and pay_time>= @start and pay_time< @end ");
{
sql.Append(" and company_name like '%歌戈儿%' and type_name in ('销售收入','收款') ");
}
else if(feeName.Contains("其中:其他收入"))
else if (feeName.Contains("其中:其他收入"))
{
sql.Append(" and type_name in ('其他收入','销售商品收入','利息收入') ");
}
......@@ -882,17 +883,17 @@ or (is_lend=2 and cost_form=1)) and pay_time>= @start and pay_time< @end ");
/// <param name="isPage"></param>
/// <param name="isSum"></param>
/// <returns></returns>
public string BuildMonthProfitFeePlatformFeeDetailSql(GetMonthProfitPlatformDetailInput input, out DynamicParameters parameters, bool isPage = false,bool isSum = false)
public string BuildMonthProfitFeePlatformFeeDetailSql(GetMonthProfitPlatformDetailInput input, out DynamicParameters parameters, bool isPage = false, bool isSum = false)
{
parameters = new DynamicParameters();
input.Month = input.Month.Replace("月份", "");
StringBuilder sql = new StringBuilder();
if (isSum)
{
// sql.Append($@"SELECT sum(s1.amountval) as amountval, sum(s1.amountval_rmb) amountval_rmb
//from order_fee_value_amazon s1
//JOIN order_fee_config s2
//ON s2.id = s1.order_fee_config_id WHERE s1.amountval != 0 AND s1.month = @month ");
// sql.Append($@"SELECT sum(s1.amountval) as amountval, sum(s1.amountval_rmb) amountval_rmb
//from order_fee_value_amazon s1
//JOIN order_fee_config s2
//ON s2.id = s1.order_fee_config_id WHERE s1.amountval != 0 AND s1.month = @month ");
sql.Append($@"
SELECT s1.platform AS platform_type,s1.website AS website ,SUM(s1.amountval) as original_amount,SUM(s1.amountval_rmb) as total_amount_sales,count(*) AS total_order
from order_fee_value_amazon s1
......@@ -1098,7 +1099,7 @@ where t1.refund_time >= @start and t1.refund_time < @end ");
}
public CommonApiResponseDto<PageResult<List<dc_month_sales_profit_orderdetail>>> GetMonthSalesProfitDetail(MonthProfitOrderDetailPageInputDto input,bool isPage = true)
public CommonApiResponseDto<PageResult<List<dc_month_sales_profit_orderdetail>>> GetMonthSalesProfitDetail(MonthProfitOrderDetailPageInputDto input, bool isPage = true)
{
var data = new List<dc_month_sales_profit_orderdetail>();
var result = new PageResult<List<dc_month_sales_profit_orderdetail>>();
......@@ -1761,7 +1762,7 @@ AND platform_type = '{item.platform_type}' AND financecategoryname = '{item.fina
/// <param name="result"></param>
/// <param name="start"></param>
/// <param name="end"></param>
public void UpateExprotTask(int id,int status,string result,DateTime? start = null,DateTime? end = null)
public void UpateExprotTask(int id, int status, string result, DateTime? start = null, DateTime? end = null)
{
var sql = new StringBuilder();
var param = new DynamicParameters();
......@@ -1801,7 +1802,7 @@ AND platform_type = '{item.platform_type}' AND financecategoryname = '{item.fina
/// <param name="input"></param>
/// <param name="name"></param>
/// <returns></returns>
private CommonApiResponseDto SyncExportMonthProfitFeePlatformFeeDetail(GetMonthProfitPlatformDetailInput input,string name)
private CommonApiResponseDto SyncExportMonthProfitFeePlatformFeeDetail(GetMonthProfitPlatformDetailInput input, string name)
{
var data = ExportMonthProfitFeePlatformFeeDetail(input);
var table = new DataTable();
......@@ -1849,7 +1850,7 @@ AND platform_type = '{item.platform_type}' AND financecategoryname = '{item.fina
/// <param name="name"></param>
/// <param name="IsCost"></param>
/// <returns></returns>
private CommonApiResponseDto SyncExportMonthProfitOrderDetail(MonthProfitOrderDetailPageInputDto input, string name,bool IsCost)
private CommonApiResponseDto SyncExportMonthProfitOrderDetail(MonthProfitOrderDetailPageInputDto input, string name, bool IsCost)
{
input.IsPages = false;
var data = GetMonthProfitOrderDetailPage(input).Data.Items;
......@@ -1945,5 +1946,52 @@ AND platform_type = '{item.platform_type}' AND financecategoryname = '{item.fina
return qiuniu.UploadStream(content, filename);
}
#endregion
#region 存货加权计价
/// <summary>
/// 查询存货计价
/// </summary>
/// <param name="bailunSku"></param>
/// <param name="month"></param>
/// <returns></returns>
public CommonApiResponseDto<GetMonthStockWeightingOutputDto> GetMonthStockWeightingList(string bailunSku, string month)
{
var result = new CommonApiResponseDto<GetMonthStockWeightingOutputDto> { Data = new GetMonthStockWeightingOutputDto() };
if (string.IsNullOrWhiteSpace(month)) return result;
var dateTime = Convert.ToDateTime(month + "-01");
var dateNow = DateTime.Now.Date;
dateNow = dateNow.AddDays(1 - dateNow.Day);
if (dateTime > dateNow) return result;
var sql = new StringBuilder();
var vueColumn = new StringBuilder();
var param = new DynamicParameters();
vueColumn.Append("[{\"title\":\"Sku\",\"key\":\"bailun_sku\"},"); ;
sql.Append("SELECT bailun_sku,");
while (dateTime <= dateNow)
{
var column = dateTime.ToString("yyyy-MM");
sql.Append($"MAX(CASE weighted_month WHEN '{column}' THEN weighted_average_price ELSE 0 END ) '{column}',");
vueColumn.Append("{\"title\":\"" + dateTime.ToString("yyyy年MM月") + "\",\"key\":\"" + column + "\"},");
dateTime = dateTime.AddMonths(1);
}
var vueColumnText = vueColumn.ToString().TrimEnd(',');
vueColumn.Clear();
vueColumn.Append(vueColumnText);
vueColumn.Append("]");
var sqlText = sql.ToString().TrimEnd(',');
sql.Clear();
sql.Append(sqlText);
sql.Append(" FROM dc_month_stock_weighting WHERE 1=1 ");
if (!string.IsNullOrWhiteSpace(bailunSku))
{
sql.Append(" AND bailun_sku = @bailun_sku");
param.Add("bailun_sku", bailunSku);
}
sql.Append(" GROUP BY bailun_sku;");
result.Data.Data = SimpleCRUD.Query<dynamic>(sql.ToString(), param, GlobalConfig.ConnectionString);
result.Data.ColumnText = vueColumn.ToString();
return result;
}
#endregion
}
}
......@@ -2,6 +2,7 @@
using Bailun.DC.Models.Common;
using Bailun.DC.Models.Common.Page;
using Bailun.DC.Models.Dtos.Finance;
using Bailun.DC.Models.Dtos.Stock;
using Bailun.DC.Models.WebApiModels;
using Bailun.DC.Services.WebApiService;
using Bailun.DC.WebApi.Models;
......@@ -612,5 +613,19 @@ namespace Bailun.DC.WebApi.Controllers
public object GetExportTaskPage()
=> new FinanceService().GetExportTaskPage();
#endregion
#region 存货计价
/// <summary>
/// 查询存货计价
/// </summary>
/// <param name="bailunSku"></param>
/// <param name="month"></param>
/// <returns></returns>
[HttpPost("getMonthStockWeightingList")]
public CommonApiResponseDto<GetMonthStockWeightingOutputDto> GetMonthStockWeightingList(string bailunSku, string month)
{
return new FinanceService().GetMonthStockWeightingList(bailunSku, month);
}
#endregion
}
}
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