add recycle
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?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.imyeyu.api.modules.gao.mapper.GaoRecycleStatMapper">
|
||||
<select id="selectRecycleStats" resultType="com.imyeyu.api.modules.gao.vo.GaoRecycleStatView">
|
||||
SELECT t.recycle_item_id AS recycleItemId, t.recycle_name AS recycleName,
|
||||
t.recycle_unit AS recycleUnit, SUM(t.received) AS receivedQuantity,
|
||||
SUM(t.returned) AS returnedQuantity, SUM(t.received - t.returned) AS netQuantity
|
||||
FROM (
|
||||
SELECT e.recycle_item_id, e.recycle_name_snapshot AS recycle_name,
|
||||
e.recycle_unit_snapshot AS recycle_unit, e.recycle_quantity AS received, 0 AS returned
|
||||
FROM gao_recycle_exchange e
|
||||
WHERE e.store_id = #{storeId} AND e.occurred_at >= #{startAt} AND e.occurred_at < #{endAt}
|
||||
UNION ALL
|
||||
SELECT e.recycle_item_id, e.recycle_name_snapshot, e.recycle_unit_snapshot,
|
||||
0, e.recycle_quantity
|
||||
FROM gao_recycle_exchange_action a
|
||||
JOIN gao_recycle_exchange e ON e.id = a.exchange_id AND e.store_id = a.store_id
|
||||
WHERE a.store_id = #{storeId} AND a.action_type IN ('CANCEL', 'REVOKE')
|
||||
AND a.recycle_returned = 1 AND a.occurred_at >= #{startAt} AND a.occurred_at < #{endAt}
|
||||
) t
|
||||
GROUP BY t.recycle_item_id, t.recycle_name, t.recycle_unit
|
||||
</select>
|
||||
<select id="selectExchangeStats" resultType="com.imyeyu.api.modules.gao.vo.GaoRecycleExchangeStatView">
|
||||
SELECT t.sku_id AS skuId, t.sku_unit_id AS skuUnitId, t.product_name AS productName,
|
||||
t.unit_name AS unit, SUM(t.created) AS createdQuantity,
|
||||
SUM(t.verified) AS verifiedQuantity, SUM(t.revoked) AS revokedQuantity
|
||||
FROM (
|
||||
SELECT e.sku_id_snapshot AS sku_id, e.sku_unit_id_snapshot AS sku_unit_id,
|
||||
e.product_name_snapshot AS product_name, e.unit_snapshot AS unit_name,
|
||||
e.exchange_quantity AS created, 0 AS verified, 0 AS revoked
|
||||
FROM gao_recycle_exchange e
|
||||
WHERE e.store_id = #{storeId} AND e.occurred_at >= #{startAt} AND e.occurred_at < #{endAt}
|
||||
UNION ALL
|
||||
SELECT e.sku_id_snapshot, e.sku_unit_id_snapshot, e.product_name_snapshot, e.unit_snapshot,
|
||||
0, CASE WHEN a.action_type = 'VERIFY' THEN e.exchange_quantity ELSE 0 END,
|
||||
CASE WHEN a.action_type = 'REVOKE' THEN e.exchange_quantity ELSE 0 END
|
||||
FROM gao_recycle_exchange_action a
|
||||
JOIN gao_recycle_exchange e ON e.id = a.exchange_id AND e.store_id = a.store_id
|
||||
WHERE a.store_id = #{storeId} AND a.action_type IN ('VERIFY', 'REVOKE')
|
||||
AND a.occurred_at >= #{startAt} AND a.occurred_at < #{endAt}
|
||||
) t
|
||||
GROUP BY t.sku_id, t.sku_unit_id, t.product_name, t.unit_name
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user