| <?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.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="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"/> | 
|         <!-- 对应项目信息--> | 
|         <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" | 
|             keyProperty="id"> | 
|         INSERT INTO sys_proj_use ( | 
|         ID, | 
|         ORDER_ITEM_ID, | 
|         PROJ_ID, | 
|         SURPLUS_COUNT, | 
|         IS_OVER, | 
|         VIP_ID, | 
|         TAOCAN_ID, | 
|         FAIL_TIME, | 
|         ASSEMBLE_ID, | 
|         SOURCE, | 
|         STATUS, | 
|         PRICE, | 
|         PLATFORM_FLAG, | 
|         type, | 
|         balance, | 
|         remark, | 
|         proj_name, | 
|         tcName, | 
|         deductionNum, | 
|         is_course | 
|         ) | 
|         VALUES ( | 
|         #{id}, | 
|         #{orderItemId}, | 
|         #{projId}, | 
|         #{surplusCount}, | 
|         #{isOver}, | 
|         #{vipId}, | 
|         #{taocanId}, | 
|         #{failTime}, | 
|         #{assembleId}, | 
|         #{source}, | 
|         #{status}, | 
|         #{price}, | 
|         #{platformFlag}, | 
|         #{type}, | 
|         #{balance}, | 
|         #{remark}, | 
|         #{projName}, | 
|         #{tcName}, | 
|         #{deductionNum}, | 
|         #{isCourse} | 
|         ) | 
|     </insert> | 
|   | 
|     <!-- 根据id更新 部分更新 --> | 
|     <update id="update"> | 
|         UPDATE sys_proj_use | 
|         <set> | 
|             <if test="orderItemId != null and orderItemId !='' "> | 
|                 ORDER_ITEM_ID = #{orderItemId}, | 
|             </if> | 
|             <if test="projId != null and projId !='' "> | 
|                 PROJ_ID = #{projId}, | 
|             </if> | 
|             <if test="(surplusCount != null and surplusCount !='') or  surplusCount == 0 "> | 
|                 SURPLUS_COUNT = #{surplusCount}, | 
|             </if> | 
|             <if test="isOver != null and isOver !='' "> | 
|                 IS_OVER = #{isOver}, | 
|             </if> | 
|             <if test="taocanId != null and taocanId !='' "> | 
|                 TAOCAN_ID = #{taocanId}, | 
|             </if> | 
|             <if test="vipId != null and vipId !='' "> | 
|                 VIP_ID = #{vipId}, | 
|             </if> | 
|             <if test="failTime != null  "> | 
|                 FAIL_TIME = #{failTime}, | 
|             </if> | 
|             <if test="price != null and price !='' "> | 
|                 PRICE = #{price}, | 
|             </if> | 
|             <if test="assembleId != null and assembleId !='' "> | 
|                 ASSEMBLE_ID = #{assembleId}, | 
|             </if> | 
|             <if test="source != null and source !='' "> | 
|                 SOURCE = #{source}, | 
|             </if> | 
|             <if test="status != null and status !='' "> | 
|                 STATUS = #{status}, | 
|             </if> | 
|             <if test="platformFlag != null and platformFlag !='' "> | 
|                 PLATFORM_FLAG = #{platformFlag}, | 
|             </if> | 
|             <if test="(balance != null and balance !='') or (balance == 0)  "> | 
|                 balance = #{balance}, | 
|             </if> | 
|             <if test="type != null and type !='' "> | 
|                 type = #{type}, | 
|             </if> | 
|             <if test="remark != null and remark !='' "> | 
|                 remark = #{remark}, | 
|             </if> | 
|             <if test="(projName != null and projName !='') or (projName == 0)  "> | 
|                 proj_name = #{projName}, | 
|             </if> | 
|             <if test="tcName != null and tcName !='' "> | 
|                 tcName = #{tcName}, | 
|             </if> | 
|             <if test="deductionNum != null and deductionNum !='' "> | 
|                 deductionNum = #{deductionNum}, | 
|             </if> | 
|             <if test="isCourse != null and isCourse !='' "> | 
|                 is_course = #{isCourse}, | 
|             </if> | 
|         </set> | 
|         WHERE id=#{id} | 
|     </update> | 
|   | 
|   | 
|     <update id="updateSurplusCount"> | 
|         UPDATE sys_proj_use | 
|         <set> | 
|             <if test="surplusCount != null "> | 
|                 SURPLUS_COUNT = #{surplusCount}, | 
|             </if> | 
|             <if test="isOver != null and isOver !='' "> | 
|                 IS_OVER = #{isOver}, | 
|             </if> | 
|             <if test="status != null and status !='' "> | 
|                 status = #{status}, | 
|             </if> | 
|             <if test="balance != null "> | 
|                 balance = #{balance}, | 
|             </if> | 
|             <if test="remark != null "> | 
|                 remark = #{remark}, | 
|             </if> | 
|             <if test="projName != null "> | 
|                 proj_name = #{projName}, | 
|             </if> | 
|             <if test="tcName != null "> | 
|                 tcName = #{tcName}, | 
|             </if> | 
|             <if test="deductionNum != null "> | 
|                 deductionNum = #{deductionNum}, | 
|             </if> | 
|             <if test="failTime != null "> | 
|                 fail_time = #{failTime}, | 
|             </if> | 
|   | 
|         </set> | 
|         WHERE ID = #{id} | 
|   | 
|     </update> | 
|   | 
|   | 
|     <!-- 根据id更新 部分更新 --> | 
|     <update id="updateProjUseCancel"> | 
|         UPDATE sys_proj_use | 
|         <set> | 
|             <if test="key != null "> | 
|                 SURPLUS_COUNT = SURPLUS_COUNT +1 | 
|             </if> | 
|         </set> | 
|         WHERE id=#{key} | 
|     </update> | 
|   | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from sys_proj_use where ID in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|                  separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|   | 
|     <!-- 根据id删除 --> | 
|     <delete id="deleteById"> | 
|         DELETE FROM sys_proj_use | 
|         where ID=#{id} | 
|     </delete> | 
|   | 
|   | 
|     <!-- 根据id订单明细id删除 --> | 
|     <delete id="deleteByOrderItemId"> | 
|         DELETE FROM sys_proj_use | 
|         where ORDER_ITEM_ID=#{id} | 
|     </delete> | 
|   | 
|   | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="SysProjUseMap"> | 
|         select | 
|         a.*, | 
|         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> | 
|             <if test="record.projId != null and record.projId !='' "> | 
|                 and a.PROJ_ID = #{record.projId} | 
|             </if> | 
|             <if test="record.surplusCount != null and record.surplusCount !='' "> | 
|                 and a.SURPLUS_COUNT = #{record.surplusCount} | 
|             </if> | 
|             <if test="record.isOver != null and record.isOver !='' "> | 
|                 and a.IS_OVER = #{record.isOver} | 
|             </if> | 
|             <!-- 查询具体某一个套餐的使用情况 --> | 
|             <if | 
|                     test="record.taocanId != null and record.taocanId !=-1 and record.taocanId !=-2"> | 
|                 and a.TAOCAN_ID = #{record.taocanId} | 
|             </if> | 
|             <!-- 查询所有的项目使用情况 --> | 
|             <if test="record.taocanId != null and record.taocanId ==-1 "> | 
|                 and a.TAOCAN_ID IS NULL | 
|             </if> | 
|             <!-- 查询所有的套餐使用情况 --> | 
|             <if test="record.taocanId != null and record.taocanId ==-2 "> | 
|                 and a.TAOCAN_ID IS NOT NULL | 
|             </if> | 
|             <if test="record.vipId != null and 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 a.PRICE = #{record.price} | 
|             </if> | 
|             <if test="record.assembleId != null and record.assembleId !='' "> | 
|                 and a.ASSEMBLE_ID = #{record.assembleId} | 
|             </if> | 
|             <if test="record.source != null and record.source !='' "> | 
|                 and a.SOURCE like concat('%',#{record.source},'%') | 
|             </if> | 
|             <if test="record.status != null and record.status !='' "> | 
|                 and a.STATUS = #{record.status} | 
|             </if> | 
|             <if test="record.platformFlag != null and record.platformFlag !='' "> | 
|                 and a.PLATFORM_FLAG = #{record.platformFlag} | 
|             </if> | 
|             <if test="record.type != null and 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 a.balance = #{record.balance} | 
|             </if> | 
|             <if test="record.remark != null and record.remark !='' "> | 
|                 and a.remark = #{record.remark} | 
|             </if> | 
|             <if test="record.isCourse != null and record.isCourse !='' "> | 
|                and  a.is_course = #{record.isCourse}, | 
|             </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="selectByVipIdPrjUseCount" | 
|             resultType="java.lang.Integer"> | 
|         select count(*) from | 
|         sys_proj_use | 
|         where | 
|         VIP_ID=#{vipId} | 
|         AND | 
|         PROJ_ID=#{prjId} | 
|     </select> | 
|     <!-- 根据会员id查询 --> | 
|     <select id="selectByVipIdPrjUse" resultMap="SysProjUseMap"> | 
|         select * | 
|         from sys_proj_use | 
|         where VIP_ID=#{vipId} | 
|         and PROJ_ID=#{prjId} | 
|     </select> | 
|   | 
|     <!-- 查询总条数 --> | 
|     <select id="selectTotalRecord" resultType="java.lang.Integer"> | 
|         select count(*) | 
|         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> | 
|             <if test="record.projId != null and record.projId !='' "> | 
|                 and a.PROJ_ID = #{record.projId} | 
|             </if> | 
|             <if test="record.surplusCount != null and record.surplusCount !='' "> | 
|                 and a.SURPLUS_COUNT = #{record.surplusCount} | 
|             </if> | 
|             <if test="record.isOver != null and record.isOver !='' "> | 
|                 and a.IS_OVER = #{record.isOver} | 
|             </if> | 
|             <!-- 查询具体某一个套餐的使用情况 --> | 
|             <if | 
|                     test="record.taocanId != null and record.taocanId !=-1 and record.taocanId !=-2"> | 
|                 and a.TAOCAN_ID = #{record.taocanId} | 
|             </if> | 
|             <!-- 查询所有的项目使用情况 --> | 
|             <if test="record.taocanId != null and record.taocanId ==-1 "> | 
|                 and a.TAOCAN_ID IS NULL | 
|             </if> | 
|             <!-- 查询所有的套餐使用情况 --> | 
|             <if test="record.taocanId != null and record.taocanId ==-2 "> | 
|                 and a.TAOCAN_ID IS NOT NULL | 
|             </if> | 
|             <if test="record.vipId != null and 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 a.PRICE = #{record.price} | 
|             </if> | 
|             <if test="record.assembleId != null and record.assembleId !='' "> | 
|                 and a.ASSEMBLE_ID = #{record.assembleId} | 
|             </if> | 
|             <if test="record.source != null and record.source !='' "> | 
|                 and a.SOURCE like concat('%',#{record.source},'%') | 
|             </if> | 
|             <if test="record.status != null and record.status !='' "> | 
|                 and a.STATUS = #{record.status} | 
|             </if> | 
|             <if test="record.platformFlag != null and record.platformFlag !='' "> | 
|                 and a.PLATFORM_FLAG = #{record.platformFlag} | 
|             </if> | 
|             <if test="record.type != null and 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 a.balance = #{record.balance} | 
|             </if> | 
|             <if test="record.remark != null and record.remark !='' "> | 
|                 and a.remark = #{record.remark} | 
|             </if> | 
|             <if test="record.isCourse != null and record.isCourse !='' "> | 
|                 and  a.is_course = #{record.isCourse}, | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|     <!-- 根据id查询 --> | 
|     <select id="selectById" resultMap="SysProjUseMap"> | 
|         select a.*, | 
|         b.TIME_LENGTH, | 
|         b.img | 
|         from sys_proj_use a | 
|         left join shopping_goods b on a.proj_id=b.id | 
|         where | 
|         a.id=#{id} | 
|     </select> | 
|   | 
|     <!-- 根据id查询 --> | 
|     <select id="selectBySerProjId" resultMap="SysProjUseMap"> | 
|         select | 
|         a.*, | 
|         b.id serProjId | 
|         from sys_proj_use a | 
|         LEFT JOIN sys_ser_proj b on | 
|         a.ID =b.PRO_USEID | 
|         WHERE b.id = #{serProjId} | 
|   | 
|     </select> | 
|   | 
|   | 
|     <!-- 根据对象查询 --> | 
|     <select id="selectByModel" resultMap="SysProjUseMap"> | 
|         select | 
|         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 !='' "> | 
|                 and a.ID = #{record.id} | 
|             </if> | 
|             <if test="record.orderItemId != null and record.orderItemId !='' "> | 
|                 and a.ORDER_ITEM_ID = #{record.orderItemId} | 
|             </if> | 
|             <if test="record.projId != null and record.projId !='' "> | 
|                 and a.PROJ_ID = #{record.projId} | 
|             </if> | 
|             <if test="record.surplusCount != null and record.surplusCount !='' "> | 
|                 and a.SURPLUS_COUNT = #{record.surplusCount} | 
|             </if> | 
|             <if test="record.isOver != null and record.isOver !='' "> | 
|                 and a.IS_OVER = #{record.isOver} | 
|             </if> | 
|             <if test="record.taocanId != null and record.taocanId !=-1 "> | 
|                 and a.TAOCAN_ID = #{record.taocanId} | 
|             </if> | 
|             <if test="record.taocanId != null and record.taocanId ==-1 "> | 
|                 and a.TAOCAN_ID IS NULL | 
|             </if> | 
|             <if test="record.vipId != null and record.vipId !='' "> | 
|                 and a.VIP_ID = #{record.vipId} | 
|             </if> | 
|             <if test="record.price != null and record.price !='' "> | 
|                 and a.PRICE = #{record.price} | 
|             </if> | 
|             <if test="record.assembleId != null and record.assembleId !='' "> | 
|                 and a.ASSEMBLE_ID = #{record.assembleId} | 
|             </if> | 
|             <if test="record.source != null and record.source !='' "> | 
|                 and a.SOURCE like concat('%',#{record.source},'%') | 
|             </if> | 
|             <if test="record.status != null and record.status !='' "> | 
|                 and a.STATUS = #{record.status} | 
|             </if> | 
|             <if test="record.platformFlag != null and record.platformFlag !='' "> | 
|                 and a.PLATFORM_FLAG = #{record.platformFlag} | 
|             </if> | 
|             <if test="record.type != null and record.type !='' "> | 
|                 and a.type = #{record.type} | 
|             </if> | 
|             <if test="record.balance != null and record.balance !='' "> | 
|                 and a.balance = #{record.balance} | 
|             </if> | 
|             <if test="record.remark != null and record.remark !='' "> | 
|                 and a.remark = #{record.remark} | 
|             </if> | 
|             <if test="record.isCourse != null and record.isCourse !='' "> | 
|                 and  a.is_course = #{record.isCourse}, | 
|             </if> | 
|         </if> | 
|     </select> | 
|   | 
|   | 
|     <!--根据orderItemId和 vipId更新套餐下的项目 --> | 
|     <update id="updateProjStatus" parameterType="SysProjUse"> | 
|         UPDATE sys_proj_use | 
|         <set> | 
|             STATUS = #{status}, | 
|             <if test="source != null and source !='' "> | 
|                 SOURCE =#{source}, | 
|             </if> | 
|             <if test="failTime != null "> | 
|                 FAIL_TIME =#{failTime}, | 
|             </if> | 
|             <if test="remark != null and remark!='' "> | 
|                 remark = #{remark} | 
|             </if> | 
|         </set> | 
|         where  id=#{id} | 
|     </update> | 
|   | 
|     <!-- 批量更新套餐 --> | 
|     <update id="updateAllVipTaocan" parameterType="java.util.List"> | 
|         <foreach collection="list" item="item" index="index" separator=";"> | 
|             UPDATE sys_proj_use | 
|             <set> | 
|                 STATUS = #{item.status}, | 
|                 <if test="item.source != null and item.source !='' "> | 
|                     SOURCE =#{item.source}, | 
|                 </if> | 
|                 <if test="item.failTime != null and item.failTime!='' "> | 
|                     FAIL_TIME =#{item.failTime}, | 
|                 </if> | 
|                 <if test="(item.surplusCount != null and item.surplusCount !='') or  item.surplusCount == 0 "> | 
|                     SURPLUS_COUNT = #{item.surplusCount}, | 
|                 </if> | 
|                 <if test="item.remark != null and item.remark!='' "> | 
|                     remark = #{item.remark} | 
|                 </if> | 
|             </set> | 
|             where PLATFORM_FLAG = #{item.platformFlag} | 
|             and VIP_ID=#{item.vipId} | 
|             and PROJ_ID=#{item.projId} | 
|         </foreach> | 
|     </update> | 
|   | 
|   | 
|     <update id="updateProjUseTck"> | 
|         UPDATE sys_proj_use | 
|         set | 
|         SURPLUS_COUNT = #{surplusCount}, | 
|         IS_OVER = #{isOver}, | 
|         status = #{status}, | 
|         balance = #{balance} | 
|         WHERE  ORDER_ITEM_ID = #{orderItemId} | 
|     </update> | 
|     <!-- 冻结套餐 --> | 
|     <update id="updateTcStatus" > | 
|         update sys_proj_use  set STATUS = #{status}  where  id=#{id} or TAOCAN_ID=#{id}; | 
|     </update> | 
|   | 
|     <insert id="insertAll" parameterType="java.util.List"> | 
|         INSERT INTO sys_proj_use ( | 
|         ORDER_ITEM_ID, | 
|         PROJ_ID, | 
|         SURPLUS_COUNT, | 
|         IS_OVER, | 
|         VIP_ID, | 
|         TAOCAN_ID, | 
|         FAIL_TIME, | 
|         ASSEMBLE_ID, | 
|         SOURCE, | 
|         STATUS, | 
|         PRICE, | 
|         PLATFORM_FLAG, | 
|         balance, | 
|         remark, | 
|         proj_name, | 
|         tcName, | 
|         deductionNum, | 
|         is_course | 
|         ) | 
|         VALUES | 
|         <foreach collection="list" item="item" separator=","> | 
|             ( | 
|             #{item.orderItemId}, | 
|             #{item.projId}, | 
|             #{item.surplusCount}, | 
|             #{item.isOver}, | 
|             #{item.vipId}, | 
|             #{item.taocanId}, | 
|             #{item.failTime}, | 
|             #{item.assembleId}, | 
|             #{item.source}, | 
|             #{item.status}, | 
|             #{item.price}, | 
|             #{item.platformFlag}, | 
|             #{item.balance}, | 
|             #{item.remark}, | 
|             #{projName}, | 
|             #{tcName}, | 
|             #{deductionNum}, | 
|             #{isCourse} | 
|             ) | 
|         </foreach> | 
|     </insert> | 
|   | 
|     <select id="selectItemDetail" resultType="java.util.HashMap" parameterType="java.util.HashMap"> | 
|         select c.VIP_NAME, | 
|         a.PROJ_NAME, | 
|         f.name as TYPE_NAME, | 
|         a.SURPLUS_COUNT, | 
|         a.PRICE, | 
|         a.IS_OVER, | 
|         a.FAIL_TIME, | 
|         a.type, | 
|         a.SOURCE, | 
|         e.ORDER_NO, | 
|         a.remark | 
|         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_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> | 
|             <if test="shopId != null and  shopId != ''"> | 
|                 and c.shop_id =#{shopId} | 
|             </if> | 
|             <if test="beginTime != null and beginTime != ''  "> | 
|                 and a.FAIL_TIME  <![CDATA[>=]]> #{beginTime} | 
|             </if> | 
|             <if test="endTime != null and endTime != ''    "> | 
|                 and a.FAIL_TIME <![CDATA[<=]]> #{endTime} | 
|   | 
|             </if> | 
|             <if test="vipQueryKey != null and vipQueryKey != ''  "> | 
|                 and e.VIP_NAME like concat('%',#{vipQueryKey},'%') | 
|                 or (e.VIP_NO like concat('%',#{vipQueryKey},'%') | 
|                 or e.PHONE like concat('%',#{vipQueryKey},'%') | 
|                 ) | 
|             </if> | 
|             <if test="projName != null and projName != ''  "> | 
|               and  a.proj_name like concat('%',#{projName},'%') | 
|             </if> | 
|             <if test="cateId != null and cateId != ''  "> | 
|                 and  b.cate_id=#{cateId} | 
|             </if> | 
|         </where> | 
|   | 
|         <if test="sort !=null and sort!=''"> order by ${sort} ${order}</if> | 
|         <if test="(offset !=null and offset!='') or offset==0 "> | 
|             limit ${offset},${limit} | 
|         </if> | 
|     </select> | 
|   | 
|   | 
|     <select id="selectItemDetailTotal" resultType="java.lang.Integer"> | 
|         select count(a.id) | 
|         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_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> | 
|             <if test="shopId != null and  shopId != ''"> | 
|                 and c.shop_id =#{shopId} | 
|             </if> | 
|             <if test="beginTime != null and beginTime != ''  "> | 
|                 and a.FAIL_TIME  <![CDATA[>=]]> #{beginTime} | 
|             </if> | 
|             <if test="endTime != null and endTime != ''    "> | 
|                 and a.FAIL_TIME <![CDATA[<=]]> #{endTime} | 
|   | 
|             </if> | 
|             <if test="vipQueryKey != null and vipQueryKey != ''  "> | 
|                 and e.VIP_NAME like concat('%',#{vipQueryKey},'%') | 
|                 or (e.VIP_NO like concat('%',#{vipQueryKey},'%') | 
|                 or e.PHONE like concat('%',#{vipQueryKey},'%') | 
|                 ) | 
|             </if> | 
|             <if test="projName != null and projName != ''  "> | 
|                 and  a.proj_name like concat('%',#{projName},'%') | 
|             </if> | 
|             <if test="cateId != null and cateId != ''  "> | 
|                 and  b.cate_id=#{cateId} | 
|             </if> | 
|         </where> | 
|     </select> | 
|   | 
|     <select id="summaryItemDetail" resultType="java.util.HashMap" parameterType="java.util.HashMap"> | 
|         select | 
|         b.id, | 
|         a.PROJ_NAME, | 
|         f.name as TYPE_NAME, | 
|         SUM(a.SURPLUS_COUNT) as SURPLUS_COUNT, | 
|         ROUND(SUM(a.PRICE*a.SURPLUS_COUNT) ,2)as PRICE | 
|         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 shopping_goods_category f on f.id = b.cate_id | 
|         <where> | 
|             <if test="shopId != null and  shopId != ''"> | 
|                 and c.shop_id =#{shopId} | 
|             </if> | 
|             <if test="projName != null and projName != ''  "> | 
|                 and  a.proj_name like concat('%',#{projName},'%') | 
|             </if> | 
|             <if test="cateId != null and cateId != ''  "> | 
|                 and  b.cate_id=#{cateId} | 
|             </if> | 
|         </where> | 
|         group by b.id | 
|   | 
|         <if test="sort !=null and sort!=''"> order by ${sort} ${order}</if> | 
|         <if test="(offset !=null and offset!='') or offset==0 "> | 
|             limit ${offset},${limit} | 
|         </if> | 
|     </select> | 
|   | 
|     <select id="summaryItemDetailTotal" resultType="java.lang.Integer"> | 
|         select count(1) from ( | 
|         select count(1) | 
|         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 shopping_goods_category f on f.id = b.cate_id | 
|         <where> | 
|             <if test="shopId != null and  shopId != ''"> | 
|                 and c.shop_id =#{shopId} | 
|             </if> | 
|             <if test="projName != null and projName != ''  "> | 
|                 and  a.proj_name like concat('%',#{projName},'%') | 
|             </if> | 
|             <if test="cateId != null and cateId != ''  "> | 
|                 and  b.cate_id=#{cateId} | 
|             </if> | 
|         </where> | 
|         group by b.id) t | 
|     </select> | 
|   | 
|     <select id="selectHasValidProjUse" resultMap="SysProjUseMap"> | 
|         select * from sys_proj_use | 
|         where date_format(now(), '%Y-%m-%d') > date_format(FAIL_TIME, '%Y-%m-%d') and STATUS='有效' | 
|     </select> | 
|   | 
|   | 
| </mapper> |