distinct cc.`id`,cc.`tenant_id`,cc.`parent_tenant_id`,cc.`coupon_id`,cc.`make_merchant_id`,cc.`coupon_status`,cc.`type`,cc.`title`,cc.`target_ad`,cc.`business`,cc.`sub_business`,cc.`show_begin_time`,cc.`begin_time`,cc.`end_time`,cc.`status`,cc.`create_date`,cc.`update_date`,cc.`sub_target_id`,cc.`qr_code`,
cc.`tt_qr_code`,cc.`tt_spu_id`,cc.`channel_price`,cc.`channel_stock`
where 1=1
and c.status = #{couponStatus}
and cc.status = #{status}
and cc.status = 0
and cc.`id` = #{id}
and cc.`tenant_id` = #{tenantId}
and cc.`parent_tenant_id` = #{parentTenantId}
and cc.`coupon_id` = #{couponId}
and cc.`type` = #{type}
and cc.`title` like concat('%', #{title},'%')
and cc.`target_ad` = #{targetAd}
and cc.`business` = #{business}
and cc.`sub_business` = #{subBusiness}
and cc.`show_begin_time` <= #{showBeginTime}
and cc.`create_date` between #{startdate} and #{enddate}
and cc.`status` = #{status}
and cc.`create_date` = #{createDate}
and cc.`update_date` = #{updateDate}
and cc.`sub_target_id` = #{subTargetId}
and cc.`tt_spu_id` = #{ttSpuId}
and c.`support_transfer` = #{supportTransfer}
and c.`credit_price` <= #{userCredit}
and c.`source_type` = #{sourceType}
and cm.`merchant_id` = #{merchantId}
and cc.id in
#{idItem}
and cc.coupon_id in
#{couponIdsItem}
order by ${sortColumns}
update wx_coupon_channel
set status=#{status}, update_date=#{updateDate}
where coupon_id=#{couponId}
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
update wx_coupon_channel
set end_time = #{endTime}
where coupon_id=#{couponId}
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
update wx_coupon_channel SET status = 1, update_date = now()
where status in (0,-1) and tenant_id = #{tenantId} and end_time < now()
update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
where cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now()
and cc.status in (0,-1) and cc.tenant_id = #{tenantId}
update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
where cc.coupon_id = c.id and c.status = 1
and cc.status in (0,-1) and cc.tenant_id = #{tenantId}
update wx_coupon_channel SET status = 1, update_date = now()
where status = 0 and tenant_id = #{tenantId} and target_ad = 2 and end_time < now()
update wx_coupon_channel set status = 1 where sub_target_id = #{id}
update wx_coupon_channel set end_time = #{endTime} where coupon_id = #{couponId} and tenant_id = #{tenantId} and target_ad = 5 and type = 100
update wx_coupon_channel SET channel_stock = channel_stock - #{number} where id = #{id} and tenant_id =#{tenantId} and channel_stock is not null and channel_stock - #{number} >= 0
update wx_coupon_channel SET channel_stock = channel_stock + #{number} where id = #{id} and tenant_id =#{tenantId} and channel_stock is not null
update wx_coupon_channel SET channel_stock = #{number} where id = #{id} and tenant_id =#{tenantId} and (channel_stock is null or channel_stock = 0)
update wx_coupon_channel SET channel_stock = null where id = #{id} and tenant_id =#{tenantId}
update wx_coupon_channel SET channel_price = #{price} where id = #{id} and tenant_id =#{tenantId}
update wx_coupon_channel
set status=#{status}, update_date=#{updateDate}
where status != #{status}
and coupon_id = #{couponId}
and target_ad = #{targetAd}
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}