|
- <?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.iformall.mapper.WxCardSpendMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCardSpend">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="card_id" jdbcType="BIGINT" property="cardId" />
- <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="order_id" jdbcType="BIGINT" property="orderId" />
- <result column="deduction_amount" jdbcType="INTEGER" property="deductionAmount" />
- <result column="payment" jdbcType="INTEGER" property="payment" />
- <result column="real_payment" jdbcType="INTEGER" property="realPayment" />
- <result column="card_remain_amount" jdbcType="INTEGER" property="cardRemainAmount" />
- <result column="card_before_amount" jdbcType="INTEGER" property="cardBeforeAmount" />
- <result column="card_remain_real_amount" jdbcType="INTEGER" property="cardRemainRealAmount" />
- <result column="card_before_real_amount" jdbcType="INTEGER" property="cardBeforeRealAmount" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`card_id`,`owner_id`,`merchant_id`,`order_id`,`deduction_amount`,`payment`,`real_payment`,
- `card_remain_amount`,`card_before_amount`,`card_remain_real_amount`,`card_before_real_amount`,`create_date`,`update_date`
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
- <if test=" null != id ">
- and `id` = #{id}
- </if>
- <if test=" null != tenantId ">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != cardId ">
- and `card_id` = #{cardId}
- </if>
- <if test=" null != ownerId ">
- and `owner_id` = #{ownerId}
- </if>
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
- <if test=" null != orderId ">
- and `order_id` = #{orderId}
- </if>
- <if test=" null != deductionAmount ">
- and `deduction_amount` = #{deductionAmount}
- </if>
- <if test=" null != payment ">
- and `payment` = #{payment}
- </if>
- <if test=" null != realPayment ">
- and `real_payment` = #{realPayment}
- </if>
- <if test=" null != cardRemainAmount ">
- and `card_remain_amount` = #{cardRemainAmount}
- </if>
- <if test=" null != cardBeforeAmount ">
- and `card_before_amount` = #{cardBeforeAmount}
- </if>
- <if test=" null != cardRemainRealAmount ">
- and `card_remain_real_amount` = #{cardRemainRealAmount}
- </if>
- <if test=" null != cardBeforeRealAmount ">
- and `card_before_real_amount` = #{cardBeforeRealAmount}
- </if>
- <if test=" null != createDate ">
- and `create_date` = #{createDate}
- </if>
- <if test=" null != updateDate ">
- and `update_date` = #{updateDate}
- </if>
- <if test=" null != startdate and null!=enddate">
- and `create_date` between #{startdate} and #{enddate}
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- <if test=" null != sortColumns"> order by ${sortColumns} </if>
- </sql>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxCardSpend" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_card_spend
- <include refid="dynamicWhereConditions" />
- </select>
-
-
- <resultMap id="VoResultMap" type="com.iformall.domain.vo.WxCardSpendVo">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="card_id" jdbcType="BIGINT" property="cardId" />
- <result column="owner_id" jdbcType="BIGINT" property="ownerId" />
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="order_id" jdbcType="BIGINT" property="orderId" />
- <result column="deduction_amount" jdbcType="INTEGER" property="deductionAmount" />
- <result column="payment" jdbcType="INTEGER" property="payment" />
- <result column="real_payment" jdbcType="INTEGER" property="realPayment" />
- <result column="card_remain_amount" jdbcType="INTEGER" property="cardRemainAmount" />
- <result column="card_before_amount" jdbcType="INTEGER" property="cardBeforeAmount" />
- <result column="card_remain_real_amount" jdbcType="INTEGER" property="cardRemainRealAmount" />
- <result column="card_before_real_amount" jdbcType="INTEGER" property="cardBeforeRealAmount" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
-
- <result column="title" jdbcType="VARCHAR" property="title"/>
-
- <result column="name" jdbcType="VARCHAR" property="merchantName"/>
-
- <result column="subsidy" jdbcType="INTEGER" property="subsidy" />
- <result column="real_subsidy" jdbcType="INTEGER" property="realSubsidy" />
- <result column="status" jdbcType="INTEGER" property="status" />
-
- <result column="onick_name" jdbcType="VARCHAR" property="onickName"/>
- <result column="ou_phone" jdbcType="VARCHAR" property="ouPhone"/>
- </resultMap>
-
- <sql id="allVoColumns">
- cs.`id`,cs.`tenant_id`,cs.`card_id`,cs.`owner_id`,cs.`merchant_id`,cs.`order_id`,cs.`deduction_amount`,cs.`payment`,cs.`real_payment`,
- cs.`card_remain_amount`,cs.`card_before_amount`,cs.`card_remain_real_amount`,cs.`card_before_real_amount`,cs.`create_date`,cs.`update_date`,
- m.`name`, c.`title`,
- ms.`subsidy`,ms.`real_subsidy`,ms.`status`,
- ou.`nick_name` as onick_name, ou.`phone` as ou_phone
- </sql>
-
- <sql id="dynamicVoWhereConditions">
- where 1 = 1
- <if test=" null != id ">
- and cs.`id` = #{id}
- </if>
- <if test=" null != tenantId ">
- and cs.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != cardId ">
- and cs.`card_id` = #{cardId}
- </if>
- <if test=" null != ownerId ">
- and cs.`owner_id` = #{ownerId}
- </if>
- <if test=" null != merchantId ">
- and cs.`merchant_id` = #{merchantId}
- </if>
- <if test=" null != orderId ">
- and cs.`order_id` = #{orderId}
- </if>
- <if test=" null != deductionAmount ">
- and cs.`deduction_amount` = #{deductionAmount}
- </if>
- <if test=" null != payment ">
- and cs.`payment` = #{payment}
- </if>
- <if test=" null != realPayment ">
- and cs.`real_payment` = #{realPayment}
- </if>
- <if test=" null != cardRemainAmount ">
- and cs.`card_remain_amount` = #{cardRemainAmount}
- </if>
- <if test=" null != cardBeforeAmount ">
- and cs.`card_before_amount` = #{cardBeforeAmount}
- </if>
- <if test=" null != cardRemainRealAmount ">
- and cs.`card_remain_real_amount` = #{cardRemainRealAmount}
- </if>
- <if test=" null != cardBeforeRealAmount ">
- and cs.`card_before_real_amount` = #{cardBeforeRealAmount}
- </if>
- <if test=" null != createDate ">
- and cs.`create_date` = #{createDate}
- </if>
- <if test=" null != updateDate ">
- and cs.`update_date` = #{updateDate}
- </if>
- <if test=" null != ouPhone ">
- and ou.`phone` = #{ouPhone}
- </if>
- <if test=" null != startdate and null!=enddate">
- and cs.`create_date` between #{startdate} and #{enddate}
- </if>
- <if test=" null != ids ">
- and cs.id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </sql>
-
- <select id="findCardSpendVoList" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultMap="VoResultMap">
- select
- <include refid="allVoColumns"/>
- from wx_card_spend cs
- left join wx_coupon_order co on co.id = cs.card_id
- left join wx_coupon c on c.id = co.coupon_id
- left join wx_merchant m on m.id = cs.merchant_id
- left join wx_merchant_subsidy ms on ms.order_id = cs.order_id
- left join wx_c_user ou on ou.id = co.owner_id
- <include refid="dynamicVoWhereConditions" />
- </select>
-
- <select id="sumCardSpendVo" parameterType="com.iformall.domain.vo.WxCardSpendVo" resultType="hashmap">
- select
- IFNULL(SUM(cs.`deduction_amount`),0) as sum_deduction_amount,
- IFNULL(SUM(cs.`payment`),0) as sum_payment,
- IFNULL(SUM(cs.`real_payment`),0) as sum_real_payment
- from wx_card_spend cs
- left join wx_coupon_order co on co.id = cs.card_id
- left join wx_coupon c on c.id = co.coupon_id
- left join wx_merchant m on m.id = cs.merchant_id
- left join wx_merchant_subsidy ms on ms.order_id = cs.order_id
- left join wx_c_user ou on ou.id = co.owner_id
- <include refid="dynamicVoWhereConditions" />
- </select>
-
-
- </mapper>
|