@@ -184,7 +184,7 @@ where t1.bailun_sku = t2.bailun_sku and quantity_final_advise=1 and quantity_ini
...
@@ -184,7 +184,7 @@ where t1.bailun_sku = t2.bailun_sku and quantity_final_advise=1 and quantity_ini
left join dc_auto_sales as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
left join dc_auto_sales as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
where t6.buyer_name in ('赵美聪','张莹霞','张莹霞1','冯兆欣')
where t6.buyer_name in ('赵美聪')
and t1.warehouse_code in ('GZBLWH','GZBLYS')
and t1.warehouse_code in ('GZBLWH','GZBLYS')
GROUP BY t1.bailun_sku
GROUP BY t1.bailun_sku
HAVING ( sum((case when t1.quantity_out_stock>0 then 0 else t1.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) < sum(t1.quantity_out_stock) )
HAVING ( sum((case when t1.quantity_out_stock>0 then 0 else t1.quantity_inventory end )) + sum(t1.quantity_transfer) + sum(t1.quantity_purchase) < sum(t1.quantity_out_stock) )
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
where t1.pay_time>'2019-03-01' and t1.shipping_status!='TotalShipping' and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0
where t1.pay_time>'2019-03-01' and t1.bailun_picking_status!='TotalPicked' and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 and t1.bailun_interception_status not in ('Success','Part')
";
";
sql=@"
sql=@"
select
select
...
@@ -161,7 +161,7 @@ t1.bailun_sku_title_cn as 'sku_name',
...
@@ -161,7 +161,7 @@ t1.bailun_sku_title_cn as 'sku_name',
t1.bailun_sku_quantity_ordered,
t1.bailun_sku_quantity_ordered,
t1.warehouse_code,
t1.warehouse_code,
t1.warehouse_name,
t1.warehouse_name,
(case when t1.bailun_sku_quantity_ordered>t1.bailun_sku_quantity_shipped then '缺货' else '不缺货' end) as 'is_out_stock',
(case when t1.bailun_sku_quantity_ordered>t1.bailun_sku_quantity_picked then '缺货' else '不缺货' end) as 'is_out_stock',
t2.quantity_out_stock,
t2.quantity_out_stock,
t3.sum_usable_stock,
t3.sum_usable_stock,
t4.sum_unshipped_quantity,
t4.sum_unshipped_quantity,
...
@@ -183,27 +183,26 @@ left join view_china_warehouse_stock as t3 on t1.bailun_sku = t3.bailun_sku and
...
@@ -183,27 +183,26 @@ left join view_china_warehouse_stock as t3 on t1.bailun_sku = t3.bailun_sku and
left join (
left join (
SELECT
SELECT
`t1`.`bailun_sku` AS `bailun_sku`,
`t1`.`bailun_sku` AS `bailun_sku`,
sum(case when t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 then ( `t1`.`bailun_sku_quantity_ordered` - `t1`.`bailun_sku_quantity_shipped` ) else 0 end ) AS `sum_unshipped_quantity`
sum(case when t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 then ( `t1`.`bailun_sku_quantity_ordered` - `t1`.`bailun_sku_quantity_picked` ) else 0 end ) AS `sum_unshipped_quantity`
FROM
FROM
( `dc_base_oms_sku` `t1` LEFT JOIN `dc_base_warehouse` `t2` ON ( ( `t1`.`warehouse_code` = `t2`.`warehouse_code` ) ) )
( `dc_base_oms_sku` `t1` LEFT JOIN `dc_base_warehouse` `t2` ON ( ( `t1`.`warehouse_code` = `t2`.`warehouse_code` ) ) )
WHERE
WHERE
( ( `t2`.`hq_type` = '国内仓' ) AND ( `t1`.`shipping_status` <> 'TotalShipping' ) AND ( `t1`.`pay_time` > '2019-03-01' ) ) -- and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0
( ( `t2`.`hq_type` = '国内仓' ) AND ( `t1`.`bailun_picking_status` <> 'TotalPicked' ) AND ( `t1`.`pay_time` > '2019-03-01' ) ) and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 and t1.bailun_interception_status not in ('Success','Part')
";
";
if(!string.IsNullOrWhiteSpace(m.bailun_sku))
if(!string.IsNullOrWhiteSpace(m.bailun_sku))
{
{
sql+=$" and bailun_sku= '{m.bailun_sku}' ";
sql+=$" and bailun_sku= '{m.bailun_sku}' ";
}
}
sql+=@" GROUP BY
sql+=@" GROUP BY
`t1`.`bailun_sku`
`t1`.`bailun_sku`
) as t4 on t1.bailun_sku = t4.bailun_sku and t_db.hq_type='国内仓'
) as t4 on t1.bailun_sku = t4.bailun_sku and t_db.hq_type='国内仓'
left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
left join dc_base_sku as t6 on t1.bailun_sku = t6.bailun_sku
left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
left join view_buy_ontheway_detail as t8 on t1.bailun_sku = t8.bailun_sku and t1.warehouse_code = t8.warehouse_code
left join view_buy_ontheway_detail as t8 on t1.bailun_sku = t8.bailun_sku and t1.warehouse_code = t8.warehouse_code
where t1.shipping_status!='TotalShipping' and t1.pay_time>'2019-03-01' and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0
where t1.bailun_picking_status!='TotalPicked' and t1.pay_time>'2019-03-01' and t1.bailun_order_status !='Canceled' and t1.has_delete=0 and t1.has_scalp=0 and t1.bailun_interception_status not in ('Success','Part')