`id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_short`,`password`,`status`,`sended_phone`,`card_id`,`create_date`,`update_date`,`expire_date`,`present_id`
where 1 = 1
and `id` = #{id}
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
and `coupon_id` = #{couponId}
and `coupon_short` = #{couponShort}
and `password` = #{password}
and `status` = #{status}
and `sended_phone` = #{sendedPhone}
and `card_id` = #{cardId}
and `create_date` = #{createDate}
and `update_date` = #{updateDate}
and `expire_date` > #{expireDate}
and `present_id` = #{presentId}
and id in
#{idItem}
and status in (${statusStr})
order by ${sortColumns}
INSERT INTO wx_coupon_password (`id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`coupon_short`,`password`,`status`,`create_date`,`update_date`)
VALUES
(
#{item.id},#{item.tenantId},#{item.parentTenantId},#{item.couponId},#{item.couponShort},#{item.password},#{item.status},
#{item.createDate},#{item.updateDate}
)
update wx_coupon_password
set status=4, update_date=now()
where status != 3 and coupon_id=#{couponId}
update wx_coupon_password
set status=1, update_date=now(), expire_date=date_add(now(),interval 365 DAY)
where status=0 and coupon_id=#{couponId}
update wx_coupon_password set
status=1,sended_phone=#{item.sendedPhone},update_date=now(),expire_date=date_add(now(),interval 30 DAY),
present_id=#{item.presentId}
where id = #{item.id}
update wx_coupon_password
set expire_date=#{expireDate}
where coupon_id=#{couponId} and status=1
and `tenant_id` = #{tenantId}
and `parent_tenant_id` = #{parentTenantId}
update wx_coupon_password set expire_date = #{expiredTime} , update_date = now() where coupon_id = #{couponId}