123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <?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.caimei.module.product.dao.ProductModuleDao">
- <sql id="BigType_Column_List">
- bigTypeID, `name`, bigTypeCode, validFlag, sortIndex, seo, displayOnHomePageFlag
- </sql>
- <sql id="SmallType_Column_List">
- smallTypeID, bigTypeID, `name`, smallTypeCode, validFlag, sortIndex, seo, displayOnHomePageFlag
- </sql>
- <sql id="Tinytype_Column_List">
- tinyTypeID, smallTypeID, `name`, tinyTypeCode, icon, validFlag, seo, sortIndex
- </sql>
- <sql id="Product_Column_List">
- productID, brandID, tinyTypeID, preferredFlag, selfTypeID, shopID, `name`, aliasName, searchKey,
- normalPrice, price, highestUserLevelPrice, lowestUserLevelPrice, lowestUserLevelID,
- price0, price0Grade, price0Text, price0TextFlag, price1, price1Grade, price1Text,
- price1TextFlag, price8, price8Grade, price8Text, price8TextFlag, ladderPriceFlag,
- price2, price3, price4, price5, price6, price7, fee, stock, hasSkuFlag, mainImage,
- propertiesInfo, addTime, updateTime, sellNumber, weekSellNumber, beforeValidFlag,
- validFlag, favoriteTimes, commentScore, commentTimes, selfRecommendFlag, sysRecommendFlag,
- sortIndex, featuredFlag, featuredSortIndex, productCode, rate1, rate2, unit, synToERPFlag,
- allAreaFlag, provinceIDs, serviceNumber, maxBuyNumber, virtualFlag, minBuyNumber,
- packageCount, byFlag, normalProductFlag, wholeSaleProductFlag, promotionProductFlag,
- groupBuyProductFlag, step, speCommisionFlag, speCommision, videourl, props, providers,
- serviceCommissionRatio, reCommissionRatio, pushToERPName, prodBeans, useBeansFlag,
- privateFlag, invisibleServiceProviderIDs, displayOnCRMFlag, needServiceFlag, actFlag, actStatus,
- actSort, actPrice0, actPrice1, actPrice2, actPrice3, actPrice4, actPrice5, actPrice6,
- actPrice7, actType, actCreateTime, beginTime, endTime, shopIndexModuleID, onlineTime,
- downlineTime, freePostFlag, crmBigTypeId, crmSmallTypeId, costPrice, costProportional,
- costCheckFlag, precisehKey, docBoost, cmbeanFlag, cmbeanPrice, cmbeanSort, actBuyGiftNum,
- actFullGiftAmount, actFullReduceAmount, actReduceAmount, visibility, surplusTime,
- priceType, tags, recommendType, machineType
- </sql>
- <sql id="ProductDetail_Column_List">
- productDetailInfoID, productID, propValueAlias, propValueImages, detailInfo, detailInfoTxt,
- seoTitle, seoKeyword, seoDes, serviceInfo, orderInfo
- </sql>
- <sql id="LadderPrice_Column_List">
- id, productId, userType, ladderNum, buyNum, buyPrice, createBy, createDate, updateBy,
- updateDate, delFlag
- </sql>
- <sql id="Image_Column_List">
- productImageID, productID, shopID, addTime, image, mainFlag, sortIndex
- </sql>
- <sql id="Shop_Column_List">
- shopID, userID, `name`, sname, nameEn, site, ledgerNo, logo, rebateAmount, `level`,
- score, productCount, legalPerson, businessLicense, businessLicenseImage, taxCertificate,
- taxCertificateImage, provinceID, cityID, townID, address, registeredCapital, nature,
- turnover, linkMan, contractPhone, contractMobile, fax, zipCode, linkMan1, duty1,
- contractPhone1, contractMobile1, contractQQ1, wechat1, contractEmail1, linkMan2,
- duty2, contractPhone2, contractMobile2, contractQQ2, wechat2, contractEmail2, `scope`,
- info, productDesc, lng, lat, addTime, auditStatus, auditTime, auditNote, favoriteTimes,
- validFlag, payFlag1, auditFlag1, payFlag2, auditFlag2, payFlag3, auditFlag3, note,
- `status`, sortIndex, rate1, rate2, masterFlag, erpFlag, shopSecret, masterLogo, cooperateFlag,
- bail, businessScope, socialCreditCode, mainpro, firstShopType, secondShopType, medicalPracticeLicenseImg1,
- medicalPracticeLicenseImg2, medicalPracticeLicenseImg3, bankAccount, bankAccountName,
- bankName, ableRebateAmount
- </sql>
- <select id="getBigType" resultType="com.caimei.module.base.entity.vo.BigtypeVo">
- select
- <include refid="BigType_Column_List" />
- from bigtype
- where validFlag = '1'
- </select>
- <select id="getSmallType" resultType="com.caimei.module.base.entity.vo.SmalltypeVo">
- select
- <include refid="SmallType_Column_List" />
- from smalltype
- where bigTypeID = #{bigTypeID,jdbcType=INTEGER}
- and validFlag = '1'
- </select>
- <select id="getTinytype" resultType="com.caimei.module.base.entity.vo.TinytypeVo">
- select
- <include refid="Tinytype_Column_List" />
- from tinytype
- where smallTypeID = #{smallTypeID,jdbcType=INTEGER}
- and validFlag = '1'
- </select>
- <!-- sortType (3:价格升序, 4:价格降序, 7:人气, 8:销量) -->
- <select id="getProductsByTinyType" resultType="com.caimei.module.base.entity.vo.ProductVo" parameterType="java.lang.Integer">
- select
- <include refid="Product_Column_List" />
- from product
- where validFlag = 2
- and tinyTypeID = #{tinyTypeID,jdbcType=INTEGER}
- <choose>
- <when test="sortType == 3">
- order by price1 asc
- </when>
- <when test="sortType == 4">
- order by price1 desc
- </when>
- <when test="sortType == 7">
- order by favoriteTimes desc
- </when>
- <when test="sortType == 8">
- order by sellNumber desc
- </when>
- <otherwise>
- order by onlineTime desc
- </otherwise>
- </choose>
- </select>
- <select id="searchProduct" resultType="com.caimei.module.base.entity.vo.ProductVo">
- select
- *
- from product
- where validFlag = 2
- and name like CONCAT('%',#{searchWord,jdbcType=VARCHAR},'%')
- </select>
- <select id="findProductById" resultType="com.caimei.module.base.entity.vo.ProductVo">
- select
- <include refid="Product_Column_List" />
- from product
- where validFlag in (2,3,9)
- and productId = #{productId,jdbcType=BIGINT}
- </select>
- <select id="getSearchHistoryList" resultType="com.caimei.module.base.entity.vo.SearchHistoryVo">
- select id, userId, searchWord, searchDate, delFlag
- from user_search_history
- where userId = #{userId,jdbcType=BIGINT}
- </select>
- <select id="getSearchHistoryIdByWord" resultType="java.lang.Long">
- select id
- from user_search_history
- where searchWord = #{searchWord,jdbcType=VARCHAR}
- limit 1
- </select>
- <select id="findLowerLadderPrice" resultType="com.caimei.module.base.entity.vo.LadderPriceVo">
- select
- <include refid="LadderPrice_Column_List" />
- from product_ladder_price
- WHERE delFlag = '0'
- AND productId = #{productId,jdbcType=BIGINT}
- ORDER BY ladderNum DESC
- LIMIT 1
- </select>
- <select id="findProductImage" resultType="com.caimei.module.base.entity.vo.ProductImageVo">
- select
- <include refid="Image_Column_List" />
- from productimage
- where productID = #{productID,jdbcType=INTEGER}
- ORDER BY mainFlag DESC
- </select>
- <select id="findProductDetailById" resultType="com.caimei.module.base.entity.vo.ProductDetailVo">
- select
- <include refid="ProductDetail_Column_List" />
- from productdetailinfo
- where productId = #{productId,jdbcType=BIGINT}
- </select>
- <select id="findProductShopById" resultType="com.caimei.module.base.entity.vo.ShopVo">
- SELECT
- <include refid="Shop_Column_List" />
- FROM shop
- where shopID = #{shopID,jdbcType=INTEGER}
- </select>
- <!--新品上线(001) 优惠商品(010) 常用商品(100),三者同时存在111-->
- <select id="getProductsByPreferredFlag" resultType="com.caimei.module.base.entity.vo.ProductVo">
- select
- <include refid="Product_Column_List" />
- from product
- where validFlag = 2
- <if test="preferredFlag == 100">
- and preferredFlag in (100,101,110,111)
- </if>
- <if test="preferredFlag == 10">
- and preferredFlag in (10,11,110,111)
- </if>
- <if test="preferredFlag == 1">
- and preferredFlag in (1,11,101,111)
- </if>
- </select>
- <update id="updateSearchHistoryById" parameterType="com.caimei.module.base.entity.vo.SearchHistoryVo">
- update user_search_history
- <set>
- <if test="userId != null">
- userId = #{userId,jdbcType=BIGINT},
- </if>
- <if test="searchWord != null">
- searchWord = #{searchWord,jdbcType=VARCHAR},
- </if>
- <if test="searchDate != null">
- searchDate = #{searchDate,jdbcType=TIMESTAMP},
- </if>
- <if test="delFlag != null">
- delFlag = #{delFlag,jdbcType=VARCHAR},
- </if>
- </set>
- where id = #{id,jdbcType=BIGINT}
- </update>
- <insert id="insertSearchHistory" keyColumn="id" keyProperty="id" parameterType="com.caimei.module.base.entity.vo.SearchHistoryVo">
- insert into user_search_history
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="userId != null">
- userId,
- </if>
- <if test="searchWord != null">
- searchWord,
- </if>
- <if test="searchDate != null">
- searchDate,
- </if>
- <if test="delFlag != null">
- delFlag,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="userId != null">
- #{userId,jdbcType=BIGINT},
- </if>
- <if test="searchWord != null">
- #{searchWord,jdbcType=VARCHAR},
- </if>
- <if test="searchDate != null">
- #{searchDate,jdbcType=TIMESTAMP},
- </if>
- <if test="delFlag != null">
- #{delFlag,jdbcType=VARCHAR},
- </if>
- </trim>
- </insert>
- <!--删除大于10条的历史记录-->
- <delete id="deleteSearchHistoryByUserId" parameterType="java.lang.Long">
- DELETE tb FROM user_search_history AS tb,(
- SELECT id FROM user_search_history
- WHERE userId=#{userId,jdbcType=BIGINT}
- ORDER BY id DESC
- LIMIT 1,10
- ) AS temp
- WHERE userId=#{userId}
- AND (temp.id > tb.id)
- </delete>
- <delete id="deleteAllSearchHistory">
- DELETE FROM
- user_search_history
- WHERE
- userId=#{userId}
- </delete>
- <select id="findLadderPrice" resultType="com.caimei.module.base.entity.vo.LadderPriceVo">
- SELECT
- <include refid="LadderPrice_Column_List" />
- FROM
- product_ladder_price
- WHERE
- productId = #{productID}
- AND userType = '3'
- AND delFlag = '0'
- ORDER BY
- ladderNum ASC
- </select>
- <select id="getRecommendIds" resultType="java.lang.Integer">
- SELECT recommendProductID FROM cm_product_recommend WHERE productID=#{productID} ORDER BY sort ASC
- </select>
- <select id="getRecommendByIds" resultType="com.caimei.module.base.entity.vo.ProductVo">
- SELECT
- <include refid="Product_Column_List"/>
- FROM
- product
- WHERE
- validFlag = '2'
- AND productID IN
- <foreach collection="productIDs" open="(" separator="," close=")" item="productID">
- #{productID}
- </foreach>
- </select>
- <select id="getDeFaultRecommend" resultType="com.caimei.module.base.entity.vo.ProductVo">
- select
- <include refid="Product_Column_List" />
- from product
- where validFlag = 2
- and tinyTypeID = #{tinyTypeID}
- order by sellNumber desc,onlineTime desc
- limit 7
- </select>
- </mapper>
|