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/SysProjServicesDao.xml |  180 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 173 insertions(+), 7 deletions(-)

diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysProjServicesDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysProjServicesDao.xml
index 1df9bcf..2b3a9aa 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysProjServicesDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysProjServicesDao.xml
@@ -38,6 +38,10 @@
 			<result property="oldShopId" column="OLD_SHOP_ID"/>
 			<result property="consumeTime" column="consume_time"/>
 			<result property="companyId" column="company_id"/>
+			<result property="comment" column="comment"/>
+			<result property="reply" column="reply"/>
+			<result property="overtimeNotice" column="overtime_notice"/>
+
 
 			
 			<result property="beautiName" column="beautiName"/>
@@ -45,6 +49,7 @@
 			<result property="shopName" column="shopName"/>
 			<result property="createStaffName" column="createStaffName"/>
 			<result property="bedName" column="bedName"/>
+			<result property="vipName" column="VIP_Name"/>
 
 			<association property="vipInfo"  resultMap="com.matrix.system.hive.dao.SysVipInfoDao.SysVipInfoMapSimple" ></association>
 
@@ -87,7 +92,10 @@
 			CHANGE_ID,
 			OLD_SHOP_ID,
 			consume_time,
-			company_id
+			company_id,
+			comment,
+			reply,
+			overtime_notice
 		)
 	VALUES (
 			#{id},
@@ -122,7 +130,10 @@
 			#{changeId},
 			#{oldShopId},
 			#{consumeTime},
-			#{companyId}
+			#{companyId},
+			#{comment},
+			#{reply},
+			#{overtimeNotice}
 	)
 		
 	</insert>
@@ -131,6 +142,18 @@
 	<update id="updateOrderTime">
 		UPDATE sys_proj_services set CREATE_TIME=#{createTime} WHERE id=#{id} 
 	</update>
+
+	<!-- 设置服务单为已通知 -->
+	<update id="updateNoticeTimes" >
+		UPDATE sys_proj_services set overtime_notice=1
+		where  ID in
+		<foreach collection="list" index="index" item="item" open="("
+				 separator="," close=")">
+			#{item}
+		</foreach>
+	</update>
+
+
 	
 	<update id="update">
 		UPDATE sys_proj_services
@@ -223,14 +246,25 @@
 					CHANGE_ID = #{changeId},
 				</if>
 				<if test="oldShopId != null and oldShopId !='' ">
-					OLD_SHOP_ID = #{oldShopId}
+					OLD_SHOP_ID = #{oldShopId},
 				</if>
 				<if test="consumeTime != null  ">
-					consume_time = #{consumeTime}
+					consume_time = #{consumeTime},
+				</if>
+
+				<if test="reply != null  ">
+					reply = #{reply},
+				</if>
+				<if test="comment != null  ">
+					comment = #{comment},
+				</if>
+				<if test="overtimeNotice != null  ">
+					overtime_notice = #{overtimeNotice},
 				</if>
 		</set>
 		WHERE id=#{id} 
 	</update>
+
 
 	<!-- 批量删除 -->
 	<delete id="deleteByIds" parameterType="java.util.List">
@@ -394,7 +428,21 @@
 		left join sys_beautician_state c on a.id=c.SERVICES_ID
 		where  a.ID=#{id}
 	</select>
-	
+
+	<select id="selectNeedNoticeService" resultMap="SysProjServicesMap">
+	select
+		a.id,
+		a.company_id,
+		b.VIP_Name
+		FROM sys_proj_services a
+		LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID
+		where   a.YY_TIME > now()
+		and DATE_ADD(now(),INTERVAL 1 HOUR) > a.YY_TIME
+		and overtime_notice is null
+	</select>
+
+
+
 	<!-- 根据对象查询-->
 	<select id="selectByModel" resultMap="SysProjServicesMap">
 		select	distinct
@@ -464,8 +512,11 @@
 		<result property="time" column="time"/>
 		<result property="bed" column="bed" />
 		<result property="vipName" column="vipName" />
+		<result property="vipId" column="vipId" />
 		<result property="timeLength" column="timeLength" />
 		<result property="status" column="status" />
+		<result property="createStaffId" column="createStaffId" />
+		<result property="shopName" column="shop_short_name" />
 		<collection property="projs" ofType="com.matrix.system.app.vo.ServiceOrderListProjVo">
 			<result property="projName" column="projName" />
 			<result property="beautyName" column="beautyName" />
@@ -481,11 +532,14 @@
 		   a.YY_TIME time,
 		   a.TOTAL_TIME timeLength,
 		   a.state status,
+		   a.create_staff_id createStaffId,
 		   d.BED_NAME bed,
 		   e.VIP_NAME vipName,
+		   e.id vipId,
 		   b.staff_id staffId,
 		   f.su_name beautyName,
-		   g.proj_name projName
+		   g.proj_name projName,
+		   h.shop_short_name
 		from sys_proj_services a
 		left join sys_beautician_state b on a.ID=b.SERVICES_ID
 		left join sys_bed_state c on a.ID = c.SERVICE_ID
@@ -493,16 +547,25 @@
 		left join sys_vip_info e on a.VIP_ID=e.ID
 		left join sys_users f on f.su_id=b.STAFF_ID
 		left join sys_proj_use g on b.puse_id=g.ID
+		left join sys_shop_info h on a.SHOP_ID=h.ID
 		<where>
+			and a.company_id=#{record.companyId}
 			<if test="record.queryKey != null and record.queryKey != ''">
 				and (instr(a.SERVICE_NO, #{record.queryKey}) or instr(e.phone, #{record.queryKey}) or instr(e.vip_name, #{record.queryKey}) )
 			</if>
+			<if test="record.vipId != null and record.vipId != ''">
+				and a.vip_id = #{record.vipId}
+			</if>
 			<if test="record.status != null and record.status != ''">
 				and a.state = #{record.status}
-			</if>
+			 </if>
 			<if test="record.shopId != null">
 				and a.shop_id=#{record.shopId}
 			</if>
+			<if test="record.userId!=null">
+				and (a.create_staff_id=#{record.userId} or b.staff_id=#{record.userId})
+			</if>
+
 		</where>
 		<if test="pageVo !=null"><!-- 判断pageVo对象是否为空 -->
 			order by a.yy_time desc
@@ -523,6 +586,7 @@
 		left join sys_users f on f.su_id=b.STAFF_ID
 		left join sys_proj_use g on b.puse_id=g.ID
 		<where>
+			and a.company_id=#{record.companyId}
 			<if test="record.queryKey != null and record.queryKey != ''">
 				and (instr(a.SERVICE_NO, #{record.queryKey}) or instr(e.phone, #{record.queryKey}) or instr(e.vip_name, #{record.queryKey}) )
 			</if>
@@ -532,6 +596,108 @@
 			<if test="record.shopId != null">
 				and a.shop_id=#{record.shopId}
 			</if>
+			<if test="record.userId!=null">
+				and (a.create_staff_id=#{record.userId} or b.staff_id=#{record.userId})
+			</if>
 		</where>
 	</select>
+
+
+
+
+	<resultMap id="ErpServiceOrderListVoMap" type="com.matrix.system.shopXcx.api.vo.ErpServiceOrderListVo">
+		<id column="id" property="id" />
+		<result column="serviceNo" property="serviceNo"/>
+		<result property="time" column="time"/>
+		<result property="bed" column="bed" />
+		<result property="timeLength" column="timeLength" />
+		<result property="status" column="status" />
+		<result property="shopName" column="shopName" />
+		<result property="shopAddr" column="shopAddr" />
+		<result property="comment" column="comment" />
+		<result property="reply" column="reply" />
+		<collection property="projs" ofType="com.matrix.system.shopXcx.api.vo.ErpServiceOrderListProjVo">
+			<result property="projName" column="projName" />
+			<result property="beautyName" column="beautyName" />
+			<result property="imgMobile" column="imgMobile" />
+		</collection>
+	</resultMap>
+    <select id="findWxServiceOrderList" resultMap="ErpServiceOrderListVoMap">
+		select
+		a.id id,
+		a.SERVICE_NO serviceNo,
+		a.YY_TIME time,
+		a.TOTAL_TIME timeLength,
+		a.state status,
+		d.BED_NAME bed,
+		f.su_name beautyName,
+		g.proj_name projName,
+		h.shop_short_name as shopName,
+		h.shop_addr as shopAddr,
+		m.img as imgMobile
+		from sys_proj_services a
+		left join sys_beautician_state b on a.ID=b.SERVICES_ID
+		left join sys_bed_state c on a.ID = c.SERVICE_ID
+		left join sys_bed_info d on c.BED_ID=d.ID
+		left join sys_vip_info e on a.VIP_ID=e.ID
+		left join sys_users f on f.su_id=b.STAFF_ID
+		left join sys_proj_use g on b.puse_id=g.ID
+		left join sys_shop_info h on a.SHOP_ID=h.ID
+		left join shopping_goods m on g.proj_id=m.id
+		<where>
+			<if test="queryKey != null and queryKey != ''">
+				and instr(a.SERVICE_NO, #{queryKey})
+			</if>
+			<if test="vipId != null and vipId != ''">
+				and a.vip_id = #{vipId}
+			</if>
+			<if test="vipStatus != null and vipStatus != '' and vipStatus!=0 ">
+				<if test="vipStatus == 1">
+					and a.state = '待确认'
+				</if>
+				<if test="vipStatus == 2">
+					and a.state in ( '预约成功待处理' ,'需配料','配料完成','服务中')
+				</if>
+				<if test="vipStatus == 3">
+					and ( a.state in ( '服务完成' ,'服务单结束') and a.comment is  null)
+				</if>
+				<if test="vipStatus == 4">
+					and a.comment is not null
+				</if>
+				<if test="vipStatus == 5">
+					and a.state = '预约取消'
+				</if>
+			</if>
+		</where>
+			order by a.yy_time desc
+			limit #{offset}, #{limit}
+	</select>
+	<select id="findWxServiceOrderById" resultMap="ErpServiceOrderListVoMap">
+		select
+		a.id id,
+		a.SERVICE_NO serviceNo,
+		a.YY_TIME time,
+		a.TOTAL_TIME timeLength,
+		a.state status,
+		a.comment,
+		a.reply,
+		d.BED_NAME bed,
+		f.su_name beautyName,
+		g.proj_name projName,
+		h.shop_short_name as shopName,
+		h.shop_addr as shopAddr,
+		m.img as imgMobile
+		from sys_proj_services a
+		left join sys_beautician_state b on a.ID=b.SERVICES_ID
+		left join sys_bed_state c on a.ID = c.SERVICE_ID
+		left join sys_bed_info d on c.BED_ID=d.ID
+		left join sys_vip_info e on a.VIP_ID=e.ID
+		left join sys_users f on f.su_id=b.STAFF_ID
+		left join sys_proj_use g on b.puse_id=g.ID
+		left join sys_shop_info h on a.SHOP_ID=h.ID
+		left join shopping_goods m on g.proj_id=m.id
+		where a.id=#{id}
+	</select>
+
+
 </mapper>

--
Gitblit v1.9.1