yujian
2019-09-25 8b3ef26b10d1dced4408dee62cc1a18f72205cd0
品牌加入搜索关键词
5个文件已修改
79 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/entity/brand/BrandInfo.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandInfoMapper.xml 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandShopCaheServiceImpl.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/brand/BrandInfo.java
@@ -30,6 +30,9 @@
    @Column(name = "bf_name")
    private String name; // 品牌名称
    
    @Column(name = "bf_search_key")
    private String searchKey; // 搜索词
    @Expose
    @Column(name = "bf_icon")
    private String icon; // 品牌logo
@@ -130,4 +133,12 @@
    public void setGoodsTotal(Integer goodsTotal) {
        this.goodsTotal = goodsTotal;
    }
    public String getSearchKey() {
        return searchKey;
    }
    public void setSearchKey(String searchKey) {
        this.searchKey = searchKey;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandInfoMapper.xml
@@ -5,20 +5,22 @@
  <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.brand.BrandInfo">
    <id column="bf_id" property="id" jdbcType="BIGINT"/>
    <result column="bf_name" property="name" jdbcType="VARCHAR"/>
    <result column="bf_search_key" property="searchKey" jdbcType="VARCHAR"/>
    <result column="bf_icon" property="icon" jdbcType="VARCHAR"/>
    <result column="bf_weight" property="weight" jdbcType="DOUBLE"/>
    <result column="bf_goods_total" property="goodsTotal" jdbcType="INTEGER"/>
    <result column="bf_weight" property="weight" jdbcType="VARCHAR"/>
    <result column="bf_state" property="state" jdbcType="INTEGER"/>
    <result column="bf_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="bf_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
    <association column="bf_cid" property="brandClass" javaType="com.yeshi.fanli.entity.brand.BrandClass">
    <association column="bf_cid" property="brandClass" javaType="com.yeshi.fanli.entity.brand.BrandClass">
        <id column="bf_cid" property="id" jdbcType="BIGINT" />    
    </association>
  </resultMap>
  
  <resultMap id="ResultVOMap" type="com.yeshi.fanli.vo.brand.BrandInfoVO">
   <resultMap id="ResultVOMap" type="com.yeshi.fanli.vo.brand.BrandInfoVO">
    <id column="bf_id" property="id" jdbcType="BIGINT"/>
    <result column="bf_name" property="name" jdbcType="VARCHAR"/>
    <result column="bf_search_key" property="searchKey" jdbcType="VARCHAR"/>
    <result column="bf_icon" property="icon" jdbcType="VARCHAR"/>
    <result column="bf_weight" property="weight" jdbcType="DOUBLE"/>
    <result column="bf_goods_total" property="goodsTotal" jdbcType="INTEGER"/>
@@ -30,20 +32,21 @@
    </association>
  </resultMap>
  
  <sql id="Base_Column_List">bf_id,bf_cid,bf_name,bf_icon,bf_weight,bf_goods_total,bf_state,bf_create_time,bf_update_time</sql>
  <sql id="Base_Column_List">bf_id,bf_cid,bf_name,bf_search_key,bf_icon,bf_goods_total,bf_weight,bf_state,bf_create_time,bf_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_brand_info where bf_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_brand_info where bf_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.brand.BrandInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_info (bf_id,bf_cid,bf_name,bf_icon,bf_weight,bf_goods_total,bf_state,bf_create_time,bf_update_time) values (#{id,jdbcType=BIGINT},#{brandClass.id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{icon,jdbcType=VARCHAR},#{weight,jdbcType=DOUBLE},#{goodsTotal,jdbcType=INTEGER},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.brand.BrandInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_info (bf_id,bf_cid,bf_name,bf_search_key,bf_icon,bf_goods_total,bf_weight,bf_state,bf_create_time,bf_update_time) values (#{id,jdbcType=BIGINT},#{brandClass.id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{searchKey,jdbcType=VARCHAR},#{icon,jdbcType=VARCHAR},#{goodsTotal,jdbcType=INTEGER},#{weight,jdbcType=VARCHAR},#{state,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.brand.BrandInfo" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_brand_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">bf_id,</if>
      <if test="brandClass != null">bf_cid,</if>
      <if test="name != null">bf_name,</if>
      <if test="searchKey != null">bf_search_key,</if>
      <if test="icon != null">bf_icon,</if>
      <if test="weight != null">bf_weight,</if>
      <if test="goodsTotal != null">bf_goods_total,</if>
      <if test="weight != null">bf_weight,</if>
      <if test="state != null">bf_state,</if>
      <if test="createTime != null">bf_create_time,</if>
      <if test="updateTime != null">bf_update_time,</if>
@@ -52,28 +55,29 @@
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="brandClass != null">#{brandClass.id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="searchKey != null">#{searchKey,jdbcType=VARCHAR},</if>
      <if test="icon != null">#{icon,jdbcType=VARCHAR},</if>
      <if test="weight != null">#{weight,jdbcType=DOUBLE},</if>
      <if test="goodsTotal != null">#{goodsTotal,jdbcType=INTEGER},</if>
      <if test="weight != null">#{weight,jdbcType=VARCHAR},</if>
      <if test="state != null">#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.brand.BrandInfo">update yeshi_ec_brand_info set bf_cid = #{brandClass.id,jdbcType=BIGINT},bf_name = #{name,jdbcType=VARCHAR},bf_icon = #{icon,jdbcType=VARCHAR},bf_weight = #{weight,jdbcType=DOUBLE},bf_goods_total = #{goodsTotal,jdbcType=INTEGER},bf_state = #{state,jdbcType=INTEGER},bf_create_time = #{createTime,jdbcType=TIMESTAMP},bf_update_time = #{updateTime,jdbcType=TIMESTAMP} where bf_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.brand.BrandInfo">update yeshi_ec_brand_info set bf_cid = #{brandClass.id,jdbcType=BIGINT},bf_name = #{name,jdbcType=VARCHAR},bf_search_key = #{searchKey,jdbcType=VARCHAR},bf_icon = #{icon,jdbcType=VARCHAR},bf_goods_total = #{goodsTotal,jdbcType=INTEGER},bf_weight = #{weight,jdbcType=VARCHAR},bf_state = #{state,jdbcType=INTEGER},bf_create_time = #{createTime,jdbcType=TIMESTAMP},bf_update_time = #{updateTime,jdbcType=TIMESTAMP} where bf_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.brand.BrandInfo">update yeshi_ec_brand_info
    <set>
      <if test="brandClass != null">bf_cid=#{brandClass.id,jdbcType=BIGINT},</if>
      <if test="name != null">bf_name=#{name,jdbcType=VARCHAR},</if>
      <if test="searchKey != null">bf_search_key=#{searchKey,jdbcType=VARCHAR},</if>
      <if test="icon != null">bf_icon=#{icon,jdbcType=VARCHAR},</if>
      <if test="weight != null">bf_weight=#{weight,jdbcType=DOUBLE},</if>
      <if test="goodsTotal != null">bf_goods_total=#{goodsTotal,jdbcType=INTEGER},</if>
      <if test="weight != null">bf_weight=#{weight,jdbcType=VARCHAR},</if>
      <if test="state != null">bf_state=#{state,jdbcType=INTEGER},</if>
      <if test="createTime != null">bf_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">bf_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where bf_id = #{id,jdbcType=BIGINT}
  </update>
  <delete id="deleteBatchByPrimaryKey" parameterType="java.util.List">
    delete from yeshi_ec_brand_info WHERE bf_id in
        <foreach collection="list" item="item" open="(" close=")"
@@ -121,7 +125,7 @@
      SELECT * FROM yeshi_ec_brand_info
      WHERE 1=1 
          <if test="key != null and key !='' ">
              AND bf_name LIKE '%${key}%'
              AND (bf_name LIKE '%${key}%' or bf_search_key LIKE '%${key}%')
          </if>
          <if test="state != null">
               AND bf_state = #{state}
@@ -137,7 +141,7 @@
      SELECT IFNULL(COUNT(bf_id),0) FROM yeshi_ec_brand_info
      WHERE 1=1 
          <if test="key != null and key !='' ">
              AND bf_name LIKE '%${key}%'
              AND (bf_name LIKE '%${key}%' or bf_search_key LIKE '%${key}%')
          </if>
          <if test="state != null">
               AND bf_state = #{state}
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java
@@ -68,9 +68,13 @@
     * @return
     */
    private int addBrandGoodsTB(BrandInfo brandInfo) {
        String searchKey = brandInfo.getSearchKey();
        if (StringUtil.isNullOrEmpty(searchKey))
            searchKey = brandInfo.getName();
        Date date = new Date();
        SearchFilter filter = new SearchFilter();
        filter.setKey(brandInfo.getName());
        filter.setKey(searchKey);
        filter.setPage(1);
        filter.setPageSize(100);
        filter.setTmall(true);
@@ -120,6 +124,10 @@
     * @return
     */
    private int addBrandGoodsJD(BrandInfo brandInfo) {
        String searchKey = brandInfo.getSearchKey();
        if (StringUtil.isNullOrEmpty(searchKey))
            searchKey = brandInfo.getName();
        int count = 0;
        JDSearchResult result = null;
        String way = configService.get("jd_api_search_key");
@@ -127,7 +135,7 @@
        for (int i=0; i < 2;i ++) {
            if ("1".equals(way)) {
                JDFilter filterAPI = new JDFilter();
                filterAPI.setKeyword(SearchFilterUtil.filterSearchContent(brandInfo.getName()));
                filterAPI.setKeyword(SearchFilterUtil.filterSearchContent(searchKey));
                filterAPI.setPageIndex(1);
                filterAPI.setPageSize(30);
                filterAPI.setSort(JDFilter.SORT_DESC);
@@ -136,7 +144,7 @@
            } else {
                // 网页爬取
                JDSearchFilter jdfilter = new JDSearchFilter();
                jdfilter.setKey(SearchFilterUtil.filterSearchContent(brandInfo.getName()));
                jdfilter.setKey(SearchFilterUtil.filterSearchContent(searchKey));
                jdfilter.setPageNo(1);
                jdfilter.setPageSize(30);
                jdfilter.setSort(JDSearchFilter.SORT_DESC);
@@ -185,8 +193,12 @@
     * @return
     */
    private int addBrandGoodsPDD(BrandInfo brandInfo) {
        String searchKey = brandInfo.getSearchKey();
        if (StringUtil.isNullOrEmpty(searchKey))
            searchKey = brandInfo.getName();
        PDDSearchFilter pddfilter = new PDDSearchFilter();
        pddfilter.setKw(brandInfo.getName());
        pddfilter.setKw(searchKey);
        pddfilter.setPage(1);
        pddfilter.setPageSize(100);
        pddfilter.setSortType(6);
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
@@ -71,9 +71,13 @@
    @Override
    public void saveObject(MultipartFile file, BrandInfo record) throws BrandInfoException {
        String name = record.getName();
        if (name == null || name.trim().length() == 0)
        if (StringUtil.isNullOrEmpty(name))
            throw new BrandInfoException(1, "名称不能为空");
        String searchKey = record.getSearchKey();
        if (StringUtil.isNullOrEmpty(searchKey))
            record.setSearchKey(name);
        Integer state = record.getState();
        if (state == null)
            record.setState(0);
@@ -212,8 +216,9 @@
            return;
        for (BrandInfo brandInfo : list) {
            String key = brandInfo.getName();
            if (StringUtil.isNullOrEmpty(key))
            String name = brandInfo.getName();
            String searchKey = brandInfo.getSearchKey();
            if (StringUtil.isNullOrEmpty(name) && StringUtil.isNullOrEmpty(searchKey))
                continue;
            // 添加商品
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandShopCaheServiceImpl.java
@@ -85,10 +85,13 @@
     */
    @Override
    public void addBrandShopPDD(BrandInfo brandInfo) {
        String searchKey = brandInfo.getSearchKey();
        if (StringUtil.isNullOrEmpty(searchKey))
            searchKey = brandInfo.getName();
        ShopInfoVO shopInfoVO = null;
        String key = brandInfo.getName();
        PDDSearchFilter pddfilter = new PDDSearchFilter();
        pddfilter.setKw(key);
        pddfilter.setKw(searchKey);
        pddfilter.setPage(1);
        pddfilter.setPageSize(100);
        pddfilter.setSortType(6);
@@ -99,7 +102,7 @@
            if (goodsList != null && goodsList.size() > 0) {
                for (PDDGoodsDetail goods : goodsList) {
                    String mallName = goods.getMallName();
                    if(goods.getMallId() != null && !StringUtil.isNullOrEmpty(mallName) && mallName.contains(key)){
                    if(goods.getMallId() != null && !StringUtil.isNullOrEmpty(mallName) && mallName.contains(brandInfo.getName())){
                        shopInfoVO = new ShopInfoVO();
                        shopInfoVO.setId(goods.getMallId().toString());
                        shopInfoVO.setShopName(mallName);