会员商品 添加购物车 记录
This commit is contained in:
172
src/main/resources/mapper/TbActivateInRecordMapper.xml
Normal file
172
src/main/resources/mapper/TbActivateInRecordMapper.xml
Normal file
@@ -0,0 +1,172 @@
|
||||
<?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.chaozhanggui.system.cashierservice.dao.TbActivateInRecordMapper">
|
||||
|
||||
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbActivateInRecord" id="TbActivateInRecordMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="vipUserId" column="vip_user_id" jdbcType="INTEGER"/>
|
||||
<result property="proId" column="pro_id" jdbcType="INTEGER"/>
|
||||
<result property="num" column="num" jdbcType="INTEGER"/>
|
||||
<result property="overNum" column="over_num" jdbcType="INTEGER"/>
|
||||
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
||||
<result property="sourceActId" column="source_act_id" jdbcType="INTEGER"/>
|
||||
<result property="sourceFlowId" column="source_flow_id" jdbcType="INTEGER"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id
|
||||
, vip_user_id, pro_id, num, over_num, shop_id, source_act_id, source_flow_id, create_time, update_time </sql>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="TbActivateInRecordMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
|
||||
from tb_activate_in_record
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="queryByVipIdAndShopId" resultType="com.chaozhanggui.system.cashierservice.entity.TbProduct">
|
||||
SELECT
|
||||
tb_product.*, sum(tb_activate_in_record.over_num) as limitNumber
|
||||
FROM
|
||||
tb_activate_in_record
|
||||
LEFT JOIN tb_product ON tb_activate_in_record.pro_id = tb_product.id
|
||||
WHERE
|
||||
vip_user_id = #{vipUserId} and tb_activate_in_record.shop_id = #{shopId}
|
||||
group by tb_activate_in_record.pro_id
|
||||
</select>
|
||||
|
||||
<select id="queryByVipIdAndShopIdAndProId" resultType="INTEGER">
|
||||
SELECT
|
||||
sum(tb_activate_in_record.num)
|
||||
FROM
|
||||
tb_activate_in_record
|
||||
WHERE
|
||||
vip_user_id = #{vipUserId} and shop_id = #{shopId} and pro_id = #{productId}
|
||||
</select>
|
||||
|
||||
<select id="queryAllByVipIdAndShopIdAndProId" resultMap="TbActivateInRecordMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from tb_activate_in_record
|
||||
WHERE
|
||||
vip_user_id = #{vipUserId}
|
||||
and shop_id = #{shopId}
|
||||
and pro_id = #{productId}
|
||||
and over_num > 0
|
||||
order by create_time
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAll" resultMap="TbActivateInRecordMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
|
||||
from tb_activate_in_record
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="vipUserId != null">
|
||||
and vip_user_id = #{vipUserId}
|
||||
</if>
|
||||
<if test="proId != null">
|
||||
and pro_id = #{proId}
|
||||
</if>
|
||||
<if test="num != null">
|
||||
and num = #{num}
|
||||
</if>
|
||||
<if test="overNum != null">
|
||||
and over_num = #{overNum}
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
and shop_id = #{shopId}
|
||||
</if>
|
||||
<if test="sourceActId != null">
|
||||
and source_act_id = #{sourceActId}
|
||||
</if>
|
||||
<if test="sourceFlowId != null">
|
||||
and source_flow_id = #{sourceFlowId}
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
and create_time = #{createTime}
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
and update_time = #{updateTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_activate_in_record(vip_user_id, pro_id, num, over_num, shop_id, source_act_id, source_flow_id,
|
||||
create_time, update_time)
|
||||
values (#{vipUserId}, #{proId}, #{num}, #{overNum}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{createTime},
|
||||
#{updateTime})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_activate_in_record(vip_user_id, pro_id, num, over_num, shop_id, source_act_id, source_flow_id,
|
||||
create_time, update_time)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.vipUserId}, #{entity.proId}, #{entity.num}, #{entity.overNum}, #{entity.shopId},
|
||||
#{entity.sourceActId}, #{entity.sourceFlowId}, #{entity.createTime}, #{entity.updateTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update tb_activate_in_record
|
||||
<set>
|
||||
<if test="vipUserId != null">
|
||||
vip_user_id = #{vipUserId},
|
||||
</if>
|
||||
<if test="proId != null">
|
||||
pro_id = #{proId},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num = #{num},
|
||||
</if>
|
||||
<if test="overNum != null">
|
||||
over_num = #{overNum},
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
shop_id = #{shopId},
|
||||
</if>
|
||||
<if test="sourceActId != null">
|
||||
source_act_id = #{sourceActId},
|
||||
</if>
|
||||
<if test="sourceFlowId != null">
|
||||
source_flow_id = #{sourceFlowId},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateOverNumById">
|
||||
update tb_activate_in_record
|
||||
set
|
||||
over_num = #{overNum}
|
||||
where id = #{id};
|
||||
</update>
|
||||
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete
|
||||
from tb_activate_in_record
|
||||
where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user