<?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.ks.tool.bkz.dao.mybatis.sdlj.SDLJUserGoodsMapper">
|
<resultMap id="BaseResultMap" type="com.ks.tool.bkz.entity.sdlj.SDLJUserGoods">
|
<id column="id" property="id" jdbcType="BIGINT"/>
|
<result column="goods_id" property="goodsId" jdbcType="BIGINT"/>
|
<result column="uid" property="uid" jdbcType="BIGINT"/>
|
<result column="tb_uid" property="tbUid" jdbcType="VARCHAR"/>
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
</resultMap>
|
|
<resultMap id="QueryResultMap" type="com.ks.tool.bkz.vo.sdlj.SDLJGoodsInfoVO">
|
<result column="title" property="title" jdbcType="VARCHAR"/>
|
<result column="zkPrice" property="zkPrice" jdbcType="DECIMAL"/>
|
<result column="couponPrice" property="couponPrice" jdbcType="DECIMAL"/>
|
<result column="lijinAmount" property="lijinAmount" jdbcType="DECIMAL"/>
|
<result column="goodsId" property="goodsId" jdbcType="BIGINT"/>
|
<result column="actualPrice" property="actualPrice" jdbcType="DECIMAL"/>
|
<result column="commissionRate" property="commissionRate" jdbcType="DECIMAL"/>
|
<result column="imgs" property="imgs" jdbcType="VARCHAR"/>
|
<result column="tkl" property="tkl" jdbcType="VARCHAR"/>
|
</resultMap>
|
|
<sql id="Base_Column_List">
|
id, goods_id, uid, tb_uid, create_time
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
|
select
|
<include refid="Base_Column_List"/>
|
from tt_user_goods
|
where id = #{id,jdbcType=BIGINT}
|
</select>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
delete from tt_user_goods
|
where id = #{id,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" parameterType="com.ks.tool.bkz.entity.sdlj.SDLJUserGoods">
|
insert into tt_user_goods (id, goods_id, uid,
|
tb_uid, create_time)
|
values (#{id,jdbcType=BIGINT}, #{goodsId,jdbcType=BIGINT}, #{uid,jdbcType=BIGINT},
|
#{tbUid,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})
|
</insert>
|
<insert id="insertSelective" parameterType="com.ks.tool.bkz.entity.sdlj.SDLJUserGoods">
|
insert into tt_user_goods
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
id,
|
</if>
|
<if test="goodsId != null">
|
goods_id,
|
</if>
|
<if test="uid != null">
|
uid,
|
</if>
|
<if test="tbUid != null">
|
tb_uid,
|
</if>
|
<if test="createTime != null">
|
create_time,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
#{id,jdbcType=BIGINT},
|
</if>
|
<if test="goodsId != null">
|
#{goodsId,jdbcType=BIGINT},
|
</if>
|
<if test="uid != null">
|
#{uid,jdbcType=BIGINT},
|
</if>
|
<if test="tbUid != null">
|
#{tbUid,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
#{createTime,jdbcType=TIMESTAMP},
|
</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKeySelective" parameterType="com.ks.tool.bkz.entity.sdlj.SDLJUserGoods">
|
update tt_user_goods
|
<set>
|
<if test="goodsId != null">
|
goods_id = #{goodsId,jdbcType=BIGINT},
|
</if>
|
<if test="uid != null">
|
uid = #{uid,jdbcType=BIGINT},
|
</if>
|
<if test="tbUid != null">
|
tb_uid = #{tbUid,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
</if>
|
</set>
|
where id = #{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKey" parameterType="com.ks.tool.bkz.entity.sdlj.SDLJUserGoods">
|
update tt_user_goods
|
set goods_id = #{goodsId,jdbcType=BIGINT},
|
uid = #{uid,jdbcType=BIGINT},
|
tb_uid = #{tbUid,jdbcType=VARCHAR},
|
create_time = #{createTime,jdbcType=TIMESTAMP}
|
where id = #{id,jdbcType=BIGINT}
|
</update>
|
|
<sql id="queryWhere">
|
1=1 and tg.id>0 AND t.id>0 and s.id>0
|
<if test="uid!=null">
|
AND t.`uid`=#{uid}
|
</if>
|
<if test="vo.couponType!=null">
|
<if test="vo.couponType==1">
|
AND tg.`coupon_amount`>=0
|
</if>
|
<if test="vo.couponType==2">
|
AND 0>= tg.`coupon_amount`
|
</if>
|
</if>
|
<if test="vo.shopType!=null">
|
<if test="vo.shopType==1">
|
AND tg.`tmall`=1
|
</if>
|
<if test="vo.shopType==2">
|
AND tg.`tmall`=0
|
</if>
|
</if>
|
<if test="vo.minCouponPrice!=null">
|
AND tg.`coupon_price`>=#{vo.minCouponPrice}
|
</if>
|
<if test="vo.maxCouponPrice!=null">
|
AND #{vo.maxCouponPrice}>= tg.`coupon_price`
|
</if>
|
<if test="vo.minLiJin!=null">
|
AND s.`promotion_amount`>=#{vo.minLiJin}
|
</if>
|
<if test="vo.maxLiJin!=null">
|
AND #{vo.maxLiJin}>=s.`promotion_amount`
|
</if>
|
|
<if test="vo.minActualPrice!=null">
|
AND (tg.`coupon_price`-s.`promotion_amount`)>=#{vo.minActualPrice}
|
</if>
|
<if test="vo.maxActualPrice!=null">
|
AND #{vo.maxActualPrice}>=(tg.`coupon_price`-s.`promotion_amount`)
|
</if>
|
|
<if test="vo.minSalesNum!=null">
|
AND tg.sales_num>=#{vo.minSalesNum}
|
</if>
|
<if test="vo.maxSalesNum!=null">
|
AND #{vo.maxSalesNum}>=tg.sales_num
|
</if>
|
|
<if test="vo.minCommission!=null">
|
AND ((tg.`coupon_price`-s.`promotion_amount`)*tg.commission_rate/100)>=#{vo.minCommission}
|
</if>
|
<if test="vo.maxCommission!=null">
|
AND #{vo.maxCommission}>=((tg.`coupon_price`-s.`promotion_amount`)*tg.commission_rate/100)
|
</if>
|
|
<if test="vo.minCommissionRate!=null">
|
AND tg.commission_rate>=#{vo.minCommissionRate}
|
</if>
|
<if test="vo.maxCommissionRate!=null">
|
AND #{vo.maxCommissionRate}>=tg.commission_rate
|
</if>
|
|
<if test="vo.key!=null">
|
AND tg.title like CONCAT('%',#{vo.key},'%')
|
</if>
|
|
<if test="vo.classType!=null">
|
AND tg.cid =vo.classType
|
</if>
|
|
GROUP BY t.`goods_id`
|
|
</sql>
|
|
<select id="query" resultMap="QueryResultMap">
|
SELECT tg.`title` AS title,tg.`zk_price` AS zkPrice,tg.`coupon_price` AS couponPrice,s.`promotion_amount` AS
|
lijinAmount,tg.`goods_id` AS goodsId,(tg.`coupon_price`-s.`promotion_amount`) AS actualPrice,
|
tg.`commission_rate` AS commissionRate,tg.`imgs` AS imgs,tg.sales_num as salesNum,tg.coupon_amount as couponAmount,tg.tmall,tg.tkl
|
FROM `tt_user_goods` t
|
LEFT JOIN `tt_sdlj_goods_info` s ON s.`goods_id`=t.`goods_id`
|
LEFT JOIN `tt_tb_goods_info` tg ON tg.`goods_id`=t.`goods_id`
|
WHERE <include refid="queryWhere"></include> ORDER BY #{vo.sort} LIMIT #{start},#{count}
|
</select>
|
|
|
<select id="count" resultType="java.lang.Long">
|
SELECT count(*)
|
FROM `tt_user_goods` t
|
LEFT JOIN `tt_sdlj_goods_info` s ON s.`goods_id`=t.`goods_id`
|
LEFT JOIN `tt_tb_goods_info` tg ON tg.`goods_id`=t.`goods_id`
|
WHERE <include refid="queryWhere"></include>
|
</select>
|
|
|
<select id="selectByGoodsIdAndUidAndTBUid" resultMap="BaseResultMap" >
|
select
|
<include refid="Base_Column_List"/>
|
from tt_user_goods
|
where goods_id = #{goodsId} and uid=#{uid} and tb_uid=#{tbUid}
|
</select>
|
|
</mapper>
|