OrderSalesShipmentStatisticsMapper.xml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.sd.business.mapper.order.OrderSalesShipmentStatisticsMapper">
  4. <select id="getOrderSalesShipmentStatisticsList" resultType="com.sd.business.entity.board.bo.OrderSalesShipmentStatisticsBo">
  5. select
  6. os.bom_spec_id,
  7. bs.code bomSpecCode,
  8. bs.name bomSpecName,
  9. bs.width,
  10. bs.height,
  11. b.chromatophore,
  12. sum(case when oi.shipping_time >= date_sub(now(), interval 90 day) then os.quantity else 0 end) ninetyDaysSalesQuantity,
  13. sum(case when oi.shipping_time >= date_sub(now(), interval 60 day) then os.quantity else 0 end) sixtyDaysSalesQuantity,
  14. sum(case when oi.shipping_time >= date_sub(now(), interval 30 day) then os.quantity else 0 end) thirtyDaysSalesQuantity
  15. from
  16. order_info oi
  17. inner join order_sku os on oi.id = os.order_id
  18. inner join bom_spec bs on os.bom_spec_id = bs.id
  19. inner join bom b on bs.bom_id = b.id
  20. inner join bom_classify bc on b.bom_classify_id = bc.id
  21. ${ew.customSqlSegment}
  22. </select>
  23. <select id="getTurnoverRateMapByBomSpecIds" resultType="com.sd.business.entity.board.bo.OrderSalesShipmentStatisticsBo">
  24. select
  25. oq.bom_spec_id,
  26. ifnull(90 / (90 * 0.5 *
  27. (ifnull(ib.quantity, 0)
  28. +
  29. ifnull(ib.lock_quantity, 0)
  30. +
  31. ifnull(i.quantity, 0)
  32. +
  33. ifnull(i.lock_quantity, 0)) / oq.quantity), 0) turnover_rate
  34. from (
  35. select
  36. os.bom_spec_id,
  37. sum(os.quantity) quantity
  38. FROM
  39. order_info oi
  40. inner join order_sku os on oi.id = os.order_id
  41. where oi.shipping_time >= date_sub(now(), INTERVAL 90 day)
  42. group by os.bom_spec_id
  43. ) oq
  44. left join inventory_backup ib on oq.bom_spec_id = ib.bom_spec_id
  45. and backup_date = date(date_sub(now(), INTERVAL 90 day))
  46. and ib.department_id = 0 and ib.warehouse_id = 1684037244354052098
  47. left join inventory i on oq.bom_spec_id = i.bom_spec_id
  48. and i.department_id = 0 and i.warehouse_id = 1684037244354052098
  49. ${ew.customSqlSegment}
  50. </select>
  51. </mapper>