`id`,`tenant_id`,`type`,`cover_img`,`title`,`sub_title`,`sale_price`,`use_price`,`use_limit_quantity`,`send_type`,`valid_type`,`valid_start_date`,`valid_end_date`,`valid_days`,`detail`,`price`,`unit`,`remain_inventory`,`inventory`,`remark`,`status`,`create_date`,`update_date`,`business`
where 1 = 1
and `id` = #{id}
and `tenant_id` = #{tenantId}
and `type` = #{type}
and `cover_img` like concat('%', #{coverImg},'%')
and `title` like concat('%', #{title},'%')
and `sub_title` like concat('%', #{subTitle},'%')
and `sale_price` = #{salePrice}
and `use_price` = #{usePrice}
and `use_limit_quantity` = #{useLimitQuantity}
and `send_type` = #{sendType}
and `valid_type` = #{validType}
and `valid_start_date` = #{validStartDate}
and `valid_end_date` = #{validEndDate}
and `valid_days` = #{validDays}
and `detail` like concat('%', #{detail},'%')
and `price` = #{price}
and `unit` = #{unit}
and `remain_inventory` = #{remainInventory}
and `inventory` = #{inventory}
and `remark` like concat('%', #{remark},'%')
and `status` = #{status}
and `create_date` between #{startdate} and #{enddate}
and `update_date` = #{updateDate}
and `business` = #{business}
and id in
#{idItem}
order by ${sortColumns}
update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and remain_inventory>= #{number}
update wx_coupon SET status = 1, update_date = now()
where status = 0 and valid_type = 1 and valid_end_date < now()
update wx_coupon c, wx_merchant m SET c.status = 1, c.update_date = now()
where c.status = 0 and m.status = 0 and m.id = c.merchant_id