| <?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.shopXcx.dao.ShopActivitiesSeckillInfoDao"> | 
|     <!-- 定义ShopActivitiesSeckillInfo 的复杂关联map --> | 
|     <resultMap type="com.matrix.system.shopXcx.bean.ShopActivitiesSeckillInfo" id="ShopActivitiesSeckillInfoMap"> | 
|         <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="actId" column="act_id" /> | 
|         <result property="goodsId" column="goods_id" /> | 
|         <result property="siPrice" column="si_price" /> | 
|         <result property="siCount" column="si_count" /> | 
|         <result property="siLimitCnt" column="si_limit_cnt" /> | 
|         <result property="siRemainCnt" column="si_remain_cnt" /> | 
|         <result property="companyId" column="company_id" /> | 
|         <association property="goods" column="goods_id" javaType="com.matrix.system.shopXcx.bean.ShopProduct"> | 
|             <id property="id" column="goodsId" /> | 
|             <result property="title" column="title" /> | 
|             <result property="briefIntroduction" column="briefIntroduction" /> | 
|             <result property="imgPc" column="img_pc"/> | 
|             <result property="imgMobile" column="img_mobile" /> | 
|             <result property="price" column="price" /> | 
|             <result property="mobileDetails" column="mobile_details" /> | 
|             <result property="dsVolume" column="ds_volume" /> | 
|             <result property="status" column="status" /> | 
|             <result property="delFlag" column="del_flag" /> | 
|         </association> | 
|     </resultMap> | 
|      | 
|      | 
|     <!-- 定义ShopActivitiesSeckillInfo 的简单map  ,本map不添加其他的关联属性 --> | 
|     <resultMap type="com.matrix.system.shopXcx.bean.ShopActivitiesSeckillInfo" id="ShopActivitiesSeckillInfoSimpleMap"> | 
|         <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="actId" column="act_id" /> | 
|             <result property="goodsId" column="goods_id" /> | 
|             <result property="siPrice" column="si_price" /> | 
|             <result property="siCount" column="si_count" /> | 
|             <result property="siLimitCnt" column="si_limit_cnt" /> | 
|     </resultMap> | 
|      | 
|     <!-- 字段sql --> | 
|     <sql id="columns"> | 
|         create_by, | 
|         create_time, | 
|         update_by, | 
|         update_time, | 
|             id, | 
|             act_id, | 
|             goods_id, | 
|             si_price, | 
|             si_count, | 
|             si_limit_cnt, | 
|             si_remain_cnt, | 
|             company_id | 
|     </sql> | 
|      | 
|     <!-- 属性sql --> | 
|     <sql id="propertys"> | 
|         #{item.createBy}, | 
|         now(), | 
|         #{item.updateBy}, | 
|         now(), | 
|             #{item.id}, | 
|             #{item.actId}, | 
|             #{item.goodsId}, | 
|             #{item.siPrice}, | 
|             #{item.siCount}, | 
|             #{item.siLimitCnt}, | 
|             #{item.siRemainCnt}, | 
|             #{item.companyId} | 
|     </sql> | 
|      | 
|     <!-- where sql --> | 
|     <sql id="where_sql"> | 
|           | 
|          <if test="record!=null"> | 
|             <if test="(record.id!=null and record.id!='') or  (record.id!='' and record.id==0)  "> | 
|                 and id  = #{record.id}  | 
|             </if> | 
|             <if test="(record.actId!=null and record.actId!='') or  (record.actId!='' and record.actId==0)  "> | 
|                 and act_id  = #{record.actId}  | 
|             </if> | 
|              <if test="(record.companyId!=null and record.companyId!='') or  (record.companyId!='' and record.companyId==0)  "> | 
|                  and company_id  = #{record.companyId} | 
|              </if> | 
|             <if test="(record.goodsId!=null and record.goodsId!='') or  (record.goodsId!='' and record.goodsId==0)  "> | 
|                 and goods_id  = #{record.goodsId}  | 
|             </if> | 
|             <if test="(record.siPrice!=null and record.siPrice!='') or  (record.siPrice!='' and record.siPrice==0)  "> | 
|                 and si_price  = #{record.siPrice}  | 
|             </if> | 
|             <if test="(record.siCount!=null and record.siCount!='') or  (record.siCount!='' and record.siCount==0)  "> | 
|                 and si_count  = #{record.siCount}  | 
|             </if> | 
|             <if test="(record.siLimitCnt!=null and record.siLimitCnt!='') or  (record.siLimitCnt!='' and record.siLimitCnt==0)  "> | 
|                 and si_limit_cnt  = #{record.siLimitCnt}  | 
|             </if> | 
|         </if> | 
|           | 
|     </sql> | 
|      | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="com.matrix.system.shopXcx.bean.ShopActivitiesSeckillInfo" | 
|         useGeneratedKeys="true" keyProperty="item.id"> | 
|         INSERT INTO shop_activities_seckill_info ( | 
|              <include refid="columns"></include> | 
|         ) | 
|     VALUES ( | 
|          <include refid="propertys"></include> | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|      | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO shop_activities_seckill_info ( | 
|         <include refid="columns"></include>     | 
|         ) | 
|     VALUES  | 
|     <foreach collection="list" item="item" index="index" separator=",">( | 
|         <include refid="propertys"></include>     | 
|     )</foreach> | 
|     </insert> | 
|      | 
|      | 
|      | 
|      | 
|      | 
|     <!--  根据Map更新 部分更新   --> | 
|     <update id="updateByMap" parameterType="java.util.HashMap" > | 
|         UPDATE shop_activities_seckill_info | 
|         <set> | 
|             <if test="_parameter.containsKey('actId')"> | 
|                     act_id = #{actId}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('goodsId')"> | 
|                     goods_id = #{goodsId}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('siPrice')"> | 
|                     si_price = #{siPrice}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('siCount')"> | 
|                     si_count = #{siCount}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('siLimitCnt')"> | 
|                     si_limit_cnt = #{siLimitCnt}, | 
|                 </if>         | 
|         </set> | 
|         WHERE id=#{id}  | 
|     </update>  | 
|      | 
|      | 
|     <!--  根据对象更新 部分更新   --> | 
|     <update id="updateByModel" parameterType="Long"> | 
|         UPDATE shop_activities_seckill_info | 
|         <set> | 
|             <if test="record.actId != null "> | 
|                 act_id  = #{record.actId},  | 
|             </if> | 
|             <if test="record.goodsId != null "> | 
|                 goods_id  = #{record.goodsId},  | 
|             </if> | 
|             <if test="record.siPrice != null "> | 
|                 si_price  = #{record.siPrice},  | 
|             </if> | 
|             <if test="record.siCount != null "> | 
|                 si_count  = #{record.siCount},  | 
|             </if> | 
|             <if test="record.siLimitCnt != null "> | 
|                 si_limit_cnt  = #{record.siLimitCnt}, | 
|             </if> | 
|             <if test="record.siRemainCnt != null "> | 
|                 si_remain_cnt  = #{record.siRemainCnt}, | 
|             </if> | 
|         </set> | 
|         WHERE id=#{record.id}  | 
|     </update> | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from shop_activities_seckill_info where  id in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|          | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" parameterType="Long"> | 
|         DELETE FROM shop_activities_seckill_info | 
|         where  id=#{id}  | 
|     </delete> | 
|      | 
|     <!-- 根据对象删除--> | 
|     <delete id="deleteByModel" parameterType="com.matrix.system.shopXcx.bean.ShopActivitiesSeckillInfo"> | 
|         DELETE FROM shop_activities_seckill_info | 
|         <where> | 
|         <include refid="where_sql" ></include> | 
|         </where> | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="ShopActivitiesSeckillInfoMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_activities_seckill_info | 
|         <where> | 
|           <include refid="where_sql"></include> | 
|          </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="selectTotalRecord" parameterType="long"   resultType="java.lang.Integer"> | 
|     select count(*) | 
|     from shop_activities_seckill_info | 
|         <where> | 
|            <include refid="where_sql"></include> | 
|         </where> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="ShopActivitiesSeckillInfoMap"> | 
|         select | 
|             t1.*, | 
|             t2.id goodsId, | 
|             t2.title title, | 
|             t2.brief_introduction briefIntroduction, | 
|             t2.img_pc, | 
|             t2.img_mobile, | 
|             t2.price, | 
|             t2.mobile_details, | 
|             t2.ds_volume, | 
|             t2.status, | 
|             t2.del_flag | 
|         from shop_activities_seckill_info t1 | 
|         inner join shop_product t2 on t1.goods_id=t2.id | 
|         where t1.id=#{id} | 
|     </select>     | 
|      | 
|      | 
|     <!-- 根据id 锁表查询--> | 
|     <select id="selectForUpdate" resultMap="ShopActivitiesSeckillInfoMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_activities_seckill_info | 
|         where  id=#{id}  | 
|         for update | 
|     </select>     | 
|      | 
|      | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="ShopActivitiesSeckillInfoMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from shop_activities_seckill_info | 
|         <where> | 
|           <include refid="where_sql"></include> | 
|          </where> | 
|     </select> | 
|   | 
|     <select id="selectSeckillInfoByActId" resultMap="ShopActivitiesSeckillInfoMap"> | 
|         select | 
|             t1.*, | 
|             t2.id goodsId, | 
|             t2.title title, | 
|             t2.brief_introduction briefIntroduction, | 
|             t2.img_pc, | 
|             t2.img_mobile, | 
|             t2.price | 
|         from shop_activities_seckill_info t1 | 
|         inner join shop_product t2 on t1.goods_id=t2.id | 
|         where act_id=#{actId} | 
|     </select> | 
|   | 
|     <select id="selectSecKillGoodsListForWx" resultMap="ShopActivitiesSeckillInfoMap"> | 
|         select | 
|             t1.*, | 
|             t2.id goodsId, | 
|             t2.title title, | 
|             t2.brief_introduction briefIntroduction, | 
|             t2.img_pc, | 
|             t2.img_mobile, | 
|             t2.price | 
|         from shop_activities_seckill_info t1 | 
|         inner join shop_product t2 on t1.goods_id=t2.id | 
|         where act_id=#{record.id} | 
|         limit #{record.offset},#{record.limit} | 
|     </select> | 
|   | 
|     <delete id="deleteByActId"> | 
|         delete from shop_activities_seckill_info | 
|         where act_id=#{actId} | 
|     </delete> | 
|   | 
|     <select id="selectSecKillInfoByActIdAndGoodsId" resultMap="ShopActivitiesSeckillInfoMap"> | 
|         select | 
|             t1.*, | 
|             t2.id goodsId, | 
|             t2.title title, | 
|             t2.brief_introduction briefIntroduction, | 
|             t2.img_pc, | 
|             t2.img_mobile, | 
|             t2.price | 
|         from shop_activities_seckill_info t1 | 
|         inner join shop_product t2 on t1.goods_id=t2.id | 
|         where t1.act_id=#{record.id} and t1.goods_id=#{goodsId} | 
|     </select> | 
| </mapper> |