You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

419 lines
14 KiB

<?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="cc.hiver.mall.dao.mapper.CustomerMapper">
<resultMap id="BaseResultMap" type="cc.hiver.mall.entity.Customer">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="sex" jdbcType="VARCHAR" property="sex" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="address" jdbcType="VARCHAR" property="address" />
<result column="province" jdbcType="VARCHAR" property="province" />
<result column="city" jdbcType="VARCHAR" property="city" />
<result column="area" jdbcType="VARCHAR" property="area" />
<result column="shop_id" jdbcType="VARCHAR" property="shopId" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
</resultMap>
<resultMap id="DebtResultMap" type="cc.hiver.mall.pojo.dto.DebtCustomer">
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="nickname" jdbcType="VARCHAR" property="nickname" />
<result column="no_earn" jdbcType="DECIMAL" property="no_earn" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, create_by, create_time, del_flag, update_by, update_time, name, sex, phone, address,
province, city, area, shop_id, user_id
</sql>
<select id="selectByExample" parameterType="cc.hiver.mall.entity.CustomerExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_customer
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_customer
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from t_customer
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="cc.hiver.mall.entity.CustomerExample">
delete from t_customer
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="cc.hiver.mall.entity.Customer">
insert into t_customer (id, create_by, create_time,
del_flag, update_by, update_time,
name, sex, phone, address,
province, city, area,
shop_id, user_id)
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP},
#{name,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR},
#{province,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, #{area,jdbcType=VARCHAR},
#{shopId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="cc.hiver.mall.entity.Customer">
insert into t_customer
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="delFlag != null">
del_flag,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="name != null">
name,
</if>
<if test="sex != null">
sex,
</if>
<if test="phone != null">
phone,
</if>
<if test="address != null">
address,
</if>
<if test="province != null">
province,
</if>
<if test="city != null">
city,
</if>
<if test="area != null">
area,
</if>
<if test="shopId != null">
shop_id,
</if>
<if test="userId != null">
user_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=INTEGER},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="sex != null">
#{sex,jdbcType=VARCHAR},
</if>
<if test="phone != null">
#{phone,jdbcType=VARCHAR},
</if>
<if test="address != null">
#{address,jdbcType=VARCHAR},
</if>
<if test="province != null">
#{province,jdbcType=VARCHAR},
</if>
<if test="city != null">
#{city,jdbcType=VARCHAR},
</if>
<if test="area != null">
#{area,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
#{shopId,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="cc.hiver.mall.entity.CustomerExample" resultType="java.lang.Long">
select count(*) from t_customer
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_customer
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.delFlag != null">
del_flag = #{record.delFlag,jdbcType=INTEGER},
</if>
<if test="record.updateBy != null">
update_by = #{record.updateBy,jdbcType=VARCHAR},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.sex != null">
sex = #{record.sex,jdbcType=VARCHAR},
</if>
<if test="record.phone != null">
phone = #{record.phone,jdbcType=VARCHAR},
</if>
<if test="record.address != null">
address = #{record.address,jdbcType=VARCHAR},
</if>
<if test="record.province != null">
province = #{record.province,jdbcType=VARCHAR},
</if>
<if test="record.city != null">
city = #{record.city,jdbcType=VARCHAR},
</if>
<if test="record.area != null">
area = #{record.area,jdbcType=VARCHAR},
</if>
<if test="record.shopId != null">
shop_id = #{record.shopId,jdbcType=VARCHAR},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_customer
set id = #{record.id,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
del_flag = #{record.delFlag,jdbcType=INTEGER},
update_by = #{record.updateBy,jdbcType=VARCHAR},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
name = #{record.name,jdbcType=VARCHAR},
sex = #{record.sex,jdbcType=VARCHAR},
phone = #{record.phone,jdbcType=VARCHAR},
address = #{record.address,jdbcType=VARCHAR},
province = #{record.province,jdbcType=VARCHAR},
city = #{record.city,jdbcType=VARCHAR},
area = #{record.area,jdbcType=VARCHAR},
shop_id = #{record.shopId,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="cc.hiver.mall.entity.Customer">
update t_customer
<set>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=INTEGER},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="sex != null">
sex = #{sex,jdbcType=VARCHAR},
</if>
<if test="phone != null">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="address != null">
address = #{address,jdbcType=VARCHAR},
</if>
<if test="province != null">
province = #{province,jdbcType=VARCHAR},
</if>
<if test="city != null">
city = #{city,jdbcType=VARCHAR},
</if>
<if test="area != null">
area = #{area,jdbcType=VARCHAR},
</if>
<if test="shopId != null">
shop_id = #{shopId,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="cc.hiver.mall.entity.Customer">
update t_customer
set create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
del_flag = #{delFlag,jdbcType=INTEGER},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
name = #{name,jdbcType=VARCHAR},
sex = #{sex,jdbcType=VARCHAR},
phone = #{phone,jdbcType=VARCHAR},
address = #{address,jdbcType=VARCHAR},
province = #{province,jdbcType=VARCHAR},
city = #{city,jdbcType=VARCHAR},
area = #{area,jdbcType=VARCHAR},
shop_id = #{shopId,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
2 years ago
<select id="selectDebtByShopId" resultMap="DebtResultMap">
select a.user_id,a.user_name as nickname,sum(a.no_earn) as no_earn
from t_sale a
where 1=1
2 years ago
and a.del_flag = '0' -- 未删除
and a.pay_status != 1
and a.status != '6' -- 待配货
and a.status != '7' -- 挂单
and a.status != '3' -- 取消订单
2 years ago
and a.shop_id = #{queryParams.shopId}
group by a.user_id,a.user_name
order by no_earn desc
</select>
2 years ago
<select id="getCustomerList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_customer a
where a.shop_id = #{queryParams.shopId}
and del_flag = #{queryParams.delFlag}
<if test=" queryParams.searchStr != null and queryParams.searchStr != ''">
AND name like concat('%',#{queryParams.searchStr},'%')
</if>
ORDER BY CASE NAME
WHEN '散客' THEN
1 ELSE 2 END
</select>
<update id="delById" parameterType="java.lang.String">
update t_customer
set del_flag ='1'
where id = #{id,jdbcType=VARCHAR}
</update>
<select id="findByUserId" resultType="java.lang.String">
select id
from t_customer a
where a.user_id = #{userId,jdbcType=VARCHAR}
</select>
<update id="updatePhone">
update t_customer
set phone = #{newMobile,jdbcType=VARCHAR}
where user_id = #{userId,jdbcType=VARCHAR}
</update>
</mapper>