package com.hfkj.dao;

import com.hfkj.entity.BsTradeOrderProfitSharing;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * mapper扩展类
 */
public interface BsTradeOrderProfitSharingMapperExt {

    @Select({" SELECT a.* FROM bs_trade_order_profit_sharing a " +
            "  LEFT JOIN bs_trade_order b on b.id = a.trade_order_id " +
            "  where b.`status` = 3 and a.`status` in (0,2,3) " +
            "  and a.create_time <= DATE_SUB(NOW(), INTERVAL 5 MINUTE) "})
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="cmd_type", property="cmdType", jdbcType=JdbcType.BIGINT),
            @Result(column="trade_order_id", property="tradeOrderId", jdbcType=JdbcType.BIGINT),
            @Result(column="trade_order_no", property="tradeOrderNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="profit_sharing_order_no", property="profitSharingOrderNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="platform_type", property="platformType", jdbcType=JdbcType.INTEGER),
            @Result(column="platform_profit_sharing_order_no", property="platformProfitSharingOrderNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="platform_mer_no", property="platformMerNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="platform_trade_no", property="platformTradeNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="platform_appid", property="platformAppid", jdbcType=JdbcType.VARCHAR),
            @Result(column="ratio", property="ratio", jdbcType=JdbcType.DECIMAL),
            @Result(column="profit_sharing_amoun", property="profitSharingAmoun", jdbcType=JdbcType.DECIMAL),
            @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="profit_sharing_time", property="profitSharingTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
    })
    List<BsTradeOrderProfitSharing> getNeedProfitSharingOrder();


    @Select({" SELECT a.* FROM bs_trade_order_profit_sharing a " +
            "  LEFT JOIN bs_trade_order b on b.id = a.trade_order_id " +
            "  where b.`status` = 3 and a.`status` = 1 " +
            "  and a.profit_sharing_time <= DATE_SUB(NOW(), INTERVAL 2 MINUTE) "})
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
            @Result(column="trade_order_id", property="tradeOrderId", jdbcType=JdbcType.BIGINT),
            @Result(column="trade_order_no", property="tradeOrderNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="profit_sharing_order_no", property="profitSharingOrderNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="platform_type", property="platformType", jdbcType=JdbcType.INTEGER),
            @Result(column="platform_profit_sharing_order_no", property="platformProfitSharingOrderNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="platform_mer_no", property="platformMerNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="platform_trade_no", property="platformTradeNo", jdbcType=JdbcType.VARCHAR),
            @Result(column="platform_appid", property="platformAppid", jdbcType=JdbcType.VARCHAR),
            @Result(column="ratio", property="ratio", jdbcType=JdbcType.DECIMAL),
            @Result(column="profit_sharing_amoun", property="profitSharingAmoun", jdbcType=JdbcType.DECIMAL),
            @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="profit_sharing_time", property="profitSharingTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="finish_time", property="finishTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
            @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
    })
    List<BsTradeOrderProfitSharing> getNeedFinishProfitSharingOrder();
}
