<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fjhx.mapper.product.ProductInfoMapper">

    <select id="getPage" resultType="java.util.LinkedHashMap">
        select id,
               code,
               dept_id,
               name,
               classify_id,
               type,
               combination,
               unit,
               purchase_price,
               selling_price,
               jd_purchase_price,
               new_products_day,
               grow_up_day,
               computing_time,
               new_products_expected_sales,
               grow_up_expected_sales,
               mature_expected_sales,
               clearance_period,
               product_spu_id,
               CASE
                   WHEN datediff(now(), computing_time) &lt; new_products_day THEN 1
                   WHEN datediff(now(), computing_time) &lt; (new_products_day + grow_up_day) THEN 2
                   ELSE 3
                   END life_cycle
        from product_info ${ew.customSqlSegment}
    </select>

    <select id="getCombinationPage" resultType="com.fjhx.params.product.ProductCombinationEx">
        select pc.id,
               pc.link_product_id,
               pc.link_quantity,
               pi.name,
               pi.code,
               pi.unit,
               pi.combination
        from product_combination pc
                 left join product_info pi on pc.link_product_id = pi.id
            ${ew.customSqlSegment}
    </select>

</mapper>
