<?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.matrix.system.hive.dao.SysVipInfoDao">
|
|
<resultMap type="SysVipInfo" id="SysVipInfoMap">
|
<id property="id" column="ID"/>
|
<result property="vipNo" column="VIP_NO"/>
|
<result property="vipName" column="VIP_NAME"/>
|
<result property="phone" column="PHONE"/>
|
<result property="sex" column="SEX"/>
|
<result property="birthday1" column="BIRTHDAY1"/>
|
<result property="addr" column="ADDR"/>
|
<result property="constell" column="CONSTELL"/>
|
<result property="animalSign" column="ANIMAL_SIGN"/>
|
<result property="arrivalWay" column="ARRIVAL_WAY"/>
|
<result property="vipType" column="VIP_TYPE"/>
|
<result property="vipState" column="VIP_STATE"/>
|
<result property="pointAll" column="POINT_ALL"/>
|
<result property="commissionAll" column="COMMISSION_ALL"/>
|
<result property="inDate" column="IN_DATE"/>
|
<result property="remark" column="REMARK"/>
|
<result property="staffId" column="STAFF_ID"/>
|
<result property="shopId" column="SHOP_ID"/>
|
<result property="passWord" column="PASSWORD"/>
|
<result property="email" column="EMAIL"/>
|
<result property="beatuyId" column="BEATUY_ID"/>
|
<result property="createTime" column="CREATE_TIME"/>
|
<result property="levelId" column="LEVEL_ID"/>
|
<result property="uuid" column="UUID"/>
|
<result property="balance" column="BALANCE"/>
|
<result property="photo" column="photo"/>
|
<result property="openId" column="openid"/>
|
<result property="disease" column="disease"/>
|
<result property="zjm" column="zjm"/>
|
<result property="companyId" column="company_id"/>
|
<result property="province" column="province"/>
|
<result property="city" column="city"/>
|
<result property="area" column="area"/>
|
<result property="recommendId" column="recommend_id"/>
|
|
<result property="statu" column="statu"/>
|
<result property="birthdayType" column="birthdayType"/>
|
<result property="blood" column="blood"/>
|
<result property="sfCard" column="sfCard"/>
|
<result property="link" column="link"/>
|
<result property="marry" column="marry"/>
|
<result property="vocation" column="vocation"/>
|
<result property="handleTime" column="handle_time"/>
|
<result property="parentId" column="parent_id"/>
|
<result property="isDeal" column="is_deal"/>
|
<result property="createDistributionTime" column="create_distribution_time"/>
|
|
<result property="isSales" column="is_sales" />
|
<result property="withdrawalCash" column="withdrawal_cash" />
|
<result property="salesmanGrade" column="salesman_grade" />
|
<result property="nickName" column="nick_name" />
|
<result property="avatarUrl" column="avatar_url" />
|
<result property="gender" column="gender" />
|
<result property="country" column="country" />
|
<result property="sessionKey" column="session_key" />
|
<result property="userIsAuthorize" column="user_is_authorize" />
|
<result property="validFlag" column="valid_flag" />
|
|
<!-- 扩展属性 -->
|
<result property="staffName" column="STAFF_NAME"/>
|
<result property="shopName" column="SHOP_NAME"/>
|
<association property="vipLevel" column="{id=LEVEL_ID}"
|
select="com.matrix.system.hive.dao.SysVipLevelDao.selectById"></association>
|
|
<collection property="beauticains" column="{vipId=ID}"
|
select="com.matrix.system.hive.dao.MyBeaticianDao.selectByVipId"></collection>
|
</resultMap>
|
|
<resultMap type="SysVipInfo" id="SysVipInfoMapSimple">
|
<id property="id" column="ID"/>
|
<result property="vipNo" column="VIP_NO"/>
|
<result property="vipName" column="VIP_NAME"/>
|
<result property="phone" column="PHONE"/>
|
<result property="sex" column="SEX"/>
|
<result property="birthday1" column="BIRTHDAY1"/>
|
<result property="addr" column="ADDR"/>
|
<result property="constell" column="CONSTELL"/>
|
<result property="animalSign" column="ANIMAL_SIGN"/>
|
<result property="arrivalWay" column="ARRIVAL_WAY"/>
|
<result property="vipType" column="VIP_TYPE"/>
|
<result property="vipState" column="VIP_STATE"/>
|
<result property="pointAll" column="POINT_ALL"/>
|
<result property="commissionAll" column="COMMISSION_ALL"/>
|
<result property="inDate" column="IN_DATE"/>
|
<result property="remark" column="REMARK"/>
|
<result property="staffId" column="STAFF_ID"/>
|
<result property="shopId" column="SHOP_ID"/>
|
<result property="passWord" column="PASSWORD"/>
|
<result property="email" column="EMAIL"/>
|
<result property="beatuyId" column="BEATUY_ID"/>
|
<result property="createTime" column="CREATE_TIME"/>
|
<result property="levelId" column="LEVEL_ID"/>
|
<result property="uuid" column="UUID"/>
|
<result property="balance" column="BALANCE"/>
|
<result property="zjm" column="zjm"/>
|
<result property="photo" column="photo"/>
|
<result property="statu" column="statu"/>
|
<result property="blood" column="blood"/>
|
<result property="sfCard" column="sfCard"/>
|
<result property="link" column="link"/>
|
<result property="marry" column="marry"/>
|
<result property="vocation" column="vocation"/>
|
<result property="openId" column="openid"/>
|
<result property="handleTime" column="handle_time"/>
|
<result property="parentId" column="parent_id"/>
|
<result property="isDeal" column="is_deal"/>
|
<result property="birthdayType" column="birthdayType"/>
|
<result property="createDistributionTime" column="create_distribution_time"/>
|
<result property="disease" column="disease"/>
|
<result property="companyId" column="company_id"/>
|
|
<result property="isSales" column="is_sales" />
|
<result property="withdrawalCash" column="withdrawal_cash" />
|
<result property="salesmanGrade" column="salesman_grade" />
|
<result property="nickName" column="nick_name" />
|
<result property="avatarUrl" column="avatar_url" />
|
<result property="gender" column="gender" />
|
<result property="country" column="country" />
|
<result property="sessionKey" column="session_key" />
|
<result property="userIsAuthorize" column="user_is_authorize" />
|
<result property="validFlag" column="valid_flag" />
|
|
<!-- 扩展属性 -->
|
<result property="staffName" column="STAFF_NAME"/>
|
<result property="shopName" column="SHOP_NAME"/>
|
<association property="vipLevel" javaType="com.matrix.system.hive.bean.SysVipLevel" >
|
<result property="levelName" column="levelName"/>
|
<result property="vipLevel" column="vipLevel"/>
|
</association>
|
</resultMap>
|
|
<!-- 查询几天内过生日的会员 -->
|
<select id="selectByBirthday" resultMap="SysVipInfoMapSimple">
|
select
|
ID,VIP_NO,VIP_NAME,PHONE,SEX,BIRTHDAY1,disease,is_deal,
|
ADDR,CONSTELL,ANIMAL_SIGN,ARRIVAL_WAY,VIP_TYPE,VIP_STATE,POINT_ALL,
|
COMMISSION_ALL,IN_DATE,STAFF_ID,SHOP_ID,IS_DELETE,REMARK,PASSWORD,
|
EMAIL,CREATE_TIME,UUID,BALANCE,blood,sfCard,link,marry,vocation,handleTime from
|
sys_vip_info
|
WHERE company_id=#{companyId} and IS_DELETE = 'N'
|
and (STAFF_ID = #{staffId} or BEATUY_ID = #{staffId})
|
AND datediff(date_add(concat(
|
date_format(BIRTHDAY1, "%Y"),
|
date_format(curdate(), "%m%d")
|
),INTERVAL #{day} DAY),BIRTHDAY1) BETWEEN 0 AND #{day}
|
OR
|
datediff(date_add(concat(
|
date_format(BIRTHDAY1, "%Y"),
|
date_format(curdate(), "%m%d")
|
),INTERVAL #{day} DAY),BIRTHDAY1) >=365
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
<select id="selectByBirthdayCount" resultType="java.lang.Integer">
|
select count(*) from
|
sys_vip_info
|
WHERE
|
company_id=#{companyId} and IS_DELETE = 'N'
|
AND (STAFF_ID = #{staffId} or BEATUY_ID = #{staffId})
|
AND datediff(date_add(concat(
|
date_format(BIRTHDAY1, "%Y"),
|
date_format(curdate(), "%m%d")
|
),INTERVAL #{day} DAY),BIRTHDAY1) BETWEEN 0 AND #{day}
|
OR
|
datediff(date_add(concat(
|
date_format(BIRTHDAY1, "%Y"),
|
date_format(curdate(), "%m%d")
|
),INTERVAL #{day} DAY),BIRTHDAY1) >=365;
|
</select>
|
|
<!-- 查询几天内存在跟进的会员 -->
|
<select id="selectByServiceRocord" resultMap="SysVipInfoMapSimple">
|
select a.* from
|
sys_vip_info a
|
LEFT JOIN service_record b ON a.ID
|
= b.vip_id
|
WHERE company_id=#{companyId} and a.IS_DELETE = 'N'
|
and (a.STAFF_ID = #{staffId} or a.BEATUY_ID = #{staffId})
|
AND b.follow_time BETWEEN curdate()
|
AND
|
date_add(curdate(), INTERVAL #{day} DAY)
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<select id="selectByServiceRocordCount" resultType="java.lang.Integer">
|
select count(*) from
|
sys_vip_info a
|
LEFT JOIN service_record b ON a.ID
|
= b.vip_id
|
WHERE
|
company_id=#{companyId}
|
and a.IS_DELETE = 'N'
|
and
|
(a.STAFF_ID = #{staffId} or a.BEATUY_ID = #{staffId})
|
AND b.follow_time BETWEEN curdate()
|
AND
|
date_add(curdate(), INTERVAL #{day} DAY)
|
</select>
|
|
<!-- 查询几天内存在预约的会员 -->
|
<select id="selectByProjService" resultMap="SysVipInfoMapSimple">
|
select a.* FROM
|
sys_vip_info a
|
LEFT JOIN sys_proj_services b ON a.ID = b.VIP_ID
|
WHERE
|
company_id=#{companyId}
|
and a.IS_DELETE = 'N'
|
and
|
(a.STAFF_ID = #{staffId} or a.BEATUY_ID = #{staffId})
|
AND b.YY_TIME BETWEEN curdate()
|
AND date_add(curdate(), INTERVAL #{day} DAY)
|
AND (b.STATE = '预约成功待处理' or b.STATE = '待预约')
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<select id="selectByProjServiceCount" resultType="java.lang.Integer">
|
select count(*) FROM
|
sys_vip_info a
|
|
LEFT JOIN sys_proj_services b ON a.ID = b.VIP_ID
|
WHERE
|
company_id=#{companyId}
|
and a.IS_DELETE = 'N'
|
and
|
(a.STAFF_ID = #{staffId} or a.BEATUY_ID = #{staffId})
|
AND b.YY_TIME BETWEEN curdate()
|
AND date_add(curdate(), INTERVAL #{day} DAY)
|
AND (b.STATE = '预约成功待处理' or b.STATE = '待预约')
|
</select>
|
|
<!-- 插入方法 -->
|
<insert id="insert" parameterType="SysVipInfo" useGeneratedKeys="true"
|
keyProperty="id">
|
<selectKey resultType="Long" order="AFTER" keyProperty="id">
|
SELECT LAST_INSERT_ID() AS ID
|
</selectKey>
|
INSERT INTO sys_vip_info (
|
ID,
|
VIP_NO,
|
VIP_NAME,
|
PHONE,
|
SEX,
|
BIRTHDAY1,
|
ADDR,
|
CONSTELL,
|
ANIMAL_SIGN,
|
ARRIVAL_WAY,
|
VIP_TYPE,
|
VIP_STATE,
|
POINT_ALL,
|
COMMISSION_ALL,
|
IN_DATE,
|
STAFF_ID,
|
SHOP_ID,
|
IS_DELETE,
|
REMARK,
|
PASSWORD,
|
EMAIL,
|
CREATE_TIME,
|
UUID,
|
BALANCE,
|
photo,
|
LEVEL_ID,
|
openid,
|
BEATUY_ID,
|
blood,
|
sfCard,
|
link,
|
marry,
|
vocation,
|
parent_id,
|
create_distribution_time,
|
birthdayType,
|
disease,
|
is_deal,
|
zjm,
|
company_id,
|
province,
|
city,
|
area,
|
recommend_id,
|
is_sales,
|
withdrawal_cash,
|
salesman_grade,
|
nick_name,
|
avatar_url,
|
gender,
|
country,
|
session_key,
|
user_is_authorize
|
)
|
|
|
VALUES (
|
#{id},
|
#{vipNo},
|
#{vipName},
|
#{phone},
|
#{sex},
|
#{birthday1},
|
#{addr},
|
#{constell},
|
#{animalSign},
|
#{arrivalWay},
|
#{vipType},
|
#{vipState},
|
#{pointAll},
|
#{commissionAll},
|
#{inDate},
|
#{staffId},
|
#{shopId},
|
#{isDelete},
|
#{remark},
|
#{passWord},
|
#{email},
|
#{createTime},
|
#{uuid},
|
#{balance},
|
#{photo},
|
#{levelId},
|
#{openId},
|
#{beatuyId},
|
#{blood},
|
#{sfCard},
|
#{link},
|
#{marry},
|
#{vocation},
|
#{parentId},
|
#{createDistributionTime},
|
#{birthdayType},
|
#{disease},
|
#{isDeal},
|
#{zjm},
|
#{companyId},
|
#{province},
|
#{city},
|
#{area},
|
#{recommendId},
|
#{isSales},
|
#{withdrawalCash},
|
#{salesmanGrade},
|
#{nickName},
|
#{avatarUrl},
|
#{gender},
|
#{country},
|
#{sessionKey},
|
#{userIsAuthorize}
|
)
|
|
</insert>
|
|
<!-- 根据id更新 部分更新 -->
|
<update id="update">
|
UPDATE sys_vip_info
|
<set>
|
<if test="vipNo != null and vipNo !='' ">
|
VIP_NO = #{vipNo},
|
</if>
|
<if test="vipName != null and vipName !='' ">
|
VIP_NAME = #{vipName},
|
</if>
|
<if test="zjm != null and zjm !='' ">
|
zjm = #{zjm},
|
</if>
|
<if test="phone != null and phone !='' ">
|
PHONE = #{phone},
|
</if>
|
<if test="sex != null and sex !='' ">
|
SEX = #{sex},
|
</if>
|
<if test="birthday1 != null ">
|
BIRTHDAY1 = #{birthday1},
|
</if>
|
<if test="addr != null and addr !='' ">
|
ADDR = #{addr},
|
</if>
|
<if test="constell != null and constell !='' ">
|
CONSTELL = #{constell},
|
</if>
|
<if test="animalSign != null and animalSign !='' ">
|
ANIMAL_SIGN = #{animalSign},
|
</if>
|
<if test="arrivalWay != null and arrivalWay !='' ">
|
ARRIVAL_WAY = #{arrivalWay},
|
</if>
|
<if test="vipType != null and vipType !='' ">
|
VIP_TYPE = #{vipType},
|
</if>
|
<if test="vipState != null and vipState !='' ">
|
VIP_STATE = #{vipState},
|
</if>
|
<if test="pointAll != null or pointAll == 0 ">
|
POINT_ALL = #{pointAll},
|
</if>
|
<if test="commissionAll != null or commissionAll == 0 ">
|
COMMISSION_ALL = #{commissionAll},
|
</if>
|
<if test="inDate != null ">
|
IN_DATE = #{inDate},
|
</if>
|
<if test="remark != null and remark !='' ">
|
REMARK = #{remark},
|
</if>
|
<if test="staffId != null and staffId !='' ">
|
STAFF_ID = #{staffId},
|
</if>
|
<if test="shopId != null and shopId !='' ">
|
SHOP_ID = #{shopId},
|
</if>
|
<if test="isDelete != null and isDelete !='' ">
|
IS_DELETE = #{isDelete},
|
</if>
|
<if test="passWord != null and passWord !='' ">
|
PASSWORD = #{passWord},
|
</if>
|
<if test="email != null and email !='' ">
|
EMAIL = #{email},
|
</if>
|
<if test="uuid != null and uuid !='' ">
|
UUID = #{uuid},
|
</if>
|
<if test="balance != null or balance==0">
|
BALANCE = #{balance},
|
</if>
|
<if test="levelId != null ">
|
LEVEL_ID = #{levelId},
|
</if>
|
<if test="photo != null and photo !='' ">
|
photo = #{photo},
|
</if>
|
<if test="openId != null and openId !='' ">
|
openId = #{openId},
|
</if>
|
<if test="beatuyId != null and beatuyId !='' ">
|
BEATUY_ID = #{beatuyId},
|
</if>
|
<if test="blood != null and blood !='' ">
|
blood = #{blood},
|
</if>
|
<if test="sfCard != null and sfCard !='' ">
|
sfCard = #{sfCard},
|
</if>
|
<if test="link != null and link !='' ">
|
link = #{link},
|
</if>
|
<if test="marry != null and marry !='' ">
|
marry = #{marry},
|
</if>
|
<if test="vocation != null and vocation !='' ">
|
vocation = #{vocation},
|
</if>
|
<if test="handleTime != null ">
|
handle_time = #{handleTime},
|
</if>
|
<if test="statu != null and statu !='' ">
|
statu = #{statu},
|
</if>
|
|
<if test="parentId != null and parentId !='' ">
|
parent_id = #{parentId},
|
</if>
|
<if test="createDistributionTime != null ">
|
create_distribution_time = #{createDistributionTime},
|
</if>
|
<if test="birthdayType != null ">
|
birthdayType = #{birthdayType},
|
</if>
|
<if test="disease != null ">
|
disease = #{disease},
|
</if>
|
<if test="isDeal != null ">
|
is_deal = #{isDeal},
|
</if>
|
|
<if test="province != null and province !='' ">
|
province = #{province},
|
</if>
|
<if test="city != null and city !='' ">
|
city = #{city},
|
</if>
|
<if test="area != null and area !='' ">
|
area = #{area},
|
</if>
|
<if test="isSales != null ">
|
is_sales = #{isSales},
|
</if>
|
<if test="withdrawalCash != null ">
|
withdrawal_cash = #{withdrawalCash},
|
</if>
|
<if test="salesmanGrade != null ">
|
salesman_grade = #{salesmanGrade},
|
</if>
|
|
<if test="gender != null and gender != '' ">
|
gender = #{gender},
|
</if>
|
<if test="country != null and country != '' ">
|
country = #{country},
|
</if>
|
<if test="sessionKey != null and sessionKey != '' ">
|
session_key = #{sessionKey},
|
</if>
|
<if test="userIsAuthorize != null ">
|
user_is_authorize = #{userIsAuthorize},
|
</if>
|
<if test="nickName != null and nickName != '' ">
|
nick_name = #{nickName},
|
</if>
|
<if test="avatarUrl != null and avatarUrl != '' ">
|
avatar_url = #{avatarUrl},
|
</if>
|
<if test="validFlag != null and validFlag != '' ">
|
valid_flag = #{validFlag},
|
</if>
|
|
|
</set>
|
WHERE ID=#{id}
|
</update>
|
<!-- 积分清空 -->
|
<update id="pointClose">
|
UPDATE sys_vip_info set POINT_ALL = 0
|
</update>
|
|
<update id="unbundlingSaleMan">
|
UPDATE sys_vip_info set recommend_id = NULL where id=#{userId};
|
</update>
|
<update id="bindingRecommend">
|
UPDATE sys_vip_info set recommend_id = #{recommendId} where id=#{userId};
|
</update>
|
|
<!-- 批量删除 -->
|
<delete id="deleteByIds" parameterType="java.util.List">
|
delete from sys_vip_info where ID in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<update id="deleteLogicByIds" parameterType="java.util.List">
|
UPDATE sys_vip_info set IS_DELETE = 'Y' where ID in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</update>
|
|
<!-- 根据id删除 -->
|
<delete id="deleteById">
|
DELETE FROM sys_vip_info
|
where ID=#{id}
|
</delete>
|
|
|
|
<!-- 分页查询 -->
|
<select id="selectInPage" resultMap="SysVipInfoMapSimple">
|
<include refid="select"></include>
|
<include refid="from"></include>
|
<include refid="where"></include>
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<select id="selectAll" resultMap="SysVipInfoMapSimple">
|
<include refid="select"></include>
|
<include refid="from"></include>
|
<include refid="where"></include>
|
</select>
|
|
<!-- 查询总条数 -->
|
<select id="selectTotalRecord" resultType="java.lang.Integer">
|
select count(*)
|
<include refid="from"></include>
|
<include refid="where"></include>
|
</select>
|
|
|
<!-- 根据id查询 -->
|
<select id="selectById" resultMap="SysVipInfoMap">
|
<include refid="select"></include>
|
<include refid="from"></include>
|
where a.ID=#{id}
|
</select>
|
|
<select id="findByOpenId" resultMap="SysVipInfoMap">
|
select *
|
from sys_vip_info where openid=#{openId} and IS_DELETE = 'N'
|
</select>
|
|
<!-- 根据手机和密码查询 -->
|
<select id="selectVipByPhonePassWord" resultMap="SysVipInfoMap">
|
<include refid="select"></include>
|
<include refid="from"></include>
|
where a.company_id=#{record.companyId} and a.PHONE =#{record.phone} and a.PASSWORD = #{record.passWord}
|
</select>
|
<!-- 判断是否为唯一 -->
|
<select id="selectTotalByField" resultType="java.lang.Integer">
|
select count(*) from
|
sys_vip_info where ${field} = #{value} and IS_DELETE = 'N'
|
</select>
|
|
<!-- 根据对象查询 -->
|
<select id="findListByVo" resultMap="SysVipInfoMap">
|
select
|
DISTINCT a.ID,
|
a.VIP_NO,
|
a.VIP_NAME,
|
a.PHONE,
|
a.SEX,
|
a.BIRTHDAY1,
|
a.photo,
|
a.ADDR,
|
a.CONSTELL,
|
a.ANIMAL_SIGN,
|
a.ARRIVAL_WAY,
|
a.VIP_TYPE,
|
a.VIP_STATE,
|
a.POINT_ALL,
|
a.COMMISSION_ALL,
|
a.IN_DATE,
|
a.REMARK,
|
a.SHOP_ID,
|
a.IS_DELETE,
|
a.PASSWORD,
|
a.EMAIL,
|
a.STAFF_ID,
|
a.CREATE_TIME,
|
a.LEVEL_ID,
|
a.UUID,
|
a.openid,
|
a.BALANCE,
|
a.BEATUY_ID,
|
c.su_name as STAFF_NAME,
|
d.SHOP_NAME,
|
a.blood,
|
a.sfCard,
|
a.link,
|
a.marry,
|
a.vocation,
|
a.statu,
|
a.disease,
|
a.is_deal
|
from sys_vip_info a
|
left join sys_users c on c.su_id =a.STAFF_ID
|
left join sys_shop_info d ON d.ID=a.SHOP_ID
|
LEFT JOIN my_beatician e on e.vip_id = a.id
|
<include refid="whereVo"></include>
|
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<select id="findListByVoCount" resultType="java.lang.Integer">
|
select count(DISTINCT a.ID)
|
from sys_vip_info a
|
left join sys_users c on c.su_id =a.STAFF_ID
|
left join sys_shop_info d ON d.ID=a.SHOP_ID
|
LEFT JOIN my_beatician e on e.vip_id = a.id
|
<include refid="whereVo"></include>
|
</select>
|
|
|
<!-- 根据电话号码模糊查询 -->
|
<select id="selectUserByPhoto" resultMap="SysVipInfoMapSimple">
|
select ID,disease,is_deal,
|
ID,VIP_NO,VIP_NAME,PHONE,SEX,BIRTHDAY1,photo,
|
ADDR,CONSTELL,ANIMAL_SIGN,ARRIVAL_WAY,VIP_TYPE,VIP_STATE,POINT_ALL,
|
COMMISSION_ALL,IN_DATE,STAFF_ID,SHOP_ID,IS_DELETE,REMARK,PASSWORD,
|
EMAIL,CREATE_TIME,UUID,BALANCE
|
from sys_vip_info where
|
company_id=#{companyId} and IS_DELETE = 'N'
|
and PHONE like concat('%',#{keyWord},'%') limit 0,10
|
|
</select>
|
|
<!-- 根据电话号码模糊查询 -->
|
<select id="selectUserByKey" resultMap="SysVipInfoMapSimple">
|
select ID,disease,is_deal,
|
ID,VIP_NO,VIP_NAME,PHONE,SEX,BIRTHDAY1,photo,
|
ADDR,CONSTELL,ANIMAL_SIGN,ARRIVAL_WAY,VIP_TYPE,VIP_STATE,POINT_ALL,
|
COMMISSION_ALL,IN_DATE,STAFF_ID,SHOP_ID,IS_DELETE,REMARK,PASSWORD,
|
EMAIL,CREATE_TIME,UUID,BALANCE,blood,sfCard,link,marry,vocation
|
from sys_vip_info
|
where company_id=#{companyId} and IS_DELETE = 'N'
|
and (instr(PHONE,#{keyWord})
|
or instr(VIP_NAME ,#{keyWord})
|
or instr(zjm ,#{keyWord})
|
or instr(VIP_NO ,#{keyWord}))
|
limit 0,15
|
</select>
|
|
|
<!-- 根据对象查询 -->
|
<select id="selectByModel" resultMap="SysVipInfoMap">
|
<include refid="select"></include>
|
<include refid="from"></include>
|
<include refid="where"></include>
|
</select>
|
|
<select id="selectByModel1" resultMap="SysVipInfoMap">
|
<include refid="select"></include>
|
<include refid="from"></include>
|
<include refid="where1"></include>
|
</select>
|
|
<select id="selectByVipNoOrTel" resultMap="SysVipInfoMap">
|
<include refid="select"></include>
|
<include refid="from"></include>
|
where 1=1
|
and a.IS_DELETE = 'N'
|
and
|
(a.VIP_NO =#{key} or
|
a.VIP_NAME =#{key} or
|
a.PHONE =#{key})
|
</select>
|
|
<select id="getLevelIdByMoney" resultMap="SysVipInfoMap">
|
|
SELECT * from sys_vip_level where FUND_MIN <![CDATA[ <= ]]>
|
#{fundMin}
|
ORDER BY FUND_MIN DESC
|
</select>
|
|
<sql id="whereVo">
|
<where>
|
a.IS_DELETE = 'N'
|
<if test="record!=null">
|
<if test="record.keyWord != null and record.keyWord !='' ">
|
and (a.VIP_NO like CONCAT('%',#{record.keyWord},'%') or
|
a.PHONE like CONCAT('%',#{record.keyWord},'%') or
|
a.VIP_NAME like
|
CONCAT('%',#{record.keyWord},'%') )
|
</if>
|
<if test="record.shopId != null and record.shopId !='' ">
|
and a.SHOP_ID = #{record.shopId}
|
</if>
|
<if test="record.jkgwId != null and record.jkgwId !='' ">
|
and a.STAFF_ID = #{record.jkgwId}
|
</if>
|
<if test="record.mlsId != null and record.mlsId !='' ">
|
and e.beauticain_id = #{record.mlsId}
|
</if>
|
<if test="record.levelId != null and record.levelId !='' ">
|
and a.LEVEL_ID = #{record.levelId}
|
</if>
|
<if test="record.vipState != null and record.vipState!='' ">
|
and a.VIP_STATE = #{record.vipState}
|
</if>
|
<if test="(record.companyId!=null and record.companyId!='') ">
|
and a.company_id = #{record.companyId}
|
</if>
|
</if>
|
</where>
|
</sql>
|
|
<sql id="where">
|
where 1=1 and a.IS_DELETE = 'N'
|
<if test="record!=null">
|
<if test="record.id != null and record.id !='' ">
|
and a.ID = #{record.id}
|
</if>
|
<!-- 根据编号 -->
|
<if test="record.vipNo != null and record.vipNo !='' ">
|
and a.VIP_NO like CONCAT('%',#{record.vipNo},'%')
|
</if>
|
<!-- 根据姓名 -->
|
<if test="record.vipName != null and record.vipName !='' ">
|
and (instr(a.VIP_NAME ,#{record.vipName}) or instr(a.zjm ,#{record.vipName}))
|
</if>
|
<if test="record.phone != null and record.phone !='' ">
|
and a.PHONE like CONCAT('%',#{record.phone},'%')
|
</if>
|
<if test="record.sex != null and record.sex !='' ">
|
and a.SEX = #{record.sex}
|
</if>
|
<if test="record.birthday1 != null ">
|
and a.BIRTHDAY1 = #{record.birthday1}
|
</if>
|
<if test="record.addr != null and record.addr !='' ">
|
and a.ADDR = #{record.addr}
|
</if>
|
<if test="record.constell != null and record.constell !='' ">
|
and a.CONSTELL = #{record.constell}
|
</if>
|
<if test="record.animalSign != null and record.animalSign !='' ">
|
and a.ANIMAL_SIGN = #{record.animalSign}
|
</if>
|
<if test="record.arrivalWay != null and record.arrivalWay !='' ">
|
and a.ARRIVAL_WAY = #{record.arrivalWay}
|
</if>
|
<if test="record.vipType != null and record.vipType !='' ">
|
and a.VIP_TYPE = #{record.vipType}
|
</if>
|
<if test="record.vipState != null and record.vipState !='' ">
|
and a.VIP_STATE = #{record.vipState}
|
</if>
|
<if test="record.pointAll != null or record.pointAll==0 ">
|
and a.POINT_ALL = #{record.pointAll}
|
</if>
|
<if test="record.commissionAll != null and record.commissionAll !='' ">
|
and a.COMMISSION_ALL = #{record.commissionAll}
|
</if>
|
<if test="record.inDate != null ">
|
and a.IN_DATE like CONCAT('%',#{record.inDate},'%')
|
</if>
|
<if test="record.remark != null and record.remark !='' ">
|
and a.REMARK like CONCAT('%',#{record.remark},'%')
|
</if>
|
<if test="record.staffId != null and record.staffId !='' ">
|
and a.STAFF_ID = #{record.staffId}
|
</if>
|
<if test="record.shopId != null and record.shopId !='' ">
|
and a.SHOP_ID = #{record.shopId}
|
</if>
|
<if test="record.isDelete != null and record.isDelete !='' ">
|
and a.IS_DELETE = #{record.isDelete}
|
</if>
|
<if test="record.passWord != null and record.passWord !='' ">
|
and a.PASSWORD = #{record.passWord}
|
</if>
|
<if test="record.email != null and record.email !='' ">
|
and a.EMAIL = #{record.email}
|
</if>
|
<if test="record.uuid != null and record.uuid !='' ">
|
and a.UUID = #{record.uuid}
|
</if>
|
<if test="record.balance != null and record.balance !='' ">
|
and a.BALANCE = #{record.balance}
|
</if>
|
<if test="record.openId != null and record.openId !='' ">
|
and a.openid = #{record.openId}
|
</if>
|
<if test="record.blood != null and record.blood !='' ">
|
and a.blood = #{record.blood}
|
</if>
|
<if test="record.sfCard != null and record.sfCard !='' ">
|
and a.sfCard = #{record.sfCard}
|
</if>
|
<if test="record.link != null and record.link !='' ">
|
and a.link = #{record.link}
|
</if>
|
<if test="record.marry != null and record.marry !='' ">
|
and a.marry = #{record.marry}
|
</if>
|
<if test="record.vocation != null and record.vocation !='' ">
|
and a.vocation = #{record.vocation}
|
</if>
|
<if test="record.statu != null and record.statu !='' ">
|
and a.statu = #{record.statu}
|
</if>
|
<if test="record.isDeal != null and record.isDeal !='' ">
|
and a.is_deal = #{record.isDeal}
|
</if>
|
<if test="(record.companyId!=null and record.companyId!='') ">
|
and a.company_id = #{record.companyId}
|
</if>
|
|
<if test="(record.nickName!=null and record.nickName!='') or (record.nickName!='' and record.nickName==0) ">
|
and a.nick_name like concat('%',#{record.nickName},'%')
|
</if>
|
<if test="(record.avatarUrl!=null and record.avatarUrl!='') or (record.avatarUrl!='' and record.avatarUrl==0) ">
|
and a.avatar_url = #{record.avatarUrl}
|
</if>
|
<if test="record.isSales != null and record.isSales !='' ">
|
and a.is_sales = #{record.isSales}
|
</if>
|
|
<if test="record.withdrawalCash != null and record.withdrawalCash !='' ">
|
and a.withdrawal_cash = #{record.withdrawalCash}
|
</if>
|
|
<if test="record.salesmanGrade != null and record.salesmanGrade !='' ">
|
and a.salesman_grade = #{record.salesmanGrade}
|
</if>
|
<if test="(record.userIsAuthorize!=null and record.userIsAuthorize!='') or (record.userIsAuthorize!='' and record.userIsAuthorize==0) ">
|
and a.user_is_authorize = #{record.userIsAuthorize}
|
</if>
|
|
</if>
|
</sql>
|
|
|
<sql id="where1">
|
where 1=1
|
<if test="record!=null">
|
<if test="record.id != null and record.id !='' ">
|
and a.ID = #{record.id}
|
</if>
|
<!-- 根据编号 -->
|
<if test="record.vipNo != null and record.vipNo !='' ">
|
and a.VIP_NO = #{record.vipNo}
|
</if>
|
<!-- 根据姓名 -->
|
<if test="record.vipName != null and record.vipName !='' ">
|
and (instr(a.VIP_NAME ,#{record.vipName}) or instr(a.zjm ,#{record.vipName}))
|
</if>
|
|
<if test="record.phone != null and record.phone !='' ">
|
and a.PHONE =#{record.phone}
|
</if>
|
|
<if test="record.sex != null and record.sex !='' ">
|
and a.SEX = #{record.sex}
|
</if>
|
<if test="record.birthday1 != null ">
|
and a.BIRTHDAY1 = #{record.birthday1}
|
</if>
|
<if test="record.addr != null and record.addr !='' ">
|
and a.ADDR = #{record.addr}
|
</if>
|
<if test="record.constell != null and record.constell !='' ">
|
and a.CONSTELL = #{record.constell}
|
</if>
|
<if test="record.animalSign != null and record.animalSign !='' ">
|
and a.ANIMAL_SIGN = #{record.animalSign}
|
</if>
|
<if test="record.arrivalWay != null and record.arrivalWay !='' ">
|
and a.ARRIVAL_WAY = #{record.arrivalWay}
|
</if>
|
<if test="record.vipType != null and record.vipType !='' ">
|
and a.VIP_TYPE = #{record.vipType}
|
</if>
|
<if test="record.vipState != null and record.vipState !='' ">
|
and a.VIP_STATE = #{record.vipState}
|
</if>
|
<if test="(record.companyId!=null and record.companyId!='') ">
|
and a.company_id = #{record.companyId}
|
</if>
|
<if test="record.pointAll != null or record.pointAll==0 ">
|
and a.POINT_ALL = #{record.pointAll}
|
</if>
|
<if test="record.commissionAll != null and record.commissionAll !='' ">
|
and a.COMMISSION_ALL = #{record.commissionAll}
|
</if>
|
<if test="record.inDate != null ">
|
and a.IN_DATE like CONCAT('%',#{record.inDate},'%')
|
</if>
|
<if test="record.remark != null and record.remark !='' ">
|
and a.REMARK like CONCAT('%',#{record.remark},'%')
|
</if>
|
<if test="record.staffId != null and record.staffId !='' ">
|
and a.STAFF_ID = #{record.staffId}
|
</if>
|
<if test="record.shopId != null and record.shopId !='' ">
|
and a.SHOP_ID = #{record.shopId}
|
</if>
|
<if test="record.isDelete != null and record.isDelete !='' ">
|
and a.IS_DELETE = #{record.isDelete}
|
</if>
|
<if test="record.passWord != null and record.passWord !='' ">
|
and a.PASSWORD = #{record.passWord}
|
</if>
|
<if test="record.email != null and record.email !='' ">
|
and a.EMAIL = #{record.email}
|
</if>
|
<if test="record.uuid != null and record.uuid !='' ">
|
and a.UUID = #{record.uuid}
|
</if>
|
<if test="record.balance != null and record.balance !='' ">
|
and a.BALANCE = #{record.balance}
|
</if>
|
<if test="record.statu != null and record.statu !='' ">
|
and a.statu = #{record.statu}
|
</if>
|
<if test="record.blood != null and record.blood !='' ">
|
and a.blood = #{record.blood}
|
</if>
|
<if test="record.sfCard != null and record.sfCard !='' ">
|
and a.sfCard = #{record.sfCard}
|
</if>
|
<if test="record.link != null and record.link !='' ">
|
and a.link = #{record.link}
|
</if>
|
<if test="record.marry != null and record.marry !='' ">
|
and a.marry = #{record.marry}
|
</if>
|
<if test="record.vocation != null and record.vocation !='' ">
|
and a.vocation = #{record.vocation}
|
</if>
|
|
<if test="record.isDeal != null and record.isDeal !='' ">
|
and a.is_deal = #{record.isDeal}
|
</if>
|
<if test="(record.nickName!=null and record.nickName!='') or (record.nickName!='' and record.nickName==0) ">
|
and a.nick_name like concat('%',#{record.nickName},'%')
|
</if>
|
<if test="(record.avatarUrl!=null and record.avatarUrl!='') or (record.avatarUrl!='' and record.avatarUrl==0) ">
|
and a.avatar_url = #{record.avatarUrl}
|
</if>
|
<if test="record.isSales != null and record.isSales !='' ">
|
and a.is_sales = #{record.isSales}
|
</if>
|
|
<if test="record.withdrawalCash != null and record.withdrawalCash !='' ">
|
and a.withdrawal_cash = #{record.withdrawalCash}
|
</if>
|
|
<if test="record.salesmanGrade != null and record.salesmanGrade !='' ">
|
and a.salesman_grade = #{record.salesmanGrade}
|
</if>
|
<if test="(record.userIsAuthorize!=null and record.userIsAuthorize!='') or (record.userIsAuthorize!='' and record.userIsAuthorize==0) ">
|
and a.user_is_authorize = #{record.userIsAuthorize}
|
</if>
|
</if>
|
</sql>
|
|
<sql id="select">
|
select
|
a.*,
|
c.su_name as STAFF_NAME,
|
d.SHOP_NAME,
|
e.level_name levelName,
|
e.vip_level vipLevel
|
</sql>
|
<sql id="from">
|
from sys_vip_info a
|
left join sys_users c on c.su_id =a.STAFF_ID
|
left join sys_shop_info d ON d.ID=a.SHOP_ID
|
left join sys_vip_level e on a.level_id=e.id
|
|
</sql>
|
|
<select id="automaticUpdate">
|
call vipInfoUpdate();
|
</select>
|
|
<!-- 所有分销商分页查询 -->
|
<select id="selectAllInPage" resultMap="SysVipInfoMapSimple">
|
select
|
g.*,
|
h.vip_name as name
|
from
|
(select b.* from sys_vip_info b where b.parent_id in
|
|
(select a.id from sys_vip_info a
|
|
where 1=1 and a.IS_DELETE = 'N'
|
<if test="record.parentId != null and record.parentId !='' ">
|
and a.parent_id = #{record.parentId}
|
</if>
|
) )g LEFT JOIN sys_vip_info h on g.parent_id = h.id
|
|
UNION
|
|
select
|
d.*,
|
f.vip_name as name
|
from sys_vip_info d
|
LEFT JOIN sys_vip_info f on d.parent_id = f.id
|
where 1=1 and d.IS_DELETE = 'N'
|
<if test="record.parentId != null and record.parentId !='' ">
|
and d.parent_id = #{record.parentId}
|
</if>
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<!-- 所有分销商查询总条数 -->
|
<select id="selectAllTotalRecord" resultType="java.lang.Integer">
|
select count(*)
|
from
|
(select
|
g.*,
|
h.vip_name as name
|
from
|
(select b.* from sys_vip_info b where b.parent_id in
|
|
(select a.id from sys_vip_info a
|
|
where 1=1 and a.IS_DELETE = 'N')
|
<if test="record.parentId != null and record.parentId !='' ">
|
and a.parent_id = #{record.parentId}
|
</if>
|
) )g LEFT JOIN sys_vip_info h on g.parent_id = h.id
|
|
UNION
|
|
select
|
d.*,
|
f.vip_name as name
|
from sys_vip_info d
|
LEFT JOIN sys_vip_info f on d.parent_id = f.id
|
where 1=1 and d.IS_DELETE = 'N'
|
<if test="record.parentId != null and record.parentId !='' ">
|
and d.parent_id = #{record.parentId}
|
</if>)k
|
</select>
|
|
<!-- 一级分销商分页查询 -->
|
<select id="selectFristInPage" resultMap="SysVipInfoMapSimple">
|
select
|
d.*,
|
f.vip_name as name
|
from sys_vip_info d
|
LEFT JOIN sys_vip_info f on d.parent_id = f.id
|
where 1=1 and d.IS_DELETE = 'N'
|
<if test="record.parentId != null and record.parentId !='' ">
|
and d.parent_id = #{record.parentId}
|
</if>
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<!-- 一级分销商查询总条数 -->
|
<select id="selectFristTotalRecord" resultType="java.lang.Integer">
|
select
|
count(*)
|
from sys_vip_info d
|
LEFT JOIN sys_vip_info f on d.parent_id = f.id
|
where 1=1 and d.IS_DELETE = 'N'
|
<if test="record.parentId != null and record.parentId !='' ">
|
and d.parent_id = #{record.parentId}
|
</if>
|
</select>
|
|
<!-- 二级分销商分页查询 -->
|
<select id="selectSecondInPage" resultMap="SysVipInfoMapSimple">
|
select
|
g.*,
|
h.vip_name as name
|
from
|
(select b.* from sys_vip_info b where b.parent_id in
|
|
(select a.id from sys_vip_info a
|
|
where 1=1 and a.IS_DELETE = 'N'
|
<if test="record.parentId != null and record.parentId !='' ">
|
and a.parent_id = #{record.parentId}
|
</if>
|
) )g LEFT JOIN sys_vip_info h on g.parent_id = h.id
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
<!-- 二级分销商查询总条数 -->
|
<select id="selectSecondTotalRecord" resultType="java.lang.Integer">
|
select
|
count(*)
|
from
|
(select b.* from sys_vip_info b where b.parent_id in
|
|
(select a.id from sys_vip_info a
|
|
where a.IS_DELETE = 'N')
|
<if test="record.parentId != null and record.parentId !='' ">
|
and a.parent_id = #{record.parentId}
|
</if>
|
) )g LEFT JOIN sys_vip_info h on g.parent_id = h.id
|
|
</select>
|
|
<select id="selectByPhone" resultMap="SysVipInfoMapSimple">
|
|
select * from sys_vip_info where PHONE = #{phone} and company_id=#{companyId} and IS_DELETE = 'N'
|
</select>
|
|
|
<select id="selectVipTelphoneByIds" resultType="java.lang.String">
|
select phone from sys_vip_info
|
where phone is not null and IS_DELETE = 'N' and id in
|
<foreach collection="list" index="index" item="item" open="("
|
separator="," close=")">
|
#{item}
|
</foreach>
|
</select>
|
|
<select id="selectAllVipPhone" resultType="java.lang.String">
|
select phone from sys_vip_info
|
where
|
company_id=#{companyId} and IS_DELETE = 'N'
|
and phone is not null
|
|
</select>
|
|
<select id="selectVipPhoneWithShop" resultType="java.lang.String">
|
select phone from sys_vip_info
|
where phone is not null and shop_id=#{shopId} and IS_DELETE = 'N'
|
</select>
|
|
<select id="selectOldUserByTelphone" resultMap="SysVipInfoMap">
|
select * from sys_vip_info where phone=#{telphone} and is_deal=1 and IS_DELETE = 'N'
|
</select>
|
|
|
<insert id="batchInsert" parameterType="java.util.List">
|
INSERT INTO sys_vip_info
|
(ID,
|
VIP_NO,
|
VIP_NAME,
|
PHONE,
|
SEX,
|
BIRTHDAY1,
|
ADDR,
|
CONSTELL,
|
ANIMAL_SIGN,
|
ARRIVAL_WAY,
|
VIP_TYPE,
|
VIP_STATE,
|
POINT_ALL,
|
COMMISSION_ALL,
|
IN_DATE,
|
STAFF_ID,
|
SHOP_ID,
|
IS_DELETE,
|
REMARK,
|
PASSWORD,
|
EMAIL,
|
CREATE_TIME,
|
UUID,
|
BALANCE,
|
photo,
|
LEVEL_ID,
|
openid,
|
BEATUY_ID,
|
blood,
|
sfCard,
|
link,
|
marry,
|
vocation,
|
parent_id,
|
create_distribution_time,
|
birthdayType,
|
disease,
|
is_deal,
|
zjm,
|
company_id,
|
province,
|
city,
|
area,
|
recommend_id,
|
is_sales,
|
withdrawal_cash,
|
salesman_grade,
|
nick_name,
|
avatar_url,
|
gender,
|
country,
|
session_key,
|
user_is_authorize
|
)
|
VALUES
|
<foreach collection="list" item="item" index="index" separator=",">(
|
#{item.id},
|
#{item.vipNo},
|
#{item.vipName},
|
#{item.phone},
|
#{item.sex},
|
#{item.birthday1},
|
#{item.addr},
|
#{item.constell},
|
#{item.animalSign},
|
#{item.arrivalWay},
|
#{item.vipType},
|
#{item.vipState},
|
#{item.pointAll},
|
#{item.commissionAll},
|
#{item.inDate},
|
#{item.staffId},
|
#{item.shopId},
|
#{item.isDelete},
|
#{item.remark},
|
#{item.passWord},
|
#{item.email},
|
#{item.createTime},
|
#{item.uuid},
|
#{item.balance},
|
#{item.photo},
|
#{item.levelId},
|
#{item.openId},
|
#{item.beatuyId},
|
#{item.blood},
|
#{item.sfCard},
|
#{item.link},
|
#{item.marry},
|
#{item.vocation},
|
#{item.parentId},
|
#{item.createDistributionTime},
|
#{item.birthdayType},
|
#{item.disease},
|
#{item.isDeal},
|
#{zjm},
|
#{companyId},
|
#{province},
|
#{city},
|
#{area},
|
#{recommendId},
|
#{isSales},
|
#{withdrawalCash},
|
#{salesmanGrade},
|
#{nickName},
|
#{avatarUrl},
|
#{gender},
|
#{country},
|
#{sessionKey},
|
#{userIsAuthorize}
|
)</foreach>
|
</insert>
|
|
<select id="selectVipInfoByVipNo" resultMap="SysVipInfoMapSimple">
|
select * from sys_vip_info where company_id=#{companyId} and vip_no=#{vipNo} and IS_DELETE = 'N'
|
</select>
|
|
<select id="selectVipAddressBookByList" resultType="com.matrix.system.app.vo.VipInfoListVo">
|
select
|
a.ID id,
|
a.VIP_NAME vipName,
|
a.VIP_NO vipNo,
|
a.PHONE phone,
|
a.photo photo,
|
b.arriveCnt arriveCnt,
|
g.shop_short_name shopName,
|
z.level_name vipLevel
|
from sys_vip_info a
|
left join (
|
select x.vip_id, count(1) arriveCnt from (
|
select vip_id, date_format(datatime, '%Y-%m-%d')
|
from achieve_new
|
where 1=1
|
<!-- 本月到店次数 -->
|
<if test="record.sort == 'monthArrived'">
|
and date_format(curdate(), '%Y-%m') = date_format(datatime, '%Y-%m')
|
</if>
|
<!-- 本年到店次数 -->
|
<if test="record.sort == 'yearArrived'">
|
and date_format(curdate(), '%Y') = date_format(datatime, '%Y')
|
</if>
|
group by date_format(datatime, '%Y-%m-%d'), vip_id
|
) x group by x.vip_id
|
) b on a.ID=b.vip_id
|
left join sys_vip_level z on a.level_id=z.id
|
<!-- 本月消费 -->
|
<if test="record.sort == 'used'">
|
left join (
|
select y.vip_id, sum(IFNULL(card_cash, 0) + IFNULL(proj_cash,0) + IFNULL(goods_cash, 0)) used from achieve_new y where date_format(datatime,'%Y-%m') = date_format(curdate(), '%Y-%m') group by y.vip_id
|
) c on a.id=c.vip_id
|
</if>
|
<!-- 本月消耗 -->
|
<if test="record.sort == 'consume'">
|
left join (
|
select z.vip_id, SUM(IFNULL(free_consume, 0) + IFNULL(his_consume, 0) + IFNULL(consume, 0)) consume from achieve_new z where date_format(datatime,'%Y-%m') = date_format(curdate(), '%Y-%m') group by z.vip_id
|
) d on a.ID = d.vip_id
|
</if>
|
<!-- 上次到店时间 -->
|
<if test="record.sort == 'arriveTime'">
|
left join (
|
select m.vip_id, MAX(datatime) arriveTime from achieve_new m group by m.vip_id
|
) e on a.ID=e.vip_id
|
</if>
|
<!-- 会员级别排序 -->
|
<if test="record.sort == 'vipLevel'">
|
left join (
|
select n.VIP_LEVEL vipLevel, n.ID from sys_vip_level n
|
) f on a.LEVEL_ID = f.ID
|
</if>
|
left join sys_shop_info g on a.shop_id = g.id
|
left join sys_vip_level h on a.level_id=h.id
|
where 1=1 and a.IS_DELETE = 'N'
|
<if test="record.queryKey != null and record.queryKey != ''">
|
and (instr(PHONE,#{record.queryKey})
|
or instr(VIP_NAME ,#{record.queryKey})
|
or instr(zjm ,#{record.queryKey})
|
or instr(VIP_NO ,#{record.queryKey}))
|
</if>
|
<if test="record.shopId != null">
|
and a.shop_id=#{record.shopId}
|
</if>
|
<if test="record.companyId != null">
|
and a.company_id=#{record.companyId}
|
</if>
|
<if test='record.birthType=="1"'>
|
and a.BIRTHDAY1 between curdate() and DATE_ADD(CURDATE(), INTERVAL 3 DAY)
|
</if>
|
<if test='record.birthType=="2"'>
|
and date_format(a.BIRTHDAY1, '%Y-%m') = date_format(CURDATE(), '%Y-%m')
|
</if>
|
<if test='record.birthType=="3"'>
|
and PERIOD_DIFF(date_format(now() ,'%Y-%m') , date_format(a.BIRTHDAY1, '%Y-%m')) =1
|
</if>
|
<if test="record.vipType != null">
|
and a.level_id=#{record.vipType}
|
</if>
|
<if test="record.other != null and record.other!=''">
|
and a.is_deal=#{record.other}
|
</if>
|
|
<if test="record.sort == 'monthArrived' or record.sort == 'yearArrived'">
|
order by arriveCnt ${record.order}
|
</if>
|
<if test="record.sort != 'monthArrived' and record.sort != 'yearArrived'">
|
order by ${record.sort} ${record.order}
|
</if>
|
<if test="record.offset >=0 and record.limit >0">
|
limit #{record.offset},#{record.limit}
|
</if>
|
</select>
|
|
<select id="selectVipInfoById" resultType="com.matrix.system.app.vo.VipInfoVo">
|
select
|
a.ID id,
|
a.photo photo,
|
a.PHONE phone,
|
a.VIP_NAME vipName,
|
a.VIP_NO vipNo,
|
c.LEVEL_NAME vipLevel,
|
a.POINT_ALL integral,
|
e.shop_short_name shopName,
|
sum(IFNULL(b.real_money, 0)) totalBalance,
|
sum(IFNULL(b.gift_money, 0)) giftBalance,
|
(select sum(IFNULL(d.goods_cash, 0) + IFNULL(d.proj_cash, 0) + IFNULL(d.card_cash, 0)) from achieve_new d where d.vip_id=a.id) totalShopping
|
from sys_vip_info a
|
left join money_card_use b on a.ID = b.vip_id and b.status='有效'
|
left join sys_vip_level c on a.LEVEL_ID = c.ID
|
left join sys_shop_info e on a.SHOP_ID=e.ID
|
where a.ID=#{id}
|
</select>
|
|
|
|
<select id="selectVipArrearsStatistics" resultType="java.util.Map">
|
select
|
a.VIP_NAME vipName,
|
a.PHONE phone,
|
c.shop_short_name shopName,
|
sum(b.arrears) arrears,
|
count(1) cnt,
|
d.su_name staffName
|
from sys_vip_info a
|
inner join sys_order b on a.ID=b.VIP_ID
|
inner join sys_shop_info c on a.SHOP_ID=c.ID
|
left join sys_users d on a.STAFF_ID=d.su_id
|
where b.STATU='欠款' and b.arrears!=0 and a.IS_DELETE = 'N'
|
<if test="record.companyId!=null">
|
and a.company_id=#{record.companyId}
|
</if>
|
<if test="record.shopId!=null">
|
and a.shop_id=#{record.shopId}
|
</if>
|
<if test='record.vipName!=null and record.vipName!="" '>
|
and (a.vip_name like concat('%', #{record.vipName}, '%') or a.vip_no like concat('%', #{record.vipName}, '%') or a.phone like concat('%', #{record.vipName}, '%'))
|
</if>
|
group by a.id
|
<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
|
<if test="pageVo.sort !=null and pageVo.order !=null">
|
order by
|
${pageVo.sort} ${pageVo.order}
|
</if>
|
<if test="pageVo.offset >=0 and pageVo.limit >0">
|
limit
|
#{pageVo.offset},#{pageVo.limit}
|
</if>
|
</if>
|
</select>
|
|
|
<select id="selectVipArrearsStatisticsTotal" resultType="java.lang.Integer">
|
select count(1) from (
|
select
|
a.VIP_NAME vipName,
|
a.PHONE phone,
|
c.shop_short_name shopName,
|
sum(b.arrears) arrears,
|
count(1) cnt,
|
d.su_name staffName
|
from sys_vip_info a
|
inner join sys_order b on a.ID=b.VIP_ID
|
inner join sys_shop_info c on a.SHOP_ID=c.ID
|
left join sys_users d on a.STAFF_ID=d.su_id
|
where b.STATU='欠款' and b.arrears!=0 and a.IS_DELETE = 'N'
|
<if test="record.companyId!=null">
|
and a.company_id=#{record.companyId}
|
</if>
|
<if test="record.shopId!=null">
|
and a.shop_id=#{record.shopId}
|
</if>
|
|
<if test='record.vipName!=null and record.vipName!="" '>
|
and (a.vip_name like concat('%', #{record.vipName}, '%') or a.vip_no like concat('%', #{record.vipName}, '%') or a.phone like concat('%', #{record.vipName}, '%'))
|
</if>
|
group by a.id
|
) a
|
</select>
|
</mapper>
|
|