cc.`id`,cc.`tenant_id`,cc.`coupon_id`,cc.`coupon_status`,cc.`type`,cc.`title`,cc.`target_ad`,cc.`business`,cc.`begin_time`,cc.`end_time`,cc.`status`,cc.`create_date`,cc.`update_date`,cc.`sub_target_id`
where 1 = 1
and cc.`id` = #{id}
and cc.`tenant_id` = #{tenantId}
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.`begin_time` < now()
and cc.`end_time` > now()
and cc.`status` = #{status}
and cc.`create_date` = #{createDate}
and cc.`update_date` = #{updateDate}
and cc.`sub_target_id` = #{subTargetId}
and cc.id in
#{idItem}
and cc.coupon_id in
#{couponIdsItem}
order by ${sortColumns}
update wx_coupon_channel set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId}
,
c.remain_inventory,c.inventory,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.use_limit_quantity,c.send_type
cc.id,cc.coupon_id,cc.target_ad,cc.begin_time,cc.end_time,
c.tenant_id,c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.use_limit_quantity,c.send_type,c.valid_type,c.valid_start_date,c.valid_end_date,c.valid_days,c.detail,c.price,c.unit,c.remain_inventory,c.inventory,c.remark,c.status,c.create_date,c.update_date,c.business
update wx_coupon_channel SET status = 1, update_date = now()
where status = 0 and end_time < now()
update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
where cc.status = 0 and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date < now()
update wx_coupon_channel cc, wx_coupon c SET cc.status = 1, cc.update_date = now()
where cc.status = 0 and cc.coupon_id = c.id and c.status = 1
update wx_coupon_channel SET status = 1, update_date = now()
where status = 0 and target_ad = 2 and end_time < now()