| <?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.ServicesFlowDao"> | 
|     <!-- 定义ServicesFlow 的复杂关联map --> | 
|     <resultMap type="ServicesFlow" id="ServicesFlowMap"> | 
|             <id property="id" column="id" /> | 
|             <result property="serviceId" column="service_id" /> | 
|             <result property="operationId" column="operation_id" /> | 
|             <result property="content" column="content" /> | 
|             <result property="createTime" column="create_time" /> | 
|              | 
|             <!-- 扩展字段 --> | 
|             <result property="serviceNo" column="service_no" /> | 
|             <result property="shopName" column="shop_name" /> | 
|             <result property="vipName" column="vip_name" /> | 
|             <result property="staffName" column="staff_name" /> | 
|             <result property="phone" column="phone" /> | 
|              | 
|     </resultMap> | 
|      | 
|      | 
|     <!-- 定义ServicesFlow 的简单map  ,本map不添加其他的关联属性 --> | 
|     <resultMap type="ServicesFlow" id="ServicesFlowSimpleMap"> | 
|             <id property="id" column="id" /> | 
|             <result property="serviceId" column="service_id" /> | 
|             <result property="operationId" column="operation_id" /> | 
|             <result property="content" column="content" /> | 
|             <result property="createTime" column="create_time" /> | 
|     </resultMap> | 
|      | 
|      | 
|      | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="ServicesFlow" | 
|         useGeneratedKeys="true" keyProperty="id"> | 
|         INSERT INTO services_flow ( | 
|             id, | 
|             service_id, | 
|             operation_id, | 
|             content, | 
|             create_time | 
|         ) | 
|     VALUES ( | 
|             #{id}, | 
|             #{serviceId}, | 
|             #{operationId}, | 
|             #{content}, | 
|             #{createTime} | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|     <!--  根据id更新 部分更新   --> | 
|     <update id="update" > | 
|         UPDATE services_flow | 
|         <set> | 
|                 <if test="serviceId != null and serviceId !='' "> | 
|                     service_id = #{serviceId}, | 
|                 </if>         | 
|                 <if test="operationId != null and operationId !='' "> | 
|                     operation_id = #{operationId}, | 
|                 </if>         | 
|                 <if test="content != null and content !='' "> | 
|                     content = #{content}, | 
|                 </if>         | 
|                 <if test="createTime != null  "> | 
|                     create_time = #{createTime}, | 
|                 </if>         | 
|         </set> | 
|         WHERE id=#{id}  | 
|     </update> | 
|      | 
|      | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from services_flow where  id in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|          | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" > | 
|         DELETE FROM services_flow | 
|         where  id=#{id}  | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="ServicesFlowMap"> | 
|         select  | 
|             a.id, | 
|             a.service_id, | 
|             a.operation_id, | 
|             a.content, | 
|             a.create_time, | 
|             b.service_no, | 
|             (SELECT j.shop_name  from sys_shop_info j where j.id=b.SHOP_ID ) as shop_name, | 
|             c.VIP_NAME, | 
|             c.PHONE, | 
|             e.su_name | 
|         from services_flow a | 
|         LEFT JOIN sys_proj_services b on a.service_id=b.ID | 
|         LEFT JOIN sys_vip_info c on b.VIP_ID=c.ID | 
|         LEFT JOIN sys_users e on e.su_id=a.operation_id | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|              | 
|             <if test="record.beginTime != null  "> | 
|                 and a.create_time  <![CDATA[>=]]> #{record.beginTime}  | 
|             </if> | 
|             <if test="record.endTime != null  "> | 
|                 and a.create_time <![CDATA[<=]]> #{record.endTime}  | 
|             </if> | 
|             <if test="record.operationId != null and record.operationId !='' "> | 
|                 and a.operation_id  = #{record.operationId}  | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 and b.SHOP_ID  = #{record.shopId}  | 
|             </if> | 
|             <if test="record.phone != null and record.phone !='' "> | 
|                 and c.phone  like CONCAT('%',#{record.phone},'%')  | 
|             </if> | 
|             <if test="record.serviceNo != null and record.serviceNo !='' "> | 
|                 and b.service_no  like CONCAT('%',#{record.serviceNo},'%')  | 
|             </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="selectInPage2" resultMap="ServicesFlowMap"> | 
|         select  | 
|             a.id, | 
|             a.service_id, | 
|             a.operation_id, | 
|             a.content, | 
|             a.create_time, | 
|             b.service_no, | 
|             (SELECT j.shop_name  from sys_shop_info j where j.id=b.SHOP_ID ) as shop_name, | 
|             c.VIP_NAME, | 
|             c.PHONE, | 
|             e.su_name | 
|         from services_flow a | 
|         LEFT JOIN sys_proj_services b on a.service_id=b.ID | 
|         LEFT JOIN sys_vip_info c on b.VIP_ID=c.ID | 
|         LEFT JOIN sys_users e on e.su_id=a.operation_id | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|              | 
|             <if test="record.beginTime != null  "> | 
|                 and a.create_time  <![CDATA[>=]]> #{record.beginTime}  | 
|             </if> | 
|             <if test="record.endTime != null  "> | 
|                 and a.create_time <![CDATA[<=]]> #{record.endTime}  | 
|             </if> | 
|             <if test="record.operationId != null and record.operationId !='' "> | 
|                 and a.operation_id  = #{record.operationId}  | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 AND b.VIP_ID IN (SELECT t.ID FROM sys_vip_info t WHERE t.shop_id = #{record.shopId}) | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                     AND b.shop_id = #{record.shopId} | 
|                 </if> | 
|             <if test="record.phone != null and record.phone !='' "> | 
|                 and c.phone  like CONCAT('%',#{record.phone},'%')  | 
|             </if> | 
|             <if test="record.serviceNo != null and record.serviceNo !='' "> | 
|                 and b.service_no  like CONCAT('%',#{record.serviceNo},'%')  | 
|             </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 services_flow a | 
|         LEFT JOIN sys_proj_services b on a.service_id=b.ID | 
|         LEFT JOIN sys_vip_info c on b.VIP_ID=c.ID | 
|         LEFT JOIN sys_users e on e.su_id=a.operation_id | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|              | 
|             <if test="record.beginTime != null  "> | 
|                 and a.create_time  <![CDATA[>=]]> #{record.beginTime}  | 
|             </if> | 
|             <if test="record.endTime != null  "> | 
|                 and a.create_time <![CDATA[<=]]> #{record.endTime}  | 
|             </if> | 
|             <if test="record.operationId != null and record.operationId !='' "> | 
|                 and a.operation_id  = #{record.operationId}  | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 and b.SHOP_ID  = #{record.shopId}  | 
|             </if> | 
|             <if test="record.phone != null and record.phone !='' "> | 
|                 and c.phone  like CONCAT('%',#{record.phone},'%')  | 
|             </if> | 
|             <if test="record.serviceNo != null and record.serviceNo !='' "> | 
|                 and b.service_no  like CONCAT('%',#{record.serviceNo},'%')  | 
|             </if> | 
|         </if> | 
|     </select> | 
|      | 
|     <select id="selectTotalRecord2"    resultType="java.lang.Integer"> | 
|     select count(*) | 
|     from ( | 
|     select  | 
|             a.id, | 
|             a.service_id, | 
|             a.operation_id, | 
|             a.content, | 
|             a.create_time, | 
|             b.service_no, | 
|             (SELECT j.shop_name  from sys_shop_info j where j.id=b.SHOP_ID ) as shop_name, | 
|             c.VIP_NAME, | 
|             c.PHONE, | 
|             e.su_name | 
|         from services_flow a | 
|         LEFT JOIN sys_proj_services b on a.service_id=b.ID | 
|         LEFT JOIN sys_vip_info c on b.VIP_ID=c.ID | 
|         LEFT JOIN sys_users e on e.su_id=a.operation_id | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|              | 
|             <if test="record.beginTime != null  "> | 
|                 and a.create_time  <![CDATA[>=]]> #{record.beginTime}  | 
|             </if> | 
|             <if test="record.endTime != null  "> | 
|                 and a.create_time <![CDATA[<=]]> #{record.endTime}  | 
|             </if> | 
|             <if test="record.operationId != null and record.operationId !='' "> | 
|                 and a.operation_id  = #{record.operationId}  | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 AND b.VIP_ID IN (SELECT t.ID FROM sys_vip_info t WHERE t.shop_id = #{record.shopId}) | 
|             </if> | 
|             <if test="record.searchShop != null and record.searchShop !=''"> | 
|                     AND b.shop_id = #{record.searchShop} | 
|                 </if> | 
|             <if test="record.phone != null and record.phone !='' "> | 
|                 and c.phone  like CONCAT('%',#{record.phone},'%')  | 
|             </if> | 
|             <if test="record.serviceNo != null and record.serviceNo !='' "> | 
|                 and b.service_no  like CONCAT('%',#{record.serviceNo},'%')  | 
|             </if> | 
|         </if> | 
|     )t | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="ServicesFlowMap"> | 
|         select  | 
|             id, | 
|             service_id, | 
|             operation_id, | 
|             content, | 
|             create_time | 
|         from services_flow | 
|         where  id=#{id}  | 
|     </select>     | 
|      | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="ServicesFlowMap"> | 
|         select  | 
|             a.id, | 
|             a.service_id, | 
|             a.operation_id, | 
|             a.content, | 
|             a.create_time, | 
|             b.service_no, | 
|             (SELECT j.shop_name  from sys_shop_info j where j.id=b.SHOP_ID ) as shop_name, | 
|             c.VIP_NAME, | 
|             c.PHONE, | 
|             e.su_name | 
|         from services_flow a | 
|         LEFT JOIN sys_proj_services b on a.service_id=b.ID | 
|         LEFT JOIN sys_vip_info c on b.VIP_ID=c.ID | 
|         LEFT JOIN sys_users e on e.su_id=a.operation_id | 
|         where 1=1 | 
|         <if test="record!=null"> | 
|              | 
|             <if test="record.beginTime != null  "> | 
|                 and a.create_time  <![CDATA[>=]]> #{record.beginTime}  | 
|             </if> | 
|             <if test="record.endTime != null  "> | 
|                 and a.create_time <![CDATA[<=]]> #{record.endTime}  | 
|             </if> | 
|             <if test="record.operationId != null and record.operationId !='' "> | 
|                 and a.operation_id  = #{record.operationId}  | 
|             </if> | 
|             <if test="record.shopId != null and record.shopId !='' "> | 
|                 and b.SHOP_ID  = #{record.shopId}  | 
|             </if> | 
|             <if test="record.phone != null and record.phone !='' "> | 
|                 and c.phone  like CONCAT('%',#{record.phone},'%')  | 
|             </if> | 
|             <if test="record.serviceNo != null and record.serviceNo !='' "> | 
|                 and b.service_no  like CONCAT('%',#{record.serviceNo},'%')  | 
|             </if> | 
|         </if> | 
|     </select> | 
| </mapper> |