package org.springblade.finance.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springblade.finance.entity.YksytAccountView;
import org.springblade.finance.vo.*;

import java.util.List;

/**
 * <p>
 * 优酷收银台渠道发展优酷20元产品的结算表 Mapper 接口
 * </p>
 *
 * @author zbc
 * @since 2022-04-07
 */
public interface YksytAccountViewMapper extends BaseMapper<YksytAccountView> {

    @Select("SELECT\n" +
            "THEMONTH,\n" +
            "USERID,\n" +
            "SPNAME,\n" +
            "PROVINCE,\n" +
            "MONEY \n" +
            "FROM\n" +
            "YKSYT_PROV_DETAIL_PARTNER \n" +
            "WHERE\n" +
            "money > 0 \n" +
            "AND sid = #{sid}")
    List<YksytAccountSfwyVO> getSfwyDetail(@Param("sid") String sid);


    @Select("SELECT\n" +
            "THEMONTH,\n" +
            "USERID,\n" +
            "SPNAME,\n" +
            "PROVINCE,\n" +
            "MONEY \n" +
            "FROM\n" +
            "YKSYT_IRREGULAR_DETAIL_PARTNER \n" +
            "WHERE\n" +
            "money > 0 \n" +
            "AND  sid = #{sid}")
    List<YksytAccountBgfdzVO> getBgfdzDetail(@Param("sid") String sid);

    @Select("SELECT\n" +
            "a.themonth,\n" +
            "b.spname,\n" +
            "a.province,\n" +
            "a.refund_money \n" +
            "FROM\n" +
            "YKSYT_REFUND_FOR_CP a\n" +
            "INNER JOIN V_YKSYT_CHANNEL_SPID b ON a.spid = b.spid \n" +
            "WHERE\n" +
            "a.themonth = #{themonth} \n" +
            "AND b.DEAL_TYPE = 4 \n" +
            "AND b.DEAL_ACCOUNT_ID =(\n" +
            "SELECT\n" +
            "DEAL_ACCOUNT_ID \n" +
            "FROM\n" +
            "V_YKSYT_ACCOUNT \n" +
            "WHERE\n" +
            "sid = #{sid} \n" +
            ")")
    List<YksytAccountCptfVO> getCptfDetail(@Param("sid") String sid ,@Param("themonth") Integer themonth);

    @Select("SELECT\n" +
            "themonth,\n" +
            "money1 \n" +
            "FROM\n" +
            "V_YKSYT_ACCOUNT \n" +
            "WHERE\n" +
            "sid = #{sid}")
    List<YksytAccountKftpffVO> getKftpffDetail(@Param("sid") String sid);


    @Select("SELECT\n" +
            "themonth,\n" +
            "money2 \n" +
            "FROM\n" +
            "V_YKSYT_ACCOUNT \n" +
            "WHERE\n" +
            "sid = #{sid}")
    List<YksytAccountSfwykkVO> getSfwykkDetail(@Param("sid") String sid);

    @Select("SELECT\n" +
            "themonth,\n" +
            "money4 \n" +
            "FROM\n" +
            "V_YKSYT_ACCOUNT \n" +
            "WHERE\n" +
            "sid = #{sid}")
    List<YksytAccountBgfdzcfVO> getBgfdzcfDetail(@Param("sid") String sid);

}
