<?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.yc.ship.module.trade.dal.mysql.orderpolicy.OrderPolicyMapper">

    <select id="selectOrderPolicyStatsByOrderIds"
            resultType="com.yc.ship.module.trade.controller.admin.order.vo.order.OrderTotalPolicyVO">
        SELECT
            policy_id,
            policy_name,
            sum( use_num ) num,
            sum( discount ) amount
        FROM
            trade_order_policy
        WHERE
            deleted = 0
        and order_id IN
        <foreach item="item" collection="orderIds" separator="," open="(" close=")" index="">
            #{item}
        </foreach>
        GROUP BY
            policy_id
    </select>
</mapper>
