liujie
2026-09-15 ad491191ab50a259da548863d805c57d8a95d083
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.tourguide.modules.user.mapper;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tourguide.modules.user.entity.GuideTeam;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.math.BigDecimal;
 
public interface GuideTeamMapper extends BaseMapper<GuideTeam> {
    @Update("UPDATE guide_team SET balance = balance + #{amount}, updated_at = NOW() " +
            "WHERE id = #{teamId} AND deleted = 0")
    int increaseBalance(@Param("teamId") Long teamId, @Param("amount") BigDecimal amount);
 
    @Update("UPDATE guide_team SET balance = balance - #{amount}, updated_at = NOW() " +
            "WHERE id = #{teamId} AND deleted = 0 AND balance >= #{amount}")
    int decreaseBalance(@Param("teamId") Long teamId, @Param("amount") BigDecimal amount);
 
    @Update("UPDATE guide_team SET balance = COALESCE(balance, 0) - #{amount}, updated_at = NOW() " +
            "WHERE id = #{teamId} AND deleted = 0")
    int decreaseBalanceForRefund(@Param("teamId") Long teamId, @Param("amount") BigDecimal amount);
}