|
- <?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.WxMerchantSubsidyMapper">
- <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMerchantSubsidy">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="order_id" jdbcType="BIGINT" property="orderId" />
- <result column="order_type" jdbcType="INTEGER" property="orderType" />
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="b_tenant_id" jdbcType="VARCHAR" property="bTenantId" />
- <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId" />
- <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
- <result column="order_payment" jdbcType="INTEGER" property="orderPayment" />
- <result column="receiver_payment" jdbcType="INTEGER" property="receiverPayment" />
- <result column="real_payment" jdbcType="INTEGER" property="realPayment" />
- <result column="subsidy" jdbcType="INTEGER" property="subsidy" />
- <result column="real_subsidy" jdbcType="INTEGER" property="realSubsidy" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
- <result column="freeze" property="freeze" />
- <result column="type" property="type"/>
- <result column="source" property="source"/>
- <result column="card_spend_list_show" jdbcType="INTEGER" property="cardSpendListShow" />
-
- </resultMap>
-
- <sql id="allColumns">
- `id`,`tenant_id`,`parent_tenant_id`,`order_id`,`order_type`,`merchant_id`,`b_tenant_id`,`coupon_order_id`,`coupon_type`,`order_payment`,`receiver_payment`,`real_payment`,`subsidy`,`real_subsidy`,`status`,`create_date`,`update_date`,freeze,type,source,card_spend_list_show
- </sql>
-
- <sql id="dynamicWhereConditions">
- where 1 = 1
- <if test=" null != id ">
- and `id` = #{id}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != orderId ">
- and `order_id` = #{orderId}
- </if>
- <if test=" null != orderType ">
- and `order_type` = #{orderType}
- </if>
- <if test=" null != merchantId ">
- and `merchant_id` = #{merchantId}
- </if>
- <if test=" null != bTenantId and '' != bTenantId">
- and `b_tenant_id` = #{bTenantId}
- </if>
- <if test=" null != couponOrderId ">
- and `coupon_order_id` = #{couponOrderId}
- </if>
- <if test=" null != couponType ">
- and `coupon_type` = #{couponType}
- </if>
- <if test=" null != orderPayment ">
- and `order_payment` = #{orderPayment}
- </if>
- <if test=" null != receiverPayment ">
- and `receiver_payment` = #{receiverPayment}
- </if>
- <if test=" null != realPayment ">
- and `real_payment` = #{realPayment}
- </if>
- <if test=" null != subsidy ">
- and `subsidy` = #{subsidy}
- </if>
- <if test=" null != realSubsidy ">
- and `real_subsidy` = #{realSubsidy}
- </if>
- <if test=" null != status ">
- and `status` = #{status}
- </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 != type">
- and `type` = #{type}
- </if>
-
- <if test=" null != source">
- and `source` = #{source}
- </if>
-
- <if test=" null != statusS ">
- and `status` in
- <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
- #{sItem}
- </foreach>
- </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="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_merchant_subsidy where id = #{id} and tenant_id = #{tenantId}
- </select>
-
- <delete id="deleteById" parameterType="java.util.HashMap">
- delete from wx_merchant_subsidy where id = #{id} and tenant_id = #{tenantId}
- </delete>
-
- <select id="findList" parameterType="com.iformall.domain.po.WxMerchantSubsidy" resultMap="BaseResultMap">
- select <include refid="allColumns" /> from wx_merchant_subsidy
- <include refid="dynamicWhereConditions" />
- </select>
-
- <update id="updateByCond" parameterType="com.iformall.domain.po.WxMerchantSubsidy">
- update wx_merchant_subsidy
- set `status` = #{status}
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and `tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and `parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != merchantId ">
- and `merchant_id`=#{merchantId}
- </if>
- <if test=" null != bTenantId and '' != bTenantId">
- and `b_tenant_id` = #{bTenantId}
- </if>
- <if test=" null != ids ">
- and id in
- <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
- #{idItem}
- </foreach>
- </if>
- </update>
-
-
- <resultMap id="VoBaseResultMap" type="com.iformall.domain.vo.WxMerchantSubsidyVo">
- <id column="id" jdbcType="BIGINT" property="id" />
- <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
- <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
- <result column="order_id" jdbcType="BIGINT" property="orderId" />
- <result column="order_type" jdbcType="INTEGER" property="orderType" />
- <result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
- <result column="b_tenant_id" jdbcType="VARCHAR" property="bTenantId" />
- <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId" />
- <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
- <result column="order_payment" jdbcType="INTEGER" property="orderPayment" />
- <result column="receiver_payment" jdbcType="INTEGER" property="receiverPayment" />
- <result column="real_payment" jdbcType="INTEGER" property="realPayment" />
- <result column="subsidy" jdbcType="INTEGER" property="subsidy" />
- <result column="real_subsidy" jdbcType="INTEGER" property="realSubsidy" />
- <result column="status" jdbcType="INTEGER" property="status" />
- <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
- <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
-
- <result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
- <result column="title" jdbcType="VARCHAR" property="title" />
- <result column="sub_title" jdbcType="VARCHAR" property="subTitle" />
- <result column="detail" jdbcType="VARCHAR" property="detail" />
- <result column="unit" jdbcType="INTEGER" property="unit" />
- <result column="remark" jdbcType="VARCHAR" property="remark" />
- <result column="name" jdbcType="VARCHAR" property="merchantName" />
-
- <result column="nick_name" jdbcType="VARCHAR" property="nickName" />
- <result column="phone" jdbcType="VARCHAR" property="phone" />
- <result column="freeze" property="freeze" />
-
- <result column="source" property="source"/>
- <result column="type" property="type"/>
-
-
- </resultMap>
-
- <sql id="allVoColumns">
- ms.`id`,ms.`tenant_id`,ms.`parent_tenant_id`,ms.`order_id`,ms.`order_type`,ms.`merchant_id`,ms.`b_tenant_id`,ms.`coupon_order_id`,ms.`coupon_type`,
- ms.`order_payment`,ms.`receiver_payment`,ms.`real_payment`,
- ms.`subsidy`,ms.`real_subsidy`,ms.`status`,ms.`create_date`,ms.`update_date`,
- c.`title`,c.`sub_title`,c.`unit`,m.`name`,
- cu.`nick_name`, cu.`phone`,ms.freeze
- </sql>
-
- <sql id="dynamicVoWhereConditions">
- <if test=" null != id ">
- and t.`id` = #{id}
- </if>
- <if test=" null != tenantId and '' != tenantId">
- and t.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and t.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != orderId ">
- and t.`order_id` = #{orderId}
- </if>
- <if test=" null != orderType ">
- and t.`order_type` = #{orderType}
- </if>
- <if test=" null != merchantId ">
- and t.`merchant_id` = #{merchantId}
- </if>
- <if test=" null != bTenantId and '' != bTenantId">
- and t.`b_tenant_id` = #{bTenantId}
- </if>
- <if test=" null != couponOrderId ">
- and t.`coupon_order_id` = #{couponOrderId}
- </if>
- <if test=" null != couponType ">
- and t.`coupon_type` = #{couponType}
- </if>
- <if test=" null != orderPayment ">
- and t.`order_payment` = #{orderPayment}
- </if>
- <if test=" null != receiverPayment ">
- and t.`receiver_payment` = #{receiverPayment}
- </if>
- <if test=" null != realPayment ">
- and t.`real_payment` = #{realPayment}
- </if>
- <if test=" null != subsidy ">
- and t.`subsidy` = #{subsidy}
- </if>
- <if test=" null != realSubsidy ">
- and t.`real_subsidy` = #{realSubsidy}
- </if>
- <if test=" null != status ">
- and t.`status` = #{status}
- </if>
- <if test=" null != createDate ">
- and t.`create_date` = #{createDate}
- </if>
- <if test=" null != updateDate ">
- and t.`update_date` = #{updateDate}
- </if>
- <if test=" null != startdate and null!=enddate">
- and t.`create_date` between #{startdate} and #{enddate}
- </if>
- <if test=" null != title">
- and t.`title` like concat('%', #{title},'%')
- </if>
- <if test=" null != statusS ">
- and t.`status` in
- <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
- #{sItem}
- </foreach>
- </if>
- <if test=" null != ids ">
- and t.`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="findVoList" parameterType="com.iformall.domain.vo.WxMerchantSubsidyVo" resultMap="VoBaseResultMap">
- select ms.id,ms.order_id,m.name,ms.source,ms.type,
- ms.create_date create_date,ms.subsidy subsidy,ms.real_subsidy,ms.status,ms.freeze
- from wx_merchant_subsidy ms left join wx_merchant m on ms.merchant_id=m.id
- where 1=1
- <if test=" null != tenantId and '' != tenantId">
- and ms.`tenant_id` = #{tenantId}
- </if>
- <if test=" null != parentTenantId and '' != parentTenantId">
- and ms.`parent_tenant_id` = #{parentTenantId}
- </if>
- <if test=" null != orderId ">
- and ms.`order_id` = #{orderId}
- </if>
- <if test=" null != merchantId ">
- and ms.`merchant_id` = #{merchantId}
- </if>
- <if test=" null != bTenantId and '' != bTenantId">
- and ms.`b_tenant_id` = #{bTenantId}
- </if>
- <if test=" null != source ">
- and ms.`source` = #{source}
- </if>
- <if test=" null != type ">
- and ms.`type` = #{type}
- </if>
- <if test=" null != status">
- <choose>
- <when test="status==0">
- and ms.`status` = #{status}
- </when>
- <otherwise>
- and ms.`status` in (1,2)
- </otherwise>
- </choose>
- </if>
- <if test=" null != freeze ">
- and ms.`freeze` = #{freeze}
- </if>
- <if test=" null != startdate and null!=enddate">
- and ms.`create_date` between #{startdate} and #{enddate}
- </if>
- <if test=" null != sortColumns">order by ${sortColumns}</if>
-
- </select>
-
- <select id="sumVoList" parameterType="com.iformall.domain.vo.WxMerchantSubsidyVo" resultType="hashmap">
- select ms.`merchant_id` merchantId, m.`name` as merchantName,
- IFNULL(sum(ms.`order_payment`),0) as sumOrderPayment,
- IFNULL(sum(ms.`receiver_payment`),0) as sumReceiverPayment,
- IFNULL(sum(ms.`subsidy`),0) as sumSubsidy,
- IFNULL(sum(ms.`real_subsidy`),0) as sumRealSubsidy
- from wx_merchant_subsidy ms
- left join wx_coupon_order co on co.id = ms.coupon_order_id
- left join wx_coupon c on c.id = co.coupon_id
- left join wx_merchant m on m.id = ms.merchant_id
- <where>
- <if test=" null != status ">
- and ms.`status` = #{status}
- </if>
- <if test=" null != merchantId ">
- and ms.`merchant_id` = #{merchantId}
- </if>
- <if test=" null != bTenantId and '' != bTenantId">
- and ms.`b_tenant_id` = #{bTenantId}
- </if>
- <if test=" null != title ">
- and c.`title` like concat('%', #{title},'%')
- </if>
- <if test=" null != statusS ">
- and ms.`status` in
- <foreach collection="statusS" index="index" item="sItem" open="(" separator="," close=")">
- #{sItem}
- </foreach>
- </if>
- <if test=" null != startdate and null!=enddate">
- and ms.`create_date` between #{startdate} and #{enddate}
- </if>
- </where>
- group by ms.`merchant_id`
- </select>
-
- </mapper>
|