<?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.iotechn.unimall.data.mapper.CouponUserMapper">
|
|
<select id="getUserCoupons" resultType="com.iotechn.unimall.data.dto.CouponUserDTO">
|
SELECT
|
u.id,
|
u.user_id AS userId,
|
u.coupon_id AS couponId,
|
u.gmt_update AS gmtUpdate,
|
u.gmt_create AS gmtCreate,
|
u.gmt_end AS gmtEnd,
|
c.title,
|
c.category_id AS categoryId,
|
y.title AS categoryTitle,
|
c.`min`,
|
c.discount
|
FROM
|
unimall_coupon_user AS u,
|
unimall_coupon AS c
|
LEFT JOIN unimall_category AS y ON c.category_id = y.id
|
WHERE
|
u.coupon_id = c.id
|
AND u.user_id = #{userId}
|
AND u.gmt_used IS NULL
|
AND unix_timestamp(u.gmt_start) <= unix_timestamp(now())
|
AND unix_timestamp(u.gmt_end) > unix_timestamp(now())
|
</select>
|
|
<select id="getCouponUserById" resultType="com.iotechn.unimall.data.dto.CouponUserDTO">
|
SELECT
|
u.id,
|
u.user_id AS userId,
|
u.coupon_id AS couponId,
|
u.gmt_update AS gmtUpdate,
|
u.gmt_create AS gmtCreate,
|
c.title,
|
c.category_id AS categoryId,
|
y.title AS categoryTitle,
|
c.`min`,
|
c.discount
|
FROM
|
unimall_coupon_user AS u,
|
unimall_coupon AS c
|
LEFT JOIN unimall_category AS y ON c.category_id = y.id
|
WHERE
|
u.id = #{userCouponId}
|
AND u.coupon_id = c.id
|
AND u.user_id = #{userId}
|
AND u.gmt_used IS NULL
|
AND unix_timestamp(u.gmt_start) <= unix_timestamp(now())
|
AND unix_timestamp(u.gmt_end) > unix_timestamp(now())
|
</select>
|
|
</mapper>
|