You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
6.1 KiB
126 lines
6.1 KiB
<?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.qniao.dam.infrastructure.persistent.dao.view.ProductViewDao">
|
|
|
|
|
|
<select id="pageProductByOperator"
|
|
resultType="com.qniao.dam.api.query.product.user.response.UserPageProductByOperatorVo">
|
|
select
|
|
dp.id as productId,
|
|
dps.id as productSpecId,
|
|
dp.main_category,
|
|
dp.sub_category,
|
|
dp.product_title,
|
|
dp.product_desc,
|
|
dp.detail_desc,
|
|
dp.`status`,
|
|
dps.unit_original_price,
|
|
dps.unit_selling_price,
|
|
dpst1.unit as productSpecUnit,
|
|
dpst2.`value` as validityPeriodValue
|
|
from da_product as dp
|
|
LEFT JOIN da_product_spec as dps on dps.is_delete=0 and dps.product_id=dp.id
|
|
LEFT JOIN da_product_spec_term as dpst1 on dpst1.is_delete=0 and dpst1.product_spec_id =dps.id and dpst1.`name`=1
|
|
LEFT JOIN da_product_spec_term as dpst2 on dpst2.is_delete=0 and dpst2.product_spec_id =dps.id and dpst2.`name`=3
|
|
where dp.is_delete=0
|
|
<if test="queryParam.mainCategory != null">
|
|
AND dp.main_category = #{queryParam.mainCategory}
|
|
</if>
|
|
<if test="queryParam.subCategory != null">
|
|
AND dp.sub_category = #{queryParam.subCategory}
|
|
</if>
|
|
<if test="queryParam.productIds != null and queryParam.productIds.size > 0">
|
|
AND dp.id IN
|
|
<foreach collection="queryParam.productIds" item="id" open="(" close=")" separator=",">
|
|
#{id}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<select id="pageProductByCustomer"
|
|
resultType="com.qniao.dam.api.query.product.user.response.UserPageProductByCustomerVo">
|
|
select
|
|
dp.id as productId,
|
|
dps.id as productSpecId,
|
|
dp.main_category,
|
|
dp.sub_category,
|
|
dp.product_title,
|
|
dp.product_desc,
|
|
dp.detail_desc,
|
|
dps.unit_original_price,
|
|
dps.unit_selling_price,
|
|
dpst1.unit as productSpecUnit,
|
|
dpst2.`value` as validityPeriodValue,
|
|
dpst3.`value` as purchaseTimeValue,
|
|
dpst4.`value` as dailyUseLimitValue
|
|
from da_product as dp
|
|
LEFT JOIN da_product_spec as dps on dps.is_delete=0 and dps.product_id=dp.id
|
|
LEFT JOIN da_product_spec_term as dpst1 on dpst1.is_delete=0 and dpst1.product_spec_id =dps.id and dpst1.`name`=1
|
|
LEFT JOIN da_product_spec_term as dpst2 on dpst2.is_delete=0 and dpst2.product_spec_id =dps.id and dpst2.`name`=3
|
|
LEFT JOIN da_product_spec_term as dpst3 on dpst3.is_delete=0 and dpst3.product_spec_id =dps.id and dpst3.`name`=2
|
|
LEFT JOIN da_product_spec_term as dpst4 on dpst4.is_delete=0 and dpst4.product_spec_id =dps.id and dpst4.`name`=4
|
|
where dp.is_delete=0 and dp.`status`=1
|
|
<if test="queryParam.subCategory != null">
|
|
AND dp.sub_category = #{queryParam.subCategory}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectProductByCustomerList" resultType="com.qniao.dam.api.query.product.user.response.UserPageProductByCustomerExtendVo">
|
|
|
|
SELECT
|
|
1 groupType,
|
|
a.id,
|
|
ap.product_id as productId,
|
|
ap.product_spec_id as productSpecId,
|
|
a.activity_name productName,
|
|
p.main_category,
|
|
p.sub_category,
|
|
p.product_title,
|
|
p.product_desc,
|
|
p.detail_desc,
|
|
ap.activity_unit_original_price unit_original_price,
|
|
ap.activity_unit_selling_price unit_selling_price,
|
|
dpst1.unit as productSpecUnit,
|
|
dpst2.`value` as validityPeriodValue,
|
|
dpst3.`value` as purchaseTimeValue,
|
|
dpst4.`value` as dailyUseLimitValue
|
|
FROM
|
|
da_activity a
|
|
LEFT JOIN da_activity_product ap ON a.id = ap.activity_id AND ap.is_delete = 0
|
|
LEFT JOIN da_product p ON ap.product_id = p.id AND p.is_delete = 0
|
|
LEFT JOIN da_product_spec ps ON ps.id = ap.product_spec_id AND ps.product_id = ap.product_id AND ps.is_delete = 0
|
|
LEFT JOIN da_product_spec_term as dpst1 on dpst1.is_delete=0 and dpst1.product_spec_id =ps.id and dpst1.`name`=1
|
|
LEFT JOIN da_product_spec_term as dpst2 on dpst2.is_delete=0 and dpst2.product_spec_id =ps.id and dpst2.`name`=3
|
|
LEFT JOIN da_product_spec_term as dpst3 on dpst3.is_delete=0 and dpst3.product_spec_id =ps.id and dpst3.`name`=2
|
|
LEFT JOIN da_product_spec_term as dpst4 on dpst4.is_delete=0 and dpst4.product_spec_id =ps.id and dpst4.`name`=4
|
|
WHERE a.is_delete = 0 AND a.start_time <= NOW() AND a.end_time >= NOW() ORDER BY a.create_time ASC , ap.create_time ASC
|
|
|
|
UNION
|
|
|
|
select
|
|
0 groupType,
|
|
dp.id,
|
|
dp.id as productId,
|
|
dps.id as productSpecId,
|
|
'' productName,
|
|
dp.main_category,
|
|
dp.sub_category,
|
|
dp.product_title,
|
|
dp.product_desc,
|
|
dp.detail_desc,
|
|
dps.unit_original_price,
|
|
dps.unit_selling_price,
|
|
dpst1.unit as productSpecUnit,
|
|
dpst2.`value` as validityPeriodValue,
|
|
dpst3.`value` as purchaseTimeValue,
|
|
dpst4.`value` as dailyUseLimitValue
|
|
from da_product as dp
|
|
LEFT JOIN da_product_spec as dps on dps.is_delete=0 and dps.product_id=dp.id
|
|
LEFT JOIN da_product_spec_term as dpst1 on dpst1.is_delete=0 and dpst1.product_spec_id =dps.id and dpst1.`name`=1
|
|
LEFT JOIN da_product_spec_term as dpst2 on dpst2.is_delete=0 and dpst2.product_spec_id =dps.id and dpst2.`name`=3
|
|
LEFT JOIN da_product_spec_term as dpst3 on dpst3.is_delete=0 and dpst3.product_spec_id =dps.id and dpst3.`name`=2
|
|
LEFT JOIN da_product_spec_term as dpst4 on dpst4.is_delete=0 and dpst4.product_spec_id =dps.id and dpst4.`name`=4
|
|
where dp.is_delete=0 and dp.`status`=1
|
|
</select>
|
|
</mapper>
|
|
|