| 
							- <?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.WxCouponMapper">
 -     <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCoupon">
 -         <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="make_merchant_id" jdbcType="BIGINT" property="makeMerchantId"/>
 -         <result column="brand" jdbcType="BIGINT" property="brand"/>
 -         <result column="type" jdbcType="INTEGER" property="type"/>
 -         <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
 -         <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
 -         <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
 -         <result column="title" jdbcType="VARCHAR" property="title"/>
 -         <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
 -         <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
 -         <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
 -         <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
 -         <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
 -         <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
 -         <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
 -         <result column="send_type" jdbcType="INTEGER" property="sendType"/>
 -         <result column="valid_type" jdbcType="INTEGER" property="validType"/>
 -         <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
 -         <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
 -         <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
 -         <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
 -         <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
 -         <result column="detail" jdbcType="VARCHAR" property="detail"/>
 -         <result column="price" jdbcType="INTEGER" property="price"/>
 -         <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
 -         <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
 -         <result column="unit" jdbcType="INTEGER" property="unit"/>
 -         <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
 -         <result column="inventory" jdbcType="INTEGER" property="inventory"/>
 -         <result column="remark" jdbcType="VARCHAR" property="remark"/>
 -         <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="business" jdbcType="INTEGER" property="business"/>
 -         <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
 -         <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
 -         <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
 -         <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
 -         <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
 -         <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
 -         <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
 -         <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/>
 -         <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/>
 -         <result column="is_del" property="isDel"/>
 -         <result column="put_apply_status" property="putApplyStatus"/>
 -         <result column="stock_apply_status" property="stockApplyStatus"/>
 -         <result column="cancle_apply_status" property="cancleApplyStatus"/>
 -         <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
 -         <result column="approval_type"  property="approvalType"/>
 -         <result column="password_support"  property="passwordSupport"/>
 -         <result column="content_type"  property="contentType"/>
 -         <result column="html"  property="html"/>
 -         <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
 -         <result column="merchant_type" jdbcType="INTEGER" property="merchantType"/>
 -         <result column="product_type" jdbcType="INTEGER" property="productType"/>
 -         <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
 -         <result column="goods_id" jdbcType="VARCHAR" property="goodsId"/>
 - 
 -         <result column="spu_id" jdbcType="VARCHAR" property="spuId"/>
 -         <result column="poi_status" jdbcType="INTEGER" property="poiStatus"/>
 -         <result column="status_desc" jdbcType="VARCHAR" property="statusDesc"/>
 -         <result column="last_status" jdbcType="INTEGER" property="lastStatus"/>
 -         <result column="last_status_desc" jdbcType="VARCHAR" property="lastStatusDesc"/>
 -     </resultMap>
 -     <resultMap id="statisMap" type="com.iformall.domain.vo.WxCouponStatisVo">
 -         <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="make_merchant_id" jdbcType="BIGINT" property="makeMerchantId"/>
 -         <result column="brand" jdbcType="BIGINT" property="brand"/>
 -         <result column="type" jdbcType="INTEGER" property="type"/>
 -         <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
 -         <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
 -         <result column="title" jdbcType="VARCHAR" property="title"/>
 -         <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
 -         <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
 -         <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
 -         <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
 -         <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
 -         <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
 -         <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
 -         <result column="send_type" jdbcType="INTEGER" property="sendType"/>
 -         <result column="valid_type" jdbcType="INTEGER" property="validType"/>
 -         <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
 -         <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
 -         <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
 -         <result column="detail" jdbcType="VARCHAR" property="detail"/>
 -         <result column="price" jdbcType="INTEGER" property="price"/>
 -         <result column="unit" jdbcType="INTEGER" property="unit"/>
 -         <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
 -         <result column="inventory" jdbcType="INTEGER" property="inventory"/>
 -         <result column="remark" jdbcType="VARCHAR" property="remark"/>
 -         <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="business" jdbcType="INTEGER" property="business"/>
 -         <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
 -         <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
 -         <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
 -         <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
 -         <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
 -         <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
 -         <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
 - 
 -         <result column="sale_count" property="saleCount"/>
 -         <result column="transfer_count" property="transferCount"/>
 -         <result column="sale_amount" property="saleAmount"/>
 -         <result column="sum_payment" property="sumPayment"/>
 -         <result column="press_count" property="pressSendCount"/>
 -         <result column="press_succ_count" property="pressSuccCount"/>
 -         <result column="join_count" property="pressJoinCount"/>
 -         <result column="sum_subsidy" property="sumSubsidy"/>
 -         <result column="payment_rate" property="paymentRate"/>
 -         <result column="change_rate" property="changeRate"/>
 -         <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
 -         <result column="merchant_type" jdbcType="INTEGER" property="merchantType"/>
 -     </resultMap>
 - 
 -     <sql id="allColumns">
 -         c.`id`,c.`tenant_id`,c.`parent_tenant_id`,c.`make_merchant_id`,c.`brand`,c.`type`,c.`cover_img`,c.`cover_picture`,c.`detail_picture`,
 -         c.`title`,c.`sub_title`,c.`item_group`,c.`sale_price`,c.`freight_price`,c.`use_price`,c.`use_limit_rule`,c.`use_limit_quantity`,c.`send_type`,
 -         c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date,c.`valid_days`,c.`detail`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`,
 -         c.`remark`,c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,c.`support_transfer`,c.`subsidy_num`,c.`subsidy_type`,
 -         c.`press_limit_num`, c.`press_limit_hours`, c.`auto_refund`,c.`credit_price`,c.`credit_refund`,c.`put_apply_status`,c.`stock_apply_status`,c.`cancle_apply_status`,
 -         c.`conditions`,c.approval_type,c.content_type,c.source_type,c.merchant_type,c.password_support,c.gift_list,c.product_type,c.category_id,c.goods_id
 -     </sql>
 - 
 -     <sql id="statusColumns">
 -         `id`,`remain_inventory`,`status`
 -     </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 != makeMerchantId ">
 -             and `make_merchant_id` = #{makeMerchantId}
 -         </if>
 - 
 -         <if test=" null != brand ">
 -             and `brand` = #{brand}
 -         </if>
 - 
 -         <if test=" null != type ">
 -             and `type` = #{type}
 -         </if>
 - 
 -         <if test=" null != coverImg ">
 -             and `cover_img` like concat('%', #{coverImg},'%')
 -         </if>
 - 
 -         <if test=" null != title and ''!=title">
 -             and `title` like concat('%', #{title},'%')
 -         </if>
 - 
 -         <if test=" null != subTitle ">
 -             and `sub_title` like concat('%', #{subTitle},'%')
 -         </if>
 - 
 -         <if test=" null != salePrice ">
 -             and `sale_price` = #{salePrice}
 -         </if>
 - 
 -         <if test=" null != usePrice ">
 -             and `use_price` = #{usePrice}
 -         </if>
 - 
 -         <if test=" null != useLimitRule ">
 -             and `use_limit_rule` = #{useLimitRule}
 -         </if>
 - 
 -         <if test=" null != useLimitQuantity ">
 -             and `use_limit_quantity` = #{useLimitQuantity}
 -         </if>
 - 
 -         <if test=" null != sendType ">
 -             and `send_type` = #{sendType}
 -         </if>
 - 
 -         <if test=" null != validType ">
 -             and `valid_type` = #{validType}
 -         </if>
 - 
 -         <if test=" null != validStartDate ">
 -             and `valid_start_date` = #{validStartDate}
 -         </if>
 - 
 -         <if test=" null != validEndDate ">
 -             and `valid_end_date` = #{validEndDate}
 -         </if>
 - 
 -         <if test=" null != validDays ">
 -             and `valid_days` = #{validDays}
 -         </if>
 - 
 -         <if test=" null != detail ">
 -             and `detail` like concat('%', #{detail},'%')
 -         </if>
 - 
 -         <if test=" null != price ">
 -             and `price` = #{price}
 -         </if>
 - 
 -         <if test=" null != unit ">
 -             and `unit` = #{unit}
 -         </if>
 - 
 -         <if test=" null != remainInventory ">
 -             and `remain_inventory` = #{remainInventory}
 -         </if>
 - 
 -         <if test=" null != inventory ">
 -             and `inventory` = #{inventory}
 -         </if>
 - 
 -         <if test=" null != remark ">
 -             and `remark` like concat('%', #{remark},'%')
 -         </if>
 - 
 -         <if test=" null != status">
 -             and `status` = #{status}
 -         </if>
 - 
 -         <if test=" null != startdate and  null!=enddate">
 -             and `create_date` between #{startdate} and #{enddate}
 -         </if>
 - 
 -         <if test=" null != updateDate ">
 -             and `update_date` = #{updateDate}
 -         </if>
 - 
 -         <if test=" null != business ">
 -             and `business` = #{business}
 -         </if>
 - 
 -         <if test=" null != subBusiness ">
 -             and `sub_business` = #{subBusiness}
 -         </if>
 - 
 -         <if test=" null != supportTransfer ">
 -             and `support_transfer` = #{supportTransfer}
 -         </if>
 - 
 -         <if test=" null != subsidyType ">
 -             and `subsidy_type` = #{subsidyType}
 -         </if>
 - 
 -         <if test=" null != subsidyNum ">
 -             and `subsidy_num` = #{subsidyNum}
 -         </if>
 - 
 -         <if test=" null != pressLimitNum ">
 -             and `press_limit_num` = #{pressLimitNum}
 -         </if>
 - 
 -         <if test=" null != pressLimitHours ">
 -             and `press_limit_hours` = #{pressLimitHours}
 -         </if>
 - 
 -         <if test=" null != autoRefund ">
 -             and `auto_refund` = #{autoRefund}
 -         </if>
 - 
 -         <if test=" null != creditPrice ">
 -             and `credit_price` = #{creditPrice}
 -         </if>
 -         <if test=" null != userCredit ">
 -             and `credit_price` <= #{userCredit}
 -         </if>
 - 
 -         <if test=" null != creditRefund ">
 -             and `credit_refund` = #{creditRefund}
 -         </if>
 - 
 -         <if test=" 1 == filterCanPut ">
 -             and `credit_refund` = #{creditRefund}
 -         </if>
 - 
 -         <if test=" null != contentType ">
 -             and `content_type` = #{contentType}
 -         </if>
 - 
 -         <if test=" null != putApplyStatus and putApplyStatus == 2">
 -             and `put_apply_status` = #{putApplyStatus}
 -         </if>
 -         <if test=" null != putApplyStatus and putApplyStatus == -1">
 -             and `put_apply_status` != 2
 -         </if>
 - 
 -         <if test=" null != stockApplyStatus ">
 -             and `stock_apply_status` = #{stockApplyStatus}
 -         </if>
 - 
 -         <if test=" null != cancleApplyStatus ">
 -             and `cancle_apply_status` = #{cancleApplyStatus}
 -         </if>
 - 
 -         <if test=" null != sourceType ">
 -             and `source_type` = #{sourceType}
 -         </if>
 - 
 -         <if test=" null != merchantType ">
 -             and `merchant_type` = #{merchantType}
 -         </if>
 - 
 -         <if test=" null != giftList">
 -             and JSON_CONTAINS(gift_list,json_array(#{giftList}))
 -         </if>
 - 
 -         <if test=" null != ids ">
 -             and id in
 -             <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
 -                 #{idItem}
 -             </foreach>
 -         </if>
 - 
 -         <if test=" null != notinTypes ">
 -             and type not in
 -             <foreach collection="notinTypes" index="index" item="ntypeItem" open="(" separator="," close=")">
 -                 #{ntypeItem}
 -             </foreach>
 -         </if>
 -         
 -         <if test=" null != types ">
 -             and type in
 -             <foreach collection="types" index="index" item="typeItem" open="(" separator="," close=")">
 -                 #{typeItem}
 -             </foreach>
 -         </if>
 - 
 -         <if test=" null != sortColumns">order by ${sortColumns}</if>
 -     </sql>
 - 
 - 
 -     <select id="selectById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
 -         select  <include refid="allColumns"/> ,c.html from wx_coupon c where id = #{id} and tenant_id = #{tenantId}
 -     </select>
 - 
 -     <resultMap id="AttrsResultMap" type="com.iformall.domain.po.WxCoupon">
 -         <id column="id" jdbcType="BIGINT" property="id"/>
 -         <result column="product_type" jdbcType="INTEGER" property="productType"/>
 -         <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
 -         <result column="product_attrs" jdbcType="VARCHAR" property="productAttrs"/>
 -         <result column="sku_attrs" jdbcType="VARCHAR" property="skuAttrs"/>
 -     </resultMap>
 - 
 -     <select id="getAttrsById" parameterType="java.util.HashMap" resultMap="AttrsResultMap">
 -         select  id,product_type,category_id,product_attrs,sku_attrs
 -         from wx_coupon  where id = #{id} and tenant_id = #{tenantId}
 -     </select>
 -     
 -     <select id="getPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap">
 -         select  c.id,c.sale_price,c.price,c.remain_inventory,c.inventory,c.credit_price from wx_coupon c where id = #{id} and tenant_id = #{tenantId}
 -     </select>
 -     
 -     <select id="batchGetPriceAndStock" parameterType="java.util.HashMap" resultMap="BaseResultMap">
 -         select  c.id,c.sale_price,c.price,c.remain_inventory,c.inventory,c.credit_price from wx_coupon c where tenant_id = #{tenantId}
 -         and id in
 -         <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
 -             #{idItem}
 -         </foreach>
 -     </select>
 -     
 -     <select id="findTenantSimpleList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
 -         select id,title,sale_price,use_price,price,tail_price,orig_price,auto_refund,business,subsidy_type,source_type,merchant_type,type,unit,cover_img,
 -         sub_title,item_group,valid_type,valid_start_date,valid_end_date,pick_start_date,pick_end_date
 -         from wx_coupon c where c.`tenant_id` = #{tenantId}
 -         <if test=" null != ids ">
 -             and id in
 -             <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
 -                 #{idItem}
 -             </foreach>
 -         </if>
 -         <if test=" null != types ">
 -             and type in
 -             <foreach collection="types" index="index" item="typeItem" open="(" separator="," close=")">
 -                 #{typeItem}
 -             </foreach>
 -         </if>
 -     </select>
 -     
 -     <select id="findSimpleDetail" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
 -         select c.id,c.type,c.cover_img,c.title,c.sub_title,c.item_group,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_type,c.valid_start_date,
 -         c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund,c.business,c.subsidy_type,c.source_type,c.merchant_type,c.content_type,c.gift_list,c.support_transfer,c.subsidy_num
 -         from wx_coupon c where c.id = #{id} and c.`tenant_id` = #{tenantId}
 -     </select>
 -     
 -     <select id="findCouponCVoDetail" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
 -         select c.id,c.type,c.cover_img,c.cover_picture,c.detail_picture,c.title,c.sub_title,c.item_group,c.sale_price,c.use_price,
 - 	    c.use_limit_rule,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,
 - 	    c.valid_days,c.detail,c.price,c.tail_price,c.orig_price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,
 - 	    c.create_date,c.update_date,c.business,c.sub_business,c.support_transfer,c.press_limit_num, c.auto_refund,c.credit_price,c.conditions,c.content_type
 -         from wx_coupon c where c.id = #{id} and c.`tenant_id` = #{tenantId}
 -     </select>
 -     
 -     
 -     
 -     <select id="findSimpleDetailList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
 -         select c.id,c.type,c.cover_img,c.title,c.sub_title,c.item_group,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_type,c.valid_start_date,
 -         c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund,c.business,c.subsidy_type,c.source_type,c.merchant_type,c.content_type
 -         from wx_coupon c 
 -         <include refid="dynamicWhereConditions"/>
 -     </select>
 -         
 -     <select id="findIdList" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
 -         select id
 -         from wx_coupon c
 -             <include refid="dynamicWhereConditions"/>
 -     </select>
 -     
 -     <select id="findSendCouponIds" parameterType="java.util.HashMap" resultType="Long">
 -         select id
 -         from wx_coupon where `tenant_id` = #{tenantId}
 -         and ((valid_type=1
 - 				<choose>
 - 					<when test="expired == 0">
 - 						and <![CDATA[ valid_end_date >= now() ]]>
 - 					</when>
 - 					<when test="expired == 1">
 - 						and <![CDATA[ valid_end_date < now() ]]>
 - 					</when>
 - 					<otherwise>
 - 					</otherwise>
 - 				</choose>
 - 			  )
 - 	    <choose>
 - 			<when test="expired == 0">
 - 				or <![CDATA[ valid_type = 2 ]]>
 - 			</when>
 - 			<when test="expired == 1">
 - 			</when>
 - 			<otherwise>
 - 				or <![CDATA[ valid_type = 2 ]]>
 - 			</otherwise>
 - 		</choose>
 - 		)
 -     </select>
 -     
 -     <select id="findSendCouponList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
 -         select 
 -         c.id,c.remain_inventory, c.use_limit_rule,c.use_limit_quantity, c.inventory, c.valid_start_date, c.valid_end_date,c.valid_type,c.valid_days
 -         from wx_coupon c where c.`tenant_id` = #{tenantId}
 -         <if test=" null != ids ">
 -             and id in
 -             <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
 -                 #{idItem}
 -             </foreach>
 -         </if>
 -     </select>
 -     
 -     <delete id="deleteById" parameterType="java.util.HashMap">
 -     	update wx_coupon set is_del = 1 where id = #{id} and tenant_id = #{tenantId}
 -     </delete>
 - 
 -     <select id="findList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
 -         select
 -         <include refid="allColumns"/>
 -         from wx_coupon c
 -             <include refid="dynamicWhereConditions"/>
 -     </select>
 - 
 -     <update id="updateStockAndValidDate" parameterType="com.iformall.domain.po.WxCoupon">
 -         update wx_coupon
 -         SET
 -           `remain_inventory` = #{remainInventory}, `inventory` = #{inventory},
 -           `valid_type` = #{validType}, `valid_end_date` = #{validEndDate}, `valid_days` = #{validDays}
 -         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>
 -         and id = #{id} and `remain_inventory` = #{orgRemainInventory} and `inventory` = #{orgInventory}
 -     </update>
 - 
 - 
 -     <sql id="dynamicWhereConditionsForCoupon">
 - 
 -         <if test=" null != id ">
 -             and c.`id` = #{id}
 -         </if>
 - 
 -         <if test=" null != tenantId and '' != tenantId">
 -             and c.`tenant_id` = #{tenantId}
 -         </if>
 -         <if test=" null != parentTenantId and '' != parentTenantId">
 -             and c.`parent_tenant_id` = #{parentTenantId}
 -         </if>
 - 
 -         <if test=" null != type ">
 -             and c.`type` = #{type}
 -         </if>
 - 
 -         <if test=" null != coverImg ">
 -             and c.`cover_img` like concat('%', #{coverImg},'%')
 -         </if>
 - 
 -         <if test=" null != title and ''!=title">
 -             and c.`title` like concat('%', #{title},'%')
 -         </if>
 - 
 -         <if test=" null != subTitle ">
 -             and c.`sub_title` like concat('%', #{subTitle},'%')
 -         </if>
 - 
 -         <if test=" null != salePrice ">
 -             and c.`sale_price` = #{salePrice}
 -         </if>
 - 
 -         <if test=" null != usePrice ">
 -             and c.`use_price` = #{usePrice}
 -         </if>
 - 
 -         <if test=" null != useLimitRule ">
 -             and c.`use_limit_rule` = #{useLimitRule}
 -         </if>
 - 
 -         <if test=" null != useLimitQuantity ">
 -             and c.`use_limit_quantity` = #{useLimitQuantity}
 -         </if>
 - 
 -         <if test=" null != sendType ">
 -             and c.`send_type` = #{sendType}
 -         </if>
 - 
 -         <if test=" null != validType ">
 -             and c.`valid_type` = #{validType}
 -         </if>
 - 
 -         <if test=" null != validStartDate ">
 -             and c.`valid_start_date` = #{validStartDate}
 -         </if>
 - 
 -         <if test=" null != validEndDate ">
 -             and c.`valid_end_date` = #{validEndDate}
 -         </if>
 - 
 -         <if test=" null != validDays ">
 -             and c.`valid_days` = #{validDays}
 -         </if>
 - 
 -         <if test=" null != detail ">
 -             and c.`detail` like concat('%', #{detail},'%')
 -         </if>
 - 
 -         <if test=" null != price ">
 -             and c.`price` = #{price}
 -         </if>
 - 
 -         <if test=" null != unit ">
 -             and c.`unit` = #{unit}
 -         </if>
 - 
 -         <if test=" null != remainInventory ">
 -             and c.`remain_inventory` = #{remainInventory}
 -         </if>
 - 
 -         <if test=" null != inventory ">
 -             and c.`inventory` = #{inventory}
 -         </if>
 - 
 -         <if test=" null != remark ">
 -             and c.`remark` like concat('%', #{remark},'%')
 -         </if>
 - 
 -         <if test=" null != status">
 -             and c.`status` = #{status}
 -         </if>
 - 
 -         <if test=" null != startdate and  null!=enddate">
 -             and c.`create_date` between #{startdate} and #{enddate}
 -         </if>
 - 
 -         <if test=" null != updateDate ">
 -             and c.`update_date` = #{updateDate}
 -         </if>
 - 
 -         <if test=" null != business ">
 -             and c.`business` = #{business}
 -         </if>
 - 
 -         <if test=" null != subBusiness ">
 -             and c.`sub_business` = #{subBusiness}
 -         </if>
 - 
 -         <if test=" null != supportTransfer ">
 -             and c.`support_transfer` = #{supportTransfer}
 -         </if>
 - 
 -         <if test=" null != subsidyType ">
 -             and c.`subsidy_type` = #{subsidyType}
 -         </if>
 - 
 -         <if test=" null != subsidyNum ">
 -             and c.`subsidy_num` = #{subsidyNum}
 -         </if>
 - 
 -         <if test=" null != pressLimitNum ">
 -             and c.`press_limit_num` = #{pressLimitNum}
 -         </if>
 - 
 -         <if test=" null != pressLimitHours ">
 -             and c.`press_limit_hours` = #{pressLimitHours}
 -         </if>
 - 
 -         <if test=" null != autoRefund ">
 -             and c.`auto_refund` = #{autoRefund}
 -         </if>
 - 
 -         <if test=" null != contentType ">
 -             and c.`content_type` = #{contentType}
 -         </if>
 - 
 -         <if test=" null != putApplyStatus and putApplyStatus == 2">
 -             and c.`put_apply_status` = #{putApplyStatus}
 -         </if>
 -         <if test=" null != putApplyStatus and putApplyStatus == -1">
 -             and c.`put_apply_status` != 2
 -         </if>
 - 
 -         <if test=" null != stockApplyStatus ">
 -             and c.`stock_apply_status` = #{stockApplyStatus}
 -         </if>
 - 
 -         <if test=" null != cancleApplyStatus ">
 -             and c.`cancle_apply_status` = #{cancleApplyStatus}
 -         </if>
 - 
 -         <if test=" null != sourceType ">
 -             and c.`source_type` = #{sourceType}
 -         </if>
 - 
 -         <if test=" null != merchantType ">
 -             and c.`merchant_type` = #{merchantType}
 -         </if>
 - 
 -         <if test=" null != giftList">
 -             and JSON_CONTAINS(c.gift_list,json_array(#{giftList}))
 -         </if>
 - 
 -         <if test=" null != targetAd ">
 -             and 0 = (select count(*) from wx_coupon_channel cc
 -             where c.`id` = cc.coupon_id
 -             and cc.status = 0
 -             and cc.target_ad = #{targetAd})
 -         </if>
 - 
 -         <if test=" null != ids ">
 -             and c.id in
 -             <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
 -                 #{idItem}
 -             </foreach>
 -         </if>
 - 
 -         <if test=" null != types ">
 -             and c.type in
 -             <foreach collection="types" index="index" item="typesItem" open="(" separator="," close=")">
 -                 #{typesItem}
 -             </foreach>
 -         </if>
 - 
 -         <if test=" null != sendTypes ">
 -             and c.send_type in
 -             <foreach collection="sendTypes" index="index" item="typesItem" open="(" separator="," close=")">
 -                 #{typesItem}
 -             </foreach>
 -         </if>
 - 
 -     </sql>
 - 
 -     <select id="findCouponList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
 -         select
 -         <include refid="allColumns"/>
 -         <if test="plat != null and plat == 3">
 -             ,poi.spu_id,poi.status poi_status,poi.status_desc,poi.last_status,poi.last_status_desc
 -         </if>
 -         from wx_coupon c
 -         <if test="plat != null and plat == 3">
 -             left join tt_coupon_channel_poi poi on poi.id = c.id
 -         </if>
 -         where c.is_del = 0
 -         <if test="plat != null and plat == 3">
 -             <if test=" null != spuId and '' != spuId">
 -                 and poi.`spu_id` = #{spuId}
 -             </if>
 - 
 -             <if test=" null != poiStatus">
 -                 and poi.`status` = #{poiStatus}
 -             </if>
 - 
 -             <if test=" null != lastStatus">
 -                 and poi.`last_status` = #{lastStatus}
 -             </if>
 -         </if>
 -         <include refid="dynamicWhereConditionsForCoupon"/>
 -         <if test=" null != sortColumns">order by ${sortColumns}</if>
 - 
 -         <if test="null != limitStart and null != limitEnd">
 -             limit #{limitStart},#{limitEnd}
 -         </if>
 -     </select>
 - 
 -     <select id="findCouponListCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Integer">
 -         select
 -         count(c.id)
 -         from wx_coupon c
 -         <if test="plat != null and plat == 3">
 -             left join tt_coupon_channel_poi poi on poi.id = c.id
 -         </if>
 -         where c.is_del = 0
 -         <if test="plat != null and plat == 3">
 -             <if test=" null != spuId and '' != spuId">
 -                 and poi.`spu_id` = #{spuId}
 -             </if>
 - 
 -             <if test=" null != poiStatus">
 -                 and poi.`status` = #{poiStatus}
 -             </if>
 - 
 -             <if test=" null != lastStatus">
 -                 and poi.`last_status` = #{lastStatus}
 -             </if>
 -         </if>
 -         <include refid="dynamicWhereConditionsForCoupon"/>
 -     </select>
 - 
 -     <resultMap id="WxCouponCVoMap" type="com.iformall.domain.vo.WxCouponCVo">
 -         <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="type" jdbcType="INTEGER" property="type"/>
 -         <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
 -         <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
 -         <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
 -         <result column="title" jdbcType="VARCHAR" property="title"/>
 -         <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
 -         <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
 -         <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
 -         <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
 -         <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
 -         <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
 -         <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
 -         <result column="send_type" jdbcType="INTEGER" property="sendType"/>
 -         <result column="valid_type" jdbcType="INTEGER" property="validType"/>
 -         <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
 -         <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
 -         <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
 -         <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
 -         <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
 -         <result column="detail" jdbcType="VARCHAR" property="detail"/>
 -         <result column="price" jdbcType="INTEGER" property="price"/>
 -         <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
 -         <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
 -         <result column="unit" jdbcType="INTEGER" property="unit"/>
 -         <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
 -         <result column="inventory" jdbcType="INTEGER" property="inventory"/>
 -         <result column="remark" jdbcType="VARCHAR" property="remark"/>
 -         <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="business" jdbcType="INTEGER" property="business"/>
 -         <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
 -         <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
 -         <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
 -         <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
 -         <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
 -         <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
 -         <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
 -         <result column="content_type" jdbcType="INTEGER" property="contentType"/>
 -         <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
 -         <result column="merchant_type" jdbcType="INTEGER" property="merchantType"/>
 - 
 -         <result column="gift_list" jdbcType="VARCHAR" property="giftList"></result>
 - 
 -         <result column="product_type" jdbcType="INTEGER" property="productType"/>
 -         <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
 - 
 -     </resultMap>
 - 
 -     <resultMap id="WxCouponCVoMapL" type="com.iformall.domain.vo.WxCouponCVo">
 -         <id column="id" jdbcType="BIGINT" property="id"/>
 -         <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
 -         <result column="type" jdbcType="INTEGER" property="type"/>
 -         <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
 -         <result column="cover_picture" jdbcType="VARCHAR" property="coverPicture"/>
 -         <result column="detail_picture" jdbcType="VARCHAR" property="detailPicture"/>
 -         <result column="title" jdbcType="VARCHAR" property="title"/>
 -         <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/>
 -         <result column="item_group" jdbcType="VARCHAR" property="itemGroup"/>
 -         <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
 -         <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
 -         <result column="use_price" jdbcType="INTEGER" property="usePrice"/>
 -         <result column="use_limit_rule" jdbcType="INTEGER" property="useLimitRule"/>
 -         <result column="use_limit_quantity" jdbcType="INTEGER" property="useLimitQuantity"/>
 -         <result column="send_type" jdbcType="INTEGER" property="sendType"/>
 -         <result column="valid_type" jdbcType="INTEGER" property="validType"/>
 -         <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
 -         <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
 -         <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
 -         <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
 -         <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
 -         <result column="detail" jdbcType="VARCHAR" property="detail"/>
 -         <result column="price" jdbcType="INTEGER" property="price"/>
 -         <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
 -         <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
 -         <result column="unit" jdbcType="INTEGER" property="unit"/>
 -         <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
 -         <result column="inventory" jdbcType="INTEGER" property="inventory"/>
 -         <result column="remark" jdbcType="VARCHAR" property="remark"/>
 -         <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="business" jdbcType="INTEGER" property="business"/>
 -         <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
 -         <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/>
 -         <result column="subsidy_type" jdbcType="INTEGER" property="subsidyType"/>
 -         <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"/>
 -         <result column="press_limit_num" jdbcType="INTEGER" property="pressLimitNum"/>
 -         <result column="press_limit_hours" jdbcType="INTEGER" property="pressLimitHours"/>
 -         <result column="conditions" jdbcType="VARCHAR" property="conditions"/>
 -         <result column="content_type" jdbcType="INTEGER" property="contentType"/>
 -         <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
 -         <result column="merchant_type" jdbcType="INTEGER" property="merchantType"/>
 -     </resultMap>
 - 
 -     <select id="findVoDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMap">
 -         select
 -         <include refid="allColumns"/>
 -         from wx_coupon c
 -         where id = #{id} and tenant_id =#{tenantId}
 -     </select>
 - 
 -     <select id="findVoStatusDetail" parameterType="java.util.HashMap" resultMap="WxCouponCVoMapL">
 -         select id, remain_inventory, status
 -         from wx_coupon
 -         where id = #{id} and tenant_id =#{tenantId}
 -     </select>
 - 
 -     <update id="reduceInventory">
 -         update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory - #{number} >= 0
 -     </update>
 - 
 -     <update id="backInventory">
 -         update wx_coupon SET remain_inventory = remain_inventory + #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory + #{number} <= inventory
 -     </update>
 - 
 -     <update id="offExpiriedCouponByValidDate" parameterType="String">
 -         update wx_coupon SET status = 1, update_date = now()
 -         where status = 0 and tenant_id =#{tenantId} and valid_type = 1 and valid_end_date < now()
 -     </update>
 - 
 -     <update id="offExpiriedCouponByMerchantStatus" parameterType="HashMap">
 -         update wx_coupon c
 -         SET c.status = 1, c.update_date = now()
 -         where c.status = 0 and c.tenant_id =#{tenantId}
 -         <!-- type=12 礼包卷没有门店 -->
 -         and c.type != 12
 -         <if test=" null != validIds ">
 -             and c.id not in
 -             <foreach collection="validIds" index="index" item="idItem" open="(" separator="," close=")">
 -                 #{idItem}
 -             </foreach>
 -         </if>
 -     </update>
 -     
 -     <select id="getValidMerchantProductIds" resultType="Long">
 -     	select cm.product_id from wx_coupon_merchant cm, wx_merchant m
 -         where m.id = cm.merchant_id
 -         and cm.status = 0
 -         and m.status = 1
 -     </select>
 - 
 -     <select id="findSaleMoneyByDate"
 -             resultType="com.iformall.domain.vo.WxCouponStatisVo">
 -         select DATE_FORMAT(ci.create_date,'%Y-%m-%d') xtime,sum(round(ci.sale_amount/100,2)) xcount from wx_card_info ci
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) c on c.id = ci.coupon_id
 -         where c.type = 100
 -         and ci.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         group by xtime
 -     </select>
 - 
 -     <select id="findPaymentByDate"
 -             resultType="com.iformall.domain.vo.WxCouponStatisVo">
 -         select DATE_FORMAT(wcs.create_date,'%Y-%m-%d') xtime,sum(round(wcs.real_payment/100,2)) xcount from wx_card_info ci
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) c on c.id = ci.coupon_id
 -         left join wx_card_spend wcs on wcs.card_id = ci.id
 -         where c.type = 100
 -         and wcs.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         group by xtime
 -     </select>
 - 
 -     <select id="findSaleCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
 -         select count(co.id)
 -         from wx_card_info ci
 -         left join wx_coupon c on c.id = ci.coupon_id
 -         left join wx_coupon_order co on co.id = ci.id
 -         where c.type = 100
 -         and co.create_date between #{startdate} and #{enddate}
 -     </select>
 - 
 -     <select id="findTranCardCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
 -         select count(distinct wcs.coupon_order_id) from wx_card_info ci
 -         left join wx_coupon c on c.id = ci.coupon_id
 -         left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
 -         where c.type = 100 and wcs.create_date between #{startdate} and #{enddate}
 -     </select>
 - 
 -     <select id="findSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
 -         select sum(round(sc.subsidy/100,2)) from wx_card_info ci
 -         left join wx_coupon c on c.id = ci.coupon_id
 -         left join wx_merchant_subsidy sc on sc.coupon_order_id = ci.id
 -         where c.type = 100 and sc.create_date between #{startdate} and #{enddate}
 -     </select>
 - 
 -     <select id="findCountData" resultMap="statisMap">
 -         select c.*,
 -         IFNULL(round((select sum(wcs.real_payment) from wx_card_info ci
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc on wc.id = ci.coupon_id
 -         left join wx_card_spend wcs on wcs.card_id = ci.id
 -         where wc.id = c.id)/(select sum(ci.sale_amount) from wx_card_info ci
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc on wc.id = ci.coupon_id
 -         where wc.id = c.id)*100,2),0) payment_rate,
 - 
 -         (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wco on wc.id = wco.coupon_id
 -         where wc.id = c.id) as sale_count,
 - 
 -         (select count(distinct wcs.coupon_order_id) from wx_card_info ci
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc on wc.id = ci.coupon_id
 -         left join wx_card_transfer_info wcs on wcs.coupon_order_id = ci.id
 -         where wc.id = c.id) as transfer_count,
 - 
 -         (select sum(ci.sale_amount) from wx_card_info ci
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc on wc.id = ci.coupon_id
 -         where wc.id = c.id) as sale_amount,
 - 
 -         (select sum(wcs.real_payment) from wx_card_info ci
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc on wc.id = ci.coupon_id
 -         left join wx_card_spend wcs on wcs.card_id = ci.id
 -         where wc.id = c.id) as sum_payment,
 - 
 -         (select sum(sc.subsidy) from wx_card_info ci
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc on wc.id = ci.coupon_id
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_merchant_subsidy${tenantEntity.shardTableSuffix}
 -     </foreach>) sc on sc.coupon_order_id = ci.id
 -         where wc.id = c.id) as sum_subsidy
 - 
 -         from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) c where c.type = 100
 -         <if test="wxCoupon.title != null and wxCoupon.title !=''">
 -             and c.title like concat('%', #{wxCoupon.title},'%')
 -         </if>
 -         <if test="wxCoupon.id != null">
 -             and c.id = #{wxCoupon.id}
 -         </if>
 -         <if test=" null != wxCoupon.sortColumns">order by ${wxCoupon.sortColumns}</if>
 -         <if test=" null == wxCoupon.sortColumns">order by c.status asc,c.create_date desc</if>
 - 
 -     </select>
 - 
 -     <select id="findCouponData" resultMap="statisMap">
 -         select c.*,
 -         IFNULL(round((select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wco where wco.coupon_id = wc.id and
 -         wco.coupon_order_status = 1 and wc.id = c.id)/(select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wco where wco.coupon_id
 -         = c.id)*100,2),0) payment_rate,
 -         (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wco where wco.coupon_id = c.id) as sale_count,
 -         (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wco where wco.coupon_id = wc.id and
 -         wco.coupon_order_status = 1 and wc.id = c.id) as sum_payment,
 -         (select count(wco.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wco where wco.coupon_id = wc.id and
 -         wco.coupon_order_status = 3 and wc.id = c.id) as backpay_count,
 -         (select sum(sc.subsidy) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wo on wo.coupon_id = wc.id
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_merchant_subsidy${tenantEntity.shardTableSuffix}
 -     </foreach>) sc on sc.coupon_order_id = wo.id
 -         where wc.id = c.id) as sum_subsidy
 -         from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) c where c.type not in(8,9,100)
 -         <if test=" 1 == wxCoupon.type ">
 -             and c.sale_price > 0
 -         </if>
 -         <if test=" 2 == wxCoupon.type ">
 -             and c.sale_price = 0
 -         </if>
 -         <if test="wxCoupon.title != null and wxCoupon.title != ''">
 -             and c.title like concat('%', #{wxCoupon.title},'%')
 -         </if>
 -         <if test="wxCoupon.id != null">
 -             and c.id = #{wxCoupon.id}
 -         </if>
 -         <if test=" null != wxCoupon.sortColumns">order by ${wxCoupon.sortColumns}</if>
 -         <if test=" null == wxCoupon.sortColumns">order by c.status asc,c.create_date desc</if>
 -     </select>
 - 
 -     <select id="findPressData" resultMap="statisMap">
 -         select c.id,c.tenant_id, c.`cover_img`,c.`title`,c.`sale_price`,c.`freight_price`,c.`price`,
 -         ifnull(op.press_count,0) as press_count,
 -         ifnull(o.press_succ_count,0) as press_succ_count,
 -         ifnull(op2.join_count,0) as join_count,
 -         ifnull(round(o.press_succ_count/op.press_count*100,2),0) as change_rate,
 -         ifnull(round(cop.xCount/op.press_count*100,2),0) as payment_rate
 -         FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) c
 -         left join (SELECT count(id) as press_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
 -     </foreach>) wx_order_press WHERE `first` = 1
 -         <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
 -             and `tenant_id` = #{wxCoupon.tenantId}
 -         </if>
 -         <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
 -             and `parent_tenant_id` = #{wxCoupon.parentTenantId}
 -         </if>
 -         group by coupon_id) op on op.coupon_id = c.id
 -         left join (SELECT count(id) as press_succ_count, product_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wx_order WHERE order_status = 1
 -         <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
 -             and `tenant_id` = #{wxCoupon.tenantId}
 -         </if>
 -         <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
 -             and `parent_tenant_id` = #{wxCoupon.parentTenantId}
 -         </if>
 -         group by product_id) o on o.product_id = c.id
 -         left join (SELECT count(id) as join_count, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
 -     </foreach>) wx_order_press WHERE 1=1
 -         <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
 -             and `tenant_id` = #{wxCoupon.tenantId}
 -         </if>
 -         <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
 -             and `parent_tenant_id` = #{wxCoupon.parentTenantId}
 -         </if>
 -         group by coupon_id) op2 on op2.coupon_id = c.id
 -         left join (SELECT count(id) as xCount, coupon_id FROM (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wx_coupon_order  WHERE coupon_order_status = 1
 -         <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
 -             and `tenant_id` = #{wxCoupon.tenantId}
 -         </if>
 -         <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
 -             and `parent_tenant_id` = #{wxCoupon.parentTenantId}
 -         </if>
 -         group by coupon_id) cop on cop.coupon_id = c.id
 -         where c.type = 8
 - 
 -         <if test=" null != wxCoupon.tenantId and '' != wxCoupon.tenantId">
 -             and c.`tenant_id` = #{wxCoupon.tenantId}
 -         </if>
 -         <if test=" null != wxCoupon.parentTenantId and '' != wxCoupon.parentTenantId">
 -             and c.`parent_tenant_id` = #{wxCoupon.parentTenantId}
 -         </if>
 -         <if test="wxCoupon.id != null">
 -             and c.id = #{wxCoupon.id}
 -         </if>
 -         <if test="wxCoupon.title != null and wxCoupon.title != ''">
 -             and c.title like concat('%', #{wxCoupon.title},'%')
 -         </if>
 -         <if test=" null != wxCoupon.startdate and  null!=wxCoupon.enddate">
 -             and c.`create_date` between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         </if>
 - 
 -         <if test=" null != wxCoupon.sortColumns">order by ${wxCoupon.sortColumns}</if>
 -         <if test=" null == wxCoupon.sortColumns">order by c.status asc,c.create_date desc</if>
 -     </select>
 - 
 -     <select id="findCouponOrderCount"
 -             resultType="com.iformall.domain.vo.WxCouponStatisVo">
 -         select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
 -         from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) c
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wco on c.id = wco.coupon_id
 -         where c.type not in(8,9,100)
 -         and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         group by xtime
 -     </select>
 - 
 - 
 -     <select id="findCouponPaymentCount"
 -             resultType="com.iformall.domain.vo.WxCouponStatisVo">
 -         select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
 -         from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) c,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wco
 -         where c.type not in(8,9,100)
 -         and wco.coupon_id = c.id and wco.coupon_order_status = 1
 -         and wco.update_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         group by xtime
 -     </select>
 - 
 -     <select id="priceCouponSaleCount"
 -             resultType="com.iformall.domain.vo.WxCouponStatisVo">
 -         select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
 -         from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) c,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wco
 -         where c.type not in(8,9,100)
 -         and wco.coupon_id = c.id and wco.coupon_price > 0
 -         and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         group by xtime
 -     </select>
 - 
 -     <select id="priceCouponPaymentCount"
 -             resultType="com.iformall.domain.vo.WxCouponStatisVo">
 -         select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
 -         from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) c,(<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wco
 -         where c.type not in(8,9,100)
 -         and wco.coupon_id = c.id and wco.coupon_order_status = 1 and wco.coupon_price > 0
 -         and wco.update_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         group by xtime
 -     </select>
 - 
 -     <select id="findSumPriceSaleMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
 -         select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
 -         where wco.coupon_id = c.id and wco.coupon_price > 0
 -         and wco.create_date between #{startdate} and #{enddate}
 -     </select>
 - 
 -     <select id="findSumPricePayMent" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
 -         select sum(round(c.sale_price/100,2)) from wx_coupon c,wx_coupon_order wco
 -         where wco.coupon_id = c.id and wco.coupon_price > 0 and wco.coupon_order_status = 1
 -         and wco.update_date between #{startdate} and #{enddate}
 -     </select>
 - 
 -     <select id="findSumSubsidyMoney" parameterType="com.iformall.domain.po.WxCoupon" resultType="String">
 -         select sum(round(sc.subsidy/100,2)) from wx_coupon c
 -         left join wx_coupon_order wo on wo.coupon_id = c.id
 -         left join wx_merchant_subsidy sc on sc.coupon_order_id = wo.id
 -         where c.type not in(8,9,100) and wo.coupon_order_status = 1
 -         and sc.create_date between #{startdate} and #{enddate}
 -     </select>
 - 
 - 
 -     <!--砍价-->
 -     <select id="pressSendHistory"
 -             resultType="com.iformall.domain.vo.WxCouponStatisVo">
 -         select DATE_FORMAT(wop.create_date,'%Y-%m-%d') xtime,count(wop.id) xcount from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wo on wo.product_id = wc.id
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
 -     </foreach>) wop on wop.order_id = wo.id
 -         where wc.type = 8 and wop.first = 1 and
 -         wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         group by xtime
 -     </select>
 -     <select id="pressSuccHistory"
 -             resultType="com.iformall.domain.vo.WxCouponStatisVo">
 -         select DATE_FORMAT(wo.create_date,'%Y-%m-%d') xtime,count(wo.id) xcount
 -         from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wo on wo.product_id = wc.id
 -         where wc.type = 8 and wo.order_status = 1
 -         and wo.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         group by xtime
 -     </select>
 -     <select id="pressPaymentHistory"
 -             resultType="com.iformall.domain.vo.WxCouponStatisVo">
 -         select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount
 -         from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wco on wco.coupon_id = wc.id
 -         where wc.type = 8 and wco.coupon_order_status = 1
 -         and wco.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         group by xtime
 -     </select>
 -     <select id="pressSuccRate" resultType="java.lang.String">
 -         select
 -         round(
 -         (select count(wo.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wo on wo.product_id = wc.id
 -         where wo.order_status = 1 and wc.type = 8
 -         and wo.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         )
 -         /
 -         (select count(wop.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wo on wo.product_id = wc.id
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
 -     </foreach>) wop on wop.order_id = wo.id
 -         where wop.first = 1 and wc.type = 8
 -         and wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         )
 -         * 100
 -         ,2)
 -     </select>
 -     <select id="sumJoin" resultType="Long">
 -         select count(wop.id) from (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) wc
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_order${tenantEntity.shardTableSuffix}
 -     </foreach>) wo on wo.product_id = wc.id
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_order_press${tenantEntity.shardTableSuffix}
 -     </foreach>) wop on wop.order_id = wo.id
 -         where wc.type = 8
 -         and wop.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -     </select>
 - 
 -     <select id="priceCouponCancelCount" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
 -         select count(c.id) from wx_coupon c
 -         left join wx_coupon_order wco on c.id = wco.coupon_id
 -         where c.type not in(8,9,100)
 -         and wco.create_date between #{startdate} and #{enddate}
 -         and wco.coupon_order_status = 3
 -     </select>
 - 
 -     <select id="findSaleCardCountHistory"
 -             resultType="com.iformall.domain.vo.WxCouponStatisVo">
 -         select DATE_FORMAT(co.create_date,'%Y-%m-%d') xtime,count(co.id) xcount
 -         from wx_card_info ci
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon${tenantEntity.shardTableSuffix}
 -     </foreach>) c on c.id = ci.coupon_id
 -         left join (<foreach collection="tenantEntitys" item="tenantEntity" index="index" separator="union all">
 -         SELECT * from wx_coupon_order${tenantEntity.shardTableSuffix}
 -     </foreach>) co on co.id = ci.id
 -         where c.type = 100
 -         and co.create_date between #{wxCoupon.startdate} and #{wxCoupon.enddate}
 -         group by xtime
 -     </select>
 - 
 -     <select id="findCouponByTopic" parameterType="com.iformall.domain.po.WxTopic"
 -             resultType="com.iformall.domain.po.WxCoupon">
 -        select ct.id as id,wc.id as couponId,
 -         wc.tenant_id,wc.parent_tenant_id,wc.`type`,wc.`cover_img`,wc.`cover_picture`,wc.`detail_picture`,wc.`title`,wc.`sub_title`,wc.`item_group`,wc.`sale_price`,wc.`freight_price`,wc.`use_price`,wc.`use_limit_rule`,wc.`use_limit_quantity`,wc.`send_type`,
 -         wc.`valid_type`,wc.`valid_start_date`,wc.`valid_end_date`,wc.pick_start_date,wc.pick_end_date,wc.`valid_days`,wc.`detail`,wc.`price`,wc.tail_price,wc.orig_price,wc.`unit`,wc.`remain_inventory`,wc.`inventory`,
 -         wc.`remark`,wc.`status`,wc.`create_date`,wc.`update_date`,wc.`business`,wc.`sub_business`,wc.`support_transfer`,wc.`subsidy_num`,wc.`subsidy_type`,
 -         wc.`press_limit_num`, wc.`press_limit_hours`, wc.`auto_refund`,wc.`credit_price`,wc.`credit_refund`,wc.`conditions`,
 -         wc.title as couponName,wc.`cover_img` as couponPic,wc.`cover_picture` as couponPicture,wc.`detail_picture` as detailPicture,wc.id as couponId
 -        from wx_coupon_channel ct
 -        left join wx_coupon wc on wc.id = ct.coupon_id
 - 	   where ct.`sub_target_id` = #{id} and ct.status = 0
 -     </select>
 - 
 -     <select id="findCouponModel" parameterType="com.iformall.domain.po.WxCoupon" resultType="com.iformall.domain.po.WxCoupon">
 -         select
 -         max(case type when 9 then model_id else 0 end) couponModelId,
 -         max(case type when 10 then model_id else 0 end) cardModelId,
 -         max(case type when 11 then model_id else 0 end) groupModelId,
 -         max(case type when 12 then model_id else 0 end) pressModelId
 -         from wx_flow_config
 -         where type in(9,10,11,12)
 -         <if test=" null != tenantId and '' != tenantId">
 -             and `tenant_id` = #{tenantId}
 -         </if>
 -         <if test=" null != parentTenantId and '' != parentTenantId">
 -             and `parent_tenant_id` = #{parentTenantId}
 -         </if>
 -     </select>
 -     
 -     <update id="updateValidEndDate" parameterType="com.iformall.domain.po.WxCoupon">
 -     	update wx_coupon set valid_end_date = #{validEndDate} , update_date = #{updateDate} where id = #{id}
 -     </update>
 - 
 -     <select id="newfindCList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
 -         select id,remain_inventory,inventory,cover_img,title,sub_title,item_group,sale_price,use_price,price,tail_price,
 -         orig_price,unit,use_limit_rule,use_limit_quantity,send_type,support_transfer,press_limit_num,auto_refund,
 -         conditions,valid_type,valid_start_date,valid_end_date,pick_start_date,pick_end_date,valid_days,credit_price,
 -         content_type,source_type,merchant_type
 -         from wx_coupon where `tenant_id` = #{tenantId}
 -         <if test=" null != id ">
 -             and `id` = #{id}
 -         </if>
 -         <if test=" null != business ">
 -             and `business` = #{business}
 -         </if>
 -         <if test=" null != subBusiness ">
 -             and `sub_business` = #{subBusiness}
 -         </if>
 -         <if test=" null != ids ">
 -             and id in
 -             <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
 -                 #{idItem}
 -             </foreach>
 -         </if>
 -     </select>
 -     
 -     <select id="findIdsListHasConditons" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
 -         select c.id
 -         from wx_coupon  c
 -         where c.`tenant_id` = #{tenantId} and c.conditions is not null
 -         /*and JSON_EXTRACT(c.conditions, '$.type') = 1*/
 -         <if test=" null != parentTenantId and '' != parentTenantId">
 -             and c.`parent_tenant_id` = #{parentTenantId}
 -         </if>
 -     </select>
 - 
 - 
 -     <resultMap id="TtCouponVoResultMap" type="com.iformall.domain.vo.TtCouponVo">
 -         <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="type" jdbcType="INTEGER" property="type"/>
 -         <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/>
 -         <result column="title" jdbcType="VARCHAR" property="title"/>
 -         <result column="sale_price" jdbcType="INTEGER" property="salePrice"/>
 -         <result column="send_type" jdbcType="INTEGER" property="sendType"/>
 -         <result column="valid_type" jdbcType="INTEGER" property="validType"/>
 -         <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
 -         <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
 -         <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
 -         <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>
 -         <result column="valid_days" jdbcType="INTEGER" property="validDays"/>
 -         <result column="price" jdbcType="INTEGER" property="price"/>
 -         <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/>
 -         <result column="orig_price" jdbcType="INTEGER" property="origPrice"/>
 -         <result column="unit" jdbcType="INTEGER" property="unit"/>
 -         <result column="remain_inventory" jdbcType="INTEGER" property="remainInventory"/>
 -         <result column="inventory" jdbcType="INTEGER" property="inventory"/>
 -         <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="business" jdbcType="INTEGER" property="business"/>
 -         <result column="sub_business" jdbcType="INTEGER" property="subBusiness"/>
 -         <result column="auto_refund" jdbcType="INTEGER" property="autoRefund"/>
 -         <result column="credit_price" jdbcType="INTEGER" property="creditPrice"/>
 -         <result column="credit_refund" jdbcType="INTEGER" property="creditRefund"/>
 -         <result column="content_type"  property="contentType"/>
 -         <result column="source_type" jdbcType="INTEGER" property="sourceType"/>
 -         <result column="merchant_type" jdbcType="INTEGER" property="merchantType"/>
 -         <result column="product_type" jdbcType="INTEGER" property="productType"/>
 -         <result column="category_id" jdbcType="INTEGER" property="categoryId"/>
 - 
 -         <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/>
 -         <result column="spu_id" jdbcType="VARCHAR" property="spuId"/>
 -         <result column="poi_status" jdbcType="INTEGER" property="poiStatus"/>
 -         <result column="status_desc" jdbcType="VARCHAR" property="statusDesc"/>
 -         <result column="last_status" jdbcType="INTEGER" property="lastStatus"/>
 -         <result column="last_status_desc" jdbcType="VARCHAR" property="lastStatusDesc"/>
 -     </resultMap>
 - 
 - 
 -     <select id="ttCouponList" parameterType="com.iformall.domain.vo.TtCouponVo" resultMap="TtCouponVoResultMap">
 -         select c.`id`,c.`tenant_id`,c.`parent_tenant_id`,c.`type`,c.`cover_img`,
 -         c.`title`,c.`sub_title`,c.`sale_price`,c.`freight_price`,c.`send_type`,
 -         c.`valid_type`,c.`valid_start_date`,c.`valid_end_date`,c.pick_start_date,c.pick_end_date,
 -         c.`valid_days`,c.`price`,c.tail_price,c.orig_price,c.`unit`,c.`remain_inventory`,c.`inventory`,
 -         c.`status`,c.`create_date`,c.`update_date`,c.`business`,c.`sub_business`,
 -         c.`auto_refund`,c.`credit_price`,c.`credit_refund`,
 -         c.content_type,c.source_type,c.merchant_type,c.product_type,c.category_id,
 -         poi.coupon_channel_id,poi.spu_id,poi.status poi_status,poi.status_desc,poi.last_status,poi.last_status_desc
 -         from wx_coupon c
 -         left join tt_coupon_channel_poi poi on poi.id = c.id
 -         where c.`type` = #{type}
 - 
 -         <if test=" null != id ">
 -             and c.`id` = #{id}
 -         </if>
 - 
 -         <if test=" null != tenantId and '' != tenantId">
 -             and c.`tenant_id` = #{tenantId}
 -         </if>
 -         <if test=" null != parentTenantId and '' != parentTenantId">
 -             and c.`parent_tenant_id` = #{parentTenantId}
 -         </if>
 - 
 -         <if test=" null != title and ''!=title">
 -             and c.`title` like concat('%', #{title},'%')
 -         </if>
 - 
 -         <if test=" null != sendType ">
 -             and c.`send_type` = #{sendType}
 -         </if>
 - 
 -         <if test=" null != status">
 -             and c.`status` = #{status}
 -         </if>
 - 
 -         <if test=" null != startdate and  null!=enddate">
 -             and c.`create_date` between #{startdate} and #{enddate}
 -         </if>
 - 
 -         <if test=" null != sourceType ">
 -             and c.`source_type` = #{sourceType}
 -         </if>
 - 
 -         <if test=" null != merchantType ">
 -             and c.`merchant_type` = #{merchantType}
 -         </if>
 - 
 -         <if test=" null != couponChannelId ">
 -             and poi.`coupon_channel_id` = #{couponChannelId}
 -         </if>
 - 
 -         <if test=" null != spuId and '' != spuId">
 -             and poi.`spu_id` = #{spuId}
 -         </if>
 - 
 -         <if test=" null != poiStatus">
 -             and poi.`status` = #{poiStatus}
 -         </if>
 - 
 -         <if test=" null != lastStatus">
 -             and poi.`last_status` = #{lastStatus}
 -         </if>
 - 
 -         <if test=" null != sortColumns">order by ${sortColumns}</if>
 -     </select>
 - 
 - 
 -     <select id="findCategoryIdById" parameterType="java.util.HashMap" resultType="Integer">
 -         select  category_id
 -         from wx_coupon
 -         where id = #{id}
 -         and tenant_id = #{tenantId}
 -     </select>
 -     
 -     <update id="setMakeMerchantId" parameterType="com.iformall.domain.po.WxCoupon" >
 -     	update wx_coupon set make_merchant_id = #{makeMerchantId} where id = #{id} and tenant_id = #{tenantId}
 -     </update>
 - 
 - </mapper>
 
 
  |