每周一次,导出excel私发给 徐淑銮
(SELECT fc.TenantId, fc.CustomerCode, fc.DetailNo as 'jiaoyihao', fc.WarehouseId, w.WarehouseName, fc.FeeCategoryName, fc.FeeOrderCode as OrderCode, fc.TransactionTypeId , sum(fc.ChargeAmount) as '总金额', fc.CurrencyId, d.DicName as '币种', fc.TransactionTypeName, fc.ChargeDetailType, Case when fc.ChargeDetailType = 0 and FeeCategoryName != '仓储费' then '操作费' when fc.ChargeDetailType = 0 and FeeCategoryName = '仓储费' then '仓储费' when fc.ChargeDetailType = 1 then '手工费用' when fc.ChargeDetailType = 2 then '运费' else 0 end as '费用类型', fc.CreationTime, w.TimeZoneName, w.TimeZoneMinutes AS '与UTC相隔的分钟' FROM `fee_chargedetail` fc LEFT JOIN inv_warehouse w ON w.Id = fc.WarehouseId LEFT JOIN sys_datadictionary d on d.TypeName = '币种' and d.DicValue = fc.CurrencyId WHERE fc.TenantId = 101 AND fc.creationtime >= DATE_ADD('2021-12-13 00:00:00', INTERVAL w.TimeZoneMinutes MINUTE) AND fc.creationtime < DATE_ADD('2021-12-20 00:00:00',INTERVAL w.TimeZoneMinutes MINUTE) GROUP BY fc.WarehouseId, fc.CustomerCode, fc.TransactionTypeId, fc.CurrencyId, fc.FeeCategoryName) union (select c.TenantId, wc.CustomerCode, wc.OrderCode as 'jiaoyihao', wc.WarehouseId, wc.WarehouseName, wc.FeeCategoryName, wc.StorageOrderCode as OrderCode, Case when WarehouseChargeCode != 0 then '3' else 0 end as TransactionTypeId, sum(wc.ChargingAmount) as '总金额', wc.CurrencyId, wc.CurrencyName as '币种', Case when WarehouseChargeCode != 0 then '应收' else 0 end as TransactionTypeName, Case when WarehouseChargeCode != 0 then '仓储费' else 0 end as ChargeDetailType, Case when WarehouseChargeCode != 0 then '仓储费' else 0 end as '费用类型', wc.ChargingDate, w.TimeZoneName, w.TimeZoneMinutes AS '与UTC相隔的分钟' from fee_warehousechargecount_forbill wc left join cl_customer c on c.CustomerCode = wc.CustomerCode left join inv_warehouse w ON w.Id = wc.WarehouseId WHERE c.TenantId = 101 AND wc.ChargingDate >= DATE_ADD('2021-12-13 00:00:00', INTERVAL w.TimeZoneMinutes MINUTE) AND wc.ChargingDate < DATE_ADD('2021-12-20 00:00:00',INTERVAL w.TimeZoneMinutes MINUTE) GROUP BY wc.WarehouseId, wc.CustomerCode, wc.CurrencyId)
