|
@@ -0,0 +1,266 @@
|
|
|
+<?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,
|
|
|
+ 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,
|
|
|
+ endTimeStr, 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.product.entity.vo.BigtypeVo">
|
|
|
+ select
|
|
|
+ <include refid="BigType_Column_List" />
|
|
|
+ from bigtype
|
|
|
+ </select>
|
|
|
+ <select id="getSmallType" resultType="com.caimei.module.product.entity.vo.SmalltypeVo">
|
|
|
+ select
|
|
|
+ <include refid="SmallType_Column_List" />
|
|
|
+ from smalltype
|
|
|
+ where bigTypeID = #{bigTypeID,jdbcType=INTEGER}
|
|
|
+ </select>
|
|
|
+ <select id="getTinytype" resultType="com.caimei.module.product.entity.vo.TinytypeVo">
|
|
|
+ select
|
|
|
+ <include refid="Tinytype_Column_List" />
|
|
|
+ from tinytype
|
|
|
+ where smallTypeID = #{smallTypeID,jdbcType=INTEGER}
|
|
|
+ </select>
|
|
|
+ <!-- sortType (3:价格升序, 4:价格降序, 7:人气, 8:销量) -->
|
|
|
+ <select id="getProductsByTinyType" resultType="com.caimei.module.product.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.product.entity.vo.ProductVo">
|
|
|
+ select
|
|
|
+ *
|
|
|
+ from product
|
|
|
+ where validFlag = 2
|
|
|
+ and name like CONCAT('%',#{searchWord,jdbcType=VARCHAR},'%')
|
|
|
+ </select>
|
|
|
+ <select id="findProductById" resultType="com.caimei.module.product.entity.vo.ProductVo">
|
|
|
+ select
|
|
|
+ <include refid="Product_Column_List" />
|
|
|
+ from product
|
|
|
+ where validFlag in (2,3)
|
|
|
+ and productId = #{productId,jdbcType=BIGINT}
|
|
|
+ </select>
|
|
|
+ <select id="getSearchHistoryList" resultType="com.caimei.module.product.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.product.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.product.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.product.entity.vo.ProductDetailVo">
|
|
|
+ select
|
|
|
+ <include refid="ProductDetail_Column_List" />
|
|
|
+ from productdetailinfo
|
|
|
+ where productId = #{productId,jdbcType=BIGINT}
|
|
|
+ </select>
|
|
|
+ <select id="findProductShopById" resultType="com.caimei.module.product.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.product.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.product.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.product.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,jdbcType=BIGINT}
|
|
|
+ AND (temp.id > tb.id)
|
|
|
+ </delete>
|
|
|
+ <select id="findLadderPrice" resultType="com.caimei.module.product.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.product.entity.vo.ProductVo">
|
|
|
+ SELECT
|
|
|
+ <include refid="Product_Column_List"/>
|
|
|
+ FROM
|
|
|
+ product
|
|
|
+ WHERE
|
|
|
+ validFlag = '2'
|
|
|
+ AND productID IN
|
|
|
+ <foreach collection="list" close="(" separator="," open=")" item="productID">
|
|
|
+ #{productIDs}
|
|
|
+ </foreach>
|
|
|
+ </select>
|
|
|
+ <select id="getDeFaultRecommend" resultType="com.caimei.module.product.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>
|