admin
2019-09-17 5eab2b71f0749e9f61fc83d9d7e03553e9fa75ef
Merge remote-tracking branch 'origin/div' into div
10个文件已修改
9个文件已添加
777 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserCouponController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/brand/BrandGoodsCaheDao.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/brand/BrandShopCaheDao.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/BrandInfoMapper.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/brand/BrandGoodsCahe.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/brand/BrandInfo.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/brand/BrandShopCahe.java 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/taobao/SearchShopFilter.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandInfoMapper.xml 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java 182 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandShopCaheServiceImpl.java 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandGoodsCaheService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandShopCaheService.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/ShopInfoVOFactory.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/vo/user/UserInfoVO.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserCouponController.java
@@ -295,7 +295,7 @@
        
        try {
            UserSystemCouponService.useOrderCoupon(uid, cid, orderNo, goodsType);
            JSONObject data = commonOrderService.getRewardJumpInfo(orderNo);
            JSONObject data = commonOrderService.getRewardJumpInfo(orderNo, goodsType);
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserSystemCouponException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
fanli/src/main/java/com/yeshi/fanli/dao/brand/BrandGoodsCaheDao.java
New file
@@ -0,0 +1,35 @@
package com.yeshi.fanli.dao.brand;
import java.util.List;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import com.yeshi.fanli.dao.MongodbBaseDao;
import com.yeshi.fanli.entity.brand.BrandGoodsCahe;
@Repository
public class BrandGoodsCaheDao extends MongodbBaseDao<BrandGoodsCahe> {
    /**
     * 查询商品列表
     * @param count
     * @param brandId
     * @return
     */
    public List<BrandGoodsCahe> getByBrandId(int start, int count, Long brandId){
        if (brandId == null)
            return null;
        Query query = new Query();
        query.addCriteria(Criteria.where("brandId").is(brandId));
        //分页
        query.skip(start).limit(count);
        //排序
        query.with(new Sort(Sort.Direction.DESC,"weight"));
        return mongoTemplate.find(query, BrandGoodsCahe.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/brand/BrandShopCaheDao.java
New file
@@ -0,0 +1,28 @@
package com.yeshi.fanli.dao.brand;
import java.util.List;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import com.yeshi.fanli.dao.MongodbBaseDao;
import com.yeshi.fanli.entity.brand.BrandShopCahe;
@Repository
public class BrandShopCaheDao extends MongodbBaseDao<BrandShopCahe> {
    /**
     * 查询品牌下店铺
     * @param brandId
     * @return
     */
    public List<BrandShopCahe> getByBrandId(Long brandId){
        if (brandId == null)
            return null;
        Query query = new Query();
        query.addCriteria(Criteria.where("brandId").is(brandId));
        return mongoTemplate.find(query, BrandShopCahe.class);
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/brand/BrandInfoMapper.java
@@ -25,11 +25,14 @@
    long countBrandInfo(@Param("cid") Long cid);
    
    
    /**
     * 查询有效店铺
     * @param cid
     * @param start
     * @param count
     * @return
     */
    List<BrandInfoVO> listValidBrandInfoCache(@Param("cid") Long cid);
    List<BrandInfo> listValidAll(@Param("start")long start, @Param("count")int count);
    
}
fanli/src/main/java/com/yeshi/fanli/entity/brand/BrandGoodsCahe.java
New file
@@ -0,0 +1,81 @@
package com.yeshi.fanli.entity.brand;
import java.io.Serializable;
import java.util.Date;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
@Document(collection = "brand_goods_cahe")
public class BrandGoodsCahe implements Serializable{
    private static final long serialVersionUID = 1L;
    @Field("id")
    private String id;
    @Field("brandId")
    private Long brandId;
    @Field("goods")
    private GoodsDetailVO goods;
    @Field("weight")
    private Integer weight;
    @Field("createTime")
    private Date createTime;
    @Field("updateTime")
    private Date updateTime;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public Long getBrandId() {
        return brandId;
    }
    public void setBrandId(Long brandId) {
        this.brandId = brandId;
    }
    public GoodsDetailVO getGoods() {
        return goods;
    }
    public void setGoods(GoodsDetailVO goods) {
        this.goods = goods;
    }
    public Integer getWeight() {
        return weight;
    }
    public void setWeight(Integer weight) {
        this.weight = weight;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/brand/BrandInfo.java
@@ -2,13 +2,11 @@
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
import com.google.gson.annotations.Expose;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
/**
 * 品牌信息
@@ -35,6 +33,9 @@
    @Expose
    @Column(name = "bf_icon")
    private String icon; // 品牌logo
    @Column(name = "bf_goods_total")
    private Integer goodsTotal; // 拥有商品数量
    
    @Column(name = "bf_weight")
    private Double weight; // 权重:值越大越前
@@ -120,4 +121,13 @@
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getGoodsTotal() {
        return goodsTotal;
    }
    public void setGoodsTotal(Integer goodsTotal) {
        this.goodsTotal = goodsTotal;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/brand/BrandShopCahe.java
New file
@@ -0,0 +1,70 @@
package com.yeshi.fanli.entity.brand;
import java.io.Serializable;
import java.util.Date;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import com.yeshi.fanli.vo.goods.ShopInfoVO;
@Document(collection = "brand_shop_cahe")
public class BrandShopCahe implements Serializable{
    private static final long serialVersionUID = 1L;
    @Field("id")
    private String id;
    @Field("brandId")
    private Long brandId;
    @Field("shop")
    private ShopInfoVO shop;
    @Field("createTime")
    private Date createTime;
    @Field("updateTime")
    private Date updateTime;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public Long getBrandId() {
        return brandId;
    }
    public void setBrandId(Long brandId) {
        this.brandId = brandId;
    }
    public ShopInfoVO getShop() {
        return shop;
    }
    public void setShop(ShopInfoVO shop) {
        this.shop = shop;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/taobao/SearchShopFilter.java
New file
@@ -0,0 +1,54 @@
package com.yeshi.fanli.entity.taobao;
public class SearchShopFilter {
    private int page;
    private int pageSize;
    // 搜索词
    private String key;
    // 排序字段
    private String sort;
    // 是否天猫
    private Boolean tmall;
    public int getPage() {
        return page;
    }
    public void setPage(int page) {
        this.page = page;
    }
    public int getPageSize() {
        return pageSize;
    }
    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
    public String getKey() {
        return key;
    }
    public void setKey(String key) {
        this.key = key;
    }
    public String getSort() {
        return sort;
    }
    public void setSort(String sort) {
        this.sort = sort;
    }
    public Boolean getTmall() {
        return tmall;
    }
    public void setTmall(Boolean tmall) {
        this.tmall = tmall;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/brand/BrandInfoMapper.xml
@@ -7,6 +7,7 @@
    <result column="bf_name" property="name" 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_state" property="state" jdbcType="INTEGER"/>
    <result column="bf_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="bf_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
@@ -20,6 +21,7 @@
    <result column="bf_name" property="name" 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_state" property="state" jdbcType="INTEGER"/>
    <result column="bf_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="bf_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
@@ -28,13 +30,12 @@
    </association>
  </resultMap>
  
  <sql id="Base_Column_List">bf_id,bf_cid,bf_name,bf_icon,bf_weight,bf_state,bf_create_time,bf_update_time</sql>
  <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>
  <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_state,bf_create_time,bf_update_time) values (#{id,jdbcType=BIGINT},#{brandClass.id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{icon,jdbcType=VARCHAR},#{weight,jdbcType=DOUBLE},#{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_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="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>
@@ -42,6 +43,7 @@
      <if test="name != null">bf_name,</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="state != null">bf_state,</if>
      <if test="createTime != null">bf_create_time,</if>
      <if test="updateTime != null">bf_update_time,</if>
@@ -52,18 +54,20 @@
      <if test="name != null">#{name,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="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_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_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="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="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="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>
@@ -88,10 +92,10 @@
    WHERE d.`bf_state` = 1 <if test="cid != null">AND d.`bf_cid` = #{cid} </if>
  </select>
  
  <select id="listValidBrandInfoCache" resultMap="BaseResultMap">
  <select id="listValidAll" resultMap="BaseResultMap">
      SELECT * FROM yeshi_ec_brand_info d
    WHERE d.`bf_state` = 1 AND d.`bf_cid` = #{cid}
    ORDER BY d.`bf_weight` DESC
    WHERE d.`bf_state` = 1
    LIMIT ${start},${count}
  </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandGoodsCaheServiceImpl.java
New file
@@ -0,0 +1,182 @@
package com.yeshi.fanli.service.impl.brand;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.brand.BrandGoodsCaheDao;
import com.yeshi.fanli.dto.jd.JDFilter;
import com.yeshi.fanli.dto.jd.JDSearchFilter;
import com.yeshi.fanli.dto.jd.JDSearchResult;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
import com.yeshi.fanli.entity.brand.BrandGoodsCahe;
import com.yeshi.fanli.entity.brand.BrandInfo;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.SearchFilter;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
import com.yeshi.fanli.service.inter.brand.BrandGoodsCaheService;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.jd.JDUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
import com.yeshi.fanli.util.taobao.SearchFilterUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@Service
public class BrandGoodsCaheServiceImpl implements BrandGoodsCaheService {
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private ConfigService configService;
    @Resource
    private BrandGoodsCaheDao brandGoodsCaheDao;
    @Override
    public int addBrandGoods(BrandInfo brandInfo) {
        int count = 0;
        // 淘宝
        count += addBrandGoodsTB(brandInfo);
        // 京东
        count += addBrandGoodsJD(brandInfo);
        // 拼多多
        count += addBrandGoodsPDD(brandInfo);
        return count;
    }
    /**
     * 淘宝商品
     * @param brandInfo
     * @return
     */
    private int addBrandGoodsTB(BrandInfo brandInfo) {
        SearchFilter filter = new SearchFilter();
        filter.setKey(brandInfo.getName());
        filter.setPage(1);
        filter.setPageSize(50);
        filter.setTmall(true);
        filter.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW);
        TaoBaoSearchResult searchResult = TaoKeApiUtil.searchWuLiao(filter);
        if (searchResult == null || searchResult.getTaoBaoGoodsBriefs() ==  null
                || searchResult.getTaoBaoGoodsBriefs().size() == 0)
            return 0;
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
        BigDecimal shareRate = hongBaoManageService.getShareRate();
        List<TaoBaoGoodsBrief> listGoods = searchResult.getTaoBaoGoodsBriefs();
        for (TaoBaoGoodsBrief goods: listGoods) {
            BrandGoodsCahe brandGoods = new BrandGoodsCahe();
            brandGoods.setBrandId(brandInfo.getId());
            brandGoods.setWeight((int) (Math.random() * 1000));
            brandGoods.setGoods(GoodsDetailVOFactory.convertTaoBao(goods, null, fanLiRate, shareRate));
            brandGoods.setCreateTime(new Date());
            brandGoods.setUpdateTime(new Date());
            brandGoodsCaheDao.save(brandGoods);
        }
        return listGoods.size();
    }
    /**
     *  京东商品
     *
     * @param brandInfo
     * @return
     */
    private int addBrandGoodsJD(BrandInfo brandInfo) {
        JDSearchResult result = null;
        String way = configService.get("jd_api_search_key");
        if ("1".equals(way)) {
            JDFilter filterAPI = new JDFilter();
            filterAPI.setKeyword(SearchFilterUtil.filterSearchContent(brandInfo.getName()));
            filterAPI.setPageIndex(1);
            filterAPI.setPageSize(100);
            filterAPI.setSort(JDFilter.SORT_DESC);
            filterAPI.setSortName(JDFilter.SORTNAME_ORDER_COUNT_30DAYS);
            result = JDApiUtil.queryByKey(filterAPI);
        } else {
            // 网页爬取
            JDSearchFilter jdfilter = new JDSearchFilter();
            jdfilter.setKey(SearchFilterUtil.filterSearchContent(brandInfo.getName()));
            jdfilter.setPageNo(1);
            jdfilter.setPageSize(100);
            jdfilter.setSort(JDSearchFilter.SORT_DESC);
            jdfilter.setSortName(JDSearchFilter.SORTNAME_ORDER_COUNT_30DAYS);
            result = JDUtil.searchByKey(jdfilter);
        }
        int count = 0;
        if (result != null) {
            PageEntity pageEntity = result.getPageEntity();
            if (pageEntity != null) {
                count = (int) pageEntity.getTotalCount();
            }
            List<JDGoods> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
                BigDecimal shareRate = hongBaoManageService.getShareRate();
                for (JDGoods goods : goodsList) {
                    BrandGoodsCahe brandGoods = new BrandGoodsCahe();
                    brandGoods.setBrandId(brandInfo.getId());
                    brandGoods.setWeight((int) (Math.random() * 1000));
                    brandGoods.setGoods(GoodsDetailVOFactory.convertJDGoods(goods, fanLiRate, shareRate));
                    brandGoods.setCreateTime(new Date());
                    brandGoods.setUpdateTime(new Date());
                    brandGoodsCaheDao.save(brandGoods);
                }
            }
        }
          return count;
    }
    /**
     * 拼多多商品
     * @param brandInfo
     * @return
     */
    private int addBrandGoodsPDD(BrandInfo brandInfo) {
        PDDSearchFilter pddfilter = new PDDSearchFilter();
        pddfilter.setKw(brandInfo.getName());
        pddfilter.setPage(1);
        pddfilter.setPageSize(50);
        pddfilter.setSortType(6);
        int count = 0;
        PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
        if (result != null) {
            count = result.getTotalCount();
            List<PDDGoodsDetail> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
                BigDecimal shareRate = hongBaoManageService.getShareRate();
                for (PDDGoodsDetail goods : goodsList) {
                    BrandGoodsCahe brandGoods = new BrandGoodsCahe();
                    brandGoods.setBrandId(brandInfo.getId());
                    brandGoods.setWeight((int) (Math.random() * 1000));
                    brandGoods.setGoods(GoodsDetailVOFactory.convertPDDGoods(goods, fanLiRate, shareRate));
                    brandGoods.setCreateTime(new Date());
                    brandGoods.setUpdateTime(new Date());
                    brandGoodsCaheDao.save(brandGoods);
                }
            }
        }
        return count;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java
@@ -9,17 +9,24 @@
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.brand.BrandShopCaheDao;
import com.yeshi.fanli.dao.mybatis.brand.BrandInfoMapper;
import com.yeshi.fanli.entity.brand.BrandInfo;
import com.yeshi.fanli.entity.brand.BrandShopCahe;
import com.yeshi.fanli.entity.taobao.SearchShopFilter;
import com.yeshi.fanli.entity.taobao.TaoBaoShop;
import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
import com.yeshi.fanli.exception.brand.BrandInfoException;
import com.yeshi.fanli.service.inter.brand.BrandClassShopService;
import com.yeshi.fanli.service.inter.brand.BrandGoodsCaheService;
import com.yeshi.fanli.service.inter.brand.BrandInfoService;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.factory.goods.ShopInfoVOFactory;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.brand.BrandInfoVO;
import com.yeshi.fanli.vo.brand.TaoBaoShopVO;
@@ -44,6 +51,13 @@
    @Resource
    private BrandClassShopService brandClassShopService;
    @Resource
    private BrandShopCaheDao brandShopCaheDao;
    @Resource
    private BrandGoodsCaheService brandGoodsCaheService;
    
    @Override
    public void saveObject(BrandInfo record) throws BrandInfoException{
@@ -142,4 +156,73 @@
    public long countBrandInfo(Long cid){
        return brandClassShopService.countBrandShopinfo(cid);
    }
    public void addShopAndGoods(long start, int count) {
        List<BrandInfo> list = brandInfoMapper.listValidAll(start, count);
        if(list == null || list.size() == 0)
            return;
        for (BrandInfo brandInfo: list) {
            String key = brandInfo.getName();
            if(StringUtil.isNullOrEmpty(key))
                continue;
            // 添加店铺
            addBrandShop(brandInfo);
            // 添加店铺
            int goodsTotal = brandGoodsCaheService.addBrandGoods(brandInfo);
            brandInfo.setGoodsTotal(goodsTotal);
            brandInfoMapper.updateByPrimaryKeySelective(brandInfo);
        }
    }
    /**
     * 加入品牌店铺
     * @param brandInfo
     */
    private void addBrandShop(BrandInfo brandInfo) {
        SearchShopFilter filter = new SearchShopFilter();
        filter.setKey(brandInfo.getName());
        filter.setPageSize(100);
        filter.setTmall(true);
        filter.setSort("(total_auction_des");
        TaoBaoShopInfo taoBaoShop = null;
        for(int page = 1; page < 3; page++) {
            filter.setPage(page);
            List<TaoBaoShopInfo> listShop = TaoKeApiUtil.searchShop(filter);
            if(listShop == null || listShop.size() == 0)
                continue;
            for (TaoBaoShopInfo shop: listShop) {
                String shopTitle = shop.getShopTitle();
                if(StringUtil.isNullOrEmpty(shopTitle))
                    continue;
                if(!shopTitle.contains("旗舰店"))
                    continue;
                taoBaoShop = shop;
                break;
            }
            if (taoBaoShop != null)
                break;
        }
        BrandShopCahe brandShop = new BrandShopCahe();
        brandShop.setBrandId(brandInfo.getId());
        brandShop.setShop(ShopInfoVOFactory.convertTaoBaoShop(taoBaoShop));
        brandShop.setCreateTime(new Date());
        brandShop.setUpdateTime(new Date());
        brandShopCaheDao.save(brandShop);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandShopCaheServiceImpl.java
New file
@@ -0,0 +1,86 @@
package com.yeshi.fanli.service.impl.brand;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.yeshi.fanli.dao.brand.BrandGoodsCaheDao;
import com.yeshi.fanli.dao.brand.BrandShopCaheDao;
import com.yeshi.fanli.dto.jd.JDFilter;
import com.yeshi.fanli.dto.jd.JDSearchFilter;
import com.yeshi.fanli.dto.jd.JDSearchResult;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
import com.yeshi.fanli.entity.brand.BrandGoodsCahe;
import com.yeshi.fanli.entity.brand.BrandInfo;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.taobao.SearchFilter;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
import com.yeshi.fanli.service.inter.brand.BrandShopCaheService;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.jd.JDApiUtil;
import com.yeshi.fanli.util.jd.JDUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
import com.yeshi.fanli.util.taobao.SearchFilterUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
@Service
public class BrandShopCaheServiceImpl implements BrandShopCaheService {
    @Resource
    private BrandShopCaheDao brandShopCaheDao;
    @Override
    public void addBrandShop(BrandInfo brandInfo) {
        int count = 0;
//        // 淘宝
//        count += addBrandShopTB(brandInfo);
//        // 京东
//        count += addBrandShopJD(brandInfo);
//        // 拼多多
//        count += addBrandShopPDD(brandInfo);
    }
    /**
     * 淘宝商品
     * @param brandInfo
     * @return
     */
    private void addBrandShopTB(BrandInfo brandInfo) {
    }
    /**
     *  京东商品
     *
     * @param brandInfo
     * @return
     */
    private void addBrandShopJD(BrandInfo brandInfo) {
    }
    /**
     * 拼多多商品
     * @param brandInfo
     * @return
     */
    private void addBrandShopPDD(BrandInfo brandInfo) {
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -1372,7 +1372,7 @@
    }
    @Override
    public JSONObject getRewardJumpInfo(String orderNo) {
    public JSONObject getRewardJumpInfo(String orderNo, Integer goodsType) {
        JSONObject map = new JSONObject();
        // 订单标识
@@ -1389,6 +1389,7 @@
        Map<String, Object> jumpLink = new HashMap<String, Object>();
        jumpLink.put("orderNo", orderNo);
        jumpLink.put("goodsType", goodsType);
        Map<String, Object> jump = new HashMap<String, Object>();
        jump.put("type", 1);
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandGoodsCaheService.java
New file
@@ -0,0 +1,15 @@
package com.yeshi.fanli.service.inter.brand;
import com.yeshi.fanli.entity.brand.BrandInfo;
/**
 * 品牌商品
 *
 * @author Administrator
 *
 */
public interface BrandGoodsCaheService {
    public int addBrandGoods(BrandInfo brandInfo);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/brand/BrandShopCaheService.java
New file
@@ -0,0 +1,15 @@
package com.yeshi.fanli.service.inter.brand;
import com.yeshi.fanli.entity.brand.BrandInfo;
/**
 * 品牌店铺
 *
 * @author Administrator
 *
 */
public interface BrandShopCaheService {
    public void addBrandShop(BrandInfo brandInfo);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/order/CommonOrderService.java
@@ -246,7 +246,7 @@
     * @param orderNo
     * @return
     */
    public JSONObject getRewardJumpInfo(String orderNo);
    public JSONObject getRewardJumpInfo(String orderNo, Integer goodsType);
    /**
     * 根据交易号获取订单详情
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/ShopInfoVOFactory.java
@@ -4,6 +4,7 @@
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.taobao.TaoBaoShop;
import com.yeshi.fanli.entity.taobao.TaoBaoShopInfo;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.vo.goods.ShopInfoVO;
@@ -59,6 +60,29 @@
        return shopInfoVO;
    }
    
    /**
     * 淘宝店铺
     * @param goods 淘宝商品
     * @param pid
     * @param fanLiRate 返利比例
     * @return
     */
    public static ShopInfoVO convertTaoBaoShop(TaoBaoShopInfo shop) {
        ShopInfoVO shopInfoVO = new ShopInfoVO();
        shopInfoVO.setId(shop.getUserId().toString());
        shopInfoVO.setShopName(shop.getShopTitle());
        shopInfoVO.setShopIcon(shop.getPictureUrl());
        shopInfoVO.setShopLink(shop.getShopUrl());
        String shopType = shop.getShopType();
        if (shopType != null && "B".equalsIgnoreCase(shopType)) {
            shopInfoVO.setUserType(11); // 天猫
        } else {
            shopInfoVO.setUserType(10); // 淘宝
        }
        return shopInfoVO;
    }
    
    /**
     * 拼多多店铺
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeApiUtil.java
@@ -15,6 +15,7 @@
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinReport;
import com.yeshi.fanli.entity.taobao.RelateGoods;
import com.yeshi.fanli.entity.taobao.SearchFilter;
import com.yeshi.fanli.entity.taobao.SearchShopFilter;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoHead;
import com.yeshi.fanli.entity.taobao.TaoBaoProvince;
@@ -1241,6 +1242,55 @@
        dto.setPage(pageEntity);
        return dto;
    }
    /**
     * 店铺搜索
     *
     * @param key
     *            -店铺名称
     * @param page
     *            -页码
     * @return
     */
    public static List<TaoBaoShopInfo> searchShop(SearchShopFilter filter) {
        if (StringUtil.isNullOrEmpty(filter.getKey()))
            return new ArrayList<>();
        List<TaoBaoShopInfo> list = new ArrayList<>();
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.shop.get");
        map.put("fields", "user_id,shop_title,shop_type,seller_nick,pict_url,shop_url");
        map.put("q", filter.getKey());
        map.put("page_size", filter.getPageSize()+ "");
        map.put("page_no", filter.getPage() + "");
        if(!StringUtil.isNullOrEmpty(filter.getSort()))
            map.put("sort", filter.getSort());
        if(filter.getTmall() != null)
            map.put("is_tmall", filter.getTmall() + "");
        String resultStr = TaoKeBaseUtil.baseRequestForThreeTimes(map, true);
        JSONObject resultDate = JSONObject.fromObject(resultStr);
        if (resultDate.optJSONObject("tbk_shop_get_response") != null
                && resultDate.optJSONObject("tbk_shop_get_response").optJSONObject("results") != null) {
            JSONArray array = resultDate.optJSONObject("tbk_shop_get_response").optJSONObject("results")
                    .optJSONArray("n_tbk_shop");
            if (array != null)
                for (int i = 0; i < array.size(); i++) {
                    JSONObject item = array.optJSONObject(i);
                    TaoBaoShopInfo info = new TaoBaoShopInfo();
                    info.setPictureUrl(item.optString("pict_url"));
                    info.setSellerNick(item.optString("seller_nick"));
                    info.setShopTitle(item.optString("shop_title"));
                    info.setShopType(item.optString("shop_type"));
                    info.setShopUrl(item.optString("shop_url"));
                    info.setUserId(item.optLong("user_id"));
                    list.add(info);
                }
        }
        return list;
    }
    /**
     * 品牌券获取
fanli/src/main/java/com/yeshi/fanli/vo/user/UserInfoVO.java
@@ -84,7 +84,7 @@
    private String tbRelationId;
    
    // 剩余金币数量
    private Integer goldCoin;
    private int goldCoin;
    
    public String getRankId() {
@@ -343,11 +343,11 @@
        this.tbRelationId = tbRelationId;
    }
    public Integer getGoldCoin() {
    public int getGoldCoin() {
        return goldCoin;
    }
    public void setGoldCoin(Integer goldCoin) {
    public void setGoldCoin(int goldCoin) {
        this.goldCoin = goldCoin;
    }