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 `id`,`remain_inventory`,`status` where 1 = 1 and `id` = #{id} and `tenant_id` = #{tenantId} and `parent_tenant_id` = #{parentTenantId} and `make_merchant_id` = #{makeMerchantId} and `brand` = #{brand} 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_rule` = #{useLimitRule} 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 `sub_business` = #{subBusiness} 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 `credit_price` = #{creditPrice} and `credit_price` <= #{userCredit} and `credit_refund` = #{creditRefund} and `credit_refund` = #{creditRefund} and `content_type` = #{contentType} and `put_apply_status` = #{putApplyStatus} and `put_apply_status` != 2 and `stock_apply_status` = #{stockApplyStatus} and `cancle_apply_status` = #{cancleApplyStatus} and `source_type` = #{sourceType} and `merchant_type` = #{merchantType} and JSON_CONTAINS(gift_list,json_array(#{giftList})) and id in #{idItem} and type not in #{ntypeItem} and type in #{typeItem} order by ${sortColumns} update wx_coupon set is_del = 1 where id = #{id} and tenant_id = #{tenantId} update wx_coupon SET `remain_inventory` = #{remainInventory}, `inventory` = #{inventory}, `valid_type` = #{validType}, `valid_end_date` = #{validEndDate}, `valid_days` = #{validDays} WHERE 1=1 and `tenant_id` = #{tenantId} and `parent_tenant_id` = #{parentTenantId} and id = #{id} and `remain_inventory` = #{orgRemainInventory} and `inventory` = #{orgInventory} and c.`id` = #{id} and c.`tenant_id` = #{tenantId} and c.`parent_tenant_id` = #{parentTenantId} and c.`type` = #{type} and c.`cover_img` like concat('%', #{coverImg},'%') and c.`title` like concat('%', #{title},'%') and c.`sub_title` like concat('%', #{subTitle},'%') and c.`sale_price` = #{salePrice} and c.`use_price` = #{usePrice} and c.`use_limit_rule` = #{useLimitRule} and c.`use_limit_quantity` = #{useLimitQuantity} and c.`send_type` = #{sendType} and c.`valid_type` = #{validType} and c.`valid_start_date` = #{validStartDate} and c.`valid_end_date` = #{validEndDate} and c.`valid_days` = #{validDays} and c.`detail` like concat('%', #{detail},'%') and c.`price` = #{price} and c.`unit` = #{unit} and c.`remain_inventory` = #{remainInventory} and c.`inventory` = #{inventory} and c.`remark` like concat('%', #{remark},'%') and c.`status` = #{status} and c.`create_date` between #{startdate} and #{enddate} and c.`update_date` = #{updateDate} and c.`business` = #{business} and c.`sub_business` = #{subBusiness} and c.`support_transfer` = #{supportTransfer} and c.`subsidy_type` = #{subsidyType} and c.`subsidy_num` = #{subsidyNum} and c.`press_limit_num` = #{pressLimitNum} and c.`press_limit_hours` = #{pressLimitHours} and c.`auto_refund` = #{autoRefund} and c.`content_type` = #{contentType} and c.`put_apply_status` = #{putApplyStatus} and c.`put_apply_status` != 2 and c.`stock_apply_status` = #{stockApplyStatus} and c.`cancle_apply_status` = #{cancleApplyStatus} and c.`source_type` = #{sourceType} and c.`merchant_type` = #{merchantType} and JSON_CONTAINS(c.gift_list,json_array(#{giftList})) and 0 = (select count(*) from wx_coupon_channel cc where c.`id` = cc.coupon_id and cc.status = 0 and cc.target_ad = #{targetAd}) and c.id in #{idItem} and c.type in #{typesItem} and c.send_type in #{typesItem} update wx_coupon SET remain_inventory = remain_inventory - #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory - #{number} >= 0 update wx_coupon SET remain_inventory = remain_inventory + #{number} where id = #{id} and tenant_id =#{tenantId} and remain_inventory + #{number} <= inventory 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 wx_coupon c SET c.status = 1, c.update_date = now() where c.status = 0 and c.tenant_id =#{tenantId} and c.type != 12 and c.id not in #{idItem} update wx_coupon set valid_end_date = #{validEndDate} , update_date = #{updateDate} where id = #{id} update wx_coupon set make_merchant_id = #{makeMerchantId} where id = #{id} and tenant_id = #{tenantId}