| <?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.SysProjServicesDao"> | 
|      | 
|     <resultMap type="SysProjServices" id="SysProjServicesMap"> | 
|             <id property="id" column="ID" /> | 
|             <result property="bedId" column="BED_ID" /> | 
|             <result property="beauticianId" column="BEAUTICIAN_ID" /> | 
|             <result property="deviceId" column="DEVICE_ID" /> | 
|             <result property="devisionId" column="DEVISION_ID" /> | 
|             <result property="skinCond" column="SKIN_COND" /> | 
|             <result property="isPeeling" column="IS_PEELING" /> | 
|             <result property="useTime" column="USE_TIME" /> | 
|             <result property="isDry" column="IS_DRY" /> | 
|             <result property="isMakeup" column="IS_MAKEUP" /> | 
|             <result property="valuable" column="VALUABLE" /> | 
|             <result property="containNo" column="CONTAIN_NO" /> | 
|             <result property="remark" column="REMARK" /> | 
|             <result property="state" column="STATE" /> | 
|             <result property="isWheel" column="IS_WHEEL" /> | 
|             <result property="medicalId" column="MEDICAL_ID" /> | 
|             <result property="lightId" column="LIGHT_ID" /> | 
|             <result property="doctorId" column="DOCTOR_ID" /> | 
|             <result property="shopId" column="SHOP_ID" /> | 
|             <result property="yyTime" column="YY_TIME" /> | 
|             <result property="vipId" column="VIP_ID" /> | 
|             <result property="createTime" column="CREATE_TIME" /> | 
|             <result property="createStaffId" column="CREATE_STAFF_ID" /> | 
|             <result property="startTime" column="START_TIME"/> | 
|             <result property="endTime" column="END_TIME"/> | 
|             <result property="isOverTime" column="IS_OVERTIME"/> | 
|             <result property="serviceNo" column="SERVICE_NO"/> | 
|             <result property="totalTime" column="TOTAL_TIME"/> | 
|             <result property="money" column="MONEY"/> | 
|             <result property="changeId" column="CHANGE_ID"/> | 
|             <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"/> | 
|             <result property="plsName" column="plsName"/> | 
|             <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> | 
|   | 
|     </resultMap> | 
|   | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="SysProjServices" | 
|         useGeneratedKeys="true" keyProperty="id"> | 
|         INSERT INTO sys_proj_services ( | 
|             ID, | 
|             BED_ID, | 
|             BEAUTICIAN_ID, | 
|             DEVICE_ID, | 
|             DEVISION_ID, | 
|             SKIN_COND, | 
|             IS_PEELING, | 
|             USE_TIME, | 
|             IS_DRY, | 
|             IS_MAKEUP, | 
|      | 
|             VALUABLE, | 
|             CONTAIN_NO, | 
|             REMARK, | 
|             STATE, | 
|             IS_WHEEL, | 
|             MEDICAL_ID, | 
|             LIGHT_ID, | 
|             DOCTOR_ID, | 
|             SHOP_ID, | 
|             YY_TIME, | 
|             VIP_ID, | 
|             CREATE_TIME, | 
|             CREATE_STAFF_ID, | 
|             START_TIME, | 
|             END_TIME, | 
|             IS_OVERTIME, | 
|             SERVICE_NO, | 
|             TOTAL_TIME, | 
|             MONEY, | 
|             CHANGE_ID, | 
|             OLD_SHOP_ID, | 
|             consume_time, | 
|             company_id, | 
|             comment, | 
|             reply, | 
|             overtime_notice | 
|         ) | 
|     VALUES ( | 
|             #{id}, | 
|             #{bedId}, | 
|             #{beauticianId}, | 
|             #{deviceId}, | 
|             #{devisionId}, | 
|             #{skinCond}, | 
|             #{isPeeling}, | 
|             #{useTime}, | 
|             #{isDry}, | 
|             #{isMakeup}, | 
|             #{valuable}, | 
|             #{containNo}, | 
|             #{remark}, | 
|             #{state}, | 
|             #{isWheel}, | 
|             #{medicalId}, | 
|             #{lightId}, | 
|             #{doctorId}, | 
|             #{shopId}, | 
|             #{yyTime}, | 
|             #{vipId}, | 
|             #{createTime}, | 
|             #{createStaffId}, | 
|             #{startTime}, | 
|             #{endTime}, | 
|             #{isOverTime}, | 
|             #{serviceNo}, | 
|             #{totalTime}, | 
|             #{money}, | 
|             #{changeId}, | 
|             #{oldShopId}, | 
|             #{consumeTime}, | 
|             #{companyId}, | 
|             #{comment}, | 
|             #{reply}, | 
|             #{overtimeNotice} | 
|     ) | 
|          | 
|     </insert> | 
|   | 
|     <!--  根据id更新 部分更新   --> | 
|     <update id="updateOrderTime"> | 
|         UPDATE sys_proj_services set consume_time=#{consumeTime} 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 | 
|         <set> | 
|                 <if test="bedId != null and bedId !='' "> | 
|                     BED_ID = #{bedId}, | 
|                 </if>         | 
|                 <if test="beauticianId != null and beauticianId !='' "> | 
|                     BEAUTICIAN_ID = #{beauticianId}, | 
|                 </if>         | 
|                 <if test="deviceId != null and deviceId !='' "> | 
|                     DEVICE_ID = #{deviceId}, | 
|                 </if>         | 
|                 <if test="devisionId != null and devisionId !='' "> | 
|                     DEVISION_ID = #{devisionId}, | 
|                 </if>         | 
|                 <if test="skinCond != null and skinCond !='' "> | 
|                     SKIN_COND = #{skinCond}, | 
|                 </if>         | 
|                 <if test="isPeeling != null and isPeeling !='' "> | 
|                     IS_PEELING = #{isPeeling}, | 
|                 </if>         | 
|                 <if test="useTime != null  "> | 
|                     USE_TIME = #{useTime}, | 
|                 </if>         | 
|                 <if test="isDry != null and isDry !='' "> | 
|                     IS_DRY = #{isDry}, | 
|                 </if>         | 
|                 <if test="isMakeup != null and isMakeup !='' "> | 
|                     IS_MAKEUP = #{isMakeup}, | 
|                 </if>         | 
|                 <if test="valuable != null and valuable !='' "> | 
|                     VALUABLE = #{valuable}, | 
|                 </if>         | 
|                 <if test="containNo != null and containNo !='' "> | 
|                     CONTAIN_NO = #{containNo}, | 
|                 </if>         | 
|                 <if test="remark != null and remark !='' "> | 
|                     REMARK = #{remark}, | 
|                 </if>         | 
|                 <if test="state != null and state !='' "> | 
|                     STATE = #{state}, | 
|                 </if>         | 
|                 <if test="isWheel != null and isWheel !='' "> | 
|                     IS_WHEEL = #{isWheel}, | 
|                 </if>         | 
|                 <if test="medicalId != null and medicalId !='' "> | 
|                     MEDICAL_ID = #{medicalId}, | 
|                 </if>         | 
|                 <if test="lightId != null and lightId !='' "> | 
|                     LIGHT_ID = #{lightId}, | 
|                 </if>         | 
|                 <if test="doctorId != null and doctorId !='' "> | 
|                     DOCTOR_ID = #{doctorId}, | 
|                 </if>         | 
|                 <if test="shopId != null and shopId !='' "> | 
|                     SHOP_ID = #{shopId}, | 
|                 </if>         | 
|                 <if test="yyTime != null   "> | 
|                     YY_TIME = #{yyTime}, | 
|                 </if>         | 
|                 <if test="vipId != null and vipId !='' "> | 
|                     VIP_ID = #{vipId}, | 
|                 </if>         | 
|                 <if test="createTime != null  "> | 
|                     CREATE_TIME = #{createTime}, | 
|                 </if>         | 
|                 <if test="createStaffId != null and createStaffId !='' "> | 
|                     CREATE_STAFF_ID = #{createStaffId}, | 
|                 </if> | 
|                 <if test="startTime != null  "> | 
|                     START_TIME = #{startTime}, | 
|                 </if> | 
|                 <if test="endTime != null   "> | 
|                     END_TIME = #{endTime}, | 
|                 </if> | 
|                 <if test="isOverTime != null  "> | 
|                     IS_OVERTIME = #{isOverTime}, | 
|                 </if> | 
|                 <if test="serviceNo != null and serviceNo !='' "> | 
|                     SERVICE_NO = #{serviceNo}, | 
|                 </if> | 
|                 <if test="totalTime != null  "> | 
|                     TOTAL_TIME = #{totalTime}, | 
|                 </if> | 
|                 <if test="money != null and money !='' "> | 
|                     MONEY = #{money}, | 
|                 </if> | 
|                 <if test="changeId != null and changeId !='' "> | 
|                     CHANGE_ID = #{changeId}, | 
|                 </if> | 
|                 <if test="oldShopId != null and oldShopId !='' "> | 
|                     OLD_SHOP_ID = #{oldShopId}, | 
|                 </if> | 
|                 <if test="consumeTime != null  "> | 
|                     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"> | 
|         delete from sys_proj_services where  ID in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|          | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" > | 
|         DELETE FROM sys_proj_services | 
|         where  ID=#{id}  | 
|     </delete> | 
|   | 
|     <select id="selectInPage" resultMap="SysProjServicesMap"> | 
|         select distinct | 
|         a.*, | 
|         b.PHONE , | 
|         b.VIP_NAME , | 
|         b.VIP_NO, | 
|         (select  su_name from  sys_users f where  a.CREATE_STAFF_ID=f.su_id ) as  createStaffName, | 
|         (select  su_name from  sys_users j where  a.BEAUTICIAN_ID=j.su_id ) as  beautiName, | 
|         (select  su_name from  sys_users k where  a.devision_id=k.su_id ) as plsName, | 
|         (select  shop_name from  sys_shop_info h where  a.SHOP_ID=h.ID ) as shopName, | 
|         (select  bed_name from  sys_bed_info i where  a.BED_ID=i.ID ) as bedName | 
|         FROM sys_proj_services a | 
|         LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID | 
|         left join sys_beautician_state c on a.id=c.SERVICES_ID | 
|         WHERE 1 = 1 | 
|         <if test="record!=null"> | 
|             <if test="record.queryStaffId != null and record.queryStaffId !='' "> | 
|                 and (a.CREATE_STAFF_ID  = #{record.queryStaffId}  or c.STAFF_ID=#{record.queryStaffId}  ) | 
|             </if> | 
|             <if test="record.vipName != null and record.vipName !='' "> | 
|                 and b.VIP_NAME like CONCAT('%',#{record.vipName},'%') | 
|             </if> | 
|             <if test="record.vipPhone !=null and record.vipPhone !=''  "> | 
|                 and b.PHONE like CONCAT('%',#{record.vipPhone},'%') | 
|             </if> | 
|             <if test="record.createStaffId != null and record.createStaffId !='' "> | 
|                 and a.CREATE_STAFF_ID  = #{record.createStaffId} | 
|             </if> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and a.ID  = #{record.id} | 
|             </if> | 
|             <if test="(record.companyId!=null and record.companyId!='') "> | 
|                 and a.company_id = #{record.companyId} | 
|             </if> | 
|   | 
|             <if test="record.bedId != null and record.bedId !='' "> | 
|                 and a.BED_ID  = #{record.bedId} | 
|             </if> | 
|             <if test="record.state != null and record.state !='' "> | 
|                 and a.STATE  = #{record.state} | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 AND a.SHOP_ID = #{record.shopId} | 
|             </if> | 
|             <if test="record.vipId != null and record.vipId !='' "> | 
|                 and a.VIP_ID   = #{record.vipId} | 
|             </if> | 
|             <if test="record.isOverTime != null  and record.serviceNo !=''   "> | 
|                 and a.IS_OVERTIME  > #{record.isOverTime} | 
|             </if> | 
|             <if test="record.serviceNo != null and record.serviceNo !='' "> | 
|                 and a.SERVICE_NO  like CONCAT('%',#{record.serviceNo},'%') | 
|             </if> | 
|             <if test="record.beginTime != null  "> | 
|                 and a.YY_TIME  <![CDATA[>=]]> #{record.beginTime} | 
|             </if> | 
|             <if test="record.closureTime != null  "> | 
|                 and a.YY_TIME <![CDATA[<=]]> #{record.closureTime} | 
|             </if> | 
|         </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="selectTotalRecord"    resultType="java.lang.Integer"> | 
|         select count(*) | 
|         from ( | 
|         select distinct | 
|         a.id | 
|         FROM sys_proj_services a | 
|         LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID | 
|         left join sys_beautician_state c on a.id=c.SERVICES_ID | 
|         WHERE 1 = 1 | 
|         <if test="record!=null"> | 
|             <if test="record.queryStaffId != null and record.queryStaffId !='' "> | 
|                 and (a.CREATE_STAFF_ID  = #{record.queryStaffId}  or c.STAFF_ID=#{record.queryStaffId}  ) | 
|             </if> | 
|             <if test="record.vipName != null and record.vipName !='' "> | 
|                 and b.VIP_NAME like CONCAT('%',#{record.vipName},'%') | 
|             </if> | 
|             <if test="record.vipPhone !=null and record.vipPhone !=''  "> | 
|                 and b.PHONE like CONCAT('%',#{record.vipPhone},'%') | 
|             </if> | 
|             <if test="record.createStaffId != null and record.createStaffId !='' "> | 
|                 and a.CREATE_STAFF_ID  = #{record.createStaffId} | 
|             </if> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and a.ID  = #{record.id} | 
|             </if> | 
|             <if test="record.bedId != null and record.bedId !='' "> | 
|                 and a.BED_ID  = #{record.bedId} | 
|             </if> | 
|             <if test="record.state != null and record.state !='' "> | 
|                 and a.STATE  = #{record.state} | 
|             </if> | 
|   | 
|             <if test="(record.companyId!=null and record.companyId!='') "> | 
|                 and a.company_id = #{record.companyId} | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 AND a.SHOP_ID = #{record.shopId} | 
|             </if> | 
|             <if test="record.vipId != null and record.vipId !='' "> | 
|                 and a.VIP_ID   = #{record.vipId} | 
|             </if> | 
|             <if test="record.isOverTime != null  and record.serviceNo !=''   "> | 
|                 and a.IS_OVERTIME  > #{record.isOverTime} | 
|             </if> | 
|             <if test="record.serviceNo != null and record.serviceNo !='' "> | 
|                 and a.SERVICE_NO  like CONCAT('%',#{record.serviceNo},'%') | 
|             </if> | 
|             <if test="record.beginTime != null  "> | 
|                 and a.YY_TIME  <![CDATA[>=]]> #{record.beginTime} | 
|             </if> | 
|             <if test="record.closureTime != null  "> | 
|                 and a.YY_TIME <![CDATA[<=]]> #{record.closureTime} | 
|             </if> | 
|         </if> | 
|              ) t | 
|   | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="SysProjServicesMap"> | 
|         select    distinct | 
|         a.*, | 
|         b.PHONE , | 
|         b.VIP_Name , | 
|         b.VIP_NO, | 
|         (select  su_name from  sys_users f where  a.CREATE_STAFF_ID=f.su_id ) as  createStaffName, | 
|         (select  su_name from  sys_users j where  a.BEAUTICIAN_ID=j.su_id ) as  beautiName, | 
|         (select  su_name from  sys_users k where  a.devision_id=k.su_id ) as plsName, | 
|         (select  shop_name from  sys_shop_info h where  a.SHOP_ID=h.ID ) as shopName, | 
|         (select  bed_name from  sys_bed_info i where  a.BED_ID=i.ID ) as bedName | 
|         FROM sys_proj_services a | 
|         LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID | 
|         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 | 
|         a.*, | 
|         b.PHONE , | 
|         b.VIP_Name , | 
|         b.VIP_NO, | 
|         (select  su_name from  sys_users f where  a.CREATE_STAFF_ID=f.su_id ) as  createStaffName, | 
|         (select  su_name from  sys_users j where  a.BEAUTICIAN_ID=j.su_id ) as  beautiName, | 
|         (select  su_name from  sys_users k where  a.devision_id=k.su_id ) as plsName, | 
|         (select  shop_name from  sys_shop_info h where  a.SHOP_ID=h.ID ) as shopName, | 
|         (select  bed_name from  sys_bed_info i where  a.BED_ID=i.ID ) as bedName | 
|         FROM sys_proj_services a | 
|         LEFT JOIN sys_vip_info b on b.ID=a.VIP_ID | 
|         left join sys_beautician_state c on a.id=c.SERVICES_ID | 
|         WHERE 1 = 1 | 
|         <if test="record!=null"> | 
|             <if test="record.queryStaffId != null and record.queryStaffId !='' "> | 
|                 and (a.CREATE_STAFF_ID  = #{record.queryStaffId}  or c.STAFF_ID=#{record.queryStaffId}  ) | 
|             </if> | 
|             <if test="record.vipName != null and record.vipName !='' "> | 
|                 and b.VIP_NAME like CONCAT('%',#{record.vipName},'%') | 
|             </if> | 
|             <if test="record.vipPhone !=null and record.vipPhone !=''  "> | 
|                 and b.PHONE like CONCAT('%',#{record.vipPhone},'%') | 
|             </if> | 
|             <if test="record.createStaffId != null and record.createStaffId !='' "> | 
|                 and a.CREATE_STAFF_ID  = #{record.createStaffId} | 
|             </if> | 
|             <if test="record.id != null and record.id !='' "> | 
|                 and a.ID  = #{record.id} | 
|             </if> | 
|             <if test="record.bedId != null and record.bedId !='' "> | 
|                 and a.BED_ID  = #{record.bedId} | 
|             </if> | 
|             <if test="record.state != null and record.state !='' "> | 
|                 and a.STATE  = #{record.state} | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 AND a.SHOP_ID = #{record.shopId} | 
|             </if> | 
|             <if test="record.vipId != null and record.vipId !='' "> | 
|                 and a.VIP_ID   = #{record.vipId} | 
|             </if> | 
|             <if test="record.isOverTime != null  and record.serviceNo !=''   "> | 
|                 and a.IS_OVERTIME  > #{record.isOverTime} | 
|             </if> | 
|             <if test="record.serviceNo != null and record.serviceNo !='' "> | 
|                 and a.SERVICE_NO  like CONCAT('%',#{record.serviceNo},'%') | 
|             </if> | 
|   | 
|             <if test="(record.companyId!=null and record.companyId!='') "> | 
|                 and a.company_id = #{record.companyId} | 
|             </if> | 
|             <if test="record.beginTime != null  "> | 
|                 and a.YY_TIME  <![CDATA[>=]]> #{record.beginTime} | 
|             </if> | 
|             <if test="record.closureTime != null  "> | 
|                 and a.YY_TIME <![CDATA[<=]]> #{record.closureTime} | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <resultMap id="ServiceOrderListVoMap" type="com.matrix.system.app.vo.ServiceOrderListVo"> | 
|         <id column="id" property="id" /> | 
|         <result column="serviceNo" property="serviceNo"/> | 
|         <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" /> | 
|             <result property="id" column="staffId" /> | 
|         </collection> | 
|     </resultMap> | 
|   | 
|   | 
|     <select id="selectApiServiceOrderListInPage" resultMap="ServiceOrderListVoMap"> | 
|         select | 
|            a.id id, | 
|            a.SERVICE_NO serviceNo, | 
|            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, | 
|            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 | 
|         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 | 
|         <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 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 | 
|             <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|                 limit | 
|                 #{pageVo.offset},#{pageVo.limit} | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="selectApiServiceOrderListTotal" resultType="java.lang.Integer"> | 
|         select count(1) | 
|         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 | 
|         <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.status != null and record.status != ''"> | 
|                 and a.state = #{record.status} | 
|             </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> | 
|     </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> | 
|   | 
|   | 
|     <select id="selectProjServicesByOrderItemId" resultMap="SysProjServicesMap"> | 
|         select a.* from sys_proj_services a | 
|           inner join sys_beautician_state b on a.id=b.SERVICES_ID | 
|           inner join sys_proj_use c on c.id=b.puse_id | 
|         where ORDER_ITEM_ID=#{itemId} and a.STATE!='预约取消' | 
|     </select> | 
| </mapper> |