| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?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.sckw.order.dao.KwpWantBuyMapper">
- <sql id="Base_Column_List">
- kb.id
- ,kb.`name`
- ,kb.ent_id
- , kb.goods_type goodsType
- , kb.spec
- , kb.price
- , kb.amount
- , kb.contacts
- , kb.phone
- , kb.status
- , kb.remark
- , kb.create_time createTime
- , kb.update_time updateTime
- , kt.want_buy_id wantBuyId
- , kt.trading trading
- , kba.name addressName
- , kba.city_name cityName
- , kba.detail_address detailAddress
- </sql>
- <resultMap id="wangBuyResultMap" type="com.sckw.order.model.vo.res.WantBuySelectRes">
- <id column="id" property="id"/>
- <result column="name" property="name"/>
- <result column="goodsType" property="goodsType"/>
- <result column="spec" property="spec"/>
- <result column="price" property="price"/>
- <result column="amount" property="amount"/>
- <result column="contacts" property="contacts"/>
- <result column="phone" property="phone"/>
- <result column="status" property="status"/>
- <result column="remark" property="remark"/>
- <result column="createTime" property="createTime"/>
- <result column="updateTime" property="updateTime"/>
- </resultMap>
- <sql id="managerWhere">
- kb.del_flag = 0
- <if test="authEntIdList != null and authEntIdList.size() != 0">
- and kb.ent_id in
- <foreach collection="authEntIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="wantBuyReq.startCreateTime != null">
- and kb.create_time >= #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP}
- </if>
- <if test="wantBuyReq.endCreateTime != null">
- and kb.create_time <= #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
- </if>
- <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
- <!--私用and条件-->
- <!-- and kt.trading in-->
- <!-- <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">-->
- <!-- #{item,jdbcType=VARCHAR}-->
- <!-- </foreach>-->
- <!-- 使用 AND 条件 -->
- <!-- and (-->
- <!-- <foreach collection="wantBuyReq.tradings" item="item" separator=" and ">-->
- <!-- kt.trading = #{item,jdbcType=VARCHAR}-->
- <!-- </foreach>-->
- <!-- )-->
- <foreach collection="wantBuyReq.tradings" item="value" separator="">
- AND EXISTS (
- SELECT 1
- FROM kwo_want_buy_trading kt2
- WHERE kt2.want_buy_id = kb.id
- AND kt2.trading = #{value}
- )
- </foreach>
- </if>
- <if test="wantBuyReq.wantBuyIds != null and wantBuyReq.wantBuyIds.size() > 0">
- and kb.id in
- <foreach collection="wantBuyReq.wantBuyIds" item="item" open="(" close=")" separator=",">
- #{item,jdbcType=BIGINT}
- </foreach>
- </if>
- <if test="wantBuyReq.status != null">
- and kb.status = #{wantBuyReq.status}
- </if>
- <if test="wantBuyReq.entId != null ">
- and kb.ent_id = #{wantBuyReq.entId}
- </if>
- <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
- <if test="wantBuyReq.entIds != null and wantBuyReq.entIds.size() > 0">
- and (kb.ent_id in
- <foreach collection="wantBuyReq.entIds" item="item" open="(" close=")" separator=",">
- #{item,jdbcType=BIGINT}
- </foreach>
- or kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
- )
- </if>
- <if test="wantBuyReq.entIds == null or wantBuyReq.entIds.size() == 0">
- and (kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%'))
- </if>
- </if>
- <if test="wantBuyReq.goodsTypeValueSearch != null and wantBuyReq.goodsTypeValueSearch.size() > 0">
- and kb.goods_type in
- <foreach collection="wantBuyReq.goodsTypeValueSearch" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="wantBuyReq.cityCode != null and wantBuyReq.cityCode != ''">
- and (kba.`city_code` like concat(#{wantBuyReq.cityCode,jdbcType=VARCHAR}, '%'))
- </if>
- <if test="wantBuyReq.systemType != null and wantBuyReq.systemType == 1">
- and kb.status in (1,2)
- </if>
- </sql>
- <sql id="where">
- kb.del_flag = 0
- <if test="wantBuyReq.startCreateTime != null">
- and kb.create_time >= #{wantBuyReq.startCreateTime,jdbcType=TIMESTAMP}
- </if>
- <if test="wantBuyReq.endCreateTime != null">
- and kb.create_time <= #{wantBuyReq.endCreateTime,jdbcType=TIMESTAMP}
- </if>
- <if test="wantBuyReq.tradings != null and wantBuyReq.tradings.size() > 0">
- <!--私用and条件-->
- <!-- and kt.trading in-->
- <!-- <foreach collection="wantBuyReq.tradings" item="item" open="(" close=")" separator=",">-->
- <!-- #{item,jdbcType=VARCHAR}-->
- <!-- </foreach>-->
- <!-- 使用 AND 条件 -->
- <!-- and (-->
- <!-- <foreach collection="wantBuyReq.tradings" item="item" separator=" and ">-->
- <!-- kt.trading = #{item,jdbcType=VARCHAR}-->
- <!-- </foreach>-->
- <!-- )-->
- <foreach collection="wantBuyReq.tradings" item="value" separator="">
- AND EXISTS (
- SELECT 1
- FROM kwo_want_buy_trading kt2
- WHERE kt2.want_buy_id = kb.id
- AND kt2.trading = #{value}
- )
- </foreach>
- </if>
- <if test="wantBuyReq.wantBuyIds != null and wantBuyReq.wantBuyIds.size() > 0">
- and kb.id in
- <foreach collection="wantBuyReq.wantBuyIds" item="item" open="(" close=")" separator=",">
- #{item,jdbcType=BIGINT}
- </foreach>
- </if>
- <if test="wantBuyReq.status != null">
- and kb.status = #{wantBuyReq.status}
- </if>
- <if test="wantBuyReq.entId != null ">
- and kb.ent_id = #{wantBuyReq.entId}
- </if>
- <if test="wantBuyReq.keywords != null and wantBuyReq.keywords != ''">
- <if test="wantBuyReq.entIds != null and wantBuyReq.entIds.size() > 0">
- and (kb.ent_id in
- <foreach collection="wantBuyReq.entIds" item="item" open="(" close=")" separator=",">
- #{item,jdbcType=BIGINT}
- </foreach>
- or kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%')
- )
- </if>
- <if test="wantBuyReq.entIds == null or wantBuyReq.entIds.size() == 0">
- and (kb.`name` like concat('%', #{wantBuyReq.keywords,jdbcType=VARCHAR}, '%'))
- </if>
- </if>
- <if test="wantBuyReq.goodsTypeValueSearch != null and wantBuyReq.goodsTypeValueSearch.size() > 0">
- and kb.goods_type in
- <foreach collection="wantBuyReq.goodsTypeValueSearch" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="wantBuyReq.cityCode != null and wantBuyReq.cityCode != ''">
- and (kba.`city_code` like concat(#{wantBuyReq.cityCode,jdbcType=VARCHAR}, '%'))
- </if>
- <if test="wantBuyReq.systemType != null and wantBuyReq.systemType == 1">
- and kb.status in (1,2)
- </if>
- <if test="wantBuyReq.specialEntIds != null and wantBuyReq.specialEntIds.size() > 0">
- and kb.ent_id in
- <foreach collection="wantBuyReq.specialEntIds" item="item" open="(" close=")" separator=",">
- #{item,jdbcType=BIGINT}
- </foreach>
- </if>
- </sql>
- <select id="pageSelect" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
- select
- <include refid="Base_Column_List" />
- from kwo_want_buy kb
- left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
- <where>
- <include refid="where" />
- </where>
- order by kb.create_time desc
- </select><select id="pageSelectAllByManager" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
- select
- <include refid="Base_Column_List" />
- from kwo_want_buy kb
- left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
- <where>
- <include refid="managerWhere" />
- </where>
- order by kb.create_time desc
- </select>
- <!-- <resultMap id="tradIngMap" type="com.sckw.order.model.KwoWantBuyTrading">-->
- <resultMap id="tradIngMap" type="com.sckw.order.model.vo.res.WantBuyTradingRes">
- <id column="wantBuyId" property="wantBuyId"/>
- <result column="trading" property="trading"/>
- </resultMap>
- <select id="tradingSql" resultMap="tradIngMap">
- select want_buy_id wantBuyId, trading
- from kwo_want_buy_trading
- where want_buy_id = #{wantBuyId} and del_flag = 0
- </select>
- <select id="statisticsCount" resultType="com.sckw.order.model.vo.res.TableTopRes" parameterType="java.util.Map">
- select kb.`status` value
- from kwo_want_buy kb left join kwo_want_buy_trading kt on kb.id = kt.want_buy_id
- <where>
- <include refid="where" />
- </where>
- group by kb.id
- order by kb.create_time desc
- </select>
- <select id="queryBuyHallList" resultMap="wangBuyResultMap" resultType="com.sckw.order.model.vo.res.WantBuySelectRes">
- select
- <include refid="Base_Column_List" />
- from kwo_want_buy kb
- left join kwo_want_buy_address kba on kb.id = kba.want_buy_id and kba.del_flag = 0
- <where>
- <include refid="where" />
- </where>
- order by RAND()
- </select>
- </mapper>
|