Commit e954e034 by lizefeng

投资回报分析的 单位头程费取值,由最近2个月,改成最近5单

parent 522d955f
...@@ -300,7 +300,7 @@ namespace AutoTurnOver.DB ...@@ -300,7 +300,7 @@ namespace AutoTurnOver.DB
} }
//计算单位运费 //计算单位运费
ana.freight_unit_price = CalculationFreight(ana.sku, ana.warehouse_code, day30Btime.AddDays(-30 *5),dayEtime); ana.freight_unit_price = CalculationFreight(ana.sku, ana.warehouse_code);
//预估运费,库存 * 单位运费 //预估运费,库存 * 单位运费
ana.estimated_freight = ana.freight_unit_price * ana.stock; ana.estimated_freight = ana.freight_unit_price * ana.stock;
...@@ -422,7 +422,7 @@ namespace AutoTurnOver.DB ...@@ -422,7 +422,7 @@ namespace AutoTurnOver.DB
/// <summary> /// <summary>
/// 计算单位运费 /// 计算单位运费
/// </summary> /// </summary>
public static decimal CalculationFreight(string bailun_sku, string warehouse_code, DateTime btime, DateTime etime) public static decimal CalculationFreight(string bailun_sku, string warehouse_code)
{ {
// 清理运费计算日志 // 清理运费计算日志
_connection.Execute(" delete from dc_base_transfer_freight_new_order where main_bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ", new _connection.Execute(" delete from dc_base_transfer_freight_new_order where main_bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ", new
...@@ -430,7 +430,16 @@ namespace AutoTurnOver.DB ...@@ -430,7 +430,16 @@ namespace AutoTurnOver.DB
bailun_sku = bailun_sku, bailun_sku = bailun_sku,
warehouse_code = warehouse_code warehouse_code = warehouse_code
}); });
var top5DataIds = _connection.Query<string>($@" select dataid from dc_base_transfer_info where
dataid in ( select dataid from dc_base_transfer_info_skus where sku=@sku )
and isdeleted=0
and isexception = 0
and estimatedcost>0
and targetwareno=@warehouse_code
order by creationtime desc limit 5 ",new { sku = bailun_sku, warehouse_code = warehouse_code }).ToList();
if(top5DataIds!=null && top5DataIds.Count >= 1)
{
// 查询这个sku 时间范围内所有的调拨单明细 // 查询这个sku 时间范围内所有的调拨单明细
var tempDatas = _connection.Query<CalculationFreightDto>($@"select t2.sku , var tempDatas = _connection.Query<CalculationFreightDto>($@"select t2.sku ,
t1.`code`, t1.`code`,
...@@ -442,17 +451,9 @@ from dc_base_transfer_info as t1 ...@@ -442,17 +451,9 @@ from dc_base_transfer_info as t1
left join dc_base_transfer_info_skus as t2 on t1.dataid = t2.dataid left join dc_base_transfer_info_skus as t2 on t1.dataid = t2.dataid
left join ( select dataid,sum(deliverycount) as 'deliverycount' from dc_base_transfer_info_skus GROUP BY dataid ) as t3 on t1.dataid = t3.dataid left join ( select dataid,sum(deliverycount) as 'deliverycount' from dc_base_transfer_info_skus GROUP BY dataid ) as t3 on t1.dataid = t3.dataid
left join dc_base_sku as t4 on t2.sku = t4.bailun_sku left join dc_base_sku as t4 on t2.sku = t4.bailun_sku
where t1.isdeleted=0 where t1.dataid in @dataIds", new
and t1.isexception = 0 {
and t1.creationtime >=@btime and t1.creationtime <=@etime dataIds = top5DataIds
and t1.targetwareno=@warehouse_code
and t1.estimatedcost>0
and t1.dataid in ( select dataid from dc_base_transfer_info_skus where sku=@sku)", new
{
btime = btime,
etime = etime,
warehouse_code = warehouse_code,
sku = bailun_sku
}, commandTimeout: 0).ToList(); }, commandTimeout: 0).ToList();
if (tempDatas != null && tempDatas.Count >= 1) if (tempDatas != null && tempDatas.Count >= 1)
...@@ -485,7 +486,7 @@ and t1.dataid in ( select dataid from dc_base_transfer_info_skus where sku=@sku ...@@ -485,7 +486,7 @@ and t1.dataid in ( select dataid from dc_base_transfer_info_skus where sku=@sku
groupOrders.Add(new_order); groupOrders.Add(new_order);
} }
var cha = (sumCost - groupOrders.Sum(s => s.sku_cost)); var cha = (sumCost - groupOrders.Sum(s => s.sku_cost));
if (cha>0) if (cha > 0)
{ {
var topSkuOrder = groupOrders.OrderByDescending(s => s.order_cost).FirstOrDefault(); var topSkuOrder = groupOrders.OrderByDescending(s => s.order_cost).FirstOrDefault();
...@@ -532,6 +533,12 @@ and t1.dataid in ( select dataid from dc_base_transfer_info_skus where sku=@sku ...@@ -532,6 +533,12 @@ and t1.dataid in ( select dataid from dc_base_transfer_info_skus where sku=@sku
return 0; return 0;
} }
} }
else
{
return 0;
}
}
public class CalculationFreightDto public class CalculationFreightDto
{ {
......
...@@ -48,7 +48,7 @@ namespace ResetOutofstock ...@@ -48,7 +48,7 @@ namespace ResetOutofstock
// report_invest_return_dao.SynchBtmAdFees(); // report_invest_return_dao.SynchBtmAdFees();
//report_invest_return_dao.ShareAdFee(); //report_invest_return_dao.ShareAdFee();
//report_invest_return_dao.SynchBtmOrderRefund(); //report_invest_return_dao.SynchBtmOrderRefund();
//report_invest_return_dao.CalculationStockScore(); report_invest_return_dao.CalculationStockScore();
} }
catch (Exception ex) catch (Exception ex)
{ {
......
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