package com.hai.dao;

import com.hai.model.ApiProductConfigModel;
import com.hai.model.OutUserOrderModel;
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 ApiProductConfigMapperExt {

    @Select(value = {
            "<script>",
            " select ap.recharge_type as rechargeType , phone_recharge_type as phoneRechargeType , operator_type as operatorType , recharge_price as rechargePrice  , discount_price , apc.id as api_config_product_id , discount , apc.status as configStatus from api_product ap join api_product_config apc on ap.id = apc.product_id where apc.status != 100",
            "  and merchants_id = #{merchantsId} " +
            "</script>"
    })
    @Results({
            @Result(column="rechargeType", property="rechargeType", jdbcType=JdbcType.INTEGER),
            @Result(column="phoneRechargeType", property="phoneRechargeType", jdbcType=JdbcType.INTEGER),
            @Result(column="operatorType", property="operatorType", jdbcType=JdbcType.INTEGER),
            @Result(column="rechargePrice", property="rechargePrice", jdbcType=JdbcType.DECIMAL),
            @Result(column="api_config_product_id", property="apiConfigProductId", jdbcType=JdbcType.BIGINT),
            @Result(column="discount", property="discount", jdbcType=JdbcType.DECIMAL),
            @Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL),
            @Result(column="configStatus", property="configStatus", jdbcType=JdbcType.INTEGER),

    })
    List<ApiProductConfigModel> getListMerchProduct(Long merchantsId);

    @Select(value = {
            "<script>",
            " select recharge_type , phone_recharge_type ,operator_type , recharge_price , discount_price , apc.id as api_config_product_id , discount from api_product ap join api_product_config apc on ap.id = apc.product_id where apc.status = 101",
            "  and merchants_id = #{merchantsId}  and ap.recharge_type = #{rechargeType}" +
                    "</script>"
    })
    @Results({
            @Result(column="recharge_type", property="rechargeType", jdbcType=JdbcType.INTEGER),
            @Result(column="phone_recharge_type", property="phoneRechargeType", jdbcType=JdbcType.INTEGER),
            @Result(column="operator_type", property="operatorType", jdbcType=JdbcType.INTEGER),
            @Result(column="recharge_price", property="rechargePrice", jdbcType=JdbcType.DECIMAL),
            @Result(column="api_config_product_id", property="apiConfigProductId", jdbcType=JdbcType.BIGINT),
            @Result(column="discount", property="discount", jdbcType=JdbcType.DECIMAL),
            @Result(column="discount_price", property="discountPrice", jdbcType=JdbcType.DECIMAL),

    })
    List<ApiProductConfigModel> getMerchProduct(Long merchantsId , Integer rechargeType);

}
