liujie
2026-09-17 825a575deb96cce822468bb9d9ac3e4eea0f91d1
backend/src/main/java/com/tourguide/modules/user/mapper/GuideUserMapper.java
@@ -9,6 +9,32 @@
import java.math.BigDecimal;
public interface GuideUserMapper extends BaseMapper<GuideUser> {
    @Update("UPDATE guide_user SET username = #{username}, mobile = NULL, certificate_no = NULL, " +
            "id_card_no = NULL, id_card_front_url = NULL, id_card_back_url = NULL, status = 3, " +
            "auto_disable_whitelisted = 0, auto_disabled = 0, updated_at = NOW() " +
            "WHERE id = #{guideId} AND deleted = 0")
    int cancelAccount(@Param("guideId") Long guideId, @Param("username") String username);
    @Update("UPDATE guide_user SET username = #{username}, mobile = NULL, certificate_no = NULL, " +
            "id_card_no = NULL, id_card_front_url = NULL, id_card_back_url = NULL, updated_at = NOW() " +
            "WHERE id = #{guideId} AND status = 3 AND deleted = 0")
    int anonymizeCancelledGuide(@Param("guideId") Long guideId, @Param("username") String username);
    @Update("UPDATE guide_user SET id_card_no = NULL, id_card_front_url = NULL, " +
            "id_card_back_url = NULL, certificate_no = NULL, updated_at = NOW() " +
            "WHERE id_card_no = #{idCardNo} AND status = 3 AND deleted = 0")
    int clearCancelledIdentityByIdCard(@Param("idCardNo") String idCardNo);
    @Update("UPDATE guide_user SET id_card_no = NULL, id_card_front_url = NULL, " +
            "id_card_back_url = NULL, certificate_no = NULL, updated_at = NOW() " +
            "WHERE id = #{guideId} AND status = 2 AND deleted = 0")
    int releasePendingIdentity(@Param("guideId") Long guideId);
    @Update("UPDATE guide_user SET id_card_no = NULL, id_card_front_url = NULL, " +
            "id_card_back_url = NULL, certificate_no = NULL, updated_at = NOW() " +
            "WHERE id_card_no = #{idCardNo} AND status = 2 AND deleted = 0")
    int clearPendingIdentityByIdCard(@Param("idCardNo") String idCardNo);
    @Select("SELECT * FROM guide_user WHERE id = #{guideId} AND deleted = 0 FOR UPDATE")
    GuideUser selectForUpdate(@Param("guideId") Long guideId);
@@ -23,7 +49,7 @@
            "WHERE id = #{guideId} AND deleted = 0 AND balance >= #{amount}")
    int decreaseBalance(@Param("guideId") Long guideId, @Param("amount") BigDecimal amount);
    @Update("UPDATE guide_user SET balance = GREATEST(balance - #{amount}, 0), updated_at = NOW() " +
    @Update("UPDATE guide_user SET balance = COALESCE(balance, 0) - #{amount}, updated_at = NOW() " +
            "WHERE id = #{guideId} AND deleted = 0")
    int decreaseBalanceForRefund(@Param("guideId") Long guideId, @Param("amount") BigDecimal amount);