package com.buy507.mall.mapper;

import com.buy507.mall.model.UmsDevelopmentFund;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

/**
* @author curry
* @description 针对表【ums_development_fund(发展基金流水)】的数据库操作Mapper
* @createDate 2025-02-17 13:41:58
* @Entity com.buy507.mall.model.UmsDevelopmentFund
*/
public interface UmsDevelopmentFundMapper {

    /**
     * 查询现金总和
     * @return
     */
    @Select("SELECT cash_total FROM ums_development_fund")
    BigDecimal getTotalCash();

    /**
     * 查询积分总和
     * @return
     */
    @Select("SELECT points_total FROM ums_development_fund")
    Integer getTotalPoints();


    /**
     * 更新积分
     * @param fundPoints
     */
    @Update("update ums_development_fund set points_total = points_total + #{fundPoints}")
    void updatePoints(int fundPoints);

    /**
     * 更新现金
     * @param fundCash
     */
    @Update("update ums_development_fund set cash_total = cash_total + #{fundCash}")
    void updateCash(BigDecimal fundCash);

    /**
     * 发展基金
     * @return
     */
    @Select("select id, cash_total, points_total, updated_at from ums_development_fund")
    UmsDevelopmentFund selectAll();
}




