update wxmp_work_user_subscribe
set COUNT=COUNT + #{incr},
WX_SUBSCRIBE_STATUS = 'subscribe'
where USER_ID = #{userId}
and CUSTOMER_ID = #{customerId}
and TEMPLATE_ID = #{templateId}
and WX_OPEN_ID = #{openId}
update Wxmp_Work_User_Subscribe
set count = if(count < 1, 0, count - ${num} )
where
del_flag =0
and customer_id = #{customerId}
and template_id = #{templateId}
and wx_open_id = #{openId}
and wx_subscribe_status = 'subscribe'
update Wxmp_Work_User_Subscribe
set count = 0,
wx_subscribe_status = 'unsubscribe'
where
del_flag =0
and customer_id = #{customerId}
and template_id = #{templateId}
and wx_open_id = #{openId}
update wxmp_work_user_subscribe
set WX_SUBSCRIBE_STATUS = 'unsubscribe',
COUNT = 0
where USER_ID = #{userId}
and CUSTOMER_ID = #{customerId}
and TEMPLATE_ID = #{templateId}
and WX_OPEN_ID = #{resiOpenId}