yujian
2019-06-25 b7b8f2a4fe9059ef7b5470a68bb1b34787bc92b2
fanli/src/main/java/com/yeshi/fanli/mapping/homemodule/SpecialMapper.xml
@@ -104,6 +104,25 @@
    </set> where b_id = #{id,jdbcType=BIGINT}
  </update>
  
  <sql id="Sex_Screen">
   <!-- 通用版 -->
   <if test="sex == 0">
      AND (sp.`b_sex`= 120 OR sp.`b_sex`= 0 OR sp.`b_sex` = 10 OR sp.`b_sex` = 20)
      ORDER BY sp.`b_orderby`
   </if>
   <!-- 女版 -->
   <if test="sex == 1">
      AND (sp.`b_sex`= 120 OR sp.`b_sex`= 1 OR sp.`b_sex` = 10 OR sp.`b_sex` = 12)
      ORDER BY sp.`b_order_woman`
   </if>
   <!-- 男版 -->
   <if test="sex == 2">
      AND (sp.`b_sex`= 120 OR sp.`b_sex`= 2 OR sp.`b_sex` = 20 OR sp.`b_sex` = 12)
      ORDER BY sp.`b_order_man`
   </if>
  </sql>
  <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
      delete from yeshi_ec_special WHERE b_id in
      <foreach collection="list" item="item" open="(" close=")"
@@ -131,40 +150,80 @@
   </select>
   
   <select id="listQueryByCard" resultMap="BaseResultMap">
      SELECT <include refid="Base_Column_List" /> FROM  `yeshi_ec_special` pp
      WHERE pp.`b_card_id` = #{cardId}
      SELECT <include refid="Base_Column_List" /> FROM  `yeshi_ec_special` sp
      WHERE sp.`b_card_id` = #{cardId}
         <if test='key != null and key != ""'>
               AND b_name like '%${key}%'
               AND sp.b_name like '%${key}%'
         </if>
      ORDER BY pp.b_orderby
         <include refid="Sex_Screen"/>
       LIMIT ${start},${count}
   </select>
   
   <select id="countlistQueryByCard" resultType="java.lang.Long">
      SELECT IFNULL(count(b_id),0) FROM  `yeshi_ec_special` pp
      WHERE pp.`b_card_id` = #{cardId}
      SELECT IFNULL(count(b_id),0) FROM  `yeshi_ec_special` sp
      WHERE sp.`b_card_id` = #{cardId}
         <if test='key != null and key != ""'>
               AND b_name like '%${key}%'
               AND sp.b_name like '%${key}%'
         </if>
         <include refid="Sex_Screen"/>
   </select>
  
   <select id="getMaxOrderByCard" resultType="java.lang.Integer">
   <select id="getDefaultMaxOrder" resultType="java.lang.Integer">
       SELECT IFNULL(MAX(pp.b_orderby),0) FROM yeshi_ec_special pp 
       WHERE pp.`b_card_id` = #{cardId}
   </select>
  
  <select id="getManMaxOrder" resultType="java.lang.Integer">
       SELECT IFNULL(MAX(pp.b_order_man),0) FROM yeshi_ec_special pp
       WHERE pp.`b_card_id` = #{cardId}
   </select>
  <select id="getWomanMaxOrder" resultType="java.lang.Integer">
       SELECT IFNULL(MAX(pp.b_order_woman),0) FROM yeshi_ec_special pp
       WHERE pp.`b_card_id` = #{cardId}
   </select>
   <select id="getOrderByCardID" resultMap="BaseResultMap">
       SELECT  <include refid="Base_Column_List" /> FROM yeshi_ec_special
       WHERE b_card_id = #{cardId}
       <if test="type == -1">
          <![CDATA[and b_orderby < #{order}]]>
          order by b_orderby desc
       </if>
       <if test="type == 1">
          <![CDATA[and b_orderby > #{order} ]]>
          order by b_orderby
       </if>
       SELECT  <include refid="Base_Column_List" /> FROM yeshi_ec_special sp
       WHERE sp.b_card_id = #{cardId}
       <!-- 通用版 -->
      <if test="sex == 0 or sex == 120">
         AND (sp.`b_sex`= 120 OR sp.`b_sex`= 0 OR sp.`b_sex` = 10 OR sp.`b_sex` = 20)
         <if test="type == -1">
             <![CDATA[and sp.b_orderby < #{order}]]>
             order by sp.b_orderby desc
          </if>
          <if test="type == 1">
             <![CDATA[and sp.b_orderby > #{order} ]]>
             order by sp.b_orderby
          </if>
      </if>
      <!-- 女版 -->
      <if test="sex == 1">
         AND (sp.`b_sex`= 120 OR sp.`b_sex`= 1 OR sp.`b_sex` = 10 OR sp.`b_sex` = 12)
         <if test="type == -1">
             <![CDATA[and sp.b_order_woman < #{order}]]>
             order by sp.b_order_woman desc
          </if>
          <if test="type == 1">
             <![CDATA[and sp.b_order_woman > #{order} ]]>
             order by sp.b_order_woman
          </if>
      </if>
      <!-- 男版 -->
      <if test="sex == 2">
         AND (sp.`b_sex`= 120 OR sp.`b_sex`= 2 OR sp.`b_sex` = 20 OR sp.`b_sex` = 12)
         <if test="type == -1">
             <![CDATA[and sp.b_order_man < #{order}]]>
             order by sp.b_order_man desc
          </if>
          <if test="type == 1">
             <![CDATA[and sp.b_order_man > #{order} ]]>
             order by sp.b_order_man
          </if>
      </if>
       limit 1
   </select>
   
@@ -194,26 +253,7 @@
         AND IF(c.`cd_end_time` IS NULL,TRUE,c.`cd_end_time`<![CDATA[>=]]>NOW())
         AND pc.`sp_key` = #{placeKey}
         LIMIT 1)c ON  sp.`b_card_id` = c.`cd_id`
      WHERE sp.`b_state` = 0
         <!-- 全部使用 -->
         <if test="sex == null">
            AND sp.`b_sex`= 120
            ORDER BY sp.`b_orderby`
         </if>
         <!-- 通用版 -->
         <if test="sex == 0">
            AND (sp.`b_sex`= 120 OR sp.`b_sex`= 0 OR sp.`b_sex` = 10 OR sp.`b_sex` = 20)
            ORDER BY sp.`b_orderby`
         </if>
         <!-- 女版 -->
         <if test="sex == 1">
            AND (sp.`b_sex`= 120 OR sp.`b_sex`= 1 OR sp.`b_sex` = 10 OR sp.`b_sex` = 12)
            ORDER BY sp.`b_order_woman`
         </if>
         <!-- 男版 -->
         <if test="sex == 2">
            AND (sp.`b_sex`= 120 OR sp.`b_sex`= 2 OR sp.`b_sex` = 20 OR sp.`b_sex` = 12)
            ORDER BY sp.`b_order_man`
         </if>
      WHERE sp.`b_state` = 0
         <include refid="Sex_Screen"/>
   </select>
</mapper>