Files
wx-cashier-service/src/main/resources/mapper/TbShopUserMapper.xml
wangw e17e2e5d60 新增会员填充加入会员时间
userInfo增加 储值和优惠卷数 字段
2024-09-25 17:59:01 +08:00

465 lines
16 KiB
XML

<?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.TbShopUserMapper">
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="amount" jdbcType="DECIMAL" property="amount" />
<result column="credit_amount" jdbcType="DECIMAL" property="creditAmount" />
<result column="consume_amount" jdbcType="DECIMAL" property="consumeAmount" />
<result column="consume_number" jdbcType="INTEGER" property="consumeNumber" />
<result column="level_consume" jdbcType="DECIMAL" property="levelConsume" />
<result column="status" jdbcType="TINYINT" property="status" />
<result column="merchant_id" jdbcType="VARCHAR" property="merchantId" />
<result column="shop_id" jdbcType="VARCHAR" property="shopId" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="parent_id" jdbcType="VARCHAR" property="parentId" />
<result column="parent_level" jdbcType="VARCHAR" property="parentLevel" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="head_img" jdbcType="VARCHAR" property="headImg" />
<result column="sex" jdbcType="TINYINT" property="sex" />
<result column="birth_day" jdbcType="VARCHAR" property="birthDay" />
<result column="telephone" jdbcType="VARCHAR" property="telephone" />
<result column="is_vip" jdbcType="TINYINT" property="isVip" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="dynamic_code" jdbcType="VARCHAR" property="dynamicCode" />
<result column="is_attention" jdbcType="TINYINT" property="isAttention" />
<result column="attention_at" jdbcType="INTEGER" property="attentionAt" />
<result column="is_shareholder" jdbcType="TINYINT" property="isShareholder" />
<result column="level" jdbcType="TINYINT" property="level" />
<result column="distribute_type" jdbcType="VARCHAR" property="distributeType" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="created_at" jdbcType="BIGINT" property="createdAt" />
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
<result column="mini_open_id" jdbcType="VARCHAR" property="miniOpenId" />
<result column="join_time" jdbcType="VARCHAR" property="joinTime" />
</resultMap>
<sql id="Base_Column_List">
id, amount, credit_amount, consume_amount, consume_number, level_consume, status,
merchant_id, shop_id, user_id, parent_id, parent_level, name, head_img, sex, birth_day,
telephone, is_vip, code, is_attention, attention_at, is_shareholder, level, distribute_type,
sort, created_at, updated_at, mini_open_id,dynamic_code,join_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_shop_user
where id = #{id,jdbcType=VARCHAR}
</select>
<select id="selectByPhone" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_shop_user
where telephone = #{phone,jdbcType=VARCHAR}
</select>
<select id="selectByShopIdAndPhone" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_shop_user
where
shop_id=#{shopId}
and telephone = #{phone,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from tb_shop_user
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
insert into tb_shop_user (id, amount, credit_amount,
consume_amount, consume_number, level_consume,
status, merchant_id, shop_id,
user_id, parent_id, parent_level,
name, head_img, sex,
birth_day, telephone, is_vip,
code, is_attention, attention_at,
is_shareholder, level, distribute_type,
sort, created_at, updated_at,
mini_open_id,join_time)
values (#{id,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, #{creditAmount,jdbcType=DECIMAL},
#{consumeAmount,jdbcType=DECIMAL}, #{consumeNumber,jdbcType=INTEGER}, #{levelConsume,jdbcType=DECIMAL},
#{status,jdbcType=TINYINT}, #{merchantId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR}, #{parentLevel,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{headImg,jdbcType=VARCHAR}, #{sex,jdbcType=TINYINT},
#{birthDay,jdbcType=VARCHAR}, #{telephone,jdbcType=VARCHAR}, #{isVip,jdbcType=TINYINT},
#{code,jdbcType=VARCHAR}, #{isAttention,jdbcType=TINYINT}, #{attentionAt,jdbcType=INTEGER},
#{isShareholder,jdbcType=TINYINT}, #{level,jdbcType=TINYINT}, #{distributeType,jdbcType=VARCHAR},
#{sort,jdbcType=INTEGER}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
#{miniOpenId,jdbcType=VARCHAR},#{joinTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
insert into tb_shop_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="amount != null">
amount,
</if>
<if test="creditAmount != null">
credit_amount,
</if>
<if test="consumeAmount != null">
consume_amount,
</if>
<if test="consumeNumber != null">
consume_number,
</if>
<if test="levelConsume != null">
level_consume,
</if>
<if test="status != null">
status,
</if>
<if test="merchantId != null">
merchant_id,
</if>
<if test="shopId != null">
shop_id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="parentId != null">
parent_id,
</if>
<if test="parentLevel != null">
parent_level,
</if>
<if test="name != null">
name,
</if>
<if test="headImg != null">
head_img,
</if>
<if test="sex != null">
sex,
</if>
<if test="birthDay != null">
birth_day,
</if>
<if test="telephone != null">
telephone,
</if>
<if test="isVip != null">
is_vip,
</if>
<if test="code != null">
code,
</if>
<if test="isAttention != null">
is_attention,
</if>
<if test="attentionAt != null">
attention_at,
</if>
<if test="isShareholder != null">
is_shareholder,
</if>
<if test="level != null">
level,
</if>
<if test="distributeType != null">
distribute_type,
</if>
<if test="sort != null">
sort,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="miniOpenId != null">
mini_open_id,
</if>
<if test="joinTime != null">
join_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="amount != null">
#{amount,jdbcType=DECIMAL},
</if>
<if test="creditAmount != null">
#{creditAmount,jdbcType=DECIMAL},
</if>
<if test="consumeAmount != null">
#{consumeAmount,jdbcType=DECIMAL},
</if>
<if test="consumeNumber != null">
#{consumeNumber,jdbcType=INTEGER},
</if>
<if test="levelConsume != null">
#{levelConsume,jdbcType=DECIMAL},
</if>
<if test="status != null">
#{status,jdbcType=TINYINT},
</if>
<if test="merchantId != null">
#{merchantId,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
#{shopId,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
#{parentId,jdbcType=VARCHAR},
</if>
<if test="parentLevel != null">
#{parentLevel,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="headImg != null">
#{headImg,jdbcType=VARCHAR},
</if>
<if test="sex != null">
#{sex,jdbcType=TINYINT},
</if>
<if test="birthDay != null">
#{birthDay,jdbcType=VARCHAR},
</if>
<if test="telephone != null">
#{telephone,jdbcType=VARCHAR},
</if>
<if test="isVip != null">
#{isVip,jdbcType=TINYINT},
</if>
<if test="code != null">
#{code,jdbcType=VARCHAR},
</if>
<if test="isAttention != null">
#{isAttention,jdbcType=TINYINT},
</if>
<if test="attentionAt != null">
#{attentionAt,jdbcType=INTEGER},
</if>
<if test="isShareholder != null">
#{isShareholder,jdbcType=TINYINT},
</if>
<if test="level != null">
#{level,jdbcType=TINYINT},
</if>
<if test="distributeType != null">
#{distributeType,jdbcType=VARCHAR},
</if>
<if test="sort != null">
#{sort,jdbcType=INTEGER},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=BIGINT},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=BIGINT},
</if>
<if test="miniOpenId != null">
#{miniOpenId,jdbcType=VARCHAR},
</if>
<if test="joinTime != null">
#{joinTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
update tb_shop_user
<set>
<if test="amount != null">
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="creditAmount != null">
credit_amount = #{creditAmount,jdbcType=DECIMAL},
</if>
<if test="consumeAmount != null">
consume_amount = #{consumeAmount,jdbcType=DECIMAL},
</if>
<if test="consumeNumber != null">
consume_number = #{consumeNumber,jdbcType=INTEGER},
</if>
<if test="levelConsume != null">
level_consume = #{levelConsume,jdbcType=DECIMAL},
</if>
<if test="status != null">
status = #{status,jdbcType=TINYINT},
</if>
<if test="merchantId != null">
merchant_id = #{merchantId,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
parent_id = #{parentId,jdbcType=VARCHAR},
</if>
<if test="parentLevel != null">
parent_level = #{parentLevel,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="headImg != null">
head_img = #{headImg,jdbcType=VARCHAR},
</if>
<if test="sex != null">
sex = #{sex,jdbcType=TINYINT},
</if>
<if test="birthDay != null">
birth_day = #{birthDay,jdbcType=VARCHAR},
</if>
<if test="telephone != null">
telephone = #{telephone,jdbcType=VARCHAR},
</if>
<if test="isVip != null">
is_vip = #{isVip,jdbcType=TINYINT},
</if>
<if test="code != null">
code = #{code,jdbcType=VARCHAR},
</if>
<if test="dynamicCode != null">
dynamic_code = #{dynamicCode,jdbcType=VARCHAR},
</if>
<if test="dynamicCode != null">
dynamic_code = #{dynamicCode,jdbcType=VARCHAR},
</if>
<if test="isAttention != null">
is_attention = #{isAttention,jdbcType=TINYINT},
</if>
<if test="attentionAt != null">
attention_at = #{attentionAt,jdbcType=INTEGER},
</if>
<if test="isShareholder != null">
is_shareholder = #{isShareholder,jdbcType=TINYINT},
</if>
<if test="level != null">
level = #{level,jdbcType=TINYINT},
</if>
<if test="distributeType != null">
distribute_type = #{distributeType,jdbcType=VARCHAR},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=INTEGER},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=BIGINT},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=BIGINT},
</if>
<if test="miniOpenId != null">
mini_open_id = #{miniOpenId,jdbcType=VARCHAR},
</if>
<if test="joinTime != null">
join_time = #{joinTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
update tb_shop_user
set amount = #{amount,jdbcType=DECIMAL},
credit_amount = #{creditAmount,jdbcType=DECIMAL},
consume_amount = #{consumeAmount,jdbcType=DECIMAL},
consume_number = #{consumeNumber,jdbcType=INTEGER},
level_consume = #{levelConsume,jdbcType=DECIMAL},
status = #{status,jdbcType=TINYINT},
merchant_id = #{merchantId,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
parent_id = #{parentId,jdbcType=VARCHAR},
parent_level = #{parentLevel,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
head_img = #{headImg,jdbcType=VARCHAR},
sex = #{sex,jdbcType=TINYINT},
birth_day = #{birthDay,jdbcType=VARCHAR},
telephone = #{telephone,jdbcType=VARCHAR},
is_vip = #{isVip,jdbcType=TINYINT},
code = #{code,jdbcType=VARCHAR},
is_attention = #{isAttention,jdbcType=TINYINT},
attention_at = #{attentionAt,jdbcType=INTEGER},
is_shareholder = #{isShareholder,jdbcType=TINYINT},
level = #{level,jdbcType=TINYINT},
distribute_type = #{distributeType,jdbcType=VARCHAR},
sort = #{sort,jdbcType=INTEGER},
created_at = #{createdAt,jdbcType=BIGINT},
updated_at = #{updatedAt,jdbcType=BIGINT},
join_time = #{joinTime,jdbcType=TIMESTAMP},
mini_open_id = #{miniOpenId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="upUserBYId" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
update tb_shop_user
set
user_id = #{userId,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="selectByUserIdAndShopId" resultMap="BaseResultMap">
select * from tb_shop_user where user_id=#{userId} and shop_id=#{shopId}
</select>
<select id="selectByPhoneAndShopId" resultMap="BaseResultMap">
select * from tb_shop_user where telephone=#{phone} and shop_id=#{shopId}
</select>
<select id="selectPCByPhoneAndShopId" resultMap="BaseResultMap">
select * from tb_shop_user where telephone=#{phone} and shop_id=#{shopId} and user_id is null
</select>
<select id="selectAllByUserId" resultMap="BaseResultMap">
select * from tb_shop_user where user_id=#{userId}
</select>
<select id="selectVipByUserId" resultMap="BaseResultMap">
select * from tb_shop_user where user_id=#{userId} and is_vip = 1
</select>
<select id="countAmount" resultType="BigDecimal">
select sum(amount) from tb_shop_user where user_id=#{userId} and is_vip = 1
</select>
<select id="selectByOpenId" resultType="com.chaozhanggui.system.cashierservice.entity.TbShopUser">
select * from tb_shop_user where mini_open_id = #{openId}
</select>
<select id="selectParams" resultType="com.chaozhanggui.system.cashierservice.entity.TbParams">
select * from tb_params where id = 1
</select>
<select id="selectByUserId" resultType="com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo">
SELECT
u.id as memberId,
i.id as shopId,
i.shop_name as shopName,
i.chain_name as chainName,
i.logo,
i.detail,
u.level_consume as levelConsume,
u.amount,
u.`code`,
u.is_vip as isVip
FROM
tb_shop_user u
left join tb_shop_info i on u.shop_id=i.id
WHERE
u.user_id = #{userId}
and is_vip = 1
<if test="shopId != null and shopId !=''">
and shop_id = #{shopId}
</if>
</select>
</mapper>