1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.sd.business.mapper.order.OrderSalesShipmentStatisticsMapper">
- <select id="getOrderSalesShipmentStatisticsList" resultType="com.sd.business.entity.board.bo.OrderSalesShipmentStatisticsBo">
- select
- os.bom_spec_id,
- bs.code bomSpecCode,
- bs.name bomSpecName,
- bs.width,
- bs.height,
- b.chromatophore,
- sum(case when oi.shipping_time >= date_sub(now(), interval 90 day) then os.quantity else 0 end) ninetyDaysSalesQuantity,
- sum(case when oi.shipping_time >= date_sub(now(), interval 60 day) then os.quantity else 0 end) sixtyDaysSalesQuantity,
- sum(case when oi.shipping_time >= date_sub(now(), interval 30 day) then os.quantity else 0 end) thirtyDaysSalesQuantity
- from
- order_info oi
- inner join order_sku os on oi.id = os.order_id
- inner join bom_spec bs on os.bom_spec_id = bs.id
- inner join bom b on bs.bom_id = b.id
- inner join bom_classify bc on b.bom_classify_id = bc.id
- ${ew.customSqlSegment}
- </select>
- <select id="getTurnoverRateMapByBomSpecIds" resultType="com.sd.business.entity.board.bo.OrderSalesShipmentStatisticsBo">
- select
- oq.bom_spec_id,
- ifnull(90 / (90 * 0.5 *
- (ifnull(ib.quantity, 0)
- +
- ifnull(ib.lock_quantity, 0)
- +
- ifnull(i.quantity, 0)
- +
- ifnull(i.lock_quantity, 0)) / oq.quantity), 0) turnover_rate
- from (
- select
- os.bom_spec_id,
- sum(os.quantity) quantity
- FROM
- order_info oi
- inner join order_sku os on oi.id = os.order_id
- where oi.shipping_time >= date_sub(now(), INTERVAL 90 day)
- group by os.bom_spec_id
- ) oq
- left join inventory_backup ib on oq.bom_spec_id = ib.bom_spec_id
- and backup_date = date(date_sub(now(), INTERVAL 90 day))
- and ib.department_id = 0 and ib.warehouse_id = 1684037244354052098
- left join inventory i on oq.bom_spec_id = i.bom_spec_id
- and i.department_id = 0 and i.warehouse_id = 1684037244354052098
- ${ew.customSqlSegment}
- </select>
- </mapper>
|