|
|
|
@ -760,6 +760,7 @@ |
|
|
|
t_sale t |
|
|
|
LEFT JOIN t_sale_detail s ON t.id = s.sale_id |
|
|
|
WHERE |
|
|
|
t.status = 4 and |
|
|
|
s.product_id = #{productId,jdbcType=VARCHAR} |
|
|
|
AND t.user_id = #{userId,jdbcType=VARCHAR} |
|
|
|
group by s.product_id,s.sale_id,s.discount_amount |
|
|
|
@ -769,24 +770,35 @@ |
|
|
|
|
|
|
|
|
|
|
|
<select id="getByUserIdAndProductIds" resultType="cc.hiver.mall.pojo.vo.ProductLastBuyVo"> |
|
|
|
|
|
|
|
select MAX(tt.discount_amount) as discount_amount, tt.product_id from t_sale_detail tt, |
|
|
|
|
|
|
|
(SELECT |
|
|
|
MAX(s.create_time) as create_time,s.product_id |
|
|
|
FROM |
|
|
|
t_sale t |
|
|
|
LEFT JOIN t_sale_detail s ON t.id = s.sale_id |
|
|
|
WHERE |
|
|
|
s.product_id IN |
|
|
|
<foreach item="productId" index="index" collection="array" open="(" separator="," close=")"> |
|
|
|
#{productId} |
|
|
|
</foreach> |
|
|
|
AND t.user_id = #{userId,jdbcType=VARCHAR} |
|
|
|
GROUP BY |
|
|
|
s.product_id) aa |
|
|
|
where tt.create_time = aa.create_time and tt.product_id = aa.product_id GROUP BY tt.product_id |
|
|
|
|
|
|
|
SELECT |
|
|
|
s.product_id AS productId, |
|
|
|
s.discount_amount AS discountAmount |
|
|
|
FROM t_sale t |
|
|
|
INNER JOIN t_sale_detail s ON t.id = s.sale_id |
|
|
|
INNER JOIN ( |
|
|
|
SELECT |
|
|
|
s2.product_id, |
|
|
|
MAX(t2.create_time) AS create_time |
|
|
|
FROM t_sale t2 |
|
|
|
INNER JOIN t_sale_detail s2 ON t2.id = s2.sale_id |
|
|
|
WHERE t2.status = 4 |
|
|
|
AND IFNULL(t2.del_flag, 0) = 0 |
|
|
|
AND IFNULL(s2.del_flag, 0) = 0 |
|
|
|
AND t2.user_id = #{userId,jdbcType=VARCHAR} |
|
|
|
AND s2.product_count > 0 |
|
|
|
AND s2.discount_amount IS NOT NULL |
|
|
|
AND s2.product_id IN |
|
|
|
<foreach item="productId" index="index" collection="array" open="(" separator="," close=")"> |
|
|
|
#{productId} |
|
|
|
</foreach> |
|
|
|
GROUP BY s2.product_id |
|
|
|
) latest ON latest.product_id = s.product_id AND latest.create_time = t.create_time |
|
|
|
WHERE t.status = 4 |
|
|
|
AND IFNULL(t.del_flag, 0) = 0 |
|
|
|
AND IFNULL(s.del_flag, 0) = 0 |
|
|
|
AND t.user_id = #{userId,jdbcType=VARCHAR} |
|
|
|
AND s.product_count > 0 |
|
|
|
AND s.discount_amount IS NOT NULL |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="getByIdOrBrcode" parameterType="java.lang.String" resultMap="BaseResultMap"> |
|
|
|
|