435 lines
18 KiB
XML
435 lines
18 KiB
XML
<?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.hzs.sale.wares.mapper.BdWaresMapper">
|
|
|
|
<!-- 通用查询映射结果 -->
|
|
<resultMap id="BaseResultMap" type="com.hzs.common.domain.sale.ext.BdWaresExt">
|
|
<id column="PK_ID" property="pkId"/>
|
|
<id column="PK_WARES_EXTEND" property="pkWaresExtend"/>
|
|
<result column="PK_COUNTRY" property="pkCountry"/>
|
|
<result column="WARES_CODE" property="waresCode"/>
|
|
<result column="WARES_NAME" property="waresName"/>
|
|
<result column="PK_TRANSACTION" property="pkTransaction"/>
|
|
<result column="WARES_PRICE" property="waresPrice"/>
|
|
<result column="WARES_ACHIEVE" property="waresAchieve"/>
|
|
<result column="PK_AREA_CLASSIFY" property="pkAreaClassify"/>
|
|
<result column="COVER" property="cover"/>
|
|
<result column="COVER1" property="cover1"/>
|
|
<result column="COVER2" property="cover2"/>
|
|
<result column="COVER3" property="cover3"/>
|
|
<result column="COVER4" property="cover4"/>
|
|
<result column="COVER5" property="cover5"/>
|
|
<result column="COVER6" property="cover6"/>
|
|
<result column="DETAILS" property="details"/>
|
|
<result column="SORT" property="sort"/>
|
|
<result column="SPECIAL_AREA" property="specialArea"/>
|
|
<result column="IS_SINGLE" property="isSingle"/>
|
|
<result column="IS_FREE_MAIL" property="isFreeMail"/>
|
|
<result column="IS_PUT_ON" property="isPutOn"/>
|
|
<result column="PRE_SALE_STATUS" property="preSaleStatus"/>
|
|
<result column="PUT_ON_TIME" property="putOnTime"/>
|
|
<result column="PUT_OFF_TIME" property="putOffTime"/>
|
|
<result column="OPERATE_SCOPE" property="operateScope"/>
|
|
<result column="PREFIX_LABEL" property="prefixLabel"/>
|
|
<result column="COOL_LABEL" property="coolLabel"/>
|
|
<result column="S_LABEL" property="sLabel"/>
|
|
<result column="SALES" property="sales"/>
|
|
<result column="IS_SALE" property="isSale"/>
|
|
<result column="IS_MAKER_GIFT" property="isMakerGift"/>
|
|
<result column="ARRIVAL_TIME" property="arrivalTime"/>
|
|
<result column="WARN_MESSAGE" property="warnMessage"/>
|
|
<result column="IS_LAND_TRANS" property="isLandTrans"/>
|
|
<result column="IS_AIR_TRANS" property="isAirTrans"/>
|
|
<result column="IS_OCEAN_TRANS" property="isOceanTrans"/>
|
|
<result column="PK_AGREEMENT" property="pkAgreement"/>
|
|
<result column="VIDEO_URL" property="videoUrl"/>
|
|
<result column="DETAILS_TYPE" property="detailsType"/>
|
|
<result column="AFTER_GUARANTEE" property="afterGuarantee"/>
|
|
<result column="giftNames" property="giftNames"/>
|
|
<result column="maker_income" property="makerIncome"/>
|
|
<result column="PK_SPECIAL_CURRENCY" property="pkSpecialCurrency"/>
|
|
</resultMap>
|
|
|
|
<resultMap id="resultMap" type="com.hzs.sale.wares.vo.WaresVo">
|
|
<result column="SORT" property="sort"/>
|
|
<result column="COVER" property="cover"/>
|
|
<result column="WARES_NAME" property="waresName"/>
|
|
<result column="WARES_CODE" property="waresCode"/>
|
|
<result column="WARES_PRICE" property="waresPrice"/>
|
|
<result column="WARES_ACHIEVE" property="waresAchieve"/>
|
|
<result column="SPECIAL_AREA" property="specialArea"/>
|
|
<result column="IS_SINGLE" property="isSingle"/>
|
|
<result column="IS_FREE_MAIL" property="isFreeMail"/>
|
|
<result column="CLASSIFY_NAME" property="classifyName"/>
|
|
<result column="OPERATE_SCOPE" property="operateScope"/>
|
|
<result column="IS_SALE" property="isSale"/>
|
|
<result column="IS_PUT_ON" property="isPutOn"/>
|
|
<result column="PRE_SALE_STATUS" property="preSaleStatus"/>
|
|
<result column="PK_ID" property="pkWares"/>
|
|
<result column="SALES" property="sales"/>
|
|
<result column="ARRIVAL_TIME" property="arrivalTime"/>
|
|
<result column="PUT_ON_TIME" property="putOnTime"/>
|
|
<result column="PUT_OFF_TIME" property="putOffTime"/>
|
|
<result column="actualSales" property="actualSales"/>
|
|
<result column="CREATION_TIME" property="creationTime"/>
|
|
<result column="IS_FORCED_READ" property="isForceoRead"/>
|
|
<result column="FORCED_READ_TIME" property="forceoReadTime"/>
|
|
<result column="IS_RECOMMEND" property="isRecommend"/>
|
|
<result column="LISTING_TIME" property="listingTime"/>
|
|
<result column="REMOVAL_TIME" property="removalTime"/>
|
|
<result column="SORT_STATUS" property="sortStatus"/>
|
|
<result column="IS_MAKER_GIFT" property="isMakerGift"/>
|
|
<result column="TEMP_NAME" property="tempName"/>
|
|
<result column="MAKER_INCOME" property="makerIncome"/>
|
|
<result column="SYSTEM_TYPE" property="systemType"/>
|
|
<result column="WARES_STATUS" property="waresStatus"/>
|
|
<result column="WARES_APPROVER" property="waresApprover"/>
|
|
<result column="WARES_APPROVAL_TIME" property="waresApprovalTime"/>
|
|
</resultMap>
|
|
|
|
<!-- 根据条件查询商品信息 -->
|
|
<select id="queryWaresByCondition" resultMap="BaseResultMap">
|
|
select bw.PK_COUNTRY,bw.PK_ID,be.pk_id PK_WARES_EXTEND,be.IS_MAKER_GIFT, bw.WARES_CODE, bw.WARES_NAME, PK_TRANSACTION,
|
|
PK_AREA_CLASSIFY, COVER1, COVER2, COVER3, COVER4, COVER5, COVER6,DETAILS_TYPE,
|
|
bw.WARES_PRICE, bw.WARES_ACHIEVE,
|
|
DETAILS, SORT, SPECIAL_AREA, IS_SINGLE,
|
|
IS_PUT_ON, PRE_SALE_STATUS, PUT_ON_TIME, PUT_OFF_TIME, OPERATE_SCOPE, PREFIX_LABEL, COOL_LABEL,
|
|
S_LABEL, SALES, IS_SALE, ARRIVAL_TIME, WARN_MESSAGE,
|
|
IS_LAND_TRANS,IS_AIR_TRANS,IS_OCEAN_TRANS,VIDEO_URL, be.maker_income,be.PK_SPECIAL_CURRENCY
|
|
from bd_wares bw
|
|
inner join bd_wares_extend be
|
|
on bw.pk_id = be.pk_wares
|
|
where bw.del_flag = 0
|
|
and be.del_flag = 0
|
|
and be.is_put_on = 0
|
|
<!-- 商品必须通过审核后才能显示 -->
|
|
and bw.wares_status = 5
|
|
<if test="specialArea != null">
|
|
and bw.special_area = #{specialArea}
|
|
</if>
|
|
<if test="pkCountry != null">
|
|
and bw.PK_COUNTRY = #{pkCountry}
|
|
</if>
|
|
<if test="pkAreaClassify != null and pkAreaClassify != ''">
|
|
and ( (
|
|
select t.pk_id
|
|
from BD_AREA_CLASSIFY t
|
|
where t.pk_id = bw.PK_AREA_CLASSIFY
|
|
start with t.PK_PARENT = #{pkAreaClassify}
|
|
connect by t.PK_PARENT = prior t.PK_ID
|
|
) > 0
|
|
or
|
|
bw.PK_AREA_CLASSIFY = #{pkAreaClassify}
|
|
)
|
|
</if>
|
|
<if test="waresCode != null and waresCode != ''">
|
|
and bw.wares_code = #{waresCode}
|
|
</if>
|
|
<if test="waresName != null and waresName != ''">
|
|
and bw.WARES_NAME like '%' || #{waresName} || '%'
|
|
</if>
|
|
|
|
<if test="null != waresCodeInList and waresCodeInList.size > 0">
|
|
and bw.wares_code in
|
|
<foreach collection="waresCodeInList" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
<if test="null != waresCodeNotInList and waresCodeNotInList.size > 0">
|
|
and bw.wares_code not in
|
|
<foreach collection="waresCodeNotInList" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
order by bw.SORT_STATUS desc , bw.WARES_PRICE ,bw.CREATION_TIME desc
|
|
</select>
|
|
|
|
<select id="getLastWaresCode" resultType="string">
|
|
select WARES_CODE
|
|
from (select t.WARES_CODE from BD_WARES t order by WARES_CODE desc)
|
|
where rownum = 1
|
|
</select>
|
|
|
|
<select id="selectByWaresInfo" resultMap="resultMap">
|
|
select
|
|
bw.SORT,bw.COVER,bw.WARES_NAME,bw.WARES_CODE,bw.WARES_PRICE,bw.WARES_ACHIEVE,bw.SPECIAL_AREA ,bw.IS_SINGLE,bw.IS_FREE_MAIL,
|
|
ac.CLASSIFY_NAME,we.OPERATE_SCOPE,we.IS_SALE,we.IS_PUT_ON,we.PRE_SALE_STATUS,bw.PK_ID,we.ARRIVAL_TIME,we.PUT_ON_TIME,we.PUT_OFF_TIME,
|
|
we.SALES actualSales,we.SALES,bw.CREATION_TIME,bw.IS_RECOMMEND,bw.LISTING_TIME,bw.REMOVAL_TIME,bw.SORT_STATUS,we.IS_MAKER_GIFT,
|
|
sc.TEMP_NAME, we.maker_income, nvl(we.SYSTEM_TYPE, 0) SYSTEM_TYPE, bw.WARES_STATUS
|
|
from bd_wares bw
|
|
left join BD_WARES_EXTEND we on we.PK_WARES = bw.PK_ID
|
|
left join BD_AREA_CLASSIFY ac on ac.PK_ID = bw.PK_AREA_CLASSIFY
|
|
left join BD_SPECIAL_CURRENCY sc on sc.pk_Id = we.PK_SPECIAL_CURRENCY
|
|
where bw.del_flag = 0
|
|
<if test="systemType != null">
|
|
and we.SYSTEM_TYPE = #{systemType}
|
|
</if>
|
|
<if test="isRecommend != null">
|
|
and bw.IS_RECOMMEND = #{isRecommend}
|
|
</if>
|
|
<if test="pkCountry != null">
|
|
and bw.PK_COUNTRY = #{pkCountry}
|
|
</if>
|
|
<if test="waresCode != null and waresCode != ''">
|
|
and bw.wares_code = #{waresCode}
|
|
</if>
|
|
<if test="waresName != null and waresName != ''">
|
|
and bw.WARES_NAME like '%' || #{waresName} || '%'
|
|
</if>
|
|
<if test="isPutOn != null">
|
|
and we.IS_PUT_ON = #{isPutOn}
|
|
</if>
|
|
<if test="preSaleStatus != null">
|
|
and we.PRE_SALE_STATUS = #{preSaleStatus}
|
|
</if>
|
|
<if test="operateScope != null">
|
|
and we.OPERATE_SCOPE = #{operateScope}
|
|
</if>
|
|
<if test="pkAreaClassify != null and pkAreaClassify != ''">
|
|
and bw.PK_AREA_CLASSIFY = #{pkAreaClassify}
|
|
</if>
|
|
<if test="specialArea != null and specialArea != ''">
|
|
and bw.SPECIAL_AREA = #{specialArea}
|
|
</if>
|
|
<if test="isSale != null">
|
|
and we.IS_SALE = #{isSale}
|
|
</if>
|
|
<if test="isSingle != null">
|
|
and bw.IS_SINGLE = #{isSingle}
|
|
</if>
|
|
<if test="isFreeMail != null">
|
|
and bw.IS_FREE_MAIL = #{isFreeMail}
|
|
</if>
|
|
<if test="startCreateDate != null">
|
|
and bw.CREATION_TIME >= #{startCreateDate}
|
|
</if>
|
|
<if test="endCreateDate != null">
|
|
and bw.CREATION_TIME <= #{endCreateDate}
|
|
</if>
|
|
<if test="startPutInfoTime != null">
|
|
and we.PUT_INTO_TIME >= #{startPutInfoTime}
|
|
</if>
|
|
<if test="endPutInfoTime != null">
|
|
and we.PUT_INTO_TIME <= #{endPutInfoTime}
|
|
</if>
|
|
<if test="startPutOnTime != null">
|
|
and bw.LISTING_TIME >= #{startPutOnTime}
|
|
</if>
|
|
<if test="endPutOnTime != null">
|
|
and bw.LISTING_TIME <= #{endPutOnTime}
|
|
</if>
|
|
<if test="startPutOffTime != null">
|
|
and bw.REMOVAL_TIME >= #{startPutOffTime}
|
|
</if>
|
|
<if test="endPutOffTime != null">
|
|
and bw.REMOVAL_TIME <= #{endPutOffTime}
|
|
</if>
|
|
<if test="waresStatus != null">
|
|
and bw.WARES_STATUS <= #{waresStatus}
|
|
</if>
|
|
order by bw.SORT_STATUS desc , bw.WARES_PRICE ,bw.CREATION_TIME desc
|
|
</select>
|
|
|
|
<select id="selectByMoveUpSort" resultType="integer">
|
|
select min(ex.SORT) FROM bd_wares ex where ex.SORT > (select SORT from bd_wares pe where pe.PK_ID = #{waresId} ) and DEL_FLAG = '0'
|
|
<if test="specialArea != null">
|
|
and ex.SPECIAL_AREA = #{specialArea}
|
|
</if>
|
|
</select>
|
|
|
|
|
|
<select id="selectByMoveDownSort" resultType="integer">
|
|
select max(ex.SORT) FROM bd_wares ex where ex.SORT < (select sort from bd_wares pe where pe.PK_ID = #{waresId} ) and DEL_FLAG = '0'
|
|
<if test="specialArea != null">
|
|
and ex.SPECIAL_AREA = #{specialArea}
|
|
</if>
|
|
</select>
|
|
|
|
<update id="updateMoveUpBySort">
|
|
update bd_wares
|
|
set sort = sort + 1
|
|
where sort >= #{sort}
|
|
and DEL_FLAG = '0'
|
|
</update>
|
|
|
|
<update id="updateMoveDownBySort">
|
|
update bd_wares
|
|
set sort = sort - 1
|
|
where sort <= #{sort}
|
|
and DEL_FLAG = '0'
|
|
</update>
|
|
|
|
<select id="getMaxSort" resultType="integer">
|
|
select max(bw.SORT)
|
|
from bd_wares bw
|
|
where bw.PK_COUNTRY = #{pkCountry}
|
|
</select>
|
|
|
|
<select id="selectByWaresCodeList" resultType="com.hzs.common.domain.system.config.BdAgreement">
|
|
select ba.* from BD_AGREEMENT ba where 1 = 1 and
|
|
(select count(bw.pk_id) from BD_WARES bw left join
|
|
BD_WARES_EXTEND we on we.PK_WARES = bw.PK_ID
|
|
where 1 = 1
|
|
<if test="waresCodeList != null and waresCodeList.size > 0">
|
|
and bw.WARES_CODE in
|
|
<foreach collection="waresCodeList" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
and ba.pk_id = we.PK_AGREEMENT ) > 0
|
|
</select>
|
|
|
|
<select id="queryRecommendWaresSpecial" resultType="integer">
|
|
select DISTINCT t.SPECIAL_AREA
|
|
from BD_WARES t
|
|
left join BD_WARES_EXTEND we on we.PK_WARES = t.PK_ID
|
|
where IS_RECOMMEND = 0
|
|
and we.IS_PUT_ON = 0
|
|
and t.del_flag = 0
|
|
and we.del_flag = 0
|
|
and t.wares_status = 5
|
|
</select>
|
|
|
|
<select id="selectByRecommentList" resultMap="BaseResultMap">
|
|
select t.* ,we.IS_SALE,we.PRE_SALE_STATUS
|
|
from BD_WARES t
|
|
left join BD_WARES_EXTEND we on we.PK_WARES = t.PK_ID
|
|
where t.IS_RECOMMEND = 0 and we.IS_PUT_ON = 0 and t.PK_COUNTRY = #{pkCountry}
|
|
and t.del_flag = 0
|
|
<!-- 商品必须通过审核后才能显示 -->
|
|
and t.wares_status = 5
|
|
<if test="specialAreaList != null and specialAreaList.size > 0">
|
|
and t.SPECIAL_AREA in
|
|
<foreach collection="specialAreaList" item="item" open="(" close=")" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
order by t.SORT desc
|
|
</select>
|
|
|
|
<update id="updateByAutoStartAndAutoStart">
|
|
update BD_WARES_EXTEND
|
|
set IS_PUT_ON = 0
|
|
where to_char(PUT_ON_TIME, 'yyyy-mm-dd hh24:mi:ss') <= to_char(#{currentTime}, 'yyyy-mm-dd hh24:mi:ss')
|
|
|
|
and IS_PUT_ON = '1'
|
|
</update>
|
|
|
|
<update id="updateByAutoStartAndAutoEnd">
|
|
update BD_WARES_EXTEND
|
|
set IS_PUT_ON = 1
|
|
where to_char(PUT_OFF_TIME, 'yyyy-mm-dd hh24:mi:ss') <= to_char(#{currentTime}, 'yyyy-mm-dd hh24:mi:ss')
|
|
and IS_PUT_ON = '0'
|
|
</update>
|
|
|
|
<!-- 修改商品预售状态-->
|
|
<update id="waresPreSale">
|
|
update BD_WARES_EXTEND
|
|
set PRE_SALE_STATUS = 0,
|
|
MODIFIED_TIME = SYSDATE
|
|
where SYSDATE >= ARRIVAL_TIME
|
|
and PRE_SALE_STATUS = 1
|
|
and DEL_FLAG = 0
|
|
</update>
|
|
|
|
|
|
<select id="queryRecommendWaresByCondition" resultMap="BaseResultMap">
|
|
select bw.PK_COUNTRY,bw.PK_ID,be.pk_id PK_WARES_EXTEND, WARES_CODE, WARES_NAME, PK_TRANSACTION,
|
|
PK_AREA_CLASSIFY, COVER1, COVER2, COVER3, COVER4, COVER5, COVER6,DETAILS_TYPE,
|
|
bw.WARES_PRICE,
|
|
bw.WARES_ACHIEVE,
|
|
DETAILS, SORT, SPECIAL_AREA, IS_SINGLE,
|
|
IS_PUT_ON, PRE_SALE_STATUS, PUT_ON_TIME, PUT_OFF_TIME, OPERATE_SCOPE, PREFIX_LABEL, COOL_LABEL,
|
|
S_LABEL, SALES, IS_SALE, ARRIVAL_TIME, WARN_MESSAGE,
|
|
IS_LAND_TRANS,IS_AIR_TRANS,IS_OCEAN_TRANS,VIDEO_URL
|
|
from bd_wares bw
|
|
inner join bd_wares_extend be
|
|
on bw.pk_id = be.pk_wares
|
|
where bw.del_flag = 0 and be.del_flag = 0
|
|
and be.is_put_on = 0
|
|
and bw.IS_RECOMMEND = 0
|
|
<!-- 商品必须通过审核后才能显示 -->
|
|
and bw.wares_status = 5
|
|
<if test="specialArea != null">
|
|
and bw.special_area = #{specialArea}
|
|
</if>
|
|
<if test="pkCountry != null">
|
|
and bw.PK_COUNTRY = #{pkCountry}
|
|
</if>
|
|
<if test="pkAreaClassify != null and pkAreaClassify != ''">
|
|
and ( (
|
|
select t.pk_id
|
|
from BD_AREA_CLASSIFY t
|
|
where t.pk_id = bw.PK_AREA_CLASSIFY
|
|
start with t.PK_PARENT = #{pkAreaClassify}
|
|
connect by t.PK_PARENT = prior t.PK_ID
|
|
) > 0
|
|
or
|
|
bw.PK_AREA_CLASSIFY = #{pkAreaClassify}
|
|
)
|
|
</if>
|
|
<if test="waresCode != null and waresCode != ''">
|
|
and bw.wares_code = #{waresCode}
|
|
</if>
|
|
<if test="waresName != null and waresName != ''">
|
|
and bw.WARES_NAME like #{waresName} || '%'
|
|
</if>
|
|
|
|
order by bw.sort,bw.creation_time desc
|
|
</select>
|
|
|
|
<!-- 查询推荐商品 -->
|
|
<select id="queryByRecommendList" resultMap="BaseResultMap">
|
|
select bw.*, be.IS_SALE, be.PRE_SALE_STATUS
|
|
from bd_wares bw
|
|
left join bd_wares_extend be on bw.pk_id = be.pk_wares
|
|
where be.IS_PUT_ON = 0 and bw.del_flag = 0 and be.del_flag = 0
|
|
and bw.WARES_STATUS = 5
|
|
<if test="specialArea != null">
|
|
and bw.SPECIAL_AREA = #{specialArea}
|
|
</if>
|
|
<if test="pkCountry != null">
|
|
and bw.PK_COUNTRY = #{pkCountry}
|
|
</if>
|
|
<if test="isRecommend != null">
|
|
and bw.IS_RECOMMEND = #{isRecommend}
|
|
</if>
|
|
order by bw.SORT desc
|
|
</select>
|
|
|
|
<update id="updatePreSaleQuantityByWaresCode">
|
|
update BD_WARES
|
|
set PRE_SALE_QUANTITY = PRE_SALE_QUANTITY - #{quantity}
|
|
where WARES_CODE = #{waresCode}
|
|
and PRE_SALE_QUANTITY > 0
|
|
</update>
|
|
|
|
<select id="getWaresAuthorityFirst" resultType="com.hzs.sale.wares.vo.WaresAuthorityVo">
|
|
select wa.AUTHORITY_TYPE authorityType, cm.MEMBER_CODE memberCode, cm.MEMBER_NAME memberName
|
|
from bd_wares_authority wa
|
|
left join cu_member cm on cm.pk_id = wa.PK_MEMBER
|
|
where wa.del_flag = 0
|
|
and wa.PK_WARES = #{pkWares}
|
|
and rownum = 1
|
|
order by wa.PK_id desc
|
|
</select>
|
|
|
|
<!-- 查询上架的发起人收益商品列表 -->
|
|
<select id="queryMakerIncomeList" resultType="com.hzs.common.domain.sale.wares.BdWares">
|
|
select bw.*
|
|
from bd_wares bw
|
|
inner join BD_WARES_EXTEND bwe
|
|
on bwe.pk_wares = bw.pk_id
|
|
and bwe.del_flag = 0
|
|
and bwe.pk_country = 1
|
|
and bwe.IS_PUT_ON = 0
|
|
and bwe.MAKER_INCOME != 0
|
|
where bw.del_flag = 0
|
|
and bw.pk_country = #{pkCountry}
|
|
<if test="null != specialArea">
|
|
and bw.SPECIAL_AREA = #{specialArea}
|
|
</if>
|
|
</select>
|
|
|
|
</mapper>
|