|  |  | 
 |  |  | <mapper namespace="com.matrix.system.hive.dao.SysProjUseDao"> | 
 |  |  |  | 
 |  |  |     <resultMap type="SysProjUse" id="SysProjUseMap"> | 
 |  |  |  | 
 |  |  |         <id property="id" column="ID"/> | 
 |  |  |         <result property="createBy" column="create_by" /> | 
 |  |  |         <result property="createTime" column="create_time" /> | 
 |  |  |         <result property="updateBy" column="update_by" /> | 
 |  |  |         <result property="updateTime" column="update_time" /> | 
 |  |  |         <result property="orderItemId" column="ORDER_ITEM_ID"/> | 
 |  |  |         <result property="projId" column="PROJ_ID"/> | 
 |  |  |         <result property="surplusCount" column="SURPLUS_COUNT"/> | 
 |  |  | 
 |  |  |         <result property="projName" column="proj_name"/> | 
 |  |  |         <result property="deductionNum" column="deductionNum"/> | 
 |  |  |         <result property="isCourse" column="is_course"/> | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         <result property="timeLength" column="time_length"/> | 
 |  |  |         <result property="orderId" column="orderId"/> | 
 |  |  |         <!-- 对应项目信息--> | 
 |  |  |         <association property="projInfo" javaType="ShoppingGoods" | 
 |  |  |                      resultMap="com.matrix.system.hive.dao.ShoppingGoodsDao.ShoppingGoodsMap"/> | 
 |  |  |  | 
 |  |  |     </resultMap> | 
 |  |  |  | 
 |  |  |     <!-- 余次使用记录map --> | 
 |  |  |     <resultMap type="com.matrix.system.hive.bean.SysProjUseFlow" id="SysProjUseFlowMap"> | 
 |  |  |         <id property="id" column="id"/> | 
 |  |  |         <result property="createBy" column="create_by" /> | 
 |  |  |         <result property="createTime" column="create_time" /> | 
 |  |  |         <result property="updateBy" column="update_by" /> | 
 |  |  |         <result property="updateTime" column="update_time" /> | 
 |  |  |         <result property="projUseId" column="proj_use_id"/> | 
 |  |  |         <result property="surplusCount" column="surplus_count"/> | 
 |  |  |         <result property="isOver" column="is_over"/> | 
 |  |  |         <result property="failTime" column="fail_time"/> | 
 |  |  |         <result property="price" column="price"/> | 
 |  |  |         <result property="status" column="status"/> | 
 |  |  |         <result property="balance" column="balance"/> | 
 |  |  |         <result property="remark" column="remark"/> | 
 |  |  |         <result property="projName" column="proj_name"/> | 
 |  |  |         <result property="optionType" column="option_type"/> | 
 |  |  |     </resultMap> | 
 |  |  |  | 
 |  |  |     <!-- 插入流水 --> | 
 |  |  |     <insert id="insertFlow" parameterType="SysProjUse" useGeneratedKeys="true" | 
 |  |  |             keyProperty="id"> | 
 |  |  |         INSERT INTO sys_proj_use_flow ( | 
 |  |  |         create_by, | 
 |  |  |       create_time, | 
 |  |  |       update_by, | 
 |  |  |       update_time, | 
 |  |  |       id, | 
 |  |  |       proj_use_id, | 
 |  |  |       surplus_count, | 
 |  |  |       is_over, | 
 |  |  |       fail_time, | 
 |  |  |       price, | 
 |  |  |       status, | 
 |  |  |       balance, | 
 |  |  |       remark, | 
 |  |  |       proj_name, | 
 |  |  |       option_type | 
 |  |  |       ) | 
 |  |  |       VALUES ( | 
 |  |  |       #{createBy}, | 
 |  |  |       now(), | 
 |  |  |       #{updateBy}, | 
 |  |  |       now(), | 
 |  |  |       #{id}, | 
 |  |  |       #{projUseId}, | 
 |  |  |       #{surplusCount}, | 
 |  |  |       #{isOver}, | 
 |  |  |       #{failTime}, | 
 |  |  |       #{price}, | 
 |  |  |       #{status}, | 
 |  |  |       #{balance}, | 
 |  |  |       #{remark}, | 
 |  |  |       #{projName}, | 
 |  |  |       #{optionType} | 
 |  |  |       ) | 
 |  |  |     </insert> | 
 |  |  |  | 
 |  |  |     <!-- 查询流水 --> | 
 |  |  |     <select id="selectProjUseFlow" resultMap="SysProjUseFlowMap"> | 
 |  |  |         select * from sys_proj_use_flow | 
 |  |  |         <where> | 
 |  |  |                 and proj_use_id=#{record.projUseId} | 
 |  |  |             <if test="record.createBy !=null and record.createBy!='' "> | 
 |  |  |                 and instr(createBy,#{record.createBy}) | 
 |  |  |             </if> | 
 |  |  |             <if test="record.beginTime !=null and record.beginTime!=''"> | 
 |  |  |                 and create_time >= #{record.beginTime} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.endTime !=null and record.endTime!=''"> | 
 |  |  |                 <![CDATA[ and create_time <=  #{record.endTime} ]]> | 
 |  |  |             </if> | 
 |  |  |  | 
 |  |  |         </where> | 
 |  |  |         <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="selectProjUseFlowTotal" resultType="java.lang.Integer"> | 
 |  |  |         select count(*) from sys_proj_use_flow | 
 |  |  |         <where> | 
 |  |  |             and proj_use_id=#{record.projUseId} | 
 |  |  |             <if test="record.createBy !=null and record.createBy!='' "> | 
 |  |  |                 and instr(createBy,#{record.createBy}) | 
 |  |  |             </if> | 
 |  |  |             <if test="record.beginTime !=null and record.beginTime!=''"> | 
 |  |  |                 and create_time >= #{record.beginTime} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.endTime !=null and record.endTime!=''"> | 
 |  |  |                 <![CDATA[ and create_time <=  #{record.endTime} ]]> | 
 |  |  |             </if> | 
 |  |  |  | 
 |  |  |         </where> | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <!-- 插入方法 --> | 
 |  |  |     <insert id="insert" parameterType="SysProjUse" useGeneratedKeys="true" | 
 |  |  | 
 |  |  |             <if test="deductionNum != null "> | 
 |  |  |                 deductionNum = #{deductionNum}, | 
 |  |  |             </if> | 
 |  |  |             <if test="failTime != null "> | 
 |  |  |                 fail_time = #{failTime}, | 
 |  |  |             </if> | 
 |  |  |  | 
 |  |  |         </set> | 
 |  |  |         WHERE ID = #{id} | 
 |  |  | 
 |  |  |     <select id="selectInPage" resultMap="SysProjUseMap"> | 
 |  |  |         select | 
 |  |  |         a.*, | 
 |  |  |         b.TIME_LENGTH | 
 |  |  |         d.id as orderId, | 
 |  |  |         b.TIME_LENGTH, | 
 |  |  |         b.img, | 
 |  |  |         b.code | 
 |  |  |         from sys_proj_use a | 
 |  |  |         left join shopping_goods b on a.proj_id=b.id | 
 |  |  |         left join sys_order_item c on a.ORDER_ITEM_ID=c.id | 
 |  |  |         left join sys_order d on c.ORDER_ID=d.id | 
 |  |  |         where 1=1 | 
 |  |  |         <if test="record!=null"> | 
 |  |  |             <if test="record.id != null and record.id !='' "> | 
 |  |  |                 and a.ID = #{record.id} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.queryKey != null and record.queryKey !='' "> | 
 |  |  |                 and (instr(b.name, #{record.queryKey}) or instr(b.zjm, #{record.queryKey}) or instr(goods_no, #{record.queryKey})) | 
 |  |  |             </if> | 
 |  |  |             <if test="record.orderItemId != null and record.orderItemId !='' "> | 
 |  |  |                 and a.ORDER_ITEM_ID = #{record.orderItemId} | 
 |  |  | 
 |  |  |             <if test="record.failTime != null  "> | 
 |  |  |                 and a.FAIL_TIME = #{record.failTime} | 
 |  |  |             </if> | 
 |  |  |  | 
 |  |  |             <if test="record.targetFailTime != null  "> | 
 |  |  |                 and date_format(#{record.targetFailTime}, '%Y-%m-%d') > date_format(a.FAIL_TIME, '%Y-%m-%d') | 
 |  |  |             </if> | 
 |  |  |             <if test="record.price != null and record.price !='' "> | 
 |  |  |                 and a.PRICE = #{record.price} | 
 |  |  |             </if> | 
 |  |  | 
 |  |  |     <!-- 查询总条数 --> | 
 |  |  |     <select id="selectTotalRecord" resultType="java.lang.Integer"> | 
 |  |  |         select count(*) | 
 |  |  |         from sys_proj_use | 
 |  |  |         from sys_proj_use a | 
 |  |  |         left join shopping_goods b on a.proj_id=b.id | 
 |  |  |         left join sys_order_item c on a.ORDER_ITEM_ID=c.id | 
 |  |  |         left join sys_order d on c.ORDER_ID=d.id | 
 |  |  |         where 1=1 | 
 |  |  |         <if test="record!=null"> | 
 |  |  |             <if test="record.id != null and record.id !='' "> | 
 |  |  |                 and ID = #{record.id} | 
 |  |  |                 and a.ID = #{record.id} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.queryKey != null and record.queryKey !='' "> | 
 |  |  |                 and (instr(b.name, #{record.queryKey}) or instr(b.zjm, #{record.queryKey}) or instr(goods_no, #{record.queryKey})) | 
 |  |  |             </if> | 
 |  |  |             <if test="record.orderItemId != null and record.orderItemId !='' "> | 
 |  |  |                 and ORDER_ITEM_ID = #{record.orderItemId} | 
 |  |  |                 and a.ORDER_ITEM_ID = #{record.orderItemId} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.projId != null and record.projId !='' "> | 
 |  |  |                 and PROJ_ID = #{record.projId} | 
 |  |  |                 and a.PROJ_ID = #{record.projId} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.surplusCount != null and record.surplusCount !='' "> | 
 |  |  |                 and SURPLUS_COUNT = #{record.surplusCount} | 
 |  |  |                 and a.SURPLUS_COUNT = #{record.surplusCount} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.isOver != null and record.isOver !='' "> | 
 |  |  |                 and IS_OVER = #{record.isOver} | 
 |  |  |                 and a.IS_OVER = #{record.isOver} | 
 |  |  |             </if> | 
 |  |  |             <!-- 查询具体某一个套餐的使用情况 --> | 
 |  |  |             <if | 
 |  |  |                     test="record.taocanId != null and record.taocanId !=-1 and record.taocanId !=-2"> | 
 |  |  |                 and TAOCAN_ID = #{record.taocanId} | 
 |  |  |                 and a.TAOCAN_ID = #{record.taocanId} | 
 |  |  |             </if> | 
 |  |  |             <!-- 查询所有的项目使用情况 --> | 
 |  |  |             <if test="record.taocanId != null and record.taocanId ==-1 "> | 
 |  |  |                 and TAOCAN_ID IS NULL | 
 |  |  |                 and a.TAOCAN_ID IS NULL | 
 |  |  |             </if> | 
 |  |  |             <!-- 查询所有的套餐使用情况 --> | 
 |  |  |             <if test="record.taocanId != null and record.taocanId ==-2 "> | 
 |  |  |                 and TAOCAN_ID IS NOT NULL | 
 |  |  |                 and a.TAOCAN_ID IS NOT NULL | 
 |  |  |             </if> | 
 |  |  |             <if test="record.vipId != null and record.vipId !='' "> | 
 |  |  |                 and VIP_ID = #{record.vipId} | 
 |  |  |                 and a.VIP_ID = #{record.vipId} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.failTime != null  "> | 
 |  |  |                 and a.FAIL_TIME = #{record.failTime} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.targetFailTime != null  "> | 
 |  |  |                 and date_format(#{record.targetFailTime}, '%Y-%m-%d') > date_format(a.FAIL_TIME, '%Y-%m-%d') | 
 |  |  |             </if> | 
 |  |  |             <if test="record.price != null and record.price !='' "> | 
 |  |  |                 and PRICE = #{record.price} | 
 |  |  |                 and a.PRICE = #{record.price} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.assembleId != null and record.assembleId !='' "> | 
 |  |  |                 and ASSEMBLE_ID = #{record.assembleId} | 
 |  |  |                 and a.ASSEMBLE_ID = #{record.assembleId} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.source != null and record.source !='' "> | 
 |  |  |                 and SOURCE like concat('%',#{record.source},'%') | 
 |  |  |                 and a.SOURCE like concat('%',#{record.source},'%') | 
 |  |  |             </if> | 
 |  |  |             <if test="record.status != null and record.status !='' "> | 
 |  |  |                 and STATUS = #{record.status} | 
 |  |  |                 and a.STATUS = #{record.status} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.platformFlag != null and record.platformFlag !='' "> | 
 |  |  |                 and PLATFORM_FLAG = #{record.platformFlag} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.projName != null and record.projName !='' "> | 
 |  |  |                 and PROJ_NAME like concat('%',#{record.projName},'%') | 
 |  |  |                 and a.PLATFORM_FLAG = #{record.platformFlag} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.type != null and record.type !='' "> | 
 |  |  |                 and type = #{record.type} | 
 |  |  |                 and a.type = #{record.type} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.projName != null and record.projName !='' "> | 
 |  |  |                 and a.PROJ_NAME like concat('%',#{record.projName},'%') | 
 |  |  |             </if> | 
 |  |  |             <if test="record.balance != null and record.balance !='' "> | 
 |  |  |                 and balance = #{record.balance} | 
 |  |  |                 and a.balance = #{record.balance} | 
 |  |  |             </if> | 
 |  |  |             <if test="record.remark != null and record.remark !='' "> | 
 |  |  |                 and remark = #{record.remark} | 
 |  |  |                 and a.remark = #{record.remark} | 
 |  |  |             </if> | 
 |  |  |  | 
 |  |  |             <if test="record.isCourse != null and record.isCourse !='' "> | 
 |  |  |                 and   is_course = #{record.isCourse}, | 
 |  |  |                 and  a.is_course = #{record.isCourse}, | 
 |  |  |             </if> | 
 |  |  |         </if> | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <!-- 根据id查询 --> | 
 |  |  |     <select id="selectById" resultMap="SysProjUseMap"> | 
 |  |  |       select  * | 
 |  |  |       from sys_proj_use | 
 |  |  |       select a.*, | 
 |  |  |         b.TIME_LENGTH, | 
 |  |  |         b.img | 
 |  |  |         from sys_proj_use a | 
 |  |  |         left join shopping_goods b on a.proj_id=b.id | 
 |  |  |       where | 
 |  |  |       id=#{id} | 
 |  |  |       a.id=#{id} | 
 |  |  |    </select> | 
 |  |  |  | 
 |  |  |     <!-- 根据id查询 --> | 
 |  |  | 
 |  |  |     <!-- 根据对象查询 --> | 
 |  |  |     <select id="selectByModel" resultMap="SysProjUseMap"> | 
 |  |  |         select | 
 |  |  |         a.* | 
 |  |  |         a.*, | 
 |  |  |         b.time_length, | 
 |  |  |         b.img | 
 |  |  |         from sys_proj_use a | 
 |  |  |         left join shopping_goods b on a.proj_id=b.id | 
 |  |  |         where 1=1 | 
 |  |  |         <if test="record!=null"> | 
 |  |  |             <if test="record.id != null and record.id !='' "> | 
 |  |  | 
 |  |  |         a.type, | 
 |  |  |         a.SOURCE, | 
 |  |  |         e.ORDER_NO, | 
 |  |  |         a.remark | 
 |  |  |         a.remark, | 
 |  |  |         s.SHOP_NAME | 
 |  |  |         from sys_proj_use a | 
 |  |  |         left join shopping_goods b on a.proj_id = b.id | 
 |  |  |         left join sys_vip_info c on c.ID = a.VIP_ID | 
 |  |  |             left join sys_shop_info s on c.SHOP_ID=s.id | 
 |  |  |         left join sys_order_item d on d.id = a.ORDER_ITEM_ID | 
 |  |  |         left join sys_order e on e.id = d.ORDER_ID | 
 |  |  |         left join shopping_goods_category f on f.id = b.cate_id | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         <where> | 
 |  |  | 
 |  |  |               and  a.proj_name like concat('%',#{projName},'%') | 
 |  |  |             </if> | 
 |  |  |             <if test="cateId != null and cateId != ''  "> | 
 |  |  |                 and  b.PROJ_TYPE_ID=#{cateId} | 
 |  |  |                 and  b.cate_id=#{cateId} | 
 |  |  |             </if> | 
 |  |  |         </where> | 
 |  |  |  | 
 |  |  | 
 |  |  |         group by b.id) t | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <update id="updateInvalidProjUse"  > | 
 |  |  |         update   sys_proj_use set STATUS='无效' | 
 |  |  |         where  date_format(now(), '%Y-%m-%d') > date_format(FAIL_TIME, '%Y-%m-%d') | 
 |  |  |           and STATUS='有效' | 
 |  |  |     </update> | 
 |  |  |  | 
 |  |  |     <resultMap type="SysProjUse" id="TaoCanWithProjMap"> | 
 |  |  |  | 
 |  |  |         <id property="id" column="ID"/> | 
 |  |  |         <result property="createBy" column="create_by" /> | 
 |  |  |         <result property="createTime" column="create_time" /> | 
 |  |  |         <result property="updateBy" column="update_by" /> | 
 |  |  |         <result property="updateTime" column="update_time" /> | 
 |  |  |         <result property="orderItemId" column="ORDER_ITEM_ID"/> | 
 |  |  |         <result property="projId" column="PROJ_ID"/> | 
 |  |  |         <result property="surplusCount" column="SURPLUS_COUNT"/> | 
 |  |  |         <result property="isOver" column="IS_OVER"/> | 
 |  |  |         <result property="taocanId" column="TAOCAN_ID"/> | 
 |  |  |         <result property="vipId" column="VIP_ID"/> | 
 |  |  |         <result property="failTime" column="FAIL_TIME"/> | 
 |  |  |         <result property="assembleId" column="ASSEMBLE_ID"/> | 
 |  |  |         <result property="source" column="SOURCE"/> | 
 |  |  |         <result property="status" column="STATUS"/> | 
 |  |  |         <result property="platformFlag" column="PLATFORM_FLAG"/> | 
 |  |  |         <result property="type" column="type"/> | 
 |  |  |         <result property="balance" column="balance"/> | 
 |  |  |         <result property="remark" column="remark"/> | 
 |  |  |         <result property="price" column="price"/> | 
 |  |  |         <result property="tcName" column="tcName"/> | 
 |  |  |         <result property="projName" column="proj_name"/> | 
 |  |  |         <result property="deductionNum" column="deductionNum"/> | 
 |  |  |         <result property="isCourse" column="is_course"/> | 
 |  |  |         <result property="timeLength" column="time_length"/> | 
 |  |  |         <result property="orderId" column="orderId"/> | 
 |  |  |  | 
 |  |  |         <collection property="taocanProjUse" ofType="com.matrix.system.hive.bean.SysProjUse"> | 
 |  |  |             <id property="id" column="proj_info_id" /> | 
 |  |  |             <result property="projName" column="proj_proj_name"/> | 
 |  |  |             <result property="source" column="proj_source"/> | 
 |  |  |             <result property="price" column="proj_price"/> | 
 |  |  |             <result property="failTime" column="proj_FAIL_TIME"/> | 
 |  |  |             <result property="surplusCount" column="proj_SURPLUS_COUNT"/> | 
 |  |  |             <result property="timeLength" column="proj_time_length"/> | 
 |  |  |             <result property="img" column="proj_img"/> | 
 |  |  |             <result property="projId" column="proj_projId"/> | 
 |  |  |             <result property="status" column="proj_status"/> | 
 |  |  |         </collection> | 
 |  |  |     </resultMap> | 
 |  |  |  | 
 |  |  |     <select id="selectTaoCanListWithProj" resultMap="TaoCanWithProjMap"> | 
 |  |  |         select | 
 |  |  |             a.*, | 
 |  |  |             d.id as orderId, | 
 |  |  |             b.TIME_LENGTH, | 
 |  |  |             b.img, | 
 |  |  |             b.code, | 
 |  |  |             e.proj_name proj_proj_name, | 
 |  |  |             e.FAIL_TIME proj_FAIL_TIME, | 
 |  |  |             e.SURPLUS_COUNT proj_SURPLUS_COUNT, | 
 |  |  |             e.id proj_info_id, | 
 |  |  |             e.proj_id proj_projId, | 
 |  |  |             e.source proj_source, | 
 |  |  |             e.price proj_price, | 
 |  |  |             e.status proj_status, | 
 |  |  |             f.time_length proj_time_length, | 
 |  |  |             f.img proj_img | 
 |  |  |         from sys_proj_use a | 
 |  |  |             left join shopping_goods b on a.proj_id=b.id | 
 |  |  |             left join sys_order_item c on a.ORDER_ITEM_ID=c.id | 
 |  |  |             left join sys_order d on c.ORDER_ID=d.id | 
 |  |  |             left join sys_proj_use e on a.id = e.TAOCAN_ID and e.VIP_ID=a.vip_id | 
 |  |  |             left join shopping_goods f on e.proj_id=f.id | 
 |  |  |         where 1=1 and a.type='套餐' and a.TAOCAN_ID IS NULL | 
 |  |  |         <if test="record.queryKey != null and record.queryKey !='' "> | 
 |  |  |             and (instr(b.name, #{record.queryKey}) or instr(b.zjm, #{record.queryKey}) or instr(b.goods_no, #{record.queryKey})) | 
 |  |  |         </if> | 
 |  |  |         <if test="record.isOver != null and record.isOver !='' "> | 
 |  |  |             and a.IS_OVER = #{record.isOver} | 
 |  |  |         </if> | 
 |  |  |         <if test="record.status != null and record.status !='' "> | 
 |  |  |             and a.STATUS = #{record.status} | 
 |  |  |         </if> | 
 |  |  |         <if test="record.vipId != null and record.vipId !='' "> | 
 |  |  |             and a.VIP_ID = #{record.vipId} | 
 |  |  |         </if> | 
 |  |  |     </select> | 
 |  |  |  | 
 |  |  |     <select id="selectTaocanCountForCourseAndInfinite" resultType="java.lang.Integer"> | 
 |  |  |         select count(1) from sys_proj_use | 
 |  |  |         where taocan_id=#{taocanId} and vip_id=#{vipId} | 
 |  |  |     </select> | 
 |  |  | </mapper> |