Merge remote-tracking branch 'origin/div' into div
| | |
| | |
|
| | | 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()));
|
New file |
| | |
| | | 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);
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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);
|
| | | }
|
| | | |
| | | }
|
| | |
| | | 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); |
| | | |
| | | } |
New file |
| | |
| | | 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;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | 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;
|
| | |
|
| | | /**
|
| | | * 品牌信息
|
| | |
| | | @Expose
|
| | | @Column(name = "bf_icon")
|
| | | private String icon; // 品牌logo
|
| | | |
| | | @Column(name = "bf_goods_total")
|
| | | private Integer goodsTotal; // 拥有商品数量
|
| | |
|
| | | @Column(name = "bf_weight")
|
| | | private Double weight; // 权重:值越大越前
|
| | |
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | |
|
| | | public Integer getGoodsTotal() {
|
| | | return goodsTotal;
|
| | | }
|
| | |
|
| | | public void setGoodsTotal(Integer goodsTotal) {
|
| | | this.goodsTotal = goodsTotal;
|
| | | }
|
| | | } |
New file |
| | |
| | | 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;
|
| | | }
|
| | | }
|
New file |
| | |
| | | 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;
|
| | | }
|
| | | }
|
| | |
| | | <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"/> |
| | |
| | | <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"/> |
| | |
| | | </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> |
| | |
| | | <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> |
| | |
| | | <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> |
| | |
| | | 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> |
New file |
| | |
| | | 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;
|
| | | }
|
| | | }
|
| | |
| | | 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;
|
| | |
|
| | |
| | | @Resource
|
| | | private BrandClassShopService brandClassShopService;
|
| | |
|
| | | @Resource
|
| | | private BrandShopCaheDao brandShopCaheDao;
|
| | | |
| | | @Resource
|
| | | private BrandGoodsCaheService brandGoodsCaheService;
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public void saveObject(BrandInfo record) throws BrandInfoException{
|
| | |
| | | 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);
|
| | | }
|
| | | |
| | | |
| | | |
| | | }
|
New file |
| | |
| | | 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) {
|
| | | |
| | | }
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public JSONObject getRewardJumpInfo(String orderNo) {
|
| | | public JSONObject getRewardJumpInfo(String orderNo, Integer goodsType) {
|
| | |
|
| | | JSONObject map = new JSONObject();
|
| | | // 订单标识
|
| | |
| | |
|
| | | 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);
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.brand;
|
| | |
|
| | | import com.yeshi.fanli.entity.brand.BrandInfo;
|
| | |
|
| | | /**
|
| | | * 品牌商品
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface BrandGoodsCaheService {
|
| | |
|
| | | public int addBrandGoods(BrandInfo brandInfo);
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.brand;
|
| | |
|
| | | import com.yeshi.fanli.entity.brand.BrandInfo;
|
| | |
|
| | | /**
|
| | | * 品牌店铺
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | public interface BrandShopCaheService {
|
| | |
|
| | | public void addBrandShop(BrandInfo brandInfo);
|
| | |
|
| | | }
|
| | |
| | | * @param orderNo
|
| | | * @return
|
| | | */
|
| | | public JSONObject getRewardJumpInfo(String orderNo);
|
| | | public JSONObject getRewardJumpInfo(String orderNo, Integer goodsType);
|
| | |
|
| | | /**
|
| | | * 根据交易号获取订单详情
|
| | |
| | |
|
| | | 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;
|
| | |
|
| | |
| | | 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;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 拼多多店铺
|
| | |
| | | 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;
|
| | |
| | | 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;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 品牌券获取
|
| | |
| | | private String tbRelationId;
|
| | |
|
| | | // 剩余金币数量
|
| | | private Integer goldCoin;
|
| | | private int goldCoin;
|
| | |
|
| | |
|
| | | public String getRankId() {
|
| | |
| | | this.tbRelationId = tbRelationId;
|
| | | }
|
| | |
|
| | | public Integer getGoldCoin() {
|
| | | public int getGoldCoin() {
|
| | | return goldCoin;
|
| | | }
|
| | |
|
| | | public void setGoldCoin(Integer goldCoin) {
|
| | | public void setGoldCoin(int goldCoin) {
|
| | | this.goldCoin = goldCoin;
|
| | | }
|
| | |
|