From af6a6f03d3da1303b6fec2cff5dbd0fd10e8ad5c Mon Sep 17 00:00:00 2001 From: jyy <935090232@qq.com> Date: Wed, 27 Jan 2021 09:59:32 +0800 Subject: [PATCH] 1、查询产品bug 2、储值卡使用完成不设置为失效 --- zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 158 insertions(+), 10 deletions(-) diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml index da5030c..328dd6a 100644 --- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml +++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml @@ -35,6 +35,10 @@ <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"/> @@ -104,6 +108,10 @@ <!-- 扩展属性 --> <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> <!-- 查询几天内过生日的会员 --> @@ -274,7 +282,11 @@ disease, is_deal, zjm, - company_id + company_id, + province, + city, + area, + recommend_id ) @@ -318,7 +330,11 @@ #{disease}, #{isDeal}, #{zjm}, - #{companyId} + #{companyId}, + #{province}, + #{city}, + #{area}, + #{recommendId} ) </insert> @@ -445,6 +461,18 @@ <if test="isDeal != null "> is_deal = #{isDeal}, </if> + <if test="recommendId != null "> + recommend_id = #{recommendId}, + </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> </set> @@ -509,6 +537,8 @@ <include refid="from"></include> where a.ID=#{id} </select> + + <!-- 根据手机和密码查询 --> <select id="selectVipByPhonePassWord" resultMap="SysVipInfoMap"> @@ -612,14 +642,11 @@ 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 - SHOP_ID=#{shopId} - and ( - instr(PHONE,#{keyWord}) + where company_id=#{companyId} + and (instr(PHONE,#{keyWord}) or instr(VIP_NAME ,#{keyWord}) or instr(zjm ,#{keyWord}) - or instr(VIP_NO ,#{keyWord}) - ) + or instr(VIP_NO ,#{keyWord})) limit 0,15 </select> @@ -644,7 +671,7 @@ and (a.VIP_NO =#{key} or a.VIP_NAME =#{key} or - a.PHONE =#{key}) and a.shop_id=#{shopId} + a.PHONE =#{key}) </select> <select id="getLevelIdByMoney" resultMap="SysVipInfoMap"> @@ -937,12 +964,19 @@ a.create_distribution_time, a.birthdayType, a.disease, - a.is_deal + a.is_deal, + a.province, + a.city, + a.area, + a.recommend_id, + 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> @@ -1219,5 +1253,119 @@ <select id="selectVipInfoByVipNo" resultMap="SysVipInfoMapSimple"> select * from sys_vip_info where company_id=#{companyId} and vip_no=#{vipNo} </select> + + <select id="selectVipAddressBookByList" resultType="com.matrix.system.app.vo.VipInfoListVo"> + select + a.ID id, + a.VIP_NAME vipName, + 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 + <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.gift_money, 0) + IFNULL(b.real_money, 0)) totalBalance, + sum(IFNULL(b.gift_money, 0)) giftBalance, + sum(IFNULL(d.goods_cash, 0) + IFNULL(d.proj_cash, 0) + IFNULL(d.card_cash, 0)) 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 achieve_new d on a.ID = d.vip_id + left join sys_shop_info e on a.SHOP_ID=e.ID + where a.ID=#{id} + </select> </mapper> -- Gitblit v1.9.1