`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`,`support_transfer`,`subsidy_num`,`subsidy_type`, `press_limit_num`, `press_limit_hours`, `auto_refund` 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 `support_transfer` = #{supportTransfer} and `subsidy_type` = #{subsidyType} and `subsidy_num` = #{subsidyNum} and `press_limit_num` = #{pressLimitNum} and `press_limit_hours` = #{pressLimitHours} and `auto_refund` = #{autoRefund} and id in #{idItem} order by ${sortColumns} where `type` = 100 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 `support_transfer` = #{supportTransfer} and `subsidy_type` = #{subsidyType} and `subsidy_num` = #{subsidyNum} and `press_limit_num` = #{pressLimitNum} and `press_limit_hours` = #{pressLimitHours} and id in #{idItem} order by ${sortColumns} where `type` < 7 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 `support_transfer` = #{supportTransfer} and `subsidy_type` = #{subsidyType} and `subsidy_num` = #{subsidyNum} and `press_limit_num` = #{pressLimitNum} and `press_limit_hours` = #{pressLimitHours} and id in #{idItem} order by ${sortColumns} where `type` = 8 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 `support_transfer` = #{supportTransfer} and `subsidy_type` = #{subsidyType} and `subsidy_num` = #{subsidyNum} and `press_limit_num` = #{pressLimitNum} and `press_limit_hours` = #{pressLimitHours} 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 SET c.status = 1, c.update_date = now() where c.status = 0 and (select count(*) from wx_coupon_merchant cm, wx_merchant m where m.id = cm.merchant_id and c.id = cm.product_id and cm.status = 0 and m.status = 1) = 0