|
|
@@ -200,4 +200,394 @@
|
|
|
ORDER BY a.rec_time desc, a.order_item_id desc
|
|
|
</select>
|
|
|
|
|
|
+ <select id="goodsTotalPrice" resultType="Double">
|
|
|
+ SELECT (SELECT SUM(IFNULL(total,0)) goods_total_price FROM tz_order
|
|
|
+ WHERE is_payed=1
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and create_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and create_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
|
|
|
+ and order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
|
|
|
+ <where>
|
|
|
+ <if test="po.skuId != null">
|
|
|
+ AND a.sku_id like concat('%',#{po.skuId} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.skuName != null and po.skuName != ''">
|
|
|
+ AND a.sku_name like concat('%',#{po.skuName} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.spec != null and po.spec != ''">
|
|
|
+ AND b.spec like concat('%',#{po.spec} ,'%')
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+
|
|
|
+ and channel_id in
|
|
|
+ <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ )
|
|
|
+ -
|
|
|
+ (SELECT IFNULL(SUM(a.sku_price * product_count),0)
|
|
|
+ FROM `tz_order_refund_sku` a
|
|
|
+ LEFT JOIN tz_order_refund b on a.order_refund_id=b.refund_id
|
|
|
+ LEFT JOIN tz_order c on b.order_number=c.order_number
|
|
|
+ LEFT JOIN tz_sku d on a.sku_id=d.sku_id
|
|
|
+ WHERE b.return_money_sts=70
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and b.apply_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and b.apply_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ and c.channel_id in
|
|
|
+ <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+
|
|
|
+ <if test="po.skuId != null">
|
|
|
+ AND a.sku_id like concat('%',#{po.skuId} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.skuName != null and po.skuName != ''">
|
|
|
+ AND d.sku_name like concat('%',#{po.skuName} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.spec != null and po.spec != ''">
|
|
|
+ AND d.spec like concat('%',#{po.spec} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ ) goods_total_price
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="totalPoints" resultType="Double">
|
|
|
+ SELECT TRUNCATE(((SELECT SUM(IFNULL(offset_points,0)) FROM tz_order
|
|
|
+ WHERE is_payed=1
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and create_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and create_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ and channel_id in
|
|
|
+ <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
|
|
|
+ and order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
|
|
|
+ <where>
|
|
|
+ <if test="po.skuId != null">
|
|
|
+ AND a.sku_id like concat('%',#{po.skuId} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.skuName != null and po.skuName != ''">
|
|
|
+ AND a.sku_name like concat('%',#{po.skuName} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.spec != null and po.spec != ''">
|
|
|
+ AND b.spec like concat('%',#{po.spec} ,'%')
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ )
|
|
|
+ -
|
|
|
+ (SELECT SUM(total_offset_points) FROM (SELECT
|
|
|
+ CASE
|
|
|
+ WHEN refund_type=1 THEN total_offset_points
|
|
|
+ ELSE total_offset_points+ (freight_amount * 100)
|
|
|
+ END AS total_offset_points
|
|
|
+ FROM tz_order_refund a
|
|
|
+ LEFT JOIN (SELECT SUM(tor.offset_points) total_offset_points ,tor.order_number
|
|
|
+ FROM tz_order_refund tor
|
|
|
+ WHERE tor.return_money_sts=70
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and tor.apply_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and tor.apply_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ and tor.order_number in(SELECT ao.order_number FROM tz_order_item ao
|
|
|
+ LEFT JOIN tz_sku b on ao.sku_id=b.sku_id
|
|
|
+ LEFT JOIN tz_order c on ao.order_number=c.order_number
|
|
|
+ <where>
|
|
|
+ c.channel_id in
|
|
|
+ <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
|
|
|
+ <if test="po.skuId != null">
|
|
|
+ AND ao.sku_id like concat('%',#{po.skuId} ,'%')
|
|
|
+ </if>
|
|
|
+ <if test="po.skuName != null and po.skuName != ''">
|
|
|
+ AND ao.sku_name like concat('%',#{po.skuName} ,'%')
|
|
|
+ </if>
|
|
|
+ <if test="po.spec != null and po.spec != ''">
|
|
|
+ AND b.spec like concat('%',#{po.spec} ,'%')
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ )
|
|
|
+ GROUP BY tor.order_number) b on a.order_number=b.order_number
|
|
|
+ WHERE return_money_sts=70
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and apply_time >= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and apply_time <= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ and a.order_number in(SELECT ao2.order_number FROM tz_order_item ao2
|
|
|
+ LEFT JOIN tz_sku b on ao2.sku_id=b.sku_id
|
|
|
+ LEFT JOIN tz_order c on ao2.order_number=c.order_number
|
|
|
+ <where>
|
|
|
+ c.channel_id in
|
|
|
+ <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
|
|
|
+ <if test="po.skuId != null">
|
|
|
+ AND ao2.sku_id like concat('%',#{po.skuId} ,'%')
|
|
|
+ </if>
|
|
|
+ <if test="po.skuName != null and po.skuName != ''">
|
|
|
+ AND ao2.sku_name like concat('%',#{po.skuName} ,'%')
|
|
|
+ </if>
|
|
|
+ <if test="po.spec != null and po.spec != ''">
|
|
|
+ AND b.spec like concat('%',#{po.spec} ,'%')
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ )
|
|
|
+ GROUP BY a.order_number) a)) /100,2) total_offset_points
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="totalCash" resultType="Double">
|
|
|
+ SELECT (SELECT SUM(IFNULL(actual_total,0)) FROM tz_order WHERE is_payed=1
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and create_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and create_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ and channel_id in
|
|
|
+ <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
|
|
|
+ and order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
|
|
|
+ <where>
|
|
|
+ <if test="po.skuId != null">
|
|
|
+ AND a.sku_id like concat('%',#{po.skuId} ,'%')
|
|
|
+ </if>
|
|
|
+ <if test="po.skuName != null and po.skuName != ''">
|
|
|
+ AND a.sku_name like concat('%',#{po.skuName} ,'%')
|
|
|
+ </if>
|
|
|
+ <if test="po.spec != null and po.spec != ''">
|
|
|
+ AND b.spec like concat('%',#{po.spec} ,'%')
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ )
|
|
|
+ -
|
|
|
+ (SELECT SUM(refund_amount) FROM tz_order_refund WHERE return_money_sts=70
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and apply_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and apply_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ and order_number in(SELECT a.order_number FROM tz_order_item a
|
|
|
+ LEFT JOIN tz_sku b on a.sku_id=b.sku_id
|
|
|
+ LEFT JOIN tz_order c on a.order_number=c.order_number
|
|
|
+ <where>
|
|
|
+ c.channel_id in
|
|
|
+ <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
|
|
|
+ <if test="po.skuId != null">
|
|
|
+ AND a.sku_id like concat('%',#{po.skuId} ,'%')
|
|
|
+ </if>
|
|
|
+ <if test="po.skuName != null and po.skuName != ''">
|
|
|
+ AND a.sku_name like concat('%',#{po.skuName} ,'%')
|
|
|
+ </if>
|
|
|
+ <if test="po.spec != null and po.spec != ''">
|
|
|
+ AND b.spec like concat('%',#{po.spec} ,'%')
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ )) cash
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="totalFreight" resultType="Double">
|
|
|
+ SELECT (SELECT SUM(IFNULL(freight_amount,0)) total_freight FROM tz_order
|
|
|
+ WHERE is_payed=1
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and create_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and create_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ and channel_id in
|
|
|
+ <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
|
|
|
+ and order_number in(SELECT a.order_number FROM tz_order_item a LEFT JOIN tz_sku b on a.sku_id=b.sku_id
|
|
|
+ <where>
|
|
|
+ <if test="po.skuId != null">
|
|
|
+ AND a.sku_id like concat('%',#{po.skuId} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.skuName != null and po.skuName != ''">
|
|
|
+ AND a.sku_name like concat('%',#{po.skuName} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.spec != null and po.spec != ''">
|
|
|
+ AND b.spec like concat('%',#{po.spec} ,'%')
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ )
|
|
|
+ </if>
|
|
|
+ )
|
|
|
+ -
|
|
|
+ (SELECT SUM(IFNULL(freight_amount,0))
|
|
|
+ FROM `tz_order_refund`
|
|
|
+ WHERE return_money_sts=70
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and apply_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and apply_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ and refund_type=1
|
|
|
+ and order_number in(SELECT a.order_number FROM tz_order_item a
|
|
|
+ LEFT JOIN tz_sku b on a.sku_id=b.sku_id
|
|
|
+ LEFT JOIN tz_order c on a.order_number=c.order_number
|
|
|
+ <where>
|
|
|
+ c.channel_id in
|
|
|
+ <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ <if test="po.skuId != null or (po.skuName != null and po.skuName != '') or (po.spec != null and po.spec != '')">
|
|
|
+ <if test="po.skuId != null">
|
|
|
+ AND a.sku_id like concat('%',#{po.skuId} ,'%')
|
|
|
+ </if>
|
|
|
+ <if test="po.skuName != null and po.skuName != ''">
|
|
|
+ AND a.sku_name like concat('%',#{po.skuName} ,'%')
|
|
|
+ </if>
|
|
|
+ <if test="po.spec != null and po.spec != ''">
|
|
|
+ AND b.spec like concat('%',#{po.spec} ,'%')
|
|
|
+ </if>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ ))
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="skuStatisticsList" resultType="com.yami.shop.bean.vo.SkuStatisticsVo">
|
|
|
+ SELECT a.prod_id,a.sku_id,a.sku_name,c.spec,TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) price,IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0) as prod_count,
|
|
|
+ TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) * (IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0)) total
|
|
|
+ FROM tz_order_item a
|
|
|
+ LEFT JOIN tz_order b on a.order_number=b.order_number
|
|
|
+ LEFT JOIN tz_sku c on a.sku_id=c.sku_id
|
|
|
+ LEFT JOIN (SELECT a.sku_id,SUM(a.product_count) product_count
|
|
|
+ FROM `tz_order_refund_sku` a
|
|
|
+ LEFT JOIN tz_order_refund b on a.order_refund_id=b.refund_id
|
|
|
+ WHERE return_money_sts=70
|
|
|
+
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and b.apply_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and b.apply_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ GROUP BY a.sku_id) d on a.sku_id = d.sku_id
|
|
|
+
|
|
|
+ WHERE b.is_payed=1
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and a.rec_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and a.rec_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ and b.channel_id in
|
|
|
+ <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ <if test="po.skuId != null">
|
|
|
+ AND a.sku_id like concat('%',#{po.skuId} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.skuName != null and po.skuName != ''">
|
|
|
+ AND a.sku_name like concat('%',#{po.skuName} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.spec != null and po.spec != ''">
|
|
|
+ AND c.spec like concat('%',#{po.spec} ,'%')
|
|
|
+ </if>
|
|
|
+ GROUP BY a.sku_id HAVING prod_count>0
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="skuStatisticsList2" resultType="com.yami.shop.bean.vo.SkuStatisticsVo">
|
|
|
+ SELECT a.prod_id,a.sku_id,a.sku_name,c.spec,TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) price,IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0) as prod_count,
|
|
|
+ TRUNCATE(IFNULL(SUM(a.price*a.prod_count)/SUM(a.prod_count),0),2) * (IFNULL(SUM(a.prod_count),0)-IFNULL(d.product_count,0)) total
|
|
|
+ FROM tz_order_item a
|
|
|
+ LEFT JOIN tz_order b on a.order_number=b.order_number
|
|
|
+ LEFT JOIN tz_sku c on a.sku_id=c.sku_id
|
|
|
+ LEFT JOIN (SELECT a.sku_id,SUM(a.product_count) product_count
|
|
|
+ FROM `tz_order_refund_sku` a
|
|
|
+ LEFT JOIN tz_order_refund b on a.order_refund_id=b.refund_id
|
|
|
+ WHERE return_money_sts=70
|
|
|
+
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and b.apply_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and b.apply_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ GROUP BY a.sku_id) d on a.sku_id = d.sku_id
|
|
|
+
|
|
|
+ WHERE b.is_payed=1
|
|
|
+ <if test="po.startTime != null and po.startTime != ''">
|
|
|
+ and a.rec_time>= #{po.startTime}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.endTime != null and po.endTime != ''">
|
|
|
+ and a.rec_time<= #{po.endTime}
|
|
|
+ </if>
|
|
|
+ and b.channel_id in
|
|
|
+ <foreach collection="po.channelIds" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ <if test="po.skuId != null">
|
|
|
+ AND a.sku_id like concat('%',#{po.skuId} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.skuName != null and po.skuName != ''">
|
|
|
+ AND a.sku_name like concat('%',#{po.skuName} ,'%')
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="po.spec != null and po.spec != ''">
|
|
|
+ AND c.spec like concat('%',#{po.spec} ,'%')
|
|
|
+ </if>
|
|
|
+ GROUP BY a.sku_id HAVING prod_count>0
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|