会员商品 添加购物车 记录

This commit is contained in:
2024-08-23 10:04:49 +08:00
parent d264f79c9e
commit 7b09e827fd
27 changed files with 984 additions and 279 deletions

View File

@@ -1,12 +1,13 @@
<?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.TbActivateGiveRecordMapper">
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbActivateInRecordMapper">
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbActivateGiveRecord" id="TbActivateGiveRecordMap">
<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"/>
@@ -16,23 +17,55 @@
<sql id="Base_Column_List">
id
, vip_user_id, pro_id, num, shop_id, source_flow_id,source_act_id, create_time, update_time </sql>
, 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="TbActivateGiveRecordMap">
<select id="queryById" resultMap="TbActivateInRecordMap">
select
<include refid="Base_Column_List"/>
from tb_activate_give_record
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="TbActivateGiveRecordMap">
<select id="queryAll" resultMap="TbActivateInRecordMap">
select
<include refid="Base_Column_List"/>
from tb_activate_give_record
from tb_activate_in_record
<where>
<if test="id != null">
and id = #{id}
@@ -46,6 +79,9 @@
<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>
@@ -67,22 +103,25 @@
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into tb_activate_give_record(vip_user_id, pro_id, num, shop_id, source_act_id, source_flow_id, create_time, update_time)
values (#{vipUserId}, #{proId}, #{num}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{createTime}, #{updateTime})
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_give_record(vip_user_id, pro_id, num, shop_id, source_act_id, source_flow_id, create_time, update_time)
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.shopId}, #{entity.sourceActId},
#{entity.sourceFlowId},#{entity.createTime}, #{entity.updateTime})
(#{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_give_record
update tb_activate_in_record
<set>
<if test="vipUserId != null">
vip_user_id = #{vipUserId},
@@ -93,6 +132,9 @@
<if test="num != null">
num = #{num},
</if>
<if test="overNum != null">
over_num = #{overNum},
</if>
<if test="shopId != null">
shop_id = #{shopId},
</if>
@@ -111,11 +153,18 @@
</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_give_record
from tb_activate_in_record
where id = #{id}
</delete>

View File

@@ -0,0 +1,130 @@
<?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.TbActivateOutRecordMapper">
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord" id="TbActivateOutRecordMap">
<result property="id" column="id" jdbcType="INTEGER"/>
<result property="giveId" column="give_id" jdbcType="INTEGER"/>
<result property="proId" column="pro_id" jdbcType="INTEGER"/>
<result property="useNum" column="use_num" jdbcType="INTEGER"/>
<result property="refNum" column="ref_num" jdbcType="INTEGER"/>
<result property="orderId" column="order_id" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id
, give_id, pro_id, use_num, ref_num, order_id,status, create_time, update_time </sql>
<!--查询单个-->
<select id="queryById" resultMap="TbActivateOutRecordMap">
select
<include refid="Base_Column_List"/>
from tb_activate_out_record
where id = #{id}
</select>
<!--查询指定行数据-->
<select id="queryAll" resultMap="TbActivateOutRecordMap">
select
<include refid="Base_Column_List"/>
from tb_activate_out_record
<where>
<if test="id != null">
and id = #{id}
</if>
<if test="giveId != null">
and give_id = #{giveId}
</if>
<if test="proId != null">
and pro_id = #{proId}
</if>
<if test="useNum != null">
and use_num = #{useNum}
</if>
<if test="refNum != null">
and ref_num = #{refNum}
</if>
<if test="orderId != null and orderId != ''">
and order_id = #{orderId}
</if>
<if test="status != null and status != ''">
and status = #{status}
</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_out_record(give_id, pro_id, use_num, ref_num, order_id, status, create_time, update_time)
values (#{giveId}, #{proId}, #{useNum}, #{refNum}, #{orderId}, #{status} #{createTime}, #{updateTime})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into tb_activate_out_record(give_id, pro_id, use_num, ref_num, order_id, status, create_time, update_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.giveId}, #{entity.proId}, #{entity.useNum}, #{entity.refNum}, #{entity.orderId},
#{entity.status}, #{entity.createTime}, #{entity.updateTime})
</foreach>
</insert>
<!--通过主键修改数据-->
<update id="update">
update tb_activate_out_record
<set>
<if test="giveId != null">
give_id = #{giveId},
</if>
<if test="proId != null">
pro_id = #{proId},
</if>
<if test="useNum != null">
use_num = #{useNum},
</if>
<if test="refNum != null">
ref_num = #{refNum},
</if>
<if test="orderId != null and orderId != ''">
order_id = #{orderId},
</if>
<if test="status != null and status != ''">
status = #{status},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
where id = #{id}
</update>
<update id="updateByOrderIdAndStatus">
update tb_activate_out_record
set
status = 'closed'
where order_id = #{orderId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete
from tb_activate_out_record
where id = #{id}
</delete>
</mapper>

View File

@@ -58,6 +58,15 @@ id, activate_id, product_id, num, create_time, update_time </sql>
activate_id = #{activateId}
</select>
<select id="queryProsByActivateId" resultType="java.lang.String">
select
CONCAT(tb_product.name, '*', SUM(tb_activate_product.num))
from tb_activate_product
LEFT JOIN tb_product ON tb_activate_product.product_id = tb_product.id
where
activate_id = #{activateId}
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">

View File

@@ -33,11 +33,12 @@
<result column="pending_at" jdbcType="BIGINT" property="pendingAt"/>
<result column="uuid" jdbcType="VARCHAR" property="uuid"/>
<result column="sku_name" jdbcType="VARCHAR" property="skuName"/>
<result column="is_vip" jdbcType="TINYINT" property="isVip" />
</resultMap>
<sql id="Base_Column_List">
id, master_id, order_id, ref_order_id, total_amount, product_id, cover_img, is_sku,pack_fee,is_pack,is_gift,pending_at,
sku_id, name, sale_price, number, total_number, refund_number, category_id, status,
type, merchant_id, shop_id, created_at, updated_at, user_id, table_id,pack_fee,trade_day,uuid,sku_name
type, merchant_id, shop_id, created_at, updated_at, user_id, table_id,pack_fee,trade_day,uuid,sku_name,is_vip
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
@@ -96,25 +97,28 @@
<delete id="deleteBymasterId">
delete from tb_cashier_cart where master_id = #{masterId} and shop_id = #{shopId} and status = #{status} and trade_day = #{day}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart" useGeneratedKeys="true" keyProperty="id">
insert into tb_cashier_cart (id, master_id, order_id,
ref_order_id, total_amount, product_id,
cover_img, is_sku, sku_id,
name, sale_price, number,
total_number, refund_number, category_id,
status, type, merchant_id,
shop_id, created_at, updated_at, pack_fee,trade_day,is_pack,is_gift,table_id,user_id,sku_name
)
values (#{id,jdbcType=INTEGER}, #{masterId,jdbcType=VARCHAR}, #{orderId,jdbcType=VARCHAR},
#{refOrderId,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL}, #{productId,jdbcType=VARCHAR},
#{coverImg,jdbcType=VARCHAR}, #{isSku,jdbcType=TINYINT}, #{skuId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{salePrice,jdbcType=DECIMAL}, #{number,jdbcType=REAL},
#{totalNumber,jdbcType=REAL}, #{refundNumber,jdbcType=REAL}, #{categoryId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, #{merchantId,jdbcType=VARCHAR},
#{shopId,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{packFee,jdbcType=DECIMAL}
, #{tradeDay,jdbcType=VARCHAR}, #{isPack,jdbcType=VARCHAR}, #{isGift,jdbcType=VARCHAR}, #{tableId,jdbcType=VARCHAR}, #{userId,jdbcType=INTEGER},#{skuName,jdbcType=VARCHAR}
)
</insert>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart"
useGeneratedKeys="true" keyProperty="id">
insert into tb_cashier_cart (id, master_id, order_id,
ref_order_id, total_amount, product_id,
cover_img, is_sku, sku_id,
name, sale_price, number,
total_number, refund_number, category_id,
status, type, merchant_id,
shop_id, created_at, updated_at, pack_fee, trade_day, is_pack, is_gift, table_id,
user_id, sku_name, is_vip)
values (#{id,jdbcType=INTEGER}, #{masterId,jdbcType=VARCHAR}, #{orderId,jdbcType=VARCHAR},
#{refOrderId,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL}, #{productId,jdbcType=VARCHAR},
#{coverImg,jdbcType=VARCHAR}, #{isSku,jdbcType=TINYINT}, #{skuId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{salePrice,jdbcType=DECIMAL}, #{number,jdbcType=REAL},
#{totalNumber,jdbcType=REAL}, #{refundNumber,jdbcType=REAL}, #{categoryId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, #{merchantId,jdbcType=VARCHAR},
#{shopId,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
#{packFee,jdbcType=DECIMAL}
, #{tradeDay,jdbcType=VARCHAR}, #{isPack,jdbcType=VARCHAR}, #{isGift,jdbcType=VARCHAR},
#{tableId,jdbcType=VARCHAR}
, #{userId,jdbcType=INTEGER}, #{skuName,jdbcType=VARCHAR}, #{isVip,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart">
insert into tb_cashier_cart
<trim prefix="(" suffix=")" suffixOverrides=",">
@@ -181,6 +185,9 @@
<if test="updatedAt != null">
updated_at,
</if>
<if test="isVip != null">
is_vip,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@@ -246,6 +253,9 @@
<if test="updatedAt != null">
#{updatedAt,jdbcType=BIGINT},
</if>
<if test="isVip != null">
#{isVip,jdbcType=TINYINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
@@ -324,6 +334,9 @@
<if test="isGift != null">
is_gift = #{isGift,jdbcType=BIGINT},
</if>
<if test="isVip != null">
is_vip = #{isVip,jdbcType=TINYINT},
</if>
<if test="isPack != null">
is_pack = #{isPack,jdbcType=VARCHAR},
</if>

View File

@@ -8,6 +8,7 @@
<result column="product_id" jdbcType="INTEGER" property="productId"/>
<result column="product_sku_id" jdbcType="INTEGER" property="productSkuId"/>
<result column="num" jdbcType="INTEGER" property="num"/>
<result column="is_vip" jdbcType="TINYINT" property="isVip" />
<result column="product_name" jdbcType="VARCHAR" property="productName"/>
<result column="product_sku_name" jdbcType="VARCHAR" property="productSkuName"/>
<result column="product_img" jdbcType="VARCHAR" property="productImg"/>
@@ -20,7 +21,7 @@
</resultMap>
<sql id="Base_Column_List">
id, order_id, shop_id, product_id, product_sku_id, num, product_name, product_sku_name,
product_img, create_time, update_time, price, price_amount,status,pack_amount
product_img, create_time, update_time, price, price_amount,status,pack_amount,is_vip
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
@@ -43,12 +44,12 @@
product_id, product_sku_id, num,
product_name, product_sku_name, product_img,
create_time, update_time, price,
price_amount,pack_amount,status)
price_amount,pack_amount,status,is_vip)
values (#{id,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER},
#{productId,jdbcType=INTEGER}, #{productSkuId,jdbcType=INTEGER}, #{num,jdbcType=INTEGER},
#{productName,jdbcType=VARCHAR}, #{productSkuName,jdbcType=VARCHAR}, #{productImg,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{price,jdbcType=DECIMAL},
#{priceAmount,jdbcType=DECIMAL},#{packAmount,jdbcType=DECIMAL},#{status,jdbcType=VARCHAR})
#{priceAmount,jdbcType=DECIMAL},#{packAmount,jdbcType=DECIMAL},#{status,jdbcType=VARCHAR},#{isVip,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbOrderDetail">
insert into tb_order_detail
@@ -92,6 +93,9 @@
<if test="priceAmount != null">
price_amount,
</if>
<if test="isVip != null">
is_vip,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@@ -133,6 +137,9 @@
<if test="priceAmount != null">
#{priceAmount,jdbcType=DECIMAL},
</if>
<if test="isVip != null">
#{isVip,jdbcType=TINYINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
@@ -154,6 +161,9 @@
<if test="num != null">
num = #{num,jdbcType=INTEGER},
</if>
<if test="isVip != null">
is_vip = #{isVip,jdbcType=TINYINT},
</if>
<if test="productName != null">
product_name = #{productName,jdbcType=VARCHAR},
</if>
@@ -197,6 +207,7 @@
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
price = #{price,jdbcType=DECIMAL},
is_vip= #{isVip,jdbcType=TINYINT},
price_amount = #{priceAmount,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER}
</update>

View File

@@ -1009,6 +1009,7 @@
AND t.sku_id = #{skuId}
AND t.`status` = 'create'
AND t.table_id = #{code}
AND t.is_vip = #{isVip}
</select>
<select id="selectByNewQcode" resultType="java.lang.Integer">
SELECT