facade-goods/src/main/java/com/yeshi/goods/facade/dto/taobao/haodanku/HaoDanKuJDGoodsInfo.java
New file @@ -0,0 +1,211 @@ package com.yeshi.goods.facade.dto.taobao.haodanku; import java.math.BigDecimal; public class HaoDanKuJDGoodsInfo { /** * skuid : 10027627962896 * goodsname : 一次性柔软珍珠纹卷筒式洗脸巾 三卷 * goodsnameshort : 一次性柔软珍珠纹卷筒式洗脸巾 三卷 * goodsdesc : 京东商城,品质无忧,万里挑一! * itemprice : 8.50 * itemendprice : 8.90 * itemsale : 7658 * itemsale2 : 477 * todaysale : 1037 * itempic : http://img14.360buyimg.com/imgzone/jfs/t1/175520/4/17098/128960/60d98958Ea8ed8d2c/6593bd71c0abb7a1.jpg * cid : 4 * commissionshare : 40.00 * commission : 3.56 * couponurl : http://coupon.m.jd.com/coupons/show.action?key=45d5f2d9b5464b3393dbeda433342b0e&roleId=54583615&to=mall.jd.com/index-10406960.html * couponmoney : 1 * couponnum : 1000000 * couponstarttime : 1624809600 * couponendtime : 1625673599 * jd_image : https://img14.360buyimg.com/pop/jfs/t1/175520/4/17098/128960/60d98958Ea8ed8d2c/6593bd71c0abb7a1.jpg,https://img14.360buyimg.com/pop/jfs/t1/168932/31/11927/91829/604b2457E41481d3d/a2e1e65a5849eae0.jpg,https://img14.360buyimg.com/pop/jfs/t1/170815/35/5445/575765/601ba3b3Ee81103a1/fa461e7210a6d060.jpg * shopname : 泽成彩妆工具拼购专营店 */ private String skuid; private String goodsname; private String goodsnameshort; private String goodsdesc; private BigDecimal itemprice; private BigDecimal itemendprice; private String itemsale; private String itemsale2; private String todaysale; private String itempic; private String cid; private BigDecimal commissionshare; private BigDecimal commission; private String couponurl; private BigDecimal couponmoney; private Integer couponnum; private String couponstarttime; private String couponendtime; private String jd_image; private String shopname; public String getSkuid() { return skuid; } public void setSkuid(String skuid) { this.skuid = skuid; } public String getGoodsname() { return goodsname; } public void setGoodsname(String goodsname) { this.goodsname = goodsname; } public String getGoodsnameshort() { return goodsnameshort; } public void setGoodsnameshort(String goodsnameshort) { this.goodsnameshort = goodsnameshort; } public String getGoodsdesc() { return goodsdesc; } public void setGoodsdesc(String goodsdesc) { this.goodsdesc = goodsdesc; } public BigDecimal getItemprice() { return itemprice; } public void setItemprice(BigDecimal itemprice) { this.itemprice = itemprice; } public BigDecimal getItemendprice() { return itemendprice; } public void setItemendprice(BigDecimal itemendprice) { this.itemendprice = itemendprice; } public String getItemsale() { return itemsale; } public void setItemsale(String itemsale) { this.itemsale = itemsale; } public String getItemsale2() { return itemsale2; } public void setItemsale2(String itemsale2) { this.itemsale2 = itemsale2; } public String getTodaysale() { return todaysale; } public void setTodaysale(String todaysale) { this.todaysale = todaysale; } public String getItempic() { return itempic; } public void setItempic(String itempic) { this.itempic = itempic; } public String getCid() { return cid; } public void setCid(String cid) { this.cid = cid; } public BigDecimal getCommissionshare() { return commissionshare; } public void setCommissionshare(BigDecimal commissionshare) { this.commissionshare = commissionshare; } public BigDecimal getCommission() { return commission; } public void setCommission(BigDecimal commission) { this.commission = commission; } public String getCouponurl() { return couponurl; } public void setCouponurl(String couponurl) { this.couponurl = couponurl; } public BigDecimal getCouponmoney() { return couponmoney; } public void setCouponmoney(BigDecimal couponmoney) { this.couponmoney = couponmoney; } public Integer getCouponnum() { return couponnum; } public void setCouponnum(Integer couponnum) { this.couponnum = couponnum; } public String getCouponstarttime() { return couponstarttime; } public void setCouponstarttime(String couponstarttime) { this.couponstarttime = couponstarttime; } public String getCouponendtime() { return couponendtime; } public void setCouponendtime(String couponendtime) { this.couponendtime = couponendtime; } public String getJd_image() { return jd_image; } public void setJd_image(String jd_image) { this.jd_image = jd_image; } public String getShopname() { return shopname; } public void setShopname(String shopname) { this.shopname = shopname; } } facade-goods/src/main/java/com/yeshi/goods/facade/dto/taobao/haodanku/HaoDanKuListResult.java
New file @@ -0,0 +1,29 @@ package com.yeshi.goods.facade.dto.taobao.haodanku; import java.util.List; public class HaoDanKuListResult { private List resultList; private Integer minId; public HaoDanKuListResult(List resultList, Integer minId) { this.resultList = resultList; this.minId = minId; } public List getResultList() { return resultList; } public void setResultList(List resultList) { this.resultList = resultList; } public Integer getMinId() { return minId; } public void setMinId(Integer minId) { this.minId = minId; } } facade-goods/src/main/java/com/yeshi/goods/facade/dto/taobao/haodanku/HaoDanKuPDDGoodsInfo.java
New file @@ -0,0 +1,232 @@ package com.yeshi.goods.facade.dto.taobao.haodanku; import java.math.BigDecimal; public class HaoDanKuPDDGoodsInfo { /** * goods_id : 256892844228 * goods_sign : Y9r2mbpPRlBKj3phwfjZN_gIiyLN0ykW_JQzhTIuSsL * zs_duo_id : 11138663 * goodsname : 正品洗头发水水去屑顺柔修护控油洗头发露持久留香男女通用 * goodsnameshort : 正品洗头发水水去屑顺柔修护控油洗头发露持久留香男女通用 * goodsdesc : 正品洗头发水水去屑顺柔修护控油洗头发露持久留香男女通用 * itemprice : 39.90 * itemendprice : 19.90 * itemsale : 3020 * itemsale2 : 249 * todaysale : 1013 * itempic : https://img.pddpic.com/mms-material-img/2021-05-17/b2ba1c69-6120-4829-8d90-a362391c45eb.jpeg.a.jpeg * cid : 14 * promotion_rate : 27.00 * commission : 5.37 * couponmoney : 20 * couponnum : 5000 * couponstarttime : 1624809600 * couponendtime : 1627401599 * pdd_image : https://img.pddpic.com/mms-material-img/2021-05-17/b2ba1c69-6120-4829-8d90-a362391c45eb.jpeg.a.jpeg,https://t16img.yangkeduo.com/garner-api/00860d6790e3dbe527830b368080bede.jpeg,https://t16img.yangkeduo.com/garner-api/08107712a286faf46408f530895fa465.jpeg,https://t16img.yangkeduo.com/garner-api/a237430f62873b82952b6a31e07f4674.jpeg,https://img.pddpic.com/mms-material-img/2021-05-17/21919094-8edb-4b35-be76-b94b392df134.jpeg.a.jpeg,https://img.pddpic.com/mms-material-img/2021-05-17/d477390e-ff35-4c7f-bb25-def84e213e49.jpeg.a.jpeg,https://img.pddpic.com/mms-material-img/2021-05-17/b9939d43-b00b-4c78-a4b4-f40cb8f5aa60.jpeg.a.jpeg,https://img.pddpic.com/mms-material-img/2021-05-17/29cfd381-b705-4040-a7d5-9fbb90664df2.jpeg.a.jpeg * shopname : 艾漫家直发店 * start_time : 1624809600 */ private String goods_id; private String goods_sign; private String zs_duo_id; private String goodsname; private String goodsnameshort; private String goodsdesc; private BigDecimal itemprice; private BigDecimal itemendprice; private String itemsale; private String itemsale2; private String todaysale; private String itempic; private String cid; private BigDecimal promotion_rate; private BigDecimal commission; private BigDecimal couponmoney; private String couponnum; private String couponstarttime; private String couponendtime; private String pdd_image; private String shopname; private String start_time; public String getGoods_id() { return goods_id; } public void setGoods_id(String goods_id) { this.goods_id = goods_id; } public String getGoods_sign() { return goods_sign; } public void setGoods_sign(String goods_sign) { this.goods_sign = goods_sign; } public String getZs_duo_id() { return zs_duo_id; } public void setZs_duo_id(String zs_duo_id) { this.zs_duo_id = zs_duo_id; } public String getGoodsname() { return goodsname; } public void setGoodsname(String goodsname) { this.goodsname = goodsname; } public String getGoodsnameshort() { return goodsnameshort; } public void setGoodsnameshort(String goodsnameshort) { this.goodsnameshort = goodsnameshort; } public String getGoodsdesc() { return goodsdesc; } public void setGoodsdesc(String goodsdesc) { this.goodsdesc = goodsdesc; } public BigDecimal getItemprice() { return itemprice; } public void setItemprice(BigDecimal itemprice) { this.itemprice = itemprice; } public BigDecimal getItemendprice() { return itemendprice; } public void setItemendprice(BigDecimal itemendprice) { this.itemendprice = itemendprice; } public String getItemsale() { return itemsale; } public void setItemsale(String itemsale) { this.itemsale = itemsale; } public String getItemsale2() { return itemsale2; } public void setItemsale2(String itemsale2) { this.itemsale2 = itemsale2; } public String getTodaysale() { return todaysale; } public void setTodaysale(String todaysale) { this.todaysale = todaysale; } public String getItempic() { return itempic; } public void setItempic(String itempic) { this.itempic = itempic; } public String getCid() { return cid; } public void setCid(String cid) { this.cid = cid; } public BigDecimal getPromotion_rate() { return promotion_rate; } public void setPromotion_rate(BigDecimal promotion_rate) { this.promotion_rate = promotion_rate; } public BigDecimal getCommission() { return commission; } public void setCommission(BigDecimal commission) { this.commission = commission; } public BigDecimal getCouponmoney() { return couponmoney; } public void setCouponmoney(BigDecimal couponmoney) { this.couponmoney = couponmoney; } public String getCouponnum() { return couponnum; } public void setCouponnum(String couponnum) { this.couponnum = couponnum; } public String getCouponstarttime() { return couponstarttime; } public void setCouponstarttime(String couponstarttime) { this.couponstarttime = couponstarttime; } public String getCouponendtime() { return couponendtime; } public void setCouponendtime(String couponendtime) { this.couponendtime = couponendtime; } public String getPdd_image() { return pdd_image; } public void setPdd_image(String pdd_image) { this.pdd_image = pdd_image; } public String getShopname() { return shopname; } public void setShopname(String shopname) { this.shopname = shopname; } public String getStart_time() { return start_time; } public void setStart_time(String start_time) { this.start_time = start_time; } } facade-goods/src/main/java/com/yeshi/goods/facade/utils/factory/TaoBaoGoodsFactory.java
New file @@ -0,0 +1,7 @@ package com.yeshi.goods.facade.utils.factory; public class TaoBaoGoodsFactory { } facade-goods/src/main/java/com/yeshi/goods/facade/utils/taobao/DaTaoKeApiUtil.java
@@ -960,6 +960,6 @@ public static void main(String[] args) { parseTaoBaoToken("3.0微Ni3dX7WcGnT微 https://m.tb.cn/h.4vPHrmS?sm=3f931f 兰古仕电热蚊香液无味非灭蚊婴儿孕妇宝宝电蚊香器驱蚊液家用防蚊"); parseTaoBaoToken("8\uD83D\uDC48嘻etMgX8V2M30信 https://m.tb.cn/h.4CFFCNf?sm=fb01ec 大码女装法式初恋复古超仙rouje碎花吊带小雏菊石原里美连衣裙子"); } } facade-goods/src/main/java/com/yeshi/goods/facade/utils/taobao/HaoDanKuApiUtil.java
@@ -1,18 +1,23 @@ package com.yeshi.goods.facade.utils.taobao; import java.io.IOException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapter; import com.google.gson.TypeAdapterFactory; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; import com.google.gson.stream.JsonWriter; import com.yeshi.goods.facade.dto.taobao.haodanku.*; import org.yeshi.utils.HttpUtil; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.yeshi.goods.facade.dto.taobao.haodanku.HDKGoodsListResultDTO; import com.yeshi.goods.facade.dto.taobao.haodanku.HDKSearchFilter; import com.yeshi.goods.facade.dto.taobao.haodanku.HDKWXCircleContentDTO; import com.yeshi.goods.facade.entity.taobao.haodanku.HDKGoodsDetail; import net.sf.json.JSONArray; @@ -21,423 +26,564 @@ /** * 好单库API * @author Administrator * * @author Administrator */ public class HaoDanKuApiUtil { private final static String API_KEY = "blks"; private final static String API_KEY = "blks"; private static HaoDanKuApiUtil instance; private static HaoDanKuApiUtil instance; public static HaoDanKuApiUtil getInstance() { if (instance == null) instance = new HaoDanKuApiUtil(); return instance; } public static HaoDanKuApiUtil getInstance() { if (instance == null) instance = new HaoDanKuApiUtil(); return instance; } private String baseGetRequest(String path, List<ParamsKeyValue> params) { params.add(0, new HaoDanKuApiUtil.ParamsKeyValue("apikey", API_KEY)); String url = "http://v2.api.haodanku.com/" + path; for (ParamsKeyValue keyValue : params) { url += ("/" + keyValue.key + "/" + keyValue.value); } return HttpUtil.get(url); } private String baseGetRequest(String path, List<ParamsKeyValue> params) { params.add(0, new HaoDanKuApiUtil.ParamsKeyValue("apikey", API_KEY)); String url = "http://v2.api.haodanku.com/" + path; for (ParamsKeyValue keyValue : params) { url += ("/" + keyValue.key + "/" + keyValue.value); } return HttpUtil.get(url); } private String basePostRequest(String url, List<ParamsKeyValue> params) { params.add(0, new HaoDanKuApiUtil.ParamsKeyValue("apikey", API_KEY)); Map<String, String> parmasMap = new HashMap<>(); for (ParamsKeyValue keyValue : params) { parmasMap.put(keyValue.key, keyValue.value); } return HttpUtil.post(url, parmasMap, null); } private String basePostRequest(String url, List<ParamsKeyValue> params) { params.add(0, new HaoDanKuApiUtil.ParamsKeyValue("apikey", API_KEY)); Map<String, String> parmasMap = new HashMap<>(); for (ParamsKeyValue keyValue : params) { parmasMap.put(keyValue.key, keyValue.value); } return HttpUtil.post(url, parmasMap, null); } /** * 获取朋友圈API的内容 * @Title: getSendWXCircleContent * @Description: * void 返回类型 * @throws */ public void getSendWXCircleContent(Integer minId) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("min_id", minId + "")); String result = baseGetRequest("selected_item", params); System.out.println(result); } /** * 获取朋友圈API的内容 * * @throws * @Title: getSendWXCircleContent * @Description: void 返回类型 */ public void getSendWXCircleContent(Integer minId) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("min_id", minId + "")); String result = baseGetRequest("selected_item", params); System.out.println(result); } public String convertLink(Long auctionId, String pid, String activityId,String specialId,String relationId) { List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("itemid", auctionId + "")); params.add(new ParamsKeyValue("pid", pid)); if(!StringUtil.isNullOrEmpty(specialId)){ params.add(new ParamsKeyValue("special_id", specialId)); } public String convertLink(Long auctionId, String pid, String activityId, String specialId, String relationId) { List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("itemid", auctionId + "")); params.add(new ParamsKeyValue("pid", pid)); if (!StringUtil.isNullOrEmpty(specialId)) { params.add(new ParamsKeyValue("special_id", specialId)); } if(!StringUtil.isNullOrEmpty(relationId)){ params.add(new ParamsKeyValue("relation_id", relationId)); } if (!StringUtil.isNullOrEmpty(relationId)) { params.add(new ParamsKeyValue("relation_id", relationId)); } if (activityId != null) params.add(new ParamsKeyValue("activityid", activityId)); String result = basePostRequest("http://v2.api.haodanku.com/ratesurl", params); System.out.println(result); JSONObject resultData = JSONObject.fromObject(result); String link = ""; if (resultData.optInt("code") == 1) { resultData = resultData.optJSONObject("data"); link = resultData.optString("coupon_click_url"); if (StringUtil.isNullOrEmpty(link)) { link = resultData.optString("item_url"); } } if (activityId != null) params.add(new ParamsKeyValue("activityid", activityId)); String result = basePostRequest("http://v2.api.haodanku.com/ratesurl", params); System.out.println(result); JSONObject resultData = JSONObject.fromObject(result); String link = ""; if (resultData.optInt("code") == 1) { resultData = resultData.optJSONObject("data"); link = resultData.optString("coupon_click_url"); if (StringUtil.isNullOrEmpty(link)) { link = resultData.optString("item_url"); } } return link; } return link; } /** * 商品列表 * @Title: listGoods * @Description: * @param minId * @param catIds * @param pageSize * @return * HDKGoodsListResultDTO 返回类型 * @throws */ // 详情:https://www.haodanku.com/api/detail/show/1.html public HDKGoodsListResultDTO listGoods(Integer minId, List<Integer> catIds, int pageSize) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("nav", 3 + "")); params.add(new ParamsKeyValue("back", pageSize + "")); params.add(new ParamsKeyValue("min_id", minId + "")); params.add(new ParamsKeyValue("sort", 0 + "")); if (catIds != null && catIds.size() > 0) { params.add(new ParamsKeyValue("cid", StringUtil.concat(catIds, ","))); } /** * 商品列表 * * @param minId * @param catIds * @param pageSize * @return HDKGoodsListResultDTO 返回类型 * @throws * @Title: listGoods * @Description: */ // 详情:https://www.haodanku.com/api/detail/show/1.html public HDKGoodsListResultDTO listGoods(Integer minId, List<Integer> catIds, int pageSize) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("nav", 3 + "")); params.add(new ParamsKeyValue("back", pageSize + "")); params.add(new ParamsKeyValue("min_id", minId + "")); params.add(new ParamsKeyValue("sort", 0 + "")); if (catIds != null && catIds.size() > 0) { params.add(new ParamsKeyValue("cid", StringUtil.concat(catIds, ","))); } String result = baseGetRequest("itemlist", params); String result = baseGetRequest("itemlist", params); JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } return null; } return null; } /** * 商品列表筛选 * @param filter * @return */ public HDKGoodsListResultDTO queryList(HDKSearchFilter filter) { List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("back", filter.getBack() + "")); params.add(new ParamsKeyValue("min_id", filter.getMinId() + "")); params.add(new ParamsKeyValue("nav", filter.getNav() + "")); if (!StringUtil.isNullOrEmpty(filter.getCid())) params.add(new ParamsKeyValue("cid", filter.getCid())); if (filter.getPriceMin() != null) params.add(new ParamsKeyValue("price_min", filter.getPriceMin() + "")); if (filter.getPriceMax() != null) params.add(new ParamsKeyValue("price_max", filter.getPriceMax() + "")); if (filter.getSaleMin() != null) params.add(new ParamsKeyValue("sale_min", filter.getSaleMin() + "")); if (filter.getSaleMax() != null) params.add(new ParamsKeyValue("sale_max", filter.getSaleMax() + "")); if (filter.getCouponMin() != null) params.add(new ParamsKeyValue("coupon_min", filter.getCouponMin() + "")); if (filter.getCouponMax() != null) params.add(new ParamsKeyValue("coupon_max", filter.getCouponMax() + "")); if (filter.getTkratesMin()!= null) params.add(new ParamsKeyValue("tkrates_min", filter.getTkratesMin() + "")); if (filter.getTkratesMax() != null) params.add(new ParamsKeyValue("tkrates_max", filter.getTkratesMax() + "")); if (filter.getTkmoneyMin()!= null) params.add(new ParamsKeyValue("tkmoney_min", filter.getTkmoneyMin() + "")); if (filter.getItemType()!= null) params.add(new ParamsKeyValue("item_type", filter.getItemType() + "")); String result = baseGetRequest("itemlist", params); JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } return null; } /** * 商品爆单列表 * @Title: listGoods * @Description: * @param minId * @param catIds * @param pageSize * @return * HDKGoodsListResultDTO 返回类型 * @throws */ public HDKGoodsListResultDTO listHotGoods(Integer minId, int pageSize, int saleType, List<Integer> catIds) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("sale_type", saleType +"")); params.add(new ParamsKeyValue("back", pageSize + "")); params.add(new ParamsKeyValue("min_id", minId + "")); params.add(new ParamsKeyValue("item_type", 1 + "")); // 是否只获取营销返利商品,1是,0否 if (catIds != null && catIds.size() > 0) { params.add(new ParamsKeyValue("cid", StringUtil.concat(catIds, ","))); } /** * 商品列表筛选 * * @param filter * @return */ public HDKGoodsListResultDTO queryList(HDKSearchFilter filter) { List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("back", filter.getBack() + "")); params.add(new ParamsKeyValue("min_id", filter.getMinId() + "")); params.add(new ParamsKeyValue("nav", filter.getNav() + "")); if (!StringUtil.isNullOrEmpty(filter.getCid())) params.add(new ParamsKeyValue("cid", filter.getCid())); if (filter.getPriceMin() != null) params.add(new ParamsKeyValue("price_min", filter.getPriceMin() + "")); if (filter.getPriceMax() != null) params.add(new ParamsKeyValue("price_max", filter.getPriceMax() + "")); if (filter.getSaleMin() != null) params.add(new ParamsKeyValue("sale_min", filter.getSaleMin() + "")); if (filter.getSaleMax() != null) params.add(new ParamsKeyValue("sale_max", filter.getSaleMax() + "")); if (filter.getCouponMin() != null) params.add(new ParamsKeyValue("coupon_min", filter.getCouponMin() + "")); if (filter.getCouponMax() != null) params.add(new ParamsKeyValue("coupon_max", filter.getCouponMax() + "")); if (filter.getTkratesMin() != null) params.add(new ParamsKeyValue("tkrates_min", filter.getTkratesMin() + "")); if (filter.getTkratesMax() != null) params.add(new ParamsKeyValue("tkrates_max", filter.getTkratesMax() + "")); if (filter.getTkmoneyMin() != null) params.add(new ParamsKeyValue("tkmoney_min", filter.getTkmoneyMin() + "")); if (filter.getItemType() != null) params.add(new ParamsKeyValue("item_type", filter.getItemType() + "")); String result = baseGetRequest("sales_list", params); String result = baseGetRequest("itemlist", params); JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } return null; } JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } return null; } /** * 增量更新的商品 * @Title: listAddGoods * @Description: * @param minId * @param startHour * @param endHour * @param pageSize * @return * HDKGoodsListResultDTO 返回类型 * @throws */ public HDKGoodsListResultDTO listAddGoods(Integer minId, int startHour, int endHour, int pageSize) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("back", pageSize + "")); params.add(new ParamsKeyValue("min_id", minId + "")); params.add(new ParamsKeyValue("start", startHour + "")); params.add(new ParamsKeyValue("end", endHour + "")); /** * 商品爆单列表 * * @param minId * @param catIds * @param pageSize * @return HDKGoodsListResultDTO 返回类型 * @throws * @Title: listGoods * @Description: */ public HDKGoodsListResultDTO listHotGoods(Integer minId, int pageSize, int saleType, List<Integer> catIds) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("sale_type", saleType + "")); params.add(new ParamsKeyValue("back", pageSize + "")); params.add(new ParamsKeyValue("min_id", minId + "")); params.add(new ParamsKeyValue("item_type", 1 + "")); // 是否只获取营销返利商品,1是,0否 if (catIds != null && catIds.size() > 0) { params.add(new ParamsKeyValue("cid", StringUtil.concat(catIds, ","))); } String result = baseGetRequest("timing_items", params); JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } String result = baseGetRequest("sales_list", params); return null; } JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } /** * 更新商品信息 * @Title: listUpdateGoods * @Description: * @param minId * @param pageSize * void 返回类型 * @throws */ public HDKGoodsListResultDTO listUpdateGoods(Integer minId, int pageSize) { List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("back", pageSize + "")); params.add(new ParamsKeyValue("min_id", minId + "")); String result = baseGetRequest("update_item", params); JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } return null; } return null; } /** * 拉取失效商品 * @Title: listInvalidGoods * @Description: * @param startHour * @param endHour * @return * List<Long> 返回类型 * @throws */ public List<Long> listInvalidGoods(int startHour, int endHour) { List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("start", startHour + "")); params.add(new ParamsKeyValue("end", endHour + "")); String result = baseGetRequest("get_down_items", params); JSONObject resultData = JSONObject.fromObject(result); List<Long> goodsIdList = new ArrayList<>(); if (resultData.optInt("code") == 1) { JSONArray array = resultData.optJSONArray("data"); for (int i = 0; i < array.size(); i++) { goodsIdList.add(array.optJSONObject(i).optLong("itemid")); } } return goodsIdList; } /** * 增量更新的商品 * * @param minId * @param startHour * @param endHour * @param pageSize * @return HDKGoodsListResultDTO 返回类型 * @throws * @Title: listAddGoods * @Description: */ public HDKGoodsListResultDTO listAddGoods(Integer minId, int startHour, int endHour, int pageSize) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("back", pageSize + "")); params.add(new ParamsKeyValue("min_id", minId + "")); params.add(new ParamsKeyValue("start", startHour + "")); params.add(new ParamsKeyValue("end", endHour + "")); class ParamsKeyValue { String key; String value; String result = baseGetRequest("timing_items", params); JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } public ParamsKeyValue(String key, String value) { super(); this.key = key; this.value = value; } } return null; } public HDKGoodsListResultDTO listSelected(Integer minId) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("min_id", minId + "")); String result = baseGetRequest("selected_item", params); /** * 更新商品信息 * * @param minId * @param pageSize void 返回类型 * @throws * @Title: listUpdateGoods * @Description: */ public HDKGoodsListResultDTO listUpdateGoods(Integer minId, int pageSize) { List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("back", pageSize + "")); params.add(new ParamsKeyValue("min_id", minId + "")); String result = baseGetRequest("update_item", params); JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } return null; } JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { JSONArray array = resultData.optJSONArray("data"); if (array != null) { List<HDKWXCircleContentDTO> list = new ArrayList<>(); for (int i = 0; i <array.size(); i ++) { JSONObject item = array.optJSONObject(i); HDKWXCircleContentDTO dto = new HDKWXCircleContentDTO(); dto.setTitle(item.optString("title")); dto.setItemid(item.optString("itemid")); dto.setItemtitle(item.optString("itemtitle")); dto.setContent(item.optString("content")); dto.setCopy_content(item.optString("copy_content")); dto.setShow_content(item.optString("show_content")); JSONArray imgArray = item.optJSONArray("itempic"); if (imgArray != null) { List<String> imgList = new ArrayList<>(); for (int n = 0; n < imgArray.size(); n++) { imgList.add(imgArray.optString(n)); } dto.setItempic(imgList); } list.add(dto); } HDKGoodsListResultDTO dto = new HDKGoodsListResultDTO(); dto.setList(list); dto.setMinId(minId); return dto; } } return null; } /** * 单品详情API * @param itemid * @return */ public HDKGoodsDetail getItemDetail(String itemid) { List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("itemid", itemid)); String result = baseGetRequest("item_detail", params); /** * 拉取失效商品 * * @param startHour * @param endHour * @return List<Long> 返回类型 * @throws * @Title: listInvalidGoods * @Description: */ public List<Long> listInvalidGoods(int startHour, int endHour) { List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("start", startHour + "")); params.add(new ParamsKeyValue("end", endHour + "")); String result = baseGetRequest("get_down_items", params); JSONObject resultData = JSONObject.fromObject(result); List<Long> goodsIdList = new ArrayList<>(); if (resultData.optInt("code") == 1) { JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Type type = new TypeToken<HDKGoodsDetail>() {}.getType(); HDKGoodsDetail goodsDetail = new Gson().fromJson(resultData.optJSONObject("data").toString(), type); return goodsDetail; } return null; } /** * 精选低价包邮专区API * @param minId * @param pageSize * @return */ public HDKGoodsListResultDTO getLowPricePinkageData(Integer minId, int pageSize, Integer typeNum) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("min_id", minId +"")); params.add(new ParamsKeyValue("back", pageSize + "")); params.add(new ParamsKeyValue("type", typeNum + "")); String result = baseGetRequest("low_price_Pinkage_data", params); JSONArray array = resultData.optJSONArray("data"); for (int i = 0; i < array.size(); i++) { goodsIdList.add(array.optJSONObject(i).optLong("itemid")); } } return goodsIdList; } JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } return null; } /** * 高佣专场商品API * @param minId * @param pageSize * @return */ public HDKGoodsListResultDTO getHighitems(Integer minId, int pageSize, Integer catId) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("min_id", minId +"")); params.add(new ParamsKeyValue("back", pageSize + "")); if (catId != null) params.add(new ParamsKeyValue("cat_id", catId +"")); String result = baseGetRequest("get_highitems", params); class ParamsKeyValue { String key; String value; JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 200) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } return null; } public ParamsKeyValue(String key, String value) { super(); this.key = key; this.value = value; } } public HDKGoodsListResultDTO listSelected(Integer minId) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("min_id", minId + "")); String result = baseGetRequest("selected_item", params); JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { JSONArray array = resultData.optJSONArray("data"); if (array != null) { List<HDKWXCircleContentDTO> list = new ArrayList<>(); for (int i = 0; i < array.size(); i++) { JSONObject item = array.optJSONObject(i); HDKWXCircleContentDTO dto = new HDKWXCircleContentDTO(); dto.setTitle(item.optString("title")); dto.setItemid(item.optString("itemid")); dto.setItemtitle(item.optString("itemtitle")); dto.setContent(item.optString("content")); dto.setCopy_content(item.optString("copy_content")); dto.setShow_content(item.optString("show_content")); JSONArray imgArray = item.optJSONArray("itempic"); if (imgArray != null) { List<String> imgList = new ArrayList<>(); for (int n = 0; n < imgArray.size(); n++) { imgList.add(imgArray.optString(n)); } dto.setItempic(imgList); } list.add(dto); } HDKGoodsListResultDTO dto = new HDKGoodsListResultDTO(); dto.setList(list); dto.setMinId(minId); return dto; } } return null; } /** * 单品详情API * * @param itemid * @return */ public HDKGoodsDetail getItemDetail(String itemid) { List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("itemid", itemid)); String result = baseGetRequest("item_detail", params); JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Type type = new TypeToken<HDKGoodsDetail>() { }.getType(); HDKGoodsDetail goodsDetail = new Gson().fromJson(resultData.optJSONObject("data").toString(), type); return goodsDetail; } return null; } /** * 精选低价包邮专区API * * @param minId * @param pageSize * @return */ public HDKGoodsListResultDTO getLowPricePinkageData(Integer minId, int pageSize, Integer typeNum) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("min_id", minId + "")); params.add(new ParamsKeyValue("back", pageSize + "")); params.add(new ParamsKeyValue("type", typeNum + "")); String result = baseGetRequest("low_price_Pinkage_data", params); JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 1) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } return null; } /** * 高佣专场商品API * * @param minId * @param pageSize * @return */ public HDKGoodsListResultDTO getHighitems(Integer minId, int pageSize, Integer catId) { if (minId == null) minId = 1; List<ParamsKeyValue> params = new ArrayList<HaoDanKuApiUtil.ParamsKeyValue>(); params.add(new ParamsKeyValue("min_id", minId + "")); params.add(new ParamsKeyValue("back", pageSize + "")); if (catId != null) params.add(new ParamsKeyValue("cat_id", catId + "")); String result = baseGetRequest("get_highitems", params); JSONObject resultData = JSONObject.fromObject(result); if (resultData.optInt("code") == 200) { Integer newMinId = resultData.optInt("min_id"); Type type = new TypeToken<ArrayList<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultData.optJSONArray("data").toString(), type); return new HDKGoodsListResultDTO(list, newMinId); } return null; } /** * 获取拼多多实时热榜 * * @param cid * @param minId * @return */ public HaoDanKuListResult getPDDHotGoods(Integer cid, Integer minId) { List<ParamsKeyValue> params = new ArrayList<>(); params.add(new ParamsKeyValue("sort", 1 + "")); if (cid != null) params.add(new ParamsKeyValue("cid", cid + "")); else params.add(new ParamsKeyValue("cid", "0")); if (minId != null) params.add(new ParamsKeyValue("min_id", minId + "")); String result = baseGetRequest("pdd_hot_rank", params); System.out.println(result); JSONObject resultJSON = JSONObject.fromObject(result); if (resultJSON.optInt("code") == 200) { Type type = new TypeToken<List<HaoDanKuPDDGoodsInfo>>() { }.getType(); List<HaoDanKuPDDGoodsInfo> list = new GsonBuilder().serializeNulls().registerTypeAdapterFactory(new NullStringToEmptyAdapterFactory()).create().fromJson(resultJSON.optJSONArray("data").toString(), type); int min_id = resultJSON.optInt("min_id"); HaoDanKuListResult listResult = new HaoDanKuListResult(list, min_id); return listResult; } return null; } /** * 获取京东实时热榜 * * @param cid * @param minId * @return */ public HaoDanKuListResult getJDHotGoods(Integer cid, Integer minId) { List<ParamsKeyValue> params = new ArrayList<>(); params.add(new ParamsKeyValue("sort", 1 + "")); if (cid != null) params.add(new ParamsKeyValue("cid", cid + "")); else params.add(new ParamsKeyValue("cid", "0")); if (minId != null) params.add(new ParamsKeyValue("min_id", minId + "")); String result = baseGetRequest("jd_hot_rank", params); System.out.println(result); JSONObject resultJSON = JSONObject.fromObject(result); if (resultJSON.optInt("code") == 200) { Type type = new TypeToken<List<HaoDanKuJDGoodsInfo>>() { }.getType(); List<HaoDanKuJDGoodsInfo> list = new Gson().fromJson(resultJSON.optJSONArray("data").toString(), type); int min_id = resultJSON.optInt("min_id"); HaoDanKuListResult listResult = new HaoDanKuListResult(list, min_id); return listResult; } return null; } /** * 获取淘宝实时热榜( https://www.haodanku.com/openapi/api_detail?id=19) * * @param cid * @param minId * @return */ public HaoDanKuListResult getTBHotGoods(Integer cid, Integer minId) { List<ParamsKeyValue> params = new ArrayList<>(); params.add(new ParamsKeyValue("sale_type", 1 + "")); if (cid != null) params.add(new ParamsKeyValue("cid", cid + "")); else params.add(new ParamsKeyValue("cid", "0")); params.add(new ParamsKeyValue("back", "20")); if (minId != null) params.add(new ParamsKeyValue("min_id", minId + "")); String result = baseGetRequest("sales_list", params); System.out.println(result); JSONObject resultJSON = JSONObject.fromObject(result); if (resultJSON.optInt("code") == 1) { Type type = new TypeToken<List<HDKGoodsDetail>>() { }.getType(); List<HDKGoodsDetail> list = new Gson().fromJson(resultJSON.optJSONArray("data").toString(), type); int min_id = resultJSON.optInt("min_id"); HaoDanKuListResult listResult = new HaoDanKuListResult(list, min_id); return listResult; } return null; } public class NullStringToEmptyAdapterFactory<T> implements TypeAdapterFactory { @SuppressWarnings("unchecked") public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) { Class<T> rawType = (Class<T>) type.getRawType(); if (rawType != String.class) { return null; } return (TypeAdapter<T>) new StringNullAdapter(); } } public class StringNullAdapter extends TypeAdapter<String> { @Override public String read(JsonReader reader) throws IOException { if (reader.peek() == JsonToken.NULL) { reader.nextNull(); return ""; } return reader.nextString(); } @Override public void write(JsonWriter writer, String value) throws IOException { if (value == null) { writer.nullValue(); return; } writer.value(value); } } public static void main(String[] args) { HaoDanKuListResult result = HaoDanKuApiUtil.getInstance().getTBHotGoods(null, null); System.out.println(result); } } facade-goods/src/main/java/com/yeshi/goods/facade/utils/taobao/HaoDankuUtil.java
New file @@ -0,0 +1,46 @@ package com.yeshi.goods.facade.utils.taobao; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.List; public class HaoDankuUtil { private final static String categorys = "[{\"id\":1,\"name\":\"女装\"},{\"id\":2,\"name\":\"男装\"},{\"id\":3,\"name\":\"内衣\"},{\"id\":4,\"name\":\"美妆\"},{\"id\":5,\"name\":\"配饰\"},{\"id\":6,\"name\":\"鞋品\"},{\"id\":7,\"name\":\"箱包\"},{\"id\":8,\"name\":\"儿童\"},{\"id\":9,\"name\":\"母婴\"},{\"id\":10,\"name\":\"居家\"},{\"id\":11,\"name\":\"美食\"},{\"id\":12,\"name\":\"数码\"},{\"id\":13,\"name\":\"家电\"},{\"id\":15,\"name\":\"车品\"},{\"id\":16,\"name\":\"文体\"},{\"id\":17,\"name\":\"宠物\"},{\"id\":14,\"name\":\"其他\"}]"; public static List<Category> CATEGORYS = null; static { Type type = new TypeToken<List<Category>>() { }.getType(); CATEGORYS = new Gson().fromJson(categorys, type); } public static class Category { private int id; private String name; public Category(int id, String name) { this.id = id; this.name = name; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } } fanli/pom.xml
@@ -18,6 +18,7 @@ <dubbo.version>2.7.5</dubbo.version> <curator.version>2.13.0</curator.version> <zookeeper.version>3.4.6</zookeeper.version> <kafka.client.version>0.10.1.1</kafka.client.version> </properties> <dependencies> <dependency> @@ -147,7 +148,6 @@ <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo</artifactId> @@ -212,13 +212,13 @@ <dependency> <groupId>com.ks</groupId> <artifactId>facade-vip</artifactId> <version>0.1.7</version> <version>0.2.1</version> </dependency> <dependency> <groupId>com.ks</groupId> <artifactId>facade-lijin</artifactId> <version>0.0.8</version> <version>0.1.1</version> </dependency> <dependency> @@ -240,6 +240,68 @@ </dependency> <!-- logback日志配置开始 --> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> <version>1.2.3</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-access</artifactId> <version>1.2.3</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>1.2.3</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>log4j-over-slf4j</artifactId> <version>1.7.7</version> </dependency> <!-- logback日志配置结束 --> <!-- kafka --> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka-clients</artifactId> <version>${kafka.client.version}</version> <scope>compile</scope> <exclusions> <exclusion> <artifactId>slf4j-api</artifactId> <groupId>org.slf4j</groupId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka_2.11</artifactId> <version>${kafka.client.version}</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <build> fanli/src/main/java/com/yeshi/fanli/controller/TestController.java
@@ -32,7 +32,6 @@ import com.yeshi.goods.facade.service.TaoBaoCouponCacheService; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.dubbo.config.annotation.Reference; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.select.Elements; fanli/src/main/java/com/yeshi/fanli/controller/client/lijin/GoodsControllerLijin.java
@@ -6,6 +6,7 @@ import com.ks.lijin.exception.LiJinGoodsException; import com.ks.lijin.exception.LiJinUserException; import com.ks.lijin.pojo.DO.LiJinExpendRecord; import com.ks.lijin.pojo.DTO.MoneyInfo; import com.ks.vip.pojo.Enums.VIPEnum; import com.yeshi.common.entity.taobao.TaoBaoShop; import com.yeshi.common.entity.taobao.TaoKeAppInfo; @@ -30,6 +31,7 @@ import com.yeshi.fanli.lijin.manager.UserLijinSendManager; import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service; import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service; import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; import com.yeshi.fanli.service.inter.pdd.PDDAuthService; import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; @@ -38,6 +40,7 @@ import com.yeshi.fanli.service.manger.PIDManager; import com.yeshi.fanli.util.*; import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil; import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; import com.yeshi.fanli.util.factory.goods.GoodsDetailVOLijinFactory; import com.yeshi.fanli.util.factory.goods.ShopInfoVOFactory; import com.yeshi.fanli.util.jd.JDApiUtil; @@ -103,6 +106,9 @@ @Resource private UserInfoService userInfoService; @Resource private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; /** * 获取商品详情 @@ -117,7 +123,9 @@ public void getGoodsDetail(AcceptData acceptData, int goodsType, String goodsId, Long uid, String from, PrintWriter out) { GoodsDetailVO goodsDetailVO = new GoodsDetailVO(); GoodsDetailVO.GoodsExtraVO extraVO = new GoodsDetailVO.GoodsExtraVO(); GoodsMoneyConfigParamsDTO paramsDTO = new GoodsMoneyConfigParamsDTO(); GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion(), acceptData.getSystem()); paramsDTO.setFanLiRate(goodsLijinMnager.getFanLiRate(uid)); // 领券人列表 List<ShamUser> listCouponUser = new ArrayList<>(); @@ -139,12 +147,15 @@ TaoBaoGoodsBrief goods = getTaoBaoGoods(Long.parseLong(goodsId)); //加载资金信息 com.yeshi.fanli.vo.goods.GoodsDetailVO goodsDetailVO1 = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); goodsDetailVO1 = goodsLijinMnager.loadTBMoneyInfo(acceptData.getSystem(), uid, goods, goodsDetailVO1); goodsDetailVO.setGoods(GoodsDetailVOLijinFactory.convertTaoBao(goods, paramsDTO)); BigDecimal lijinAmount = goodsLijinMnager.getTBLijin(uid, goods); if (lijinAmount != null && lijinAmount.compareTo(new BigDecimal(0)) > 0) { goodsDetailVO.getGoods().getMoneyInfo().setHongBaoMoney("¥" + lijinAmount); } //重置资金信息 goodsDetailVO.getGoods().setMoneyInfo(goodsDetailVO1.getMoneyInfo()); GoodsDetailVOLijinFactory.fillRights(goodsDetailVO.getGoods()); // 店铺信息 @@ -317,6 +328,12 @@ data.put("link", link); data.put("native", true); data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem())); //获取今日的剩余次数 try { int leftCount = goodsLijinMnager.getTodayLeftCount(uid, new Date(user.getCreatetime())); data.put("todayLeftCount", "立减机会:-1次 今日剩余:" + leftCount + "次"); } catch (Exception e) { } out.print(JsonUtil.loadTrueResult(data)); } catch (LiJinException e) { out.print(JsonUtil.loadFalseResult(e.getMsg())); fanli/src/main/java/com/yeshi/fanli/controller/client/lijin/LijinHongBaoController.java
@@ -1,37 +1,23 @@ package com.yeshi.fanli.controller.client.lijin; import com.google.gson.*; import com.ks.vip.exception.OrderPayException; import com.ks.vip.exception.VipOrderException; import com.ks.vip.pojo.DO.*; import com.ks.vip.pojo.DTO.PayWayInfoDTO; import com.ks.vip.pojo.Enums.OrderTypeEnum; import com.ks.vip.pojo.Enums.PayWayEnum; import com.ks.vip.pojo.Enums.VIPEnum; import com.ks.vip.service.LijinRecordService; import com.ks.vip.exception.LijinBalanceException; import com.ks.vip.pojo.DO.UserLijinRecord; import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.system.ConfigKeyEnum; import com.yeshi.fanli.lijin.dto.LijinSendInfo; import com.yeshi.fanli.lijin.dto.TodayLijinCreatedInfo; import com.yeshi.fanli.lijin.manager.UserLijinMnager; import com.yeshi.fanli.lijin.manager.UserLijinSendManager; import com.yeshi.fanli.lijin.vo.LijinRecordVO; import com.yeshi.fanli.lijin.vo.VIPGradeVO; import com.yeshi.fanli.lijin.vo.VipRecordVO; import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.util.Constant; import net.sf.json.JSONObject; import org.apache.dubbo.config.annotation.Reference; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.yeshi.utils.*; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import org.yeshi.utils.JsonUtil; import org.yeshi.utils.TimeUtil; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.PrintWriter; import java.lang.reflect.Type; import java.math.BigDecimal; @@ -40,7 +26,7 @@ import java.util.List; @Controller @RequestMapping("api/lijin/hongbao") @RequestMapping("api/v2/lijin/hongbao") public class LijinHongBaoController { @Resource @@ -67,10 +53,16 @@ userLijinSendManager.sendLijin(acceptData.getSystem(), acceptData.getDevice(), uid, new BigDecimal(10)); lijinSendInfo = userLijinSendManager.getSendingLijinInfo(acceptData.getSystem(), acceptData.getDevice(), uid); } if (lijinSendInfo == null) { out.print(JsonUtil.loadFalseResult("无红包")); return; } //填充notify的值 lijinSendInfo.setNotifyTitle("领取" + lijinSendInfo.getName()); lijinSendInfo.setNotifySubtitle("限时福利,最低66.66元起"); Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { @@ -100,10 +92,14 @@ using = new BigDecimal(0); String recordLink = configService.getValue(ConfigKeyEnum.lijinRecordLink, acceptData.getSystem()); String ruleLink = configService.getValue(ConfigKeyEnum.lijinRuleLink, acceptData.getSystem()); String courseLink = configService.getValue(ConfigKeyEnum.lijinCourseLink, acceptData.getSystem()); JSONObject data = new JSONObject(); data.put("balance", balance); data.put("using", using); data.put("recordLink", recordLink); data.put("ruleLink", ruleLink); data.put("courseLink", courseLink); out.print(JsonUtil.loadTrueResult(data)); } @@ -146,11 +142,19 @@ @RequestMapping("recieveHongBao") public void recieveHongBao(AcceptData acceptData, Long uid, String id, PrintWriter out) { try { userLijinSendManager.initBalance(uid); LijinSendInfo lijinSendInfo = userLijinSendManager.recieveLijin(id, uid); JSONObject data = new JSONObject(); data.put("url", configService.getValue(ConfigKeyEnum.lijinRecievedSuccessLink, acceptData.getSystem()).replace("{name}", lijinSendInfo.getName()).replace("{money}", lijinSendInfo.getMoney() + "")); out.print(JsonUtil.loadTrueResult(data)); return; } catch (LijinBalanceException e) { if (e.getCode() == LijinBalanceException.CODE_NOT_INIT) { out.print(JsonUtil.loadFalseResult("领取失败,请稍后重试")); userLijinMnager.initBalance(uid); } else { out.print(JsonUtil.loadFalseResult(e.getMessage())); } } catch (Exception e) { out.print(JsonUtil.loadFalseResult(e.getMessage())); } fanli/src/main/java/com/yeshi/fanli/controller/client/v1/CommonContentController.java
@@ -7,6 +7,7 @@ import javax.annotation.Resource; import com.yeshi.fanli.entity.goods.CommonGoods; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -106,26 +107,19 @@ BigDecimal pro = hongBaoManageService.getFanLiRate(acceptData.getSystem()); if (CommonContentTypeEnum.valueOf(key) == CommonContentTypeEnum.mianDan)// 免单商品 pro = new BigDecimal(100); List<TaoBaoGoodsBrief> goodsList = result.getGoodsList(); for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsList) { TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, pro.toString(), ""); if (CommonContentTypeEnum.valueOf(key) == CommonContentTypeEnum.mianDan)// 免单商品 { extra.getTaoBaoHongBaoInfo().setRate("¥" + TaoBaoUtil.getCouponPrice(taoBaoGoodsBrief)); extra.getTaoBaoHongBaoInfo().setHongbao(TaoBaoUtil.getCouponPrice(taoBaoGoodsBrief)); } array.add(gson.toJson(extra)); List<CommonGoods> goodsList = result.getGoodsList(); for (CommonGoods taoBaoGoodsBrief : goodsList) { // TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, pro.toString(), ""); // if (CommonContentTypeEnum.valueOf(key) == CommonContentTypeEnum.mianDan)// 免单商品 // { // extra.getTaoBaoHongBaoInfo().setRate("¥" + TaoBaoUtil.getCouponPrice(taoBaoGoodsBrief)); // extra.getTaoBaoHongBaoInfo().setHongbao(TaoBaoUtil.getCouponPrice(taoBaoGoodsBrief)); // } array.add(gson.toJson(taoBaoGoodsBrief)); } root.put("goodsList", array); root.put("goodsCount", result.getCount()); out.print(JsonUtil.loadTrueResult(root)); // 更新前5页数据 if (page <= 5) try { taoBaoGoodsUpdateService.addUpdateQueueAsync(goodsList); } catch (Exception e) { } } } fanli/src/main/java/com/yeshi/fanli/controller/client/v1/SearchController.java
@@ -11,6 +11,7 @@ import javax.annotation.Resource; import com.yeshi.fanli.entity.SystemEnum; import com.yeshi.fanli.entity.bus.search.HistorySearch; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -63,951 +64,961 @@ @RequestMapping("api/v1/search") public class SearchController { @Resource private BusinessSystemService businessSystemService; @Resource private BusinessSystemService businessSystemService; @Resource private ConfigService configService; @Resource private ConfigService configService; @Resource private HotSearchService hotSearchService; @Resource private HistorySearchService historySearchService; @Resource private HotSearchService hotSearchService; @Resource private HongBaoManageService manageService; @Resource private HistorySearchService historySearchService; @Resource private TaoBaoUnionConfigService taoBaoUnionConfigService; @Resource private HongBaoManageService manageService; @Resource private QualityGoodsService qualityGoodsService; @Resource private TaoBaoUnionConfigService taoBaoUnionConfigService; @Resource private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; @Resource private QualityGoodsService qualityGoodsService; @Resource private TaoBaoShopService taoBaoShopService; @Resource private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; @Resource private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; @Resource private TaoBaoShopService taoBaoShopService; /** * 热门搜索 * @param acceptData * @param goodsType * @param out */ @RequestMapping(value = "gethotsearch", method = RequestMethod.POST) public void getHotSearch(AcceptData acceptData, Integer goodsType, PrintWriter out) { // 默认淘宝 if (goodsType == null) { goodsType = Constant.SOURCE_TYPE_TAOBAO; } List<HotSearch> list = hotSearchService.getHotSearchCache(goodsType,acceptData.getSystem()); if (list == null || list.size() == 0) { out.print(JsonUtil.loadFalseResult("没有数据")); return; } JSONObject data = new JSONObject(); data.put("count", list.size()); data.put("hotSearchList", list); out.print(JsonUtil.loadTrueResult(data)); } @Resource private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; @RequestMapping("specialSearch") public void specialSearch(AcceptData acceptData, long hid, int page, PrintWriter out) { Honest honest = null; if (honest == null) { out.print(JsonUtil.loadFalseResult("")); return; } String key = hid + "#" + page; Element element = EhcacheUtil.getCache("temai").get(key); if (element != null) { String value = (String) element.getObjectValue(); if (value != null) { out.print(value); return; } } List<TaoBaoUnionConfig> config = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID); /** * 热门搜索 * * @param acceptData * @param goodsType * @param out */ @RequestMapping(value = "gethotsearch", method = RequestMethod.POST) public void getHotSearch(AcceptData acceptData, Integer goodsType, PrintWriter out) { // 默认淘宝 if (goodsType == null) { goodsType = Constant.SOURCE_TYPE_TAOBAO; } SearchFilter searchFilter = SearchFilterUtil.getSearchFilter(honest, page); TaoBaoSearchResult result = TaoBaoUtil.search3(searchFilter, config.get(0)); List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav(); if (result.getNavList() != null) navList.addAll(result.getNavList()); Gson gson = new GsonBuilder().create(); JSONObject data = new JSONObject(); data.put("nav", gson.toJson(navList)); List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>(); List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs(); BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); for (TaoBaoGoodsBrief bf : taoBaoGoodsBriefs) { re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } Gson gson2 = JsonUtil.getApiCommonGson(); data.put("result", gson2.toJson(re)); int count = 0; if (result.getTaoBaoHead() != null) { count = result.getTaoBaoHead().getDocsfound(); } data.put("count", count); List<HotSearch> list = hotSearchService.getHotSearchCache(goodsType, acceptData.getSystem()); if (list == null || list.size() == 0) { out.print(JsonUtil.loadFalseResult("没有数据")); return; } String loadTrueResult = JsonUtil.loadTrueResult(data); if (count != 0) { EhcacheUtil.getCache("temai").put(new Element(key, loadTrueResult)); } out.print(loadTrueResult); } JSONObject data = new JSONObject(); data.put("count", list.size()); data.put("hotSearchList", list); out.print(JsonUtil.loadTrueResult(data)); } @RequestMapping(value = "search") public void search(AcceptData acceptData, String kw, int page, String filter, String order, String startprice, String endprice, String fastFilter, PrintWriter out) { String bid = getHistorySearchBid(acceptData); historySearchService.addHistorySearch(kw, bid); BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages(),acceptData.getSystem()); if (system == null) { out.print(JsonUtil.loadFalseResult("系统不存在")); return; } @RequestMapping("specialSearch") public void specialSearch(AcceptData acceptData, long hid, int page, PrintWriter out) { Honest honest = null; if (honest == null) { out.print(JsonUtil.loadFalseResult("")); return; } String key = hid + "#" + page; Element element = EhcacheUtil.getCache("temai").get(key); if (element != null) { String value = (String) element.getObjectValue(); if (value != null) { out.print(value); return; } } if (!StringUtil.isNullOrEmpty(kw) && (kw.startsWith("http://") || kw.startsWith("https://"))) { out.print(JsonUtil.loadFalseResult("无法搜索链接")); return; } List<TaoBaoUnionConfig> config = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID); if (!StringUtil.isNullOrEmpty(fastFilter)) { if (!StringUtil.isNullOrEmpty(filter)) { JSONArray filterArray = JSONArray.fromObject(filter); JSONArray fastFilterArray = JSONArray.fromObject(fastFilter); filterArray.addAll(fastFilterArray); filter = filterArray.toString(); } else { filter = fastFilter; } } JSONObject data = search(acceptData, kw, page, filter, order, startprice, endprice); out.print(JsonUtil.loadTrueResult(data)); } SearchFilter searchFilter = SearchFilterUtil.getSearchFilter(honest, page); TaoBaoSearchResult result = TaoBaoUtil.search3(searchFilter, config.get(0)); List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav(); if (result.getNavList() != null) navList.addAll(result.getNavList()); Gson gson = new GsonBuilder().create(); JSONObject data = new JSONObject(); data.put("nav", gson.toJson(navList)); List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>(); List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs(); BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); for (TaoBaoGoodsBrief bf : taoBaoGoodsBriefs) { re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } Gson gson2 = JsonUtil.getApiCommonGson(); data.put("result", gson2.toJson(re)); int count = 0; if (result.getTaoBaoHead() != null) { count = result.getTaoBaoHead().getDocsfound(); } data.put("count", count); @Cacheable(value = "goodsCache", key = "#md5") public JSONObject searchClass(AcceptData acceptData, String kw, int page, String filter, String order, String startprice, String endprice, String md5) { java.lang.System.out.println("searchClass"); JSONObject data = search(acceptData, kw, page, filter, order, startprice, endprice); return data; } String loadTrueResult = JsonUtil.loadTrueResult(data); if (count != 0) { EhcacheUtil.getCache("temai").put(new Element(key, loadTrueResult)); } out.print(loadTrueResult); } private JSONObject search(AcceptData acceptData, String kw, int page, String filter, String order, String startprice, String endprice) { page = page + 1; @RequestMapping(value = "search") public void search(AcceptData acceptData, String kw, Long uid, int page, String filter, String order, String startprice, String endprice, String fastFilter, PrintWriter out) { SearchFilter sf = new SearchFilter(); sf.setKey(SearchFilterUtil.filterSearchContent(kw)); sf.setPage(page); sf.setSort(0); ThreadUtil.run(new Runnable() { @Override public void run() { HistorySearch search = new HistorySearch(); search.setDevice(StringUtil.isNullOrEmpty(acceptData.getUtdid()) ? acceptData.getDevice() : acceptData.getUtdid()); search.setKey(kw); search.setSystem(acceptData.getSystem()); search.setUid(uid); historySearchService.addHistorySearch(search); } }); BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages(), acceptData.getSystem()); if (system == null) { out.print(JsonUtil.loadFalseResult("系统不存在")); return; } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(startprice)) { sf.setStartPrice(new BigDecimal(startprice)); } if (!StringUtil.isNullOrEmpty(kw) && (kw.startsWith("http://") || kw.startsWith("https://"))) { out.print(JsonUtil.loadFalseResult("无法搜索链接")); return; } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(endprice)) { sf.setEndPrice(new BigDecimal(endprice)); } if (!StringUtil.isNullOrEmpty(fastFilter)) { if (!StringUtil.isNullOrEmpty(filter)) { JSONArray filterArray = JSONArray.fromObject(filter); JSONArray fastFilterArray = JSONArray.fromObject(fastFilter); filterArray.addAll(fastFilterArray); filter = filterArray.toString(); } else { filter = fastFilter; } } JSONObject data = search(acceptData, kw, page, filter, order, startprice, endprice); out.print(JsonUtil.loadTrueResult(data)); } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) { if (Integer.parseInt(order) == 1) { sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 2) { sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 3) { sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH); } } else { // 默认销量从高到低排序 sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); } @Cacheable(value = "goodsCache", key = "#md5") public JSONObject searchClass(AcceptData acceptData, String kw, int page, String filter, String order, String startprice, String endprice, String md5) { java.lang.System.out.println("searchClass"); JSONObject data = search(acceptData, kw, page, filter, order, startprice, endprice); return data; } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(filter)) { // 查询淘宝天猫 JSONArray array = JSONArray.fromObject(filter); Set<String> params = new HashSet<String>(); for (int i = 0; i < array.size(); i++) { // [{"type":'shoptype',id:12}] String ty = array.optJSONObject(i).optString("type"); if ("shoptype".equalsIgnoreCase(ty)) { if (array.optJSONObject(i).optInt("id") == 21) { sf.setTmFlagship(false); // 不筛�? } else { sf.setTmFlagship(true); sf.setTmall(true); sf.setShopTag("b2c"); } } else if ("category".equalsIgnoreCase(ty)) { sf.setCateIds(array.optJSONObject(i).optString("id")); } else if ("userType".equalsIgnoreCase(ty)) { // if(array.optJSONObject(i).optInt("id") == 51) sf.setTmall(true); // else // sf.setTmall(false); } else if ("baoyou".equalsIgnoreCase(ty)) { // if(array.optJSONObject(i).optInt("id") == 61) sf.setBaoYou(true); // else // sf.setBaoYou(false); } else if ("quantype".equalsIgnoreCase(ty)) { // if (array.optJSONObject(i).optInt("id") == 31){ sf.setQuan(1); if (sf.isTmFlagship()) { sf.setShopTag(sf.getShopTag() + ",dpyhq"); } else { sf.setShopTag("dpyhq"); } // } // else // sf.setQuan(2); } else if ("hongbaotype".equalsIgnoreCase(ty)) { if (array.optJSONObject(i).optInt("id") == 41)// 有红�? sf.setHongbao(1); else// 无红�? sf.setHongbao(2); } else if ("property".equalsIgnoreCase(ty)) { String pid = (String) array.optJSONObject(i).opt("pid"); String id = (String) array.optJSONObject(i).opt("id"); boolean flag = false; String str = null; for (String string : params) { flag = string.contains(pid + ":"); if (flag) { str = string; break; } } if (flag) { params.add(str + "," + id); params.remove(str); } else { params.add(pid + ":" + id); } } else if ("fahuodi".equalsIgnoreCase(ty)) { int id = array.optJSONObject(i).optInt("id"); sf.setProvinceId(id); } else if ("materialId".equalsIgnoreCase(ty)) { int id = array.optJSONObject(i).optInt("id"); sf.setProvinceId(id); } } sf.setParams(params); } TaoBaoSearchResult result = TaoBaoUtil.search(sf,null,null); if (result == null) { return null; } private JSONObject search(AcceptData acceptData, String kw, int page, String filter, String order, String startprice, String endprice) { page = page + 1; List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav(); if (result.getNavList() != null) navList.addAll(result.getNavList()); Gson gson = new GsonBuilder().create(); JSONObject data = new JSONObject(); data.put("nav", gson.toJson(navList)); List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>(); List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs(); int fq = sf.getQuan(); int fh = sf.getHongbao(); boolean ft = sf.isTmall(); BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); if (fq == 0 && fh == 0 && !ft) { if (result != null && result.getTaoBaoGoodsBriefs() != null) for (TaoBaoGoodsBrief bf : result.getTaoBaoGoodsBriefs()) { int count = bf.getBiz30day(); if (count >= 10000) { // 对销量数据做处理 页面展示7.3万 double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); bf.setSalesCount(salesCountMidea + "万"); re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } else { bf.setSalesCount(count + ""); re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } } } else { TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra; if (taoBaoGoodsBriefs != null) for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) { int count = taoBaoGoodsBrief.getBiz30day(); if (count >= 10000) { double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万"); taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } else { taoBaoGoodsBrief.setSalesCount(count + ""); taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } } } Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().create(); data.put("result", gson2.toJson(re)); data.put("count", result.getTaoBaoHead().getDocsfound()); return data; } SearchFilter sf = new SearchFilter(); sf.setKey(SearchFilterUtil.filterSearchContent(kw)); sf.setPage(page); sf.setSort(0); @RequestMapping(value = "suggestsearch", method = RequestMethod.POST) public void getSugguestSearch(AcceptData acceptData, String kw, PrintWriter out) { List<String> list = TaoBaoUtil.getSuguestSearch(kw); if (list != null && list.size() > 0) { JSONArray array = new JSONArray(); for (String st : list) array.add(st); out.print(JsonUtil.loadTrueResult(array)); } else { out.print(JsonUtil.loadFalseResult("暂无建议内容")); } return; } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(startprice)) { sf.setStartPrice(new BigDecimal(startprice)); } private String getHistorySearchBid(AcceptData acceptData) { StringBuffer sb = new StringBuffer(); String link = "#$$$#"; String platform = acceptData.getPlatform(); String packages = acceptData.getPackages(); String device = acceptData.getDevice(); sb.append(platform).append(link).append(packages).append(link).append(device); return StringUtil.Md5(sb.toString()); } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(endprice)) { sf.setEndPrice(new BigDecimal(endprice)); } /** * 搜索-新版 * * @param acceptData * @param kw * @param page * @param filter * @param order * 销量由高到低:1 、 价格从高到低:2 、 价格从低到高:3 、 推广量高到低:4(综合默认)、返利比高到低:5 * 、返利比低到高:6 、推荐20 * @param startprice * @param endprice * @param fastFilter * @param out */ @RequestMapping(value = "searchgoods") public void searchgoods(AcceptData acceptData, String kw, int page, String filter, String order, String startprice, String endprice, Double startTkRate, Double endTkRate, String fastFilter, PrintWriter out) { if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) { if (Integer.parseInt(order) == 1) { sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 2) { sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 3) { sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH); } } else { // 默认销量从高到低排序 sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); } String bid = getHistorySearchBid(acceptData); if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(filter)) { // 查询淘宝天猫 JSONArray array = JSONArray.fromObject(filter); Set<String> params = new HashSet<String>(); for (int i = 0; i < array.size(); i++) { // [{"type":'shoptype',id:12}] String ty = array.optJSONObject(i).optString("type"); if ("shoptype".equalsIgnoreCase(ty)) { if (array.optJSONObject(i).optInt("id") == 21) { sf.setTmFlagship(false); // 不筛�? } else { sf.setTmFlagship(true); sf.setTmall(true); sf.setShopTag("b2c"); } } else if ("category".equalsIgnoreCase(ty)) { sf.setCateIds(array.optJSONObject(i).optString("id")); } else if ("userType".equalsIgnoreCase(ty)) { // if(array.optJSONObject(i).optInt("id") == 51) sf.setTmall(true); // else // sf.setTmall(false); } else if ("baoyou".equalsIgnoreCase(ty)) { // if(array.optJSONObject(i).optInt("id") == 61) sf.setBaoYou(true); // else // sf.setBaoYou(false); } else if ("quantype".equalsIgnoreCase(ty)) { // if (array.optJSONObject(i).optInt("id") == 31){ sf.setQuan(1); if (sf.isTmFlagship()) { sf.setShopTag(sf.getShopTag() + ",dpyhq"); } else { sf.setShopTag("dpyhq"); } // } // else // sf.setQuan(2); } else if ("hongbaotype".equalsIgnoreCase(ty)) { if (array.optJSONObject(i).optInt("id") == 41)// 有红�? sf.setHongbao(1); else// 无红�? sf.setHongbao(2); } else if ("property".equalsIgnoreCase(ty)) { String pid = (String) array.optJSONObject(i).opt("pid"); String id = (String) array.optJSONObject(i).opt("id"); boolean flag = false; String str = null; for (String string : params) { flag = string.contains(pid + ":"); if (flag) { str = string; break; } } if (flag) { params.add(str + "," + id); params.remove(str); } else { params.add(pid + ":" + id); } } else if ("fahuodi".equalsIgnoreCase(ty)) { int id = array.optJSONObject(i).optInt("id"); sf.setProvinceId(id); } else if ("materialId".equalsIgnoreCase(ty)) { int id = array.optJSONObject(i).optInt("id"); sf.setProvinceId(id); } } sf.setParams(params); } TaoBaoSearchResult result = TaoBaoUtil.search(sf, null, null); if (result == null) { return null; } historySearchService.addHistorySearch(kw, bid); List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav(); if (result.getNavList() != null) navList.addAll(result.getNavList()); Gson gson = new GsonBuilder().create(); JSONObject data = new JSONObject(); data.put("nav", gson.toJson(navList)); List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>(); List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs(); int fq = sf.getQuan(); int fh = sf.getHongbao(); boolean ft = sf.isTmall(); BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); if (fq == 0 && fh == 0 && !ft) { if (result != null && result.getTaoBaoGoodsBriefs() != null) for (TaoBaoGoodsBrief bf : result.getTaoBaoGoodsBriefs()) { int count = bf.getBiz30day(); if (count >= 10000) { // 对销量数据做处理 页面展示7.3万 double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); bf.setSalesCount(salesCountMidea + "万"); re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } else { bf.setSalesCount(count + ""); re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } } } else { TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra; if (taoBaoGoodsBriefs != null) for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) { int count = taoBaoGoodsBrief.getBiz30day(); if (count >= 10000) { double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万"); taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } else { taoBaoGoodsBrief.setSalesCount(count + ""); taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } } } Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().create(); data.put("result", gson2.toJson(re)); data.put("count", result.getTaoBaoHead().getDocsfound()); return data; } // BusinessSystem system = // businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), // acceptData.getPackages()); // if (system == null) { // out.print(JsonUtil.loadFalseResult("系统不存在")); // return; // } @RequestMapping(value = "suggestsearch", method = RequestMethod.POST) public void getSugguestSearch(AcceptData acceptData, String kw, PrintWriter out) { List<String> list = TaoBaoUtil.getSuguestSearch(kw); if (list != null && list.size() > 0) { JSONArray array = new JSONArray(); for (String st : list) array.add(st); out.print(JsonUtil.loadTrueResult(array)); } else { out.print(JsonUtil.loadFalseResult("暂无建议内容")); } return; } if (!StringUtil.isNullOrEmpty(kw) && (kw.startsWith("http://") || kw.startsWith("https://"))) { JSONObject data = new JSONObject(); data.put("result", new JSONArray()); data.put("count", 0); data.put("nav", new JSONArray()); out.print(JsonUtil.loadTrueResult(data)); return; } private String getHistorySearchBid(AcceptData acceptData) { StringBuffer sb = new StringBuffer(); String link = "#$$$#"; String platform = acceptData.getPlatform(); String packages = acceptData.getPackages(); String device = acceptData.getDevice(); sb.append(platform).append(link).append(packages).append(link).append(device); return StringUtil.Md5(sb.toString()); } if (!StringUtil.isNullOrEmpty(fastFilter)) { if (!StringUtil.isNullOrEmpty(filter)) { JSONArray filterArray = JSONArray.fromObject(filter); JSONArray fastFilterArray = JSONArray.fromObject(fastFilter); filterArray.addAll(fastFilterArray); filter = filterArray.toString(); } else { filter = fastFilter; } } /** * 搜索-新版 * * @param acceptData * @param kw * @param page * @param filter * @param order 销量由高到低:1 、 价格从高到低:2 、 价格从低到高:3 、 推广量高到低:4(综合默认)、返利比高到低:5 * 、返利比低到高:6 、推荐20 * @param startprice * @param endprice * @param fastFilter * @param out */ @RequestMapping(value = "searchgoods") public void searchgoods(AcceptData acceptData, String kw, Long uid, int page, String filter, String order, String startprice, String endprice, Double startTkRate, Double endTkRate, String fastFilter, PrintWriter out) { // 是否是推荐 boolean recommend = false; if (!StringUtil.isNullOrEmpty(fastFilter)) { // 查询淘宝天猫 JSONArray array = JSONArray.fromObject(filter); for (int i = 0; i < array.size(); i++) { String ty = array.optJSONObject(i).optString("type"); ThreadUtil.run(new Runnable() { @Override public void run() { HistorySearch search = new HistorySearch(); search.setDevice(StringUtil.isNullOrEmpty(acceptData.getUtdid()) ? acceptData.getDevice() : acceptData.getUtdid()); search.setKey(kw); search.setSystem(acceptData.getSystem()); search.setUid(uid); historySearchService.addHistorySearch(search); } }); if ("recommend".equalsIgnoreCase(ty)) { recommend = true; } } } if (!StringUtil.isNullOrEmpty(kw) && (kw.startsWith("http://") || kw.startsWith("https://"))) { JSONObject data = new JSONObject(); data.put("result", new JSONArray()); data.put("count", 0); data.put("nav", new JSONArray()); out.print(JsonUtil.loadTrueResult(data)); return; } JSONObject data = null; if (!recommend) { // 淘宝接口请求 data = searchGoods(acceptData, kw, page, filter, order, startprice, endprice,acceptData.getSystem()); } else { // 推荐:精选库 // data = searchQualityGoods(kw, page, filter, order, startprice, // endprice); data = searchDaTaoKeGoods(acceptData, kw, page, filter, order, startprice, endprice); } if (!StringUtil.isNullOrEmpty(fastFilter)) { if (!StringUtil.isNullOrEmpty(filter)) { JSONArray filterArray = JSONArray.fromObject(filter); JSONArray fastFilterArray = JSONArray.fromObject(fastFilter); filterArray.addAll(fastFilterArray); filter = filterArray.toString(); } else { filter = fastFilter; } } // 获取推荐词 List<String> listRecommendWords = new ArrayList<String>(); // 综合 查询第一页时获取候选词 if (page == 0) { listRecommendWords = TaoBaoUtil.getSuguestSearch(kw); if (listRecommendWords == null || listRecommendWords.size() == 0) { listRecommendWords = new ArrayList<String>(); } // 是否是推荐 boolean recommend = false; if (!StringUtil.isNullOrEmpty(fastFilter)) { // 查询淘宝天猫 JSONArray array = JSONArray.fromObject(filter); for (int i = 0; i < array.size(); i++) { String ty = array.optJSONObject(i).optString("type"); List<TaoBaoShopVO> listShop =taoBaoShopService.getShopByKey(kw,acceptData.getSystem()); if (listShop != null && listShop.size() > 0 && listShop.get(0).getListGoods() != null && listShop.get(0).getListGoods().size() > 2) { data.put("shop", JsonUtil.getApiCommonGson().toJson(listShop.get(0))); } } if ("recommend".equalsIgnoreCase(ty)) { recommend = true; } } } Gson gson = new GsonBuilder().create(); if (data != null) data.put("words", gson.toJson(listRecommendWords)); JSONObject data = null; if (!recommend) { // 淘宝接口请求 data = searchGoods(acceptData, kw, page, filter, order, startprice, endprice, acceptData.getSystem()); } else { // 推荐:精选库 // data = searchQualityGoods(kw, page, filter, order, startprice, // endprice); data = searchDaTaoKeGoods(acceptData, kw, page, filter, order, startprice, endprice); } out.print(JsonUtil.loadTrueResult(data)); } // 获取推荐词 List<String> listRecommendWords = new ArrayList<String>(); // 综合 查询第一页时获取候选词 if (page == 0) { listRecommendWords = TaoBaoUtil.getSuguestSearch(kw); if (listRecommendWords == null || listRecommendWords.size() == 0) { listRecommendWords = new ArrayList<String>(); } /** * 执行搜索-新版 * * @param kw * @param page * @param filter * @param order * @param startprice * @param endprice * @return */ private JSONObject searchGoods(AcceptData acceptData, String kw, int page, String filter, String order, String startprice, String endprice,SystemEnum system) { page = page + 1; List<TaoBaoShopVO> listShop = taoBaoShopService.getShopByKey(kw, acceptData.getSystem()); if (listShop != null && listShop.size() > 0 && listShop.get(0).getListGoods() != null && listShop.get(0).getListGoods().size() > 2) { data.put("shop", JsonUtil.getApiCommonGson().toJson(listShop.get(0))); } } SearchFilter sf = new SearchFilter(); sf.setKey(SearchFilterUtil.filterSearchContent(kw)); sf.setPage(page); sf.setSort(0); Gson gson = new GsonBuilder().create(); if (data != null) data.put("words", gson.toJson(listRecommendWords)); if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(startprice)) { sf.setStartPrice(new BigDecimal(startprice)); } out.print(JsonUtil.loadTrueResult(data)); } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(endprice)) { sf.setEndPrice(new BigDecimal(endprice)); } /** * 执行搜索-新版 * * @param kw * @param page * @param filter * @param order * @param startprice * @param endprice * @return */ private JSONObject searchGoods(AcceptData acceptData, String kw, int page, String filter, String order, String startprice, String endprice, SystemEnum system) { page = page + 1; if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) { if (Integer.parseInt(order) == 1) { sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 2) { sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 3) { sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH); } else if (Integer.parseInt(order) == 4) { sf.setSort(TaoBaoUtil.SORT_TOTAL_SALES_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 5) { sf.setSort(TaoBaoUtil.SORT_TKRATE_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 6) { sf.setSort(TaoBaoUtil.SORT_TKRATE_LOW_TO_HIGH); } } else { // 默认销量从高到低排序 sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); } SearchFilter sf = new SearchFilter(); sf.setKey(SearchFilterUtil.filterSearchContent(kw)); sf.setPage(page); sf.setSort(0); if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(startprice)) { sf.setStartPrice(new BigDecimal(startprice)); } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(endprice)) { sf.setEndPrice(new BigDecimal(endprice)); } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) { if (Integer.parseInt(order) == 1) { sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 2) { sf.setSort(TaoBaoUtil.SORT_PRICE_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 3) { sf.setSort(TaoBaoUtil.SORT_PRICE_LOW_TO_HIGH); } else if (Integer.parseInt(order) == 4) { sf.setSort(TaoBaoUtil.SORT_TOTAL_SALES_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 5) { sf.setSort(TaoBaoUtil.SORT_TKRATE_HIGH_TO_LOW); } else if (Integer.parseInt(order) == 6) { sf.setSort(TaoBaoUtil.SORT_TKRATE_LOW_TO_HIGH); } } else { // 默认销量从高到低排序 sf.setSort(TaoBaoUtil.SORT_SALE_HIGH_TO_LOW); } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(filter)) { // 查询淘宝天猫 JSONArray array = JSONArray.fromObject(filter); Set<String> params = new HashSet<String>(); for (int i = 0; i < array.size(); i++) { // [{"type":'shoptype',id:12}] String ty = array.optJSONObject(i).optString("type"); if ("shoptype".equalsIgnoreCase(ty)) { if (array.optJSONObject(i).optInt("id") == 21) { sf.setTmFlagship(false); // 不筛�? } else { sf.setTmFlagship(true); sf.setTmall(true); sf.setShopTag("b2c"); } } else if ("category".equalsIgnoreCase(ty)) { sf.setCateIds(array.optJSONObject(i).optString("id")); } else if ("userType".equalsIgnoreCase(ty)) { // if(array.optJSONObject(i).optInt("id") == 51) sf.setTmall(true); // else // sf.setTmall(false); } else if ("baoyou".equalsIgnoreCase(ty)) { // if(array.optJSONObject(i).optInt("id") == 61) sf.setBaoYou(true); // else // sf.setBaoYou(false); } else if ("quantype".equalsIgnoreCase(ty)) { // if (array.optJSONObject(i).optInt("id") == 31){ sf.setQuan(1); if (sf.isTmFlagship()) { sf.setShopTag(sf.getShopTag() + ",dpyhq"); } else { sf.setShopTag("dpyhq"); } // } // else // sf.setQuan(2); } else if ("hongbaotype".equalsIgnoreCase(ty)) { if (array.optJSONObject(i).optInt("id") == 41)// 有红�? sf.setHongbao(1); else// 无红�? sf.setHongbao(2); } else if ("property".equalsIgnoreCase(ty)) { String pid = (String) array.optJSONObject(i).opt("pid"); String id = (String) array.optJSONObject(i).opt("id"); boolean flag = false; String str = null; for (String string : params) { flag = string.contains(pid + ":"); if (flag) { str = string; break; } } if (flag) { params.add(str + "," + id); params.remove(str); } else { params.add(pid + ":" + id); } } else if ("fahuodi".equalsIgnoreCase(ty)) { int id = array.optJSONObject(i).optInt("id"); sf.setProvinceId(id); } else if ("materialId".equalsIgnoreCase(ty)) { int id = array.optJSONObject(i).optInt("id"); sf.setProvinceId(id); } else if ("tkRate1".equalsIgnoreCase(ty)) { setSearchTkRate(0, sf,system); } else if ("tkRate2".equalsIgnoreCase(ty)) { setSearchTkRate(1, sf,system); } else if ("tkRate3".equalsIgnoreCase(ty)) { setSearchTkRate(2, sf,system); } else if ("tkRate4".equalsIgnoreCase(ty)) { setSearchTkRate(3, sf,system); } else if ("tkRate5".equalsIgnoreCase(ty)) { setSearchTkRate(4, sf,system); } } sf.setParams(params); } if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(filter)) { // 查询淘宝天猫 JSONArray array = JSONArray.fromObject(filter); Set<String> params = new HashSet<String>(); for (int i = 0; i < array.size(); i++) { // [{"type":'shoptype',id:12}] String ty = array.optJSONObject(i).optString("type"); if ("shoptype".equalsIgnoreCase(ty)) { if (array.optJSONObject(i).optInt("id") == 21) { sf.setTmFlagship(false); // 不筛�? } else { sf.setTmFlagship(true); sf.setTmall(true); sf.setShopTag("b2c"); } } else if ("category".equalsIgnoreCase(ty)) { sf.setCateIds(array.optJSONObject(i).optString("id")); } else if ("userType".equalsIgnoreCase(ty)) { // if(array.optJSONObject(i).optInt("id") == 51) sf.setTmall(true); // else // sf.setTmall(false); } else if ("baoyou".equalsIgnoreCase(ty)) { // if(array.optJSONObject(i).optInt("id") == 61) sf.setBaoYou(true); // else // sf.setBaoYou(false); } else if ("quantype".equalsIgnoreCase(ty)) { // if (array.optJSONObject(i).optInt("id") == 31){ sf.setQuan(1); if (sf.isTmFlagship()) { sf.setShopTag(sf.getShopTag() + ",dpyhq"); } else { sf.setShopTag("dpyhq"); } // } // else // sf.setQuan(2); } else if ("hongbaotype".equalsIgnoreCase(ty)) { if (array.optJSONObject(i).optInt("id") == 41)// 有红�? sf.setHongbao(1); else// 无红�? sf.setHongbao(2); } else if ("property".equalsIgnoreCase(ty)) { String pid = (String) array.optJSONObject(i).opt("pid"); String id = (String) array.optJSONObject(i).opt("id"); boolean flag = false; String str = null; for (String string : params) { flag = string.contains(pid + ":"); if (flag) { str = string; break; } } if (flag) { params.add(str + "," + id); params.remove(str); } else { params.add(pid + ":" + id); } } else if ("fahuodi".equalsIgnoreCase(ty)) { int id = array.optJSONObject(i).optInt("id"); sf.setProvinceId(id); } else if ("materialId".equalsIgnoreCase(ty)) { int id = array.optJSONObject(i).optInt("id"); sf.setProvinceId(id); } else if ("tkRate1".equalsIgnoreCase(ty)) { setSearchTkRate(0, sf, system); } else if ("tkRate2".equalsIgnoreCase(ty)) { setSearchTkRate(1, sf, system); } else if ("tkRate3".equalsIgnoreCase(ty)) { setSearchTkRate(2, sf, system); } else if ("tkRate4".equalsIgnoreCase(ty)) { setSearchTkRate(3, sf, system); } else if ("tkRate5".equalsIgnoreCase(ty)) { setSearchTkRate(4, sf, system); } } sf.setParams(params); } // 搜索大淘客 List<DaTaoKeDetailV2> daTaoKeList = null; if (page == 1) daTaoKeList = daTaoKeGoodsDetailV2Service.listByDtitle(kw); // 搜索大淘客 List<DaTaoKeDetailV2> daTaoKeList = null; if (page == 1) daTaoKeList = daTaoKeGoodsDetailV2Service.listByDtitle(kw); TaoBaoSearchResult result = TaoBaoUtil.search(sf,null,null); if (result == null) { return null; } // 搜索是否在营销主商品库 if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0) { // 暂时放弃更新到营销商品库 // String numIds = ""; // for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) { // numIds += goods.getAuctionId() + ","; // } // if (numIds.endsWith(",")) // numIds = numIds.substring(0, numIds.length() - 1); // try { // List<TaoBaoGoodsBrief> goodsList = // TaoKeApiUtil.getBatchGoodsInfos(numIds); // Map<Long, Integer> map = new HashMap<>(); // for (TaoBaoGoodsBrief g : goodsList) // map.put(g.getAuctionId(), g.getMaterialLibType()); // for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) // goods.setMaterialLibType(map.get(goods.getAuctionId())); TaoBaoSearchResult result = TaoBaoUtil.search(sf, null, null); if (result == null) { return null; } // 搜索是否在营销主商品库 if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0) { // 暂时放弃更新到营销商品库 // String numIds = ""; // for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) { // numIds += goods.getAuctionId() + ","; // } // if (numIds.endsWith(",")) // numIds = numIds.substring(0, numIds.length() - 1); // try { // List<TaoBaoGoodsBrief> goodsList = // TaoKeApiUtil.getBatchGoodsInfos(numIds); // Map<Long, Integer> map = new HashMap<>(); // for (TaoBaoGoodsBrief g : goodsList) // map.put(g.getAuctionId(), g.getMaterialLibType()); // for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) // goods.setMaterialLibType(map.get(goods.getAuctionId())); ThreadUtil.run(new Runnable() { @Override public void run() { // 更新到緩存 for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(goods); } }); // } catch (Exception e) { // e.printStackTrace(); // } ThreadUtil.run(new Runnable() { @Override public void run() { // 更新到緩存 for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(goods); } }); // } catch (Exception e) { // e.printStackTrace(); // } } } List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav(); if (result.getNavList() != null) navList.addAll(result.getNavList()); Gson gson = new GsonBuilder().create(); JSONObject data = new JSONObject(); data.put("nav", gson.toJson(navList)); List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>(); List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs(); if (taoBaoGoodsBriefs == null) taoBaoGoodsBriefs = new ArrayList<>(); List<TaoBaoSearchNav> navList = TaoBaoUtil.getBaseNav(); if (result.getNavList() != null) navList.addAll(result.getNavList()); Gson gson = new GsonBuilder().create(); JSONObject data = new JSONObject(); data.put("nav", gson.toJson(navList)); List<TaoBaoGoodsBriefExtra> re = new ArrayList<TaoBaoGoodsBriefExtra>(); List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs(); if (taoBaoGoodsBriefs == null) taoBaoGoodsBriefs = new ArrayList<>(); try { if (daTaoKeList != null && daTaoKeList.size() > 0) { Collections.reverse(daTaoKeList); for (DaTaoKeDetailV2 detail : daTaoKeList) { taoBaoGoodsBriefs.add(0, TaoBaoUtil.convert(detail)); } } } catch (Exception e) { } try { if (daTaoKeList != null && daTaoKeList.size() > 0) { Collections.reverse(daTaoKeList); for (DaTaoKeDetailV2 detail : daTaoKeList) { taoBaoGoodsBriefs.add(0, TaoBaoUtil.convert(detail)); } } } catch (Exception e) { } int fq = sf.getQuan(); int fh = sf.getHongbao(); boolean ft = sf.isTmall(); BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); if (fq == 0 && fh == 0 && !ft) { if (result != null && taoBaoGoodsBriefs != null) for (TaoBaoGoodsBrief bf : taoBaoGoodsBriefs) { int count = bf.getBiz30day(); if (count >= 10000) { // 对销量数据做处理 页面展示7.3万 double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); bf.setSalesCount(salesCountMidea + "万"); re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } else { bf.setSalesCount(count + ""); re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } } } else { TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra; if (taoBaoGoodsBriefs != null) for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) { int count = taoBaoGoodsBrief.getBiz30day(); if (count >= 10000) { double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万"); taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } else { taoBaoGoodsBrief.setSalesCount(count + ""); taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } } } Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().create(); data.put("result", gson2.toJson(re)); data.put("count", result.getTaoBaoHead().getDocsfound()); return data; } int fq = sf.getQuan(); int fh = sf.getHongbao(); boolean ft = sf.isTmall(); BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); if (fq == 0 && fh == 0 && !ft) { if (result != null && taoBaoGoodsBriefs != null) for (TaoBaoGoodsBrief bf : taoBaoGoodsBriefs) { int count = bf.getBiz30day(); if (count >= 10000) { // 对销量数据做处理 页面展示7.3万 double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); bf.setSalesCount(salesCountMidea + "万"); re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } else { bf.setSalesCount(count + ""); re.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(bf, proportion.toString(), "")); } } } else { TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra; if (taoBaoGoodsBriefs != null) for (TaoBaoGoodsBrief taoBaoGoodsBrief : taoBaoGoodsBriefs) { int count = taoBaoGoodsBrief.getBiz30day(); if (count >= 10000) { double sales = count; String salesCountMidea = String.format("%.1f", sales / 10000); taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万"); taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } else { taoBaoGoodsBrief.setSalesCount(count + ""); taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), ""); re.add(taoBaoGoodsBriefExtra); } } } Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().create(); data.put("result", gson2.toJson(re)); data.put("count", result.getTaoBaoHead().getDocsfound()); return data; } /** * 执行搜索精选库 * * @param key * @param page * @param filter * @param order * @param startprice * @param endprice * @return */ private JSONObject searchQualityGoods(AcceptData acceptData, String key, int page, String filter, String order, String startprice, String endprice, SystemEnum system) { /** * 执行搜索精选库 * * @param key * @param page * @param filter * @param order * @param startprice * @param endprice * @return */ private JSONObject searchQualityGoods(AcceptData acceptData, String key, int page, String filter, String order, String startprice, String endprice, SystemEnum system) { Integer hasQuan = null; Integer userType = null; Double start_Price = null; Double end_Price = null; Integer sort = null; Double startTkRate = null; Double endTkRate = null; Integer hasQuan = null; Integer userType = null; Double start_Price = null; Double end_Price = null; Integer sort = null; Double startTkRate = null; Double endTkRate = null; int provinceId = -100; int provinceId = -100; // 起始价格 if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(startprice)) { start_Price = Double.parseDouble(startprice); } // 结束价格 if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(endprice)) { end_Price = Double.parseDouble(endprice); } // 起始价格 if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(startprice)) { start_Price = Double.parseDouble(startprice); } // 结束价格 if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(endprice)) { end_Price = Double.parseDouble(endprice); } // 排序 if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) { // 排序 if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(order)) { if (Integer.parseInt(order) == 4) { sort = 20; // 综合时:采用默认权重排序 } else { sort = Integer.parseInt(order); } if (Integer.parseInt(order) == 4) { sort = 20; // 综合时:采用默认权重排序 } else { sort = Integer.parseInt(order); } } } /* 其他筛选条件 */ if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(filter)) { // 查询淘宝天猫 JSONArray array = JSONArray.fromObject(filter); for (int i = 0; i < array.size(); i++) { String ty = array.optJSONObject(i).optString("type"); /* 其他筛选条件 */ if (!com.yeshi.fanli.util.StringUtil.isNullOrEmpty(filter)) { // 查询淘宝天猫 JSONArray array = JSONArray.fromObject(filter); for (int i = 0; i < array.size(); i++) { String ty = array.optJSONObject(i).optString("type"); if ("userType".equalsIgnoreCase(ty)) { userType = 1; // 天猫 } else if ("quantype".equalsIgnoreCase(ty)) { hasQuan = 1; // 有券 } else if ("hongbaotype".equalsIgnoreCase(ty)) { if ("userType".equalsIgnoreCase(ty)) { userType = 1; // 天猫 } else if ("quantype".equalsIgnoreCase(ty)) { hasQuan = 1; // 有券 } else if ("hongbaotype".equalsIgnoreCase(ty)) { } else if ("fahuodi".equalsIgnoreCase(ty)) { provinceId = array.optJSONObject(i).optInt("id"); } else if ("tkRate1".equalsIgnoreCase(ty)) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system); if (!StringUtil.isNullOrEmpty(value)) { JSONArray tkRatearray = JSONArray.fromObject(value); if (tkRatearray != null) { String start = tkRatearray.optJSONObject(0).optString("start"); if (!StringUtil.isNullOrEmpty(start)) { startTkRate = Double.parseDouble(start); } String end = tkRatearray.optJSONObject(0).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { endTkRate = Double.parseDouble(end); } } } } else if ("tkRate2".equalsIgnoreCase(ty)) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system); if (!StringUtil.isNullOrEmpty(value)) { JSONArray tkRatearray = JSONArray.fromObject(value); if (tkRatearray != null) { String start = tkRatearray.optJSONObject(1).optString("start"); if (!StringUtil.isNullOrEmpty(start)) { startTkRate = Double.parseDouble(start); } String end = tkRatearray.optJSONObject(1).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { endTkRate = Double.parseDouble(end); } } } } else if ("tkRate3".equalsIgnoreCase(ty)) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system); if (!StringUtil.isNullOrEmpty(value)) { JSONArray tkRatearray = JSONArray.fromObject(value); if (tkRatearray != null) { String start = tkRatearray.optJSONObject(2).optString("start"); if (!StringUtil.isNullOrEmpty(start)) { startTkRate = Double.parseDouble(start); } String end = tkRatearray.optJSONObject(2).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { endTkRate = Double.parseDouble(end); } } } } else if ("tkRate4".equalsIgnoreCase(ty)) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system); if (!StringUtil.isNullOrEmpty(value)) { JSONArray tkRatearray = JSONArray.fromObject(value); if (tkRatearray != null) { String start = tkRatearray.optJSONObject(3).optString("start"); if (!StringUtil.isNullOrEmpty(start)) { startTkRate = Double.parseDouble(start); } String end = tkRatearray.optJSONObject(3).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { endTkRate = Double.parseDouble(end); } } } } else if ("tkRate5".equalsIgnoreCase(ty)) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system); if (!StringUtil.isNullOrEmpty(value)) { JSONArray tkRatearray = JSONArray.fromObject(value); if (tkRatearray != null) { String start = tkRatearray.optJSONObject(4).optString("start"); if (!StringUtil.isNullOrEmpty(start)) { startTkRate = Double.parseDouble(start); } String end = tkRatearray.optJSONObject(4).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { endTkRate = Double.parseDouble(end); } } } } } } } else if ("fahuodi".equalsIgnoreCase(ty)) { provinceId = array.optJSONObject(i).optInt("id"); } else if ("tkRate1".equalsIgnoreCase(ty)) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(), system); if (!StringUtil.isNullOrEmpty(value)) { JSONArray tkRatearray = JSONArray.fromObject(value); if (tkRatearray != null) { String start = tkRatearray.optJSONObject(0).optString("start"); if (!StringUtil.isNullOrEmpty(start)) { startTkRate = Double.parseDouble(start); } String end = tkRatearray.optJSONObject(0).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { endTkRate = Double.parseDouble(end); } } } } else if ("tkRate2".equalsIgnoreCase(ty)) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(), system); if (!StringUtil.isNullOrEmpty(value)) { JSONArray tkRatearray = JSONArray.fromObject(value); if (tkRatearray != null) { String start = tkRatearray.optJSONObject(1).optString("start"); if (!StringUtil.isNullOrEmpty(start)) { startTkRate = Double.parseDouble(start); } String end = tkRatearray.optJSONObject(1).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { endTkRate = Double.parseDouble(end); } } } } else if ("tkRate3".equalsIgnoreCase(ty)) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(), system); if (!StringUtil.isNullOrEmpty(value)) { JSONArray tkRatearray = JSONArray.fromObject(value); if (tkRatearray != null) { String start = tkRatearray.optJSONObject(2).optString("start"); if (!StringUtil.isNullOrEmpty(start)) { startTkRate = Double.parseDouble(start); } String end = tkRatearray.optJSONObject(2).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { endTkRate = Double.parseDouble(end); } } } } else if ("tkRate4".equalsIgnoreCase(ty)) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(), system); if (!StringUtil.isNullOrEmpty(value)) { JSONArray tkRatearray = JSONArray.fromObject(value); if (tkRatearray != null) { String start = tkRatearray.optJSONObject(3).optString("start"); if (!StringUtil.isNullOrEmpty(start)) { startTkRate = Double.parseDouble(start); } String end = tkRatearray.optJSONObject(3).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { endTkRate = Double.parseDouble(end); } } } } else if ("tkRate5".equalsIgnoreCase(ty)) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(), system); if (!StringUtil.isNullOrEmpty(value)) { JSONArray tkRatearray = JSONArray.fromObject(value); if (tkRatearray != null) { String start = tkRatearray.optJSONObject(4).optString("start"); if (!StringUtil.isNullOrEmpty(start)) { startTkRate = Double.parseDouble(start); } String end = tkRatearray.optJSONObject(4).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { endTkRate = Double.parseDouble(end); } } } } } } int pageSize = Constant.PAGE_SIZE; int pageSize = Constant.PAGE_SIZE; List<QualityFactory> listQuery = qualityGoodsService.listRecommendBykey(page * pageSize, pageSize, key, hasQuan, userType, start_Price, end_Price, startTkRate, endTkRate, sort); List<QualityFactory> listQuery = qualityGoodsService.listRecommendBykey(page * pageSize, pageSize, key, hasQuan, userType, start_Price, end_Price, startTkRate, endTkRate, sort); List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>(); BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); /* 遍历列表数据 */ if (listQuery != null && listQuery.size() > 0) { for (QualityFactory selectionGoods : listQuery) { List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>(); BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); /* 遍历列表数据 */ if (listQuery != null && listQuery.size() > 0) { for (QualityFactory selectionGoods : listQuery) { TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief(); TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief(); if (taoBaoGoodsBrief == null) { continue; } if (taoBaoGoodsBrief == null) { continue; } int biz30day = taoBaoGoodsBrief.getBiz30day(); if (biz30day >= 10000) { double sales = biz30day; String salesCountMidea = String.format("%.1f", sales / 10000); taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万"); } else { taoBaoGoodsBrief.setSalesCount(biz30day + ""); } int biz30day = taoBaoGoodsBrief.getBiz30day(); if (biz30day >= 10000) { double sales = biz30day; String salesCountMidea = String.format("%.1f", sales / 10000); taoBaoGoodsBrief.setSalesCount(salesCountMidea + "万"); } else { taoBaoGoodsBrief.setSalesCount(biz30day + ""); } // 改变图片尺寸 String pictUrl = taoBaoGoodsBrief.getPictUrl(); if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) { taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl)); } // 改变图片尺寸 String pictUrl = taoBaoGoodsBrief.getPictUrl(); if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) { taoBaoGoodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl)); } listExtra.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)); } } listExtra.add(TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null)); } } long count = qualityGoodsService.countRecommendBykey(key, hasQuan, userType, start_Price, end_Price, startTkRate, endTkRate); long count = qualityGoodsService.countRecommendBykey(key, hasQuan, userType, start_Price, end_Price, startTkRate, endTkRate); // 设置发货地址 TaoBaoSearchNav nav = new TaoBaoSearchNav(); nav.setName("发货地选择"); nav.setFlag("address"); nav.setId(11110); nav.setType("fahuodi"); // 设置发货地址 TaoBaoSearchNav nav = new TaoBaoSearchNav(); nav.setName("发货地选择"); nav.setFlag("address"); nav.setId(11110); nav.setType("fahuodi"); List<TaoBaoSearchNav> navList = new ArrayList<>(); List<TaoBaoSearchNav> navList = new ArrayList<>(); List<TaoBaoSearchNav> childNavList = new ArrayList<>(); List<TaoBaoProvince> provinceList = TaoBaoUtil.getTaoBaoProvinceList(); for (TaoBaoProvince province : provinceList) { TaoBaoSearchNav childNav = new TaoBaoSearchNav(); childNav.setName(province.getName()); childNav.setId(Integer.parseInt(province.getId())); childNav.setType("fahuodi-child"); if (Integer.parseInt(province.getId()) == provinceId) childNav.setSelector(1); childNavList.add(childNav); } List<TaoBaoSearchNav> childNavList = new ArrayList<>(); List<TaoBaoProvince> provinceList = TaoBaoUtil.getTaoBaoProvinceList(); for (TaoBaoProvince province : provinceList) { TaoBaoSearchNav childNav = new TaoBaoSearchNav(); childNav.setName(province.getName()); childNav.setId(Integer.parseInt(province.getId())); childNav.setType("fahuodi-child"); if (Integer.parseInt(province.getId()) == provinceId) childNav.setSelector(1); childNavList.add(childNav); } nav.setSubIds(childNavList); navList.add(nav); nav.setSubIds(childNavList); navList.add(nav); Gson gson = new GsonBuilder().create(); Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().create(); Gson gson = new GsonBuilder().create(); Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().create(); JSONObject data = new JSONObject(); data.put("nav", gson.toJson(navList)); data.put("result", gson2.toJson(listExtra)); data.put("count", count); JSONObject data = new JSONObject(); data.put("nav", gson.toJson(navList)); data.put("result", gson2.toJson(listExtra)); data.put("count", count); return data; } return data; } private JSONObject searchDaTaoKeGoods(AcceptData acceptData, String key, int page, String filter, String order, String startprice, String endprice) { page = page + 1; int sort = DaTaoKeApiUtil.SORT_DEFAULT; if ("5".equalsIgnoreCase(order)) { sort = DaTaoKeApiUtil.SORT_COMMISSION; } else if ("1".equalsIgnoreCase(order)) { sort = DaTaoKeApiUtil.SORT_SALES; } else if ("2".equalsIgnoreCase(order)) { sort = DaTaoKeApiUtil.SORT_PRICE_HIGH_TO_LOW; } else if ("3".equalsIgnoreCase(order)) { sort = DaTaoKeApiUtil.SORT_PRICE_LOW_TO_HIGH; } private JSONObject searchDaTaoKeGoods(AcceptData acceptData, String key, int page, String filter, String order, String startprice, String endprice) { page = page + 1; int sort = DaTaoKeApiUtil.SORT_DEFAULT; if ("5".equalsIgnoreCase(order)) { sort = DaTaoKeApiUtil.SORT_COMMISSION; } else if ("1".equalsIgnoreCase(order)) { sort = DaTaoKeApiUtil.SORT_SALES; } else if ("2".equalsIgnoreCase(order)) { sort = DaTaoKeApiUtil.SORT_PRICE_HIGH_TO_LOW; } else if ("3".equalsIgnoreCase(order)) { sort = DaTaoKeApiUtil.SORT_PRICE_LOW_TO_HIGH; } List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>(); BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); List<TaoBaoGoodsBriefExtra> listExtra = new ArrayList<TaoBaoGoodsBriefExtra>(); BigDecimal proportion = manageService.getFanLiRate(acceptData.getSystem()); DaTaoKeGoodsResult result = DaTaoKeApiUtil.search(key, null, null, null, page, 20, sort); if (result != null && result.getGoodsList() != null) for (DaTaoKeDetailV2 goods : result.getGoodsList()) { listExtra.add( TaoBaoUtil.getTaoBaoGoodsBriefExtra(TaoBaoUtil.convert(goods), proportion.toString(), null)); } DaTaoKeGoodsResult result = DaTaoKeApiUtil.search(key, null, null, null, page, 20, sort); if (result != null && result.getGoodsList() != null) for (DaTaoKeDetailV2 goods : result.getGoodsList()) { listExtra.add( TaoBaoUtil.getTaoBaoGoodsBriefExtra(TaoBaoUtil.convert(goods), proportion.toString(), null)); } List<TaoBaoSearchNav> navList = new ArrayList<>(); Gson gson = new GsonBuilder().create(); Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().create(); List<TaoBaoSearchNav> navList = new ArrayList<>(); Gson gson = new GsonBuilder().create(); Gson gson2 = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()) .excludeFieldsWithoutExposeAnnotation().create(); JSONObject data = new JSONObject(); data.put("nav", gson.toJson(navList)); data.put("result", gson2.toJson(listExtra)); data.put("count", result.getTotalCount()); JSONObject data = new JSONObject(); data.put("nav", gson.toJson(navList)); data.put("result", gson2.toJson(listExtra)); data.put("count", result.getTotalCount()); return data; } return data; } /** * 设置查询佣金比例范围 * * @param i * @param sf */ public void setSearchTkRate(int i, SearchFilter sf,SystemEnum system) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(),system); /** * 设置查询佣金比例范围 * * @param i * @param sf */ public void setSearchTkRate(int i, SearchFilter sf, SystemEnum system) { // 获取对应参数 String value = configService.getValue(ConfigKeyEnum.tkRateRange.getKey(), system); if (!StringUtil.isNullOrEmpty(value)) { if (!StringUtil.isNullOrEmpty(value)) { JSONArray tkRatearray = JSONArray.fromObject(value); JSONArray tkRatearray = JSONArray.fromObject(value); if (tkRatearray != null) { if (tkRatearray != null) { String start = tkRatearray.optJSONObject(i).optString("start"); String start = tkRatearray.optJSONObject(i).optString("start"); if (!StringUtil.isNullOrEmpty(start)) { int tkRate = (int) (Float.parseFloat(start) * 100); sf.setStartTkRate(tkRate); } if (!StringUtil.isNullOrEmpty(start)) { int tkRate = (int) (Float.parseFloat(start) * 100); sf.setStartTkRate(tkRate); } String end = tkRatearray.optJSONObject(i).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { int tkRate = (int) (Float.parseFloat(end) * 100); sf.setEndTkRate(tkRate); } } String end = tkRatearray.optJSONObject(i).optString("end"); if (!StringUtil.isNullOrEmpty(end)) { int tkRate = (int) (Float.parseFloat(end) * 100); sf.setEndTkRate(tkRate); } } } } } } } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java
@@ -6,7 +6,10 @@ import javax.annotation.Resource; import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.fanli.lijin.manager.GoodsLijinMnager; import com.yeshi.fanli.util.CommonGoodsUtil; import com.yeshi.fanli.util.factory.CommonGoodsFactory; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -166,21 +169,21 @@ JSONArray array = new JSONArray(); Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create(); List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); List<CommonGoods> goodsList = new ArrayList<>(); if (result != null) goodsList = result.getGoodsList(); GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion(), acceptData.getSystem()); List<GoodsDetailVO> goodsDetailVOList = goodsLijinMnager.loadTBMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO); List<GoodsDetailVO> goodsDetailVOList = goodsLijinMnager.loadCommonGoodsMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO); int p = 0; for (GoodsDetailVO vo : goodsDetailVOList) { vo.setCreatetime(null); if (type == CommonContentTypeEnum.mianDan)// 免单商品 { vo.getMoneyInfo().setFanliMoney("¥" + TaoBaoUtil.getCouponPrice(goodsList.get(p))); vo.getMoneyInfo().setShareMoney("¥" + TaoBaoUtil.getCouponPrice(goodsList.get(p))); vo.getMoneyInfo().setFanliMoney("¥" + CommonGoodsUtil.getAfterUseCouplePrice(goodsList.get(p))); vo.getMoneyInfo().setShareMoney("¥" + CommonGoodsUtil.getAfterUseCouplePrice(goodsList.get(p))); vo.getMoneyInfo().setMaxMoney(null); } array.add(gson.toJson(vo)); @@ -305,7 +308,7 @@ && searchResult.getTaoBaoGoodsBriefs().size() > 0) { CommonContentResult result = new CommonContentResult(); result.setCount(searchResult.getPageEntity().getTotalCount()); result.setGoodsList(searchResult.getTaoBaoGoodsBriefs()); result.setGoodsList(CommonGoodsFactory.createTaoBaoList(searchResult.getTaoBaoGoodsBriefs())); return result; } return null; fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ConfigControllerV2.java
@@ -680,7 +680,6 @@ */ @RequestMapping(value = "userProtocolListen") public void userProtocolListen(AcceptData acceptData, Long uid, int type, PrintWriter out) { LogHelper.userProtocolListen(String.format("%s#%s#%s", acceptData.getDevice(), uid, type)); out.print(JsonUtil.loadTrueResult("")); } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -2189,6 +2189,30 @@ JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } @RequestMapping(value = "convertPDDLink") public void convertPDDLink(AcceptData acceptData, String resourceType, String channelType, Long uid, PrintWriter out) { if (StringUtil.isNullOrEmpty(resourceType)&&StringUtil.isNullOrEmpty(channelType)) { out.print(JsonUtil.loadFalseResult(1, "resourceType|channelType为空")); return; } String customParams = null; if (uid != null) customParams = pddAuthService.getFanliCustomParams(uid); String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.fanli); PDDConvertLinkResultVO pddConvertLinkResultVO = null; if (!StringUtil.isNullOrEmpty(resourceType)) { pddConvertLinkResultVO = PinDuoDuoApiUtil.convertActivity(resourceType, null, pid, customParams); } else if (!StringUtil.isNullOrEmpty(channelType)) { pddConvertLinkResultVO = PinDuoDuoApiUtil.convertChannel(channelType, pid, customParams); } GoodsJumpLinkVO vo = GoodsJumpUtil.getPDDJumpInfo(pddConvertLinkResultVO); JSONObject data = JSONObject.fromObject(new Gson().toJson(vo)); data.put("native", vo.is_native()); out.print(JsonUtil.loadTrueResult(data)); } @RequestMapping(value = "getTaoBaoGoodsDetailImgs") public void getTaoBaoGoodsDetailImgs(AcceptData acceptData, Long id, PrintWriter out) { TaoBaoGoodsImportantInfo info = DaTaoKeApiUtil.getGoodsImportantInfo(id); fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -3,8 +3,11 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; import com.yeshi.fanli.dto.common.CommonContentResult; import com.yeshi.fanli.dto.common.CommonContentTypeEnum; import com.yeshi.fanli.entity.SystemEnum; import com.yeshi.fanli.lijin.manager.GoodsLijinMnager; import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService; import com.yeshi.goods.facade.dto.taobao.dataoke.DingDongTime; import com.yeshi.fanli.dto.jd.JDSearchResult; import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; @@ -133,6 +136,9 @@ @Resource private GoodsLijinMnager goodsLijinMnager; @Resource private CommonTemplateContentService commonTemplateContentService; /** * 新版推荐专题管理(1.5.3) * @@ -186,6 +192,103 @@ if (VersionUtil.greaterThan_2_0(acceptData.getPlatform(), acceptData.getVersion())) root.put("searchDiscovery", getSearchDiscoveryInfo(acceptData)); out.print(JsonUtil.loadTrueResult(root)); } catch (Exception e) { out.print(JsonUtil.loadFalseResult(1, "获取数据失败")); try { LogHelper.errorDetailInfo(e); } catch (Exception e1) { e1.printStackTrace(); } } } /** * 特价推荐 * * @param acceptData * @param uid * @param out */ @RequestMapping(value = "getRecommendIndexTJ") public void getRecommendIndexTJ(AcceptData acceptData, Long uid, PrintWriter out) { try { // 获取设备定义性别 int deviceSex = deviceSexService.getDeviceSex(acceptData.getDevice(), acceptData.getSystem()); // 1、专题模块 JSONObject root = specialService.listCacheSpecialToIndex(acceptData, deviceSex, acceptData.getSystem()); // 2、顶部轮播图 List<BannerVO> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("index_top", acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()); List<BannerVO> topPicList = new ArrayList<>(); if (oldtopPicList != null && oldtopPicList.size() > 0) topPicList.addAll(oldtopPicList); root.put("topPicList", JsonUtil.getApiCommonGson().toJson(topPicList)); // 3、邀请有奖 List<BannerVO> invitePicList = null; if ("ios".equalsIgnoreCase(acceptData.getPlatform()) && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) { // 如果IOS当前版本处于审核状态就不返回 } else { invitePicList = swiperPictureService.getByBannerCardAndVersion("index_invite", acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()), acceptData.getSystem()); } if (invitePicList == null) { invitePicList = new ArrayList<BannerVO>(); } root.put("invitePicList", JsonUtil.getApiCommonGson().toJson(invitePicList)); // 4、IOS的底部网页链接 String platform = acceptData.getPlatform(); if ("ios".equalsIgnoreCase(platform)) { root.put("htmlLink", configService.getValue(ConfigKeyEnum.indexHtmlLinkIos.getKey(), acceptData.getSystem())); } root.put("spikeGoods", getSpikeGoodsContent(acceptData)); if (VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) root.put("scoreExchange", getScoreExchangeInfo(acceptData)); if (VersionUtil.greaterThan_2_0(acceptData.getPlatform(), acceptData.getVersion())) root.put("searchDiscovery", getSearchDiscoveryInfo(acceptData)); //今日爆款 CommonContentResult commonContentResult = commonTemplateContentService.getContentList(CommonContentTypeEnum.pddHotGoodsRank, null, 1, 10, acceptData.getSystem()); if (commonContentResult != null && commonContentResult.getGoodsList() != null && commonContentResult.getGoodsList().size() > 0) { com.alibaba.fastjson.JSONObject hotSale = new com.alibaba.fastjson.JSONObject(); JumpDetailV2 jumpDetailV2 = new JumpDetailV2(); jumpDetailV2.setActivity("com.tejia.lijin.app.ui.sellwellcommodity.SellWellGoods"); hotSale.put("jumpDetail", jumpDetailV2); com.alibaba.fastjson.JSONObject params = new com.alibaba.fastjson.JSONObject(); String navs = "[{\"key\":\"pddHotGoodsRank\",\"title\":\"拼多多\"},{\"key\":\"jdHotGoodsRank\",\"title\":\"京东\"},{\"key\":\"tbHotGoodsRank\",\"title\":\"淘宝\"}]"; params.put("navs", navs.replace("\"","\\"+"\"")); hotSale.put("params", params); Collections.shuffle(commonContentResult.getGoodsList()); //获取goodsList GoodsMoneyConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion(), acceptData.getSystem()); List<GoodsDetailVO> goodsList = goodsLijinMnager.loadCommonGoodsMoneyInfo(acceptData.getSystem(), uid, commonContentResult.getGoodsList(), configParamsDTO); JSONArray array = new JSONArray(); Gson gson = new Gson(); for (GoodsDetailVO vo : goodsList) { array.add(gson.toJson(vo)); } hotSale.put("goodsList", array); root.put("hotSales", hotSale); } out.print(JsonUtil.loadTrueResult(root)); } catch (Exception e) { out.print(JsonUtil.loadFalseResult(1, "获取数据失败")); fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -7,10 +7,12 @@ import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import com.yeshi.fanli.entity.SystemEnum; import com.yeshi.fanli.entity.SystemPIDInfo; import com.yeshi.fanli.entity.bus.search.HistorySearch; import com.yeshi.fanli.exception.pdd.PDDApiException; import com.yeshi.fanli.exception.taobao.TaoBaoTokenParseException; import com.yeshi.fanli.lijin.manager.GoodsLijinMnager; @@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.yeshi.utils.HttpUtil; import org.yeshi.utils.IPUtil; import org.yeshi.utils.JsonUtil; import com.google.gson.Gson; @@ -528,7 +531,7 @@ */ @RequestMapping(value = "searchGoods") public void searchGoods(AcceptData acceptData, Integer goodsType, String key, Integer page, String filter, Integer order, Long uid, String notifyType, HttpSession session, PrintWriter out) { Integer order, Long uid, String notifyType, HttpSession session,HttpServletRequest request, PrintWriter out) { if (goodsType == null || goodsType < 1 || goodsType > 5) { out.print(JsonUtil.loadFalseResult(1, "请传递正确平台参数")); @@ -567,18 +570,17 @@ executor.execute(new Runnable() { @Override public void run() { StringBuffer sb = new StringBuffer(); String link = "#$$$#"; String platform = acceptData.getPlatform(); String packages = acceptData.getPackages(); String device = acceptData.getDevice(); sb.append(platform).append(link).append(packages).append(link).append(device); String bid = StringUtil.Md5(sb.toString()); // 加入搜索历史记录 historySearchService.addHistorySearch(searchkey, bid); HistorySearch search = new HistorySearch(); search.setDevice(StringUtil.isNullOrEmpty(acceptData.getUtdid()) ? acceptData.getDevice() : acceptData.getUtdid()); search.setKey(key); search.setSystem(acceptData.getSystem()); search.setUid(uid); search.setGoodsType(goodsType); search.setIpInfo(IPUtil.getRemotIP(request) + ":" + request.getRemotePort()); historySearchService.addHistorySearch(search); } }); if (searchkey.startsWith("http://") || searchkey.startsWith("https://")) { JSONObject data = new JSONObject(); @@ -635,7 +637,7 @@ @RequestMapping(value = "searchGoodsTJ") public void searchGoodsTJ(AcceptData acceptData, Integer goodsType, String key, Integer page, String filter, Integer order, Long uid, String notifyType, HttpSession session, PrintWriter out) { Integer order, Long uid, String notifyType, HttpSession session, HttpServletRequest request, PrintWriter out) { if (goodsType == null || goodsType < 1 || goodsType > 5) { out.print(JsonUtil.loadFalseResult(1, "请传递正确平台参数")); @@ -657,15 +659,14 @@ executor.execute(new Runnable() { @Override public void run() { StringBuffer sb = new StringBuffer(); String link = "#$$$#"; String platform = acceptData.getPlatform(); String packages = acceptData.getPackages(); String device = acceptData.getDevice(); sb.append(platform).append(link).append(packages).append(link).append(device); String bid = StringUtil.Md5(sb.toString()); // 加入搜索历史记录 historySearchService.addHistorySearch(searchkey, bid); HistorySearch search = new HistorySearch(); search.setDevice(StringUtil.isNullOrEmpty(acceptData.getUtdid()) ? acceptData.getDevice() : acceptData.getUtdid()); search.setKey(key); search.setSystem(acceptData.getSystem()); search.setUid(uid); search.setGoodsType(goodsType); search.setIpInfo(IPUtil.getRemotIP(request) + ":" + request.getRemotePort()); historySearchService.addHistorySearch(search); } }); @@ -748,6 +749,22 @@ goodsId = id; } } if (goodsId == null) { //解析链接 if (linkList != null && linkList.size() > 0) { String tempGoodsId = clipboardAnalysisManager.parseTBAuctionIdFromLink(linkList.get(0)); if (!StringUtil.isNullOrEmpty(tempGoodsId)) { goodsId = Long.parseLong(tempGoodsId); } } } } //商品ID为空,且是口令的形式就以未加入淘宝联盟的商品处理 if (goodsId == null && (linkList != null && linkList.size() > 0) && TaoBaoUtil.isHaveNewVersionTaoBaoToken(key)) { String[] ks = key.trim().split(" "); if (ks.length > 1) key = ks[1].trim(); } } fanli/src/main/java/com/yeshi/fanli/dao/mybatis/HistorySearchMapper.java
File was deleted fanli/src/main/java/com/yeshi/fanli/dao/user/HistorySearchDao.java
New file @@ -0,0 +1,12 @@ package com.yeshi.fanli.dao.user; import com.yeshi.common.MongodbBaseDao; import com.yeshi.fanli.entity.bus.search.HistorySearch; import org.springframework.stereotype.Repository; @Repository public class HistorySearchDao extends MongodbBaseDao<HistorySearch> { } fanli/src/main/java/com/yeshi/fanli/dto/common/CommonContentResult.java
@@ -3,18 +3,20 @@ import java.io.Serializable; import java.util.List; import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; public class CommonContentResult implements Serializable { private static final long serialVersionUID = 1L; private List<TaoBaoGoodsBrief> goodsList; private List<CommonGoods> goodsList; private long count; public List<TaoBaoGoodsBrief> getGoodsList() { public List<CommonGoods> getGoodsList() { return goodsList; } public void setGoodsList(List<TaoBaoGoodsBrief> goodsList) { public void setGoodsList(List<CommonGoods> goodsList) { this.goodsList = goodsList; } @@ -26,11 +28,11 @@ this.count = count; } public CommonContentResult(List<TaoBaoGoodsBrief> goodsList, long count) { this.goodsList = goodsList; this.count = count; public CommonContentResult() { } public CommonContentResult() { public CommonContentResult(List<CommonGoods> goodsList, long count) { this.goodsList = goodsList; this.count = count; } } fanli/src/main/java/com/yeshi/fanli/dto/common/CommonContentTypeEnum.java
@@ -2,18 +2,17 @@ public enum CommonContentTypeEnum { _9k9("9.9包邮"), haoQuan("高额好券"), chaoSheng("超级省钱"), muYin("母婴精选"), reMai("潮品热卖"), meiShi("优选美食"), juJia( "居家生活"), chuanYiDaPei("穿衣搭配"), meiZhuangGehu("美妆个护"), jingPinXieBao("精品鞋包"), chaoNanReMai( "潮男热卖"), shuMaShouJi("数码手机"), yunDongKuXie("运动酷鞋"), qiCheHuWai("汽车户外"), chaoPinReMai("新款潮品"),mianDan("免单商品") ,guessLikeDevice("猜你喜欢"); private final String desc; _9k9("9.9包邮"), haoQuan("高额好券"), chaoSheng("超级省钱"), muYin("母婴精选"), reMai("潮品热卖"), meiShi("优选美食"), juJia( "居家生活"), chuanYiDaPei("穿衣搭配"), meiZhuangGehu("美妆个护"), jingPinXieBao("精品鞋包"), chaoNanReMai( "潮男热卖"), shuMaShouJi("数码手机"), yunDongKuXie("运动酷鞋"), qiCheHuWai("汽车户外"), chaoPinReMai("新款潮品"), mianDan("免单商品"), guessLikeDevice("猜你喜欢"), pddHotGoodsRank("拼多多热销榜单"), jdHotGoodsRank("拼多多热销榜单"), tbHotGoodsRank("淘宝热销榜单"); private final String desc; private CommonContentTypeEnum(String desc) { this.desc = desc; } private CommonContentTypeEnum(String desc) { this.desc = desc; } public String getDesc() { return desc; } public String getDesc() { return desc; } } fanli/src/main/java/com/yeshi/fanli/dto/common/JDCommonContentTypeEnum.java
@@ -2,7 +2,7 @@ public enum JDCommonContentTypeEnum { _9k9("9.9包邮"), jdPeiSong("京东配送"), jiaDian("精选家电"), baiHuo("百货超市"), juJia("居家生活"); _9k9("9.9包邮"), jdPeiSong("京东配送"), jiaDian("精选家电"), baiHuo("百货超市"), juJia("居家生活"),; private final String desc; private JDCommonContentTypeEnum(String desc) { fanli/src/main/java/com/yeshi/fanli/entity/bus/search/HistorySearch.java
@@ -2,67 +2,87 @@ import java.util.Date; import com.yeshi.fanli.entity.SystemEnum; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; import org.yeshi.utils.mybatis.Column; import org.yeshi.utils.mybatis.Table; import com.google.gson.annotations.Expose; @Table("`yeshi_ec_history_search`") @Document(collection = "searchRecord") public class HistorySearch { @Column(name="id") private Long id; @Column(name="name") @Expose private String name; @Column(name="businessId") private String businessId; @Column(name="state") private int state; @Column(name="createtime") private Date createtime; public Long getId() { return id; } @Id private String id; private String device; private Integer goodsType; private Long uid; private SystemEnum system; private String key; private String ipInfo; private Date createtime; public void setId(Long id) { this.id = id; } public String getIpInfo() { return ipInfo; } public int getState() { return state; } public void setIpInfo(String ipInfo) { this.ipInfo = ipInfo; } public void setState(int state) { this.state = state; } public String getId() { return id; } public String getName() { return name; } public void setId(String id) { this.id = id; } public void setName(String name) { this.name = name; } public Integer getGoodsType() { return goodsType; } public String getBusinessId() { return businessId; } public void setGoodsType(Integer goodsType) { this.goodsType = goodsType; } public void setBusinessId(String businessId) { this.businessId = businessId; } public String getDevice() { return device; } public Date getCreatetime() { return createtime; } public void setDevice(String device) { this.device = device; } public void setCreatetime(Date createtime) { this.createtime = createtime; } public Long getUid() { return uid; } public void setUid(Long uid) { this.uid = uid; } public SystemEnum getSystem() { return system; } public void setSystem(SystemEnum system) { this.system = system; } public String getKey() { return key; } public void setKey(String key) { this.key = key; } public Date getCreatetime() { return createtime; } public void setCreatetime(Date createtime) { this.createtime = createtime; } } fanli/src/main/java/com/yeshi/fanli/entity/system/ConfigKeyEnum.java
@@ -181,6 +181,8 @@ lijinVIPLink("lijin_vip_link", "礼金会员链接"), lijinRecordLink("lijin_record_link", "礼金记录链接"), lijinRecievedSuccessLink("lijin_recieve_success_link", "礼金领取成功链接"), lijinRuleLink("lijin_rule_link", "礼金规则链接"), lijinCourseLink("lijin_course_link", "礼金教程链接"), // 文案转链 fanli/src/main/java/com/yeshi/fanli/lijin/dto/LijinSendInfo.java
@@ -29,6 +29,26 @@ private Date expireTime; @Expose private String md5; @Expose private String notifyTitle; @Expose private String notifySubtitle; public String getNotifyTitle() { return notifyTitle; } public void setNotifyTitle(String notifyTitle) { this.notifyTitle = notifyTitle; } public String getNotifySubtitle() { return notifySubtitle; } public void setNotifySubtitle(String notifySubtitle) { this.notifySubtitle = notifySubtitle; } public String getCategory() { return category; fanli/src/main/java/com/yeshi/fanli/lijin/manager/GoodsLijinMnager.java
@@ -174,16 +174,16 @@ } public BigDecimal getTBLijin(Long uid, TaoBaoGoodsBrief goodsBrief) { public MoneyInfo getTBLijinAndFanli(Long uid, TaoBaoGoodsBrief goodsBrief) { List<MoneyInfo> moneyInfo = lijinCreateService.getMoneyInfo(getUid(uid), Arrays.asList(new TaoBaoGoodsBrief[]{goodsBrief})); return moneyInfo.get(0).getLijinAmount(); return moneyInfo.get(0); } private List<GoodsDetailVOWithKey> loadTBMoneyInfo(SystemEnum system, Long uid, List<TaoBaoGoodsBrief> goodsBriefList, List<String> goodsKeyList, GoodsMoneyConfigParamsDTO paramsDTO) { Map<String, MoneyInfo> lijinMap = null; boolean hasCreateTime = false; if (SystemInfoUtil.hasFunctions(system, SystemFunction.lijinSub)) { if (SystemInfoUtil.hasFunctions(system, SystemFunction.lijinSub) && goodsBriefList.size() > 0) { loadMaterialLibsType(goodsBriefList); lijinMap = getTBLijinList(uid, goodsBriefList); hasCreateTime = true; @@ -442,6 +442,17 @@ } /** * 获取今日剩余数量 * * @param uid * @param registDate * @return */ public int getTodayLeftCount(Long uid, Date registDate) { return lijinCreateService.getTodayLeftCount(getUid(uid), registDate); } /** * 封装礼金信息 * * @param money fanli/src/main/java/com/yeshi/fanli/lijin/manager/UserLijinMnager.java
@@ -31,7 +31,7 @@ public class UserLijinMnager { //@Reference(version = "1.0", check = false, url = "dubbo://193.112.35.168:20904/com.ks.lijin.service.LijinCreateService") @Reference(version = "1.0", check = false) @Reference(version = "1.0", check = false, timeout = 30000) private LijinCreateService lijinCreateService; //@Reference(version = "1.0", check = false, url = "dubbo://193.112.35.168:20902/com.ks.vip.service.VipCenterService") @@ -332,5 +332,14 @@ return lijinBalanceService.getUsingLijin(getUid(uid)); } /** * 初始化余额 * * @param uid */ public void initBalance(Long uid) { lijinBalanceService.init(getUid(uid)); } } fanli/src/main/java/com/yeshi/fanli/lijin/manager/UserLijinSendManager.java
@@ -1,5 +1,6 @@ package com.yeshi.fanli.lijin.manager; import com.ks.vip.exception.LijinBalanceException; import com.ks.vip.pojo.DO.UserLijinRecord; import com.ks.vip.pojo.Enums.VIPEnum; import com.yeshi.fanli.entity.SystemEnum; @@ -161,7 +162,7 @@ * * @param id */ public LijinSendInfo recieveLijin(String id, Long uid) throws Exception { public LijinSendInfo recieveLijin(String id, Long uid) throws LijinBalanceException, Exception { LijinSendInfo lijinSendInfo = (LijinSendInfo) redisManager.getObj(LijinSendInfo.class, id); if (lijinSendInfo == null) throw new Exception("红包为空"); @@ -170,9 +171,9 @@ } //判断是否是新人红包 if(lijinSendInfo.getCategory().equalsIgnoreCase(UserLijinRecord.Category.newer.name())){ if (lijinSendInfo.getCategory() != null && lijinSendInfo.getCategory().equalsIgnoreCase(UserLijinRecord.Category.newer.name())) { UserLijinRecord record = userLijinMnager.getLijinRecord(uid, null, UserLijinRecord.Category.newer.name()); if(record!=null){ if (record != null) { throw new Exception("已领过新人红包"); } } @@ -212,5 +213,14 @@ } } /** * 初始化余额 * * @param uid */ public void initBalance(Long uid) { userLijinMnager.initBalance(uid); } } fanli/src/main/java/com/yeshi/fanli/log/KafkaAppender.java
New file @@ -0,0 +1,143 @@ package com.yeshi.fanli.log; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.ConsoleAppender; import org.apache.kafka.clients.producer.Callback; import org.apache.kafka.clients.producer.Producer; import org.apache.kafka.clients.producer.ProducerRecord; import org.apache.kafka.clients.producer.RecordMetadata; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class KafkaAppender extends ConsoleAppender<ILoggingEvent> { private String bootstrapServers; private String topic; private String batchSize; private String lingerMs; private String compressionType; private String retries; private String maxRequestSize; private String isSend; private Producer<String, String> producer; public KafkaAppender() { } @Override public void start() { super.start(); if ("true".equals(this.isSend)) { if (producer == null) { producer = KafkaUtil.createProducer(this.bootstrapServers, this.batchSize, this.lingerMs, this.compressionType, this.retries, this.maxRequestSize, "", ""); } } } @Override public void stop() { super.stop(); if ("true".equals(this.isSend)) { this.producer.close(); } System.out.println("Stopping kafkaAppender..."); } @Override protected void append(ILoggingEvent eventObject) { byte[] byteArray; String log; // 对日志格式进行解码 byteArray = this.encoder.encode(eventObject); log = new String(byteArray); ProducerRecord<String, String> record = new ProducerRecord<>(this.topic, log); if (eventObject.getMarker() == null && "true".equals(this.isSend)) { //如果需要进行分析日志,可以对record进行数据结构重构下 producer.send(record, new Callback() { @Override public void onCompletion(RecordMetadata metadata, Exception exception) { if (exception != null) { System.out.println(String.format("Send log to kafka failed: [%s]", log)); } } }); } } public String getBootstrapServers() { return bootstrapServers; } public void setBootstrapServers(String bootstrapServers) { this.bootstrapServers = bootstrapServers; } public String getTopic() { return topic; } public void setTopic(String topic) { this.topic = topic; } public String getBatchSize() { return batchSize; } public void setBatchSize(String batchSize) { this.batchSize = batchSize; } public String getLingerMs() { return lingerMs; } public void setLingerMs(String lingerMs) { this.lingerMs = lingerMs; } public String getCompressionType() { return compressionType; } public void setCompressionType(String compressionType) { this.compressionType = compressionType; } public String getRetries() { return retries; } public void setRetries(String retries) { this.retries = retries; } public String getMaxRequestSize() { return maxRequestSize; } public void setMaxRequestSize(String maxRequestSize) { this.maxRequestSize = maxRequestSize; } public String getIsSend() { return isSend; } public void setIsSend(String isSend) { this.isSend = isSend; } public Producer<String, String> getProducer() { return producer; } public void setProducer(Producer<String, String> producer) { this.producer = producer; } } fanli/src/main/java/com/yeshi/fanli/log/KafkaUtil.java
New file @@ -0,0 +1,82 @@ package com.yeshi.fanli.log; import org.apache.kafka.clients.consumer.KafkaConsumer; import org.apache.kafka.clients.producer.KafkaProducer; import org.apache.kafka.clients.producer.Producer; import org.apache.kafka.clients.producer.ProducerConfig; import java.util.Arrays; import java.util.Properties; public class KafkaUtil { public static Producer<String, String> createProducer( String bootstrapServers, String batchSize, String lingerMs, String compressionType, String retries, String maxRequestSize, String username, String password) { // 当配置项为IS_UNDEFINED时,使用默认值 if (bootstrapServers == null) { bootstrapServers = "kafka地址"; } if (batchSize.contains("IS_UNDEFINED")) { batchSize = "50000"; } if (lingerMs.contains("IS_UNDEFINED")) { lingerMs = "60000"; } if (retries.contains("IS_UNDEFINED")) { retries = "3"; } if (maxRequestSize.contains("IS_UNDEFINED")) { maxRequestSize = "5242880"; } Properties properties = new Properties(); // kafka地址,集群用逗号分隔开 properties.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); // acks取值: // 0: kafka不返回确认信息,不保证record是否被收到,因为没有返回所以重试机制不会生效 // 1: partition leader确认record写入到日志中,但不保证信息是否被正确复制 // all: leader会等待所有信息被同步后返回确认信息 properties.put(ProducerConfig.ACKS_CONFIG, "1"); properties.put(ProducerConfig.RETRIES_CONFIG, Integer.valueOf(retries)); // 批量发送,当达到batch size最大值触发发送机制(10.0后支持批量发送) properties.put(ProducerConfig.BATCH_SIZE_CONFIG, Integer.valueOf(batchSize)); // 该配置是指在batch.size数量未达到时,指定时间内也会推送数据 properties.put(ProducerConfig.LINGER_MS_CONFIG, Integer.valueOf(lingerMs)); // 配置缓存 properties.put(ProducerConfig.BUFFER_MEMORY_CONFIG, 33554432); if (!compressionType.contains("IS_UNDEFINED")) { // 指定压缩算法 // properties.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, compressionType); } // 每个请求的消息大小 properties.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG, Integer.valueOf(maxRequestSize)); properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer"); if (!"".equals(username)) { properties.put("security.protocol", "SASL_PLAINTEXT"); properties.put("sasl.mechanism", "PLAIN"); properties.put("sasl.jaas.config", "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"" + "用戶名" + "\" password=\"" + "密碼" + "\";"); } return new KafkaProducer<String, String>(properties); } public static KafkaConsumer<String, String> createConsumer(String servers, String topic) { Properties props = new Properties(); props.put("bootstrap.servers", servers); props.put("group.id", "test"); props.put("enable.auto.commit", true);//设置是否为自动提交 props.put("auto.offset.reset", "earliest"); props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); KafkaConsumer consumer = new KafkaConsumer<String, String>(props); consumer.subscribe(Arrays.asList(new String[]{topic})); return consumer; } } fanli/src/main/java/com/yeshi/fanli/log/LogHelper.java
@@ -1,107 +1,97 @@ package com.yeshi.fanli.log; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.log4j.Logger; import org.yeshi.utils.TimeUtil; public class LogHelper { // log private static Logger userLogger = Logger.getLogger("userInfoLog"); private static Logger orderLogger = Logger.getLogger("orderLog"); private static Logger logger = LoggerFactory.getLogger(LogHelper.class); private static Logger userOrderLogger = Logger.getLogger("userOrderLog"); private static Logger userLogger = LoggerFactory.getLogger("userInfoLog"); private static Logger testLogger = Logger.getLogger("testLog"); private static Logger orderLogger = LoggerFactory.getLogger("orderLog"); private static Logger errorLogger = Logger.getLogger("errorLog"); private static Logger userOrderLogger = LoggerFactory.getLogger("userOrderLog"); private static Logger httpLogger = Logger.getLogger("httpLog"); private static Logger testLogger = LoggerFactory.getLogger("testLog"); private static Logger taoBaoLinkLog = Logger.getLogger("taoBaoLinkLog"); private static Logger errorLogger = LoggerFactory.getLogger("errorLog"); private static Logger shareGoodsLogger = Logger.getLogger("shareGoodsLog"); private static Logger httpLogger = LoggerFactory.getLogger("httpLog"); private static Logger loginLogger = Logger.getLogger("loginLog"); private static Logger taoBaoLinkLog = LoggerFactory.getLogger("taoBaoLinkLog"); private static Logger smsLogger = Logger.getLogger("smsLog"); private static Logger shareGoodsLogger = LoggerFactory.getLogger("shareGoodsLog"); private static Logger requestLogger = Logger.getLogger("requestLog"); private static Logger loginLogger = LoggerFactory.getLogger("loginLog"); private static Logger requestTimeLogger = Logger.getLogger("requestTimeLog"); private static Logger smsLogger = LoggerFactory.getLogger("smsLog"); private static Logger jobLogger = Logger.getLogger("jobLog"); private static Logger requestLogger = LoggerFactory.getLogger("requestLog"); private static Logger mqLogger = Logger.getLogger("mqLog"); private static Logger requestTimeLogger = LoggerFactory.getLogger("requestTimeLog"); private static Logger vipInfoLogger = Logger.getLogger("vipInfoLog"); private static Logger jobLogger = LoggerFactory.getLogger("jobLog"); private static Logger userProtocolListenLog = Logger.getLogger("userProtocolListenLog"); private static Logger mqLogger = LoggerFactory.getLogger("mqLog"); private static Logger teamLogger = Logger.getLogger("teamLog"); private static Logger vipInfoLogger = LoggerFactory.getLogger("vipInfoLog"); private static Logger teamLogger = LoggerFactory.getLogger("teamLog"); private static Logger cloudLogger = Logger.getLogger("cloudLog"); private static Logger cloudLogger = LoggerFactory.getLogger("cloudLog"); private static Logger pushHWLog = Logger.getLogger("pushHWLog"); private static Logger pushHWLog = LoggerFactory.getLogger("pushLog"); public static void userProtocolListen(Object obj) { userProtocolListenLog.info(obj); } public static void userInfo(Object obj) { userLogger.info(obj); userLogger.info(obj + ""); } public static void userErrorInfo(Object obj) { userLogger.error(obj); userLogger.error(obj + ""); } public static void orderInfo(Object obj) { orderLogger.info(obj); orderLogger.info(obj + ""); } public static void orderErrorInfo(Object obj) { orderLogger.error(obj); orderLogger.error(obj + ""); } public static void userOrder(Object obj) { userOrderLogger.info(obj); userOrderLogger.info(obj + ""); } public static void test(Object obj) { testLogger.info(obj); testLogger.info(obj + ""); } public static void error(Object obj) { errorLogger.info(obj); errorLogger.error(obj + ""); } public static void taoBaoLinkError(Object obj) { taoBaoLinkLog.info(obj); taoBaoLinkLog.info(obj + ""); } public static void shareGoods(Object obj) { shareGoodsLogger.info(obj); shareGoodsLogger.info(obj + ""); } public static void job(Object obj) { jobLogger.info(obj); jobLogger.info(obj + ""); } public static void pushHW(Object obj) { pushHWLog.info(obj); pushHWLog.info(obj + ""); } public static void mqError(String errorMsg, String topic, String tag, Object data) { @@ -115,12 +105,12 @@ } public static void vipInfo(Object obj) { vipInfoLogger.info(obj); vipInfoLogger.info(obj + ""); } public static void cloudInfo(Object info) { if (info != null) cloudLogger.info(info); cloudLogger.info(info + ""); } @@ -130,78 +120,22 @@ * @param obj */ public static void lgoinInfo(Object obj) { loginLogger.info(obj); loginLogger.info(obj + ""); } public static void errorDetailInfo(Throwable e) { e.printStackTrace(); String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); String os = System.getProperty("os.name"); String filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date); if (os.toLowerCase().startsWith("win")) { filePath = String.format("C:/logs/error_detail_%s.log", date); } else filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date); OutputStream out = null; try { out = new FileOutputStream(new File(filePath), true); PrintStream ps = new PrintStream(out); ps.print(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); ps.print("\n"); e.printStackTrace(ps); ps.flush(); ps.close(); } catch (Exception ee) { } finally { try { out.close(); } catch (IOException e1) { e1.printStackTrace(); } } logger.error("", e); } public static void errorDetailInfo(Throwable e, String params, String url) { e.printStackTrace(); String date = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy_MM_dd"); String os = System.getProperty("os.name"); String filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date); if (os.toLowerCase().startsWith("win")) { filePath = String.format("C:/logs/error_detail_%s.log", date); } else filePath = String.format("/usr/local/tomcat8/logs/error_detail_%s.log", date); OutputStream out = null; try { out = new FileOutputStream(new File(filePath), true); PrintStream ps = new PrintStream(out); ps.print(TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss")); ps.print("\n"); ps.print("链接:" + url); ps.print("\n"); ps.print("参数:" + params); ps.print("\n"); e.printStackTrace(ps); ps.flush(); ps.close(); } catch (Exception e1) { } finally { try { out.close(); } catch (Exception e1) { e1.printStackTrace(); } } logger.error(String.format("链接:%s,参数:%s", url, params), e); } /** * 请求日志 * * @param request * @param url * @param map */ public static void requestInfo(String url, Map<String, Object> map) { try { @@ -218,15 +152,10 @@ paramsStr += param + "&"; if (paramsStr.endsWith("&")) paramsStr = paramsStr.substring(0, paramsStr.length() - 1); requestLogger.info(String.format("%s#####%s", url, paramsStr)); requestLogger.info("{}#####{}", url, paramsStr); } catch (Exception e) { } } public static void httpInfo(String url, String params, String response) { String msg = url + "\n" + params + "\n" + response; httpLogger.info(msg); } public static void smsInfo(String info) { @@ -256,10 +185,8 @@ if (paramsStr.endsWith("&")) paramsStr = paramsStr.substring(0, paramsStr.length() - 1); } catch (Exception e) { } String content = String.format("链接:%s 参数:%s 响应时间:%s", url, paramsStr, time + ""); requestTimeLogger.info(content); requestTimeLogger.info("链接:{} 参数:{} 响应时间:{}", new String[]{url, paramsStr, time + ""}); } } fanli/src/main/java/com/yeshi/fanli/log/category/MQ.java
New file @@ -0,0 +1,4 @@ package com.yeshi.fanli.log.category; public class MQ { } fanli/src/main/java/com/yeshi/fanli/log/category/TaoKe.java
New file @@ -0,0 +1,4 @@ package com.yeshi.fanli.log.category; public class TaoKe { } fanli/src/main/java/com/yeshi/fanli/log/category/Test.java
New file @@ -0,0 +1,4 @@ package com.yeshi.fanli.log.category; public class Test { } fanli/src/main/java/com/yeshi/fanli/log/category/User.java
New file @@ -0,0 +1,4 @@ package com.yeshi.fanli.log.category; public class User { } fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java
@@ -11,7 +11,15 @@ import com.yeshi.fanli.entity.SystemEnum; import com.yeshi.fanli.entity.SystemFunction; import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.fanli.util.SystemInfoUtil; import com.yeshi.fanli.util.factory.CommonGoodsFactory; import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuJDGoodsInfo; import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuListResult; import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuPDDGoodsInfo; import com.yeshi.goods.facade.entity.taobao.haodanku.HDKGoodsDetail; import com.yeshi.goods.facade.utils.taobao.HaoDanKuApiUtil; import com.yeshi.goods.facade.utils.taobao.HaoDankuUtil; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; @@ -88,7 +96,7 @@ } @Override public List<CommonContentNav> getNavList(CommonContentTypeEnum type,SystemEnum system) { public List<CommonContentNav> getNavList(CommonContentTypeEnum type, SystemEnum system) { List<CommonContentNav> navList = new ArrayList<>(); if (type == CommonContentTypeEnum._9k9) { navList.add(new CommonContentNav("-1", "综合")); @@ -141,6 +149,24 @@ navList = getCommonNav(system); } else if (type == CommonContentTypeEnum.mianDan) { navList = new ArrayList<>(); } else if (type == CommonContentTypeEnum.pddHotGoodsRank) { //好单库数据 navList.add(new CommonContentNav("0", "全部")); for (HaoDankuUtil.Category category : HaoDankuUtil.CATEGORYS) { navList.add(new CommonContentNav(category.getId() + "", category.getName())); } } else if (type == CommonContentTypeEnum.jdHotGoodsRank) { //好单库数据 navList.add(new CommonContentNav("0", "全部")); for (HaoDankuUtil.Category category : HaoDankuUtil.CATEGORYS) { navList.add(new CommonContentNav(category.getId() + "", category.getName())); } } else if (type == CommonContentTypeEnum.tbHotGoodsRank) { //好单库数据 navList.add(new CommonContentNav("0", "全部")); for (HaoDankuUtil.Category category : HaoDankuUtil.CATEGORYS) { navList.add(new CommonContentNav(category.getId() + "", category.getName())); } } return navList; @@ -180,11 +206,17 @@ result = getHaoQuanContent(cid, page, pageSize); } else if (type == CommonContentTypeEnum.mianDan) { result = getMianDanContent(page, pageSize); } else if (type == CommonContentTypeEnum.pddHotGoodsRank) { result = getPDDHotGoodsRankContent(cid, page); } else if (type == CommonContentTypeEnum.jdHotGoodsRank) { result = getJDHotGoodsRankContent(cid, page); } else if (type == CommonContentTypeEnum.tbHotGoodsRank) { result = getTBHotGoodsRankContent(cid, page); } if (result != null) {// 商品信息过滤 List<TaoBaoGoodsBrief> goodsList = taoBaoGoodsUpdateService .filterImportantTaoBaoGoods(result.getGoodsList()); List<CommonGoods> goodsList = taoBaoGoodsUpdateService .filterImportantTaoBaoGoodsWithCommonGoods(result.getGoodsList()); result.setGoodsList(goodsList); } @@ -247,7 +279,7 @@ for (DaTaoKeDetailV2 detail : result.getGoodsList()) goodsList.add(TaoBaoUtil.convert(detail)); } return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -308,7 +340,7 @@ } goodsList.add(taoBaoGoodsBrief); } return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -374,7 +406,7 @@ } goodsList.add(taoBaoGoodsBrief); } return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -399,7 +431,7 @@ for (DaTaoKeDetailV2 detail : result.getGoodsList()) goodsList.add(TaoBaoUtil.convert(detail)); } return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -424,7 +456,7 @@ for (DaTaoKeDetailV2 detail : result.getGoodsList()) goodsList.add(TaoBaoUtil.convert(detail)); } return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -448,7 +480,7 @@ for (DaTaoKeDetailV2 detail : result.getGoodsList()) goodsList.add(TaoBaoUtil.convert(detail)); } return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -475,7 +507,7 @@ for (DaTaoKeDetailV2 detail : result.getGoodsList()) goodsList.add(TaoBaoUtil.convert(detail)); } return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } else {// List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache("母婴_" + cid, @@ -494,7 +526,7 @@ } catch (Exception e) { e.printStackTrace(); } return new CommonContentResult(listBrands, 1000); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(listBrands), 1000); } return new CommonContentResult(new ArrayList<>(), 0); } @@ -524,7 +556,7 @@ for (DaTaoKeDetailV2 detail : result.getGoodsList()) goodsList.add(TaoBaoUtil.convert(detail)); } return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -549,7 +581,7 @@ for (DaTaoKeDetailV2 detail : result.getGoodsList()) goodsList.add(TaoBaoUtil.convert(detail)); } return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -578,7 +610,7 @@ goodsList.add(TaoBaoUtil.convert(detail)); } Collections.shuffle(goodsList); return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -602,7 +634,7 @@ goodsList.add(TaoBaoUtil.convert(detail)); } Collections.shuffle(goodsList); return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -630,7 +662,7 @@ goodsList.add(TaoBaoUtil.convert(detail)); } Collections.shuffle(goodsList); return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -658,7 +690,7 @@ goodsList.add(TaoBaoUtil.convert(detail)); } Collections.shuffle(goodsList); return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -689,7 +721,7 @@ goodsList.add(TaoBaoUtil.convert(detail)); } Collections.shuffle(goodsList); return new CommonContentResult(goodsList, count); return new CommonContentResult(CommonGoodsFactory.createTaoBaoList(goodsList), count); } /** @@ -742,6 +774,69 @@ goodsList.remove(i--); } } result.setGoodsList(CommonGoodsFactory.createTaoBaoList(goodsList)); return result; } /** * 拼多多热销 * * @return */ private CommonContentResult getPDDHotGoodsRankContent(String cid, int page) { cid = cid == null ? 0 + "" : cid; CommonContentResult result = new CommonContentResult(); HaoDanKuListResult pddResult = HaoDanKuApiUtil.getInstance().getPDDHotGoods(Integer.parseInt(cid), page == 1 ? null : page); //qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize); result.setCount(1000); List<CommonGoods> goodsList = new ArrayList<>(); if (pddResult != null) { List<HaoDanKuPDDGoodsInfo> list = pddResult.getResultList(); for (HaoDanKuPDDGoodsInfo goodsInfo : list) { goodsList.add(CommonGoodsFactory.create(goodsInfo)); } } result.setGoodsList(goodsList); return result; } /** * 京东热销 * * @return */ private CommonContentResult getJDHotGoodsRankContent(String cid, int page) { CommonContentResult result = new CommonContentResult(); HaoDanKuListResult pddResult = HaoDanKuApiUtil.getInstance().getJDHotGoods(Integer.parseInt(cid), page == 1 ? null : page); //qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize); result.setCount(1000); List<CommonGoods> goodsList = new ArrayList<>(); if (pddResult != null) { List<HaoDanKuJDGoodsInfo> list = pddResult.getResultList(); for (HaoDanKuJDGoodsInfo goodsInfo : list) { goodsList.add(CommonGoodsFactory.create(goodsInfo)); } } result.setGoodsList(goodsList); return result; } /** * 淘宝热销 * * @return */ private CommonContentResult getTBHotGoodsRankContent(String cid, int page) { CommonContentResult result = new CommonContentResult(); HaoDanKuListResult pddResult = HaoDanKuApiUtil.getInstance().getTBHotGoods(Integer.parseInt(cid), page == 1 ? null : page); //qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize); result.setCount(1000); List<CommonGoods> goodsList = new ArrayList<>(); if (pddResult != null) { List<HDKGoodsDetail> list = pddResult.getResultList(); for (HDKGoodsDetail goodsInfo : list) { goodsList.add(CommonGoodsFactory.create(goodsInfo)); } } result.setGoodsList(goodsList); return result; } fanli/src/main/java/com/yeshi/fanli/service/impl/goods/JDCommonTemplateContentServiceImpl.java
@@ -64,19 +64,19 @@ } private JDSearchResult getJiaDianContent(String cid, int page, int pageSize) { int[] arrayId = { 5, 2 }; int[] arrayId = { 24}; JDSearchResult result = getJingFenGoods(page, pageSize, "jiadian-", arrayId); return filterGoods(result); } private JDSearchResult getBaiHuoContent(String cid, int page, int pageSize) { int[] arrayId = { 6, 3 }; int[] arrayId = { 25 }; JDSearchResult result = getJingFenGoods(page, pageSize, "baihuo-", arrayId); return filterGoods(result); } private JDSearchResult getJuJiaContent(String cid, int page, int pageSize) { int[] arrayId = { 7, 4 }; int[] arrayId = { 27 }; JDSearchResult result = getJingFenGoods(page, pageSize, "jujia-", arrayId); return filterGoods(result); } fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoGoodsUpdateServiceImpl.java
@@ -408,6 +408,66 @@ } @Override public List<CommonGoods> filterImportantTaoBaoGoodsWithCommonGoods(List<CommonGoods> goodsList) { // 商品过滤不允许出错 try { Map<Long, CommonGoods> finalMap = new HashMap<>(); // 原始数据全覆盖 List<CommonGoods> tempGoodsList = new ArrayList<>(); for (CommonGoods goods : goodsList) { if (goods.getGoodsType() == CommonGoods.SHOP_TYPE_TB) { finalMap.put(goods.getGoodsId(), goods); tempGoodsList.add(goods); } } // 先从redis里面取覆盖 for (int i = 0; i < tempGoodsList.size(); i++) { TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil .getCommonTaoBaoGoodsInfo(tempGoodsList.get(i).getGoodsId()); if (goods != null) { finalMap.put(goods.getAuctionId(), CommonGoodsFactory.create(goods)); tempGoodsList.remove(i--); } } // 再从mongodb中取覆盖 List<Long> auctionIds = new ArrayList<>(); for (CommonGoods goods : tempGoodsList) { auctionIds.add(goods.getGoodsId()); } List<TaoBaoGoodsBrief> mList = taoBaoGoodsUpdateDao.listByAuctionIds(auctionIds); if (mList != null) for (TaoBaoGoodsBrief goods : mList) { if (goods.getUpdatetime().getTime() > System.currentTimeMillis() - 1000 * 60 * 60 * 24L)// 在1天内更新的数据才参与过滤 finalMap.put(goods.getAuctionId(), CommonGoodsFactory.create(goods)); } List<CommonGoods> finalList = new ArrayList<>(); for (CommonGoods goods : goodsList) { if (goods.getGoodsType() == CommonGoods.GOODS_TYPE_TB) { CommonGoods newGoods = finalMap.get(goods.getGoodsId()); // 过滤价格,返利比例,券信息 goods.setPrice(newGoods.getPrice()); goods.setRate(newGoods.getRate()); goods.setCouponAmount(newGoods.getCouponAmount()); goods.setCouponInfo(newGoods.getCouponInfo()); goods.setCouponLeftCount(newGoods.getCouponLeftCount()); goods.setCouponStartPrice(newGoods.getCouponStartPrice()); goods.setCouponTotalCount(newGoods.getCouponTotalCount()); } finalList.add(goods); } return finalList; } catch (Exception e) { LogHelper.errorDetailInfo(e); } return goodsList; } @Override public int listAndRemoveByMaxUpdateTime(Date maxTime, int page, int pageSize) { return taoBaoGoodsUpdateDao.listAndRemoveByMaxUpdateTime(maxTime, (page - 1) * pageSize, pageSize); } fanli/src/main/java/com/yeshi/fanli/service/impl/user/HistorySearchServiceImpl.java
@@ -1,29 +1,28 @@ package com.yeshi.fanli.service.impl.user; import java.util.Date; import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.yeshi.fanli.dao.mybatis.HistorySearchMapper; import com.yeshi.fanli.dao.user.HistorySearchDao; import com.yeshi.fanli.entity.bus.search.HistorySearch; import com.yeshi.fanli.service.inter.user.HistorySearchService; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.UUID; @Service public class HistorySearchServiceImpl implements HistorySearchService { @Resource private HistorySearchMapper historySearchMapper; @Resource private HistorySearchDao historySearchDao; public void addHistorySearch(String searchKey, String bid) { searchKey = searchKey != null && searchKey.length() > 64 ? searchKey.substring(0, 64) : searchKey; HistorySearch historySearch = new HistorySearch(); historySearch.setName(searchKey); historySearch.setBusinessId(bid); historySearch.setCreatetime(new Date()); historySearch.setState(0); historySearchMapper.insertSelective(historySearch); } public void addHistorySearch(HistorySearch search) { if (search.getId() == null) { search.setId(UUID.randomUUID().toString()); } if (search.getCreatetime() == null) { search.setCreatetime(new Date()); } historySearchDao.save(search); } } fanli/src/main/java/com/yeshi/fanli/service/inter/taobao/TaoBaoGoodsUpdateService.java
@@ -3,6 +3,7 @@ import java.util.Date; import java.util.List; import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException; @@ -113,6 +114,9 @@ */ public List<TaoBaoGoodsBrief> filterImportantTaoBaoGoods(List<TaoBaoGoodsBrief> goodsList); public List<CommonGoods> filterImportantTaoBaoGoodsWithCommonGoods(List<CommonGoods> goodsList); /** * 根据最大的更新时间移除 * fanli/src/main/java/com/yeshi/fanli/service/inter/user/HistorySearchService.java
@@ -1,7 +1,9 @@ package com.yeshi.fanli.service.inter.user; import com.yeshi.fanli.entity.bus.search.HistorySearch; public interface HistorySearchService { public void addHistorySearch(String searchKey, String bid); public void addHistorySearch(HistorySearch search); } fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java
@@ -1,7 +1,5 @@ package com.yeshi.fanli.util.factory; import java.math.BigDecimal; import com.alibaba.fastjson.JSONObject; import com.yeshi.fanli.dto.common.CategoryInfoDTO; import com.yeshi.fanli.dto.common.GoodsOtherInfoDTO; @@ -14,324 +12,410 @@ import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo; import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.fanli.entity.jd.JDGoods; import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; import org.yeshi.utils.MoneyBigDecimalUtil; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.factory.goods.TaoBaoGoodsFactory; import com.yeshi.fanli.util.jd.JDUtil; import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuJDGoodsInfo; import com.yeshi.goods.facade.dto.taobao.haodanku.HaoDanKuPDDGoodsInfo; import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.goods.facade.entity.taobao.haodanku.HDKGoodsDetail; import org.yeshi.utils.MoneyBigDecimalUtil; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; public class CommonGoodsFactory { /** * 淘宝商品构造 * * @param goods * @return */ public static CommonGoods create(TaoBaoGoodsBrief goods) { if (goods == null) return null; /** * 淘宝商品构造 * * @param goods * @return */ public static CommonGoods create(TaoBaoGoodsBrief goods) { if (goods == null) return null; CommonGoods cg = new CommonGoods(); cg.setCouponAmount(goods.getCouponAmount()); cg.setCouponInfo(goods.getCouponInfo()); cg.setCouponLeftCount(goods.getCouponLeftCount()); cg.setCouponStartPrice(goods.getCouponStartFee()); cg.setCouponTotalCount(goods.getCouponTotalCount()); cg.setGoodsId(goods.getAuctionId()); cg.setGoodsType(CommonGoods.GOODS_TYPE_TB); cg.setPicture(goods.getPictUrl()); cg.setPictureWhite(goods.getPictUrlWhite()); cg.setPrice(goods.getZkPrice()); cg.setSales(goods.getBiz30day()); cg.setRate(goods.getTkRate()); cg.setSellerId(goods.getSellerId()); cg.setSellerName(goods.getShopTitle()); if (goods.getUserType() == 0) cg.setShopType(CommonGoods.SHOP_TYPE_TB); else cg.setShopType(CommonGoods.SHOP_TYPE_TM); cg.setState(CommonGoods.STATE_NORMAL); cg.setTitle(goods.getTitle()); // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); cg.setState(goods.getState()); cg.setMaterialLibType(goods.getMaterialLibType()); CommonGoods cg = new CommonGoods(); cg.setCouponAmount(goods.getCouponAmount()); cg.setCouponInfo(goods.getCouponInfo()); cg.setCouponLeftCount(goods.getCouponLeftCount()); cg.setCouponStartPrice(goods.getCouponStartFee()); cg.setCouponTotalCount(goods.getCouponTotalCount()); cg.setGoodsId(goods.getAuctionId()); cg.setGoodsType(CommonGoods.GOODS_TYPE_TB); cg.setPicture(goods.getPictUrl()); cg.setPictureWhite(goods.getPictUrlWhite()); cg.setPrice(goods.getZkPrice()); cg.setSales(goods.getBiz30day()); cg.setRate(goods.getTkRate()); cg.setSellerId(goods.getSellerId()); cg.setSellerName(goods.getShopTitle()); if (goods.getUserType() == 0) cg.setShopType(CommonGoods.SHOP_TYPE_TB); else cg.setShopType(CommonGoods.SHOP_TYPE_TM); cg.setState(CommonGoods.STATE_NORMAL); cg.setTitle(goods.getTitle()); // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); cg.setState(goods.getState()); cg.setMaterialLibType(goods.getMaterialLibType()); // 分类信息 CategoryInfoDTO categoryInfo = new CategoryInfoDTO(); Integer rootCatId = goods.getRootCatId(); if (rootCatId != null) { categoryInfo.setCid1(Long.parseLong(rootCatId.toString())); } categoryInfo.setCid1Name(goods.getRootCategoryName()); // 分类信息 CategoryInfoDTO categoryInfo = new CategoryInfoDTO(); Integer rootCatId = goods.getRootCatId(); if (rootCatId != null) { categoryInfo.setCid1(Long.parseLong(rootCatId.toString())); } categoryInfo.setCid1Name(goods.getRootCategoryName()); Integer leafCatId = goods.getLeafCatId(); if (leafCatId != null) { categoryInfo.setCid2(Long.parseLong(leafCatId.toString())); } categoryInfo.setCid2Name(goods.getLeafName()); cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString()); Integer leafCatId = goods.getLeafCatId(); if (leafCatId != null) { categoryInfo.setCid2(Long.parseLong(leafCatId.toString())); } categoryInfo.setCid2Name(goods.getLeafName()); cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString()); return cg; } return cg; } /** * 淘宝商品构造 * * @param goods * @return */ public static CommonGoods create(JDGoods goods) { if (goods == null) return null; public static List<CommonGoods> createTaoBaoList(List<TaoBaoGoodsBrief> goodsList) { if (goodsList == null) return null; List<CommonGoods> commonGoodsList = new ArrayList<>(); for (TaoBaoGoodsBrief goodsBrief : goodsList) { commonGoodsList.add(create(goodsBrief)); } return commonGoodsList; } CommonGoods cg = new CommonGoods(); JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods); if (couponInfo != null) { cg.setCouponStartPrice(couponInfo.getQuota()); BigDecimal discount = couponInfo.getDiscount(); if (discount != null && discount.compareTo(new BigDecimal(0)) > 0) { cg.setCouponAmount(discount); if (cg.getCouponStartPrice().compareTo(new BigDecimal(0)) > 0) cg.setCouponInfo(String.format("满%s元减%s元", couponInfo.getQuota() + "", cg.getCouponAmount() + "")); else cg.setCouponInfo(String.format("%s元无条件券", cg.getCouponAmount() + "")); } else { cg.setCouponAmount(new BigDecimal(0)); } cg.setCouponLeftCount(1); cg.setCouponTotalCount(1); } /** * 淘宝商品构造 * * @param goods * @return */ public static CommonGoods create(JDGoods goods) { if (goods == null) return null; JDCommissionInfo commissionInfo = goods.getCommissionInfo(); if (commissionInfo != null) { cg.setRate(commissionInfo.getCommissionShare()); } else { cg.setRate(new BigDecimal(0)); } CommonGoods cg = new CommonGoods(); JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods); if (couponInfo != null) { cg.setCouponStartPrice(couponInfo.getQuota()); BigDecimal discount = couponInfo.getDiscount(); if (discount != null && discount.compareTo(new BigDecimal(0)) > 0) { cg.setCouponAmount(discount); if (cg.getCouponStartPrice().compareTo(new BigDecimal(0)) > 0) cg.setCouponInfo(String.format("满%s元减%s元", couponInfo.getQuota() + "", cg.getCouponAmount() + "")); else cg.setCouponInfo(String.format("%s元无条件券", cg.getCouponAmount() + "")); } else { cg.setCouponAmount(new BigDecimal(0)); } cg.setCouponLeftCount(1); cg.setCouponTotalCount(1); } JDShopInfo shopInfo = goods.getShopInfo(); if (shopInfo != null) { cg.setSellerId(Long.parseLong(shopInfo.getShopId().toString())); cg.setSellerName(shopInfo.getShopName() == null ? "" : shopInfo.getShopName()); } JDCommissionInfo commissionInfo = goods.getCommissionInfo(); if (commissionInfo != null) { cg.setRate(commissionInfo.getCommissionShare()); } else { cg.setRate(new BigDecimal(0)); } cg.setGoodsId(goods.getSkuId()); cg.setTitle(goods.getSkuName()); cg.setGoodsType(CommonGoods.GOODS_TYPE_JD); cg.setPicture(goods.getPicUrl()); cg.setPrice(goods.getPrice()); cg.setSales(Integer.parseInt(goods.getInOrderCount30Days().toString())); JDShopInfo shopInfo = goods.getShopInfo(); if (shopInfo != null) { cg.setSellerId(Long.parseLong(shopInfo.getShopId().toString())); cg.setSellerName(shopInfo.getShopName() == null ? "" : shopInfo.getShopName()); } String owner = goods.getOwner(); if (StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) { cg.setShopType(CommonGoods.SHOP_TYPE_JD_SELF); // 京东自营 } else { cg.setShopType(CommonGoods.SHOP_TYPE_JD); // 京东 } cg.setGoodsId(goods.getSkuId()); cg.setTitle(goods.getSkuName()); cg.setGoodsType(CommonGoods.GOODS_TYPE_JD); cg.setPicture(goods.getPicUrl()); cg.setPrice(goods.getPrice()); cg.setSales(Integer.parseInt(goods.getInOrderCount30Days().toString())); cg.setState(CommonGoods.STATE_NORMAL); String owner = goods.getOwner(); if (StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) { cg.setShopType(CommonGoods.SHOP_TYPE_JD_SELF); // 京东自营 } else { cg.setShopType(CommonGoods.SHOP_TYPE_JD); // 京东 } // 其他信息 GoodsOtherInfoDTO other = new GoodsOtherInfoDTO(); other.setOwner(owner); // 是否自营 other.setPinGouInfo(goods.getPinGouInfo()); // 拼购信息 other.setIsFreeShipping(goods.getIsFreeShipping()); // 是否包邮 cg.setOtherInfo(JSONObject.toJSON(other).toString()); cg.setState(CommonGoods.STATE_NORMAL); // 分类信息 JDCategoryInfo categoryJD = goods.getCategoryInfo(); if (categoryJD != null) { CategoryInfoDTO categoryInfo = new CategoryInfoDTO(); categoryInfo.setCid1(categoryJD.getCid1()); categoryInfo.setCid1Name(categoryJD.getCid1Name()); categoryInfo.setCid2(categoryJD.getCid2()); categoryInfo.setCid2Name(categoryJD.getCid2Name()); categoryInfo.setCid3(categoryJD.getCid3()); categoryInfo.setCid3Name(categoryJD.getCid3Name()); cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString()); } // 其他信息 GoodsOtherInfoDTO other = new GoodsOtherInfoDTO(); other.setOwner(owner); // 是否自营 other.setPinGouInfo(goods.getPinGouInfo()); // 拼购信息 other.setIsFreeShipping(goods.getIsFreeShipping()); // 是否包邮 cg.setOtherInfo(JSONObject.toJSON(other).toString()); // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); return cg; } // 分类信息 JDCategoryInfo categoryJD = goods.getCategoryInfo(); if (categoryJD != null) { CategoryInfoDTO categoryInfo = new CategoryInfoDTO(); categoryInfo.setCid1(categoryJD.getCid1()); categoryInfo.setCid1Name(categoryJD.getCid1Name()); categoryInfo.setCid2(categoryJD.getCid2()); categoryInfo.setCid2Name(categoryJD.getCid2Name()); categoryInfo.setCid3(categoryJD.getCid3()); categoryInfo.setCid3Name(categoryJD.getCid3Name()); cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString()); } public static CommonGoods create(PDDGoodsDetail goods) { if (goods == null) return null; // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); return cg; } CommonGoods cg = new CommonGoods(); public static CommonGoods create(PDDGoodsDetail goods) { if (goods == null) return null; if (goods.getCouponRemainQuantity() != null) cg.setCouponLeftCount(Integer.parseInt(goods.getCouponRemainQuantity() + "")); else cg.setCouponLeftCount(0); if (goods.getCouponMinOrderAmount() != null) cg.setCouponStartPrice( MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponMinOrderAmount()), new BigDecimal(100))); else cg.setCouponStartPrice(new BigDecimal(0)); CommonGoods cg = new CommonGoods(); if (goods.getCouponDiscount() != null && goods.getCouponDiscount() > 0) { cg.setCouponAmount(MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), new BigDecimal(100))); if (cg.getCouponStartPrice().compareTo(new BigDecimal(0)) > 0) cg.setCouponInfo(String.format("满%s元减%s元", cg.getCouponStartPrice() + "", cg.getCouponAmount() + "")); else cg.setCouponInfo(String.format("%s元无条件券", cg.getCouponAmount() + "")); } else { cg.setCouponAmount(new BigDecimal(0)); } if (goods.getCouponRemainQuantity() != null) cg.setCouponLeftCount(Integer.parseInt(goods.getCouponRemainQuantity() + "")); else cg.setCouponLeftCount(0); if (goods.getCouponMinOrderAmount() != null) cg.setCouponStartPrice( MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponMinOrderAmount()), new BigDecimal(100))); else cg.setCouponStartPrice(new BigDecimal(0)); cg.setCouponTotalCount(Integer.parseInt(goods.getCouponTotalQuantity() + "")); cg.setGoodsId(goods.getGoodsId()); cg.setGoodsType(CommonGoods.GOODS_TYPE_PDD); cg.setPicture(goods.getGoodsThumbnailUrl()); cg.setPictureWhite(null); cg.setPrice(MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100))); if (goods.getCouponDiscount() != null && goods.getCouponDiscount() > 0) { cg.setCouponAmount(MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), new BigDecimal(100))); if (cg.getCouponStartPrice().compareTo(new BigDecimal(0)) > 0) cg.setCouponInfo(String.format("满%s元减%s元", cg.getCouponStartPrice() + "", cg.getCouponAmount() + "")); else cg.setCouponInfo(String.format("%s元无条件券", cg.getCouponAmount() + "")); } else { cg.setCouponAmount(new BigDecimal(0)); } String salesTip = goods.getSalesTip(); if (StringUtil.isNullOrEmpty(salesTip)) { salesTip = "0"; } else { int indexOf = salesTip.indexOf("+"); if (indexOf > 0) { salesTip = salesTip.substring(0, indexOf); } } cg.setCouponTotalCount(Integer.parseInt(goods.getCouponTotalQuantity() + "")); cg.setGoodsId(goods.getGoodsId()); cg.setGoodsType(CommonGoods.GOODS_TYPE_PDD); cg.setPicture(goods.getGoodsThumbnailUrl()); cg.setPictureWhite(null); cg.setPrice(MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100))); int totalSales = 0; if (salesTip.contains("万")) { salesTip = salesTip.substring(0, salesTip.indexOf("万")); totalSales = (int) (Float.parseFloat(salesTip) * 10000); } else { totalSales = Integer.parseInt(salesTip); } cg.setSales(totalSales); cg.setRate(MoneyBigDecimalUtil.div(new BigDecimal(goods.getPromotionRate()), new BigDecimal(10))); cg.setSellerId(goods.getMallId()); cg.setSellerName(goods.getMallName()); cg.setShopType(CommonGoods.SHOP_TYPE_PDD); cg.setState(CommonGoods.STATE_NORMAL); cg.setTitle(goods.getGoodsName()); // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); cg.setState(goods.getState()); cg.setMaterialLibType(1); String salesTip = goods.getSalesTip(); if (StringUtil.isNullOrEmpty(salesTip)) { salesTip = "0"; } else { int indexOf = salesTip.indexOf("+"); if (indexOf > 0) { salesTip = salesTip.substring(0, indexOf); } } // 分类信息 CategoryInfoDTO categoryInfo = new CategoryInfoDTO(); categoryInfo.setCid1(goods.getCategoryId()); categoryInfo.setCid1Name(goods.getCategoryName()); cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString()); int totalSales = 0; if (salesTip.contains("万")) { salesTip = salesTip.substring(0, salesTip.indexOf("万")); totalSales = (int) (Float.parseFloat(salesTip) * 10000); } else { totalSales = Integer.parseInt(salesTip); } cg.setSales(totalSales); cg.setRate(MoneyBigDecimalUtil.div(new BigDecimal(goods.getPromotionRate()), new BigDecimal(10))); cg.setSellerId(goods.getMallId()); cg.setSellerName(goods.getMallName()); cg.setShopType(CommonGoods.SHOP_TYPE_PDD); cg.setState(CommonGoods.STATE_NORMAL); cg.setTitle(goods.getGoodsName()); // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); cg.setState(goods.getState()); cg.setMaterialLibType(1); return cg; } // 分类信息 CategoryInfoDTO categoryInfo = new CategoryInfoDTO(); categoryInfo.setCid1(goods.getCategoryId()); categoryInfo.setCid1Name(goods.getCategoryName()); cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString()); public static CommonGoods create(VIPGoodsInfo goods) { if (goods == null) return null; return cg; } CommonGoods cg = new CommonGoods(); public static CommonGoods create(VIPGoodsInfo goods) { if (goods == null) return null; // 折扣信息 cg.setCouponInfo(new BigDecimal(goods.getDiscount()) + ""); cg.setCouponLeftCount(0); cg.setCouponStartPrice(new BigDecimal(0)); cg.setCouponAmount(new BigDecimal(0)); CommonGoods cg = new CommonGoods(); cg.setCouponTotalCount(0); cg.setGoodsId(Long.parseLong(goods.getGoodsId())); cg.setGoodsType(CommonGoods.GOODS_TYPE_VIP); cg.setPicture(goods.getGoodsThumbUrl()); cg.setPictureWhite(null); cg.setPrice(new BigDecimal(goods.getMarketPrice())); // 折扣信息 cg.setCouponInfo(new BigDecimal(goods.getDiscount()) + ""); cg.setCouponLeftCount(0); cg.setCouponStartPrice(new BigDecimal(0)); cg.setCouponAmount(new BigDecimal(0)); int totalSales = 0; cg.setSales(totalSales); cg.setRate(new BigDecimal(goods.getCommissionRate())); cg.setSellerId(goods.getBrandId()); cg.setSellerName(goods.getBrandName()); cg.setShopType(CommonGoods.SHOP_TYPE_VIP); cg.setState(CommonGoods.STATE_NORMAL); cg.setTitle(goods.getGoodsName()); // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); cg.setState(goods.getStatus() == 1 ? CommonGoods.STATE_NORMAL : CommonGoods.STATE_OFFLINE); cg.setMaterialLibType(1); cg.setCouponTotalCount(0); cg.setGoodsId(Long.parseLong(goods.getGoodsId())); cg.setGoodsType(CommonGoods.GOODS_TYPE_VIP); cg.setPicture(goods.getGoodsThumbUrl()); cg.setPictureWhite(null); cg.setPrice(new BigDecimal(goods.getMarketPrice())); // 分类信息 CategoryInfoDTO categoryInfo = new CategoryInfoDTO(); categoryInfo.setCid1(goods.getCategoryId()); categoryInfo.setCid1Name(goods.getCategoryName()); cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString()); //存放折扣价 cg.setCouponStartPrice(new BigDecimal(goods.getVipPrice())); cg.setCouponInfo(MoneyBigDecimalUtil.getWithNoZera(MoneyBigDecimalUtil.mul(new BigDecimal(goods.getDiscount()), new BigDecimal(10))) + "折"); return cg; } int totalSales = 0; cg.setSales(totalSales); cg.setRate(new BigDecimal(goods.getCommissionRate())); cg.setSellerId(goods.getBrandId()); cg.setSellerName(goods.getBrandName()); cg.setShopType(CommonGoods.SHOP_TYPE_VIP); cg.setState(CommonGoods.STATE_NORMAL); cg.setTitle(goods.getGoodsName()); // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); cg.setState(goods.getStatus() == 1 ? CommonGoods.STATE_NORMAL : CommonGoods.STATE_OFFLINE); cg.setMaterialLibType(1); public static CommonGoods create(SuningGoodsInfo goods) { if (goods == null) return null; // 分类信息 CategoryInfoDTO categoryInfo = new CategoryInfoDTO(); categoryInfo.setCid1(goods.getCategoryId()); categoryInfo.setCid1Name(goods.getCategoryName()); cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString()); //存放折扣价 cg.setCouponStartPrice(new BigDecimal(goods.getVipPrice())); cg.setCouponInfo(MoneyBigDecimalUtil.getWithNoZera(MoneyBigDecimalUtil.mul(new BigDecimal(goods.getDiscount()), new BigDecimal(10))) + "折"); return cg; } CommonGoods cg = new CommonGoods(); public static CommonGoods create(SuningGoodsInfo goods) { if (goods == null) return null; if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {// 有券 cg.setCouponInfo(String.format("满%s元减%s元", goods.getCouponInfo().getBounsLimit(), goods.getCouponInfo().getCouponValue())); cg.setCouponAmount(new BigDecimal(goods.getCouponInfo().getCouponValue())); if (goods.getCouponInfo().getCouponCount() == null) { cg.setCouponLeftCount(500000); cg.setCouponTotalCount(500000); } else { cg.setCouponLeftCount(Integer.parseInt(goods.getCouponInfo().getCouponCount())); cg.setCouponTotalCount(Integer.parseInt(goods.getCouponInfo().getCouponCount())); } cg.setCouponStartPrice(new BigDecimal(goods.getCouponInfo().getBounsLimit())); } else { cg.setCouponLeftCount(0); cg.setCouponTotalCount(0); cg.setCouponAmount(new BigDecimal(0)); } CommonGoods cg = new CommonGoods(); cg.setGoodsId(Long.parseLong(goods.getCommodityInfo().getCommodityCode())); cg.setGoodsType(CommonGoods.GOODS_TYPE_SUNING); if (goods.getCommodityInfo().getPictureUrl() != null && goods.getCommodityInfo().getPictureUrl().size() > 0) cg.setPicture(goods.getCommodityInfo().getPictureUrl().get(0).getPicUrl()); cg.setPictureWhite(null); cg.setPrice(new BigDecimal(goods.getCommodityInfo().getSnPrice())); if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {// 有券 cg.setCouponInfo(String.format("满%s元减%s元", goods.getCouponInfo().getBounsLimit(), goods.getCouponInfo().getCouponValue())); cg.setCouponAmount(new BigDecimal(goods.getCouponInfo().getCouponValue())); cg.setSales(Integer.parseInt(goods.getCommodityInfo().getMonthSales())); cg.setRate(new BigDecimal(goods.getCommodityInfo().getRate())); cg.setSellerId(Long.parseLong(goods.getCommodityInfo().getSupplierCode())); cg.setSellerName(goods.getCommodityInfo().getSupplierName()); cg.setShopType(CommonGoods.SHOP_TYPE_SUNING); cg.setState(CommonGoods.STATE_NORMAL); cg.setTitle(goods.getCommodityInfo().getCommodityName()); // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); cg.setState(0); cg.setMaterialLibType(1); if (goods.getCouponInfo().getCouponCount() == null) { cg.setCouponLeftCount(500000); cg.setCouponTotalCount(500000); } else { cg.setCouponLeftCount(Integer.parseInt(goods.getCouponInfo().getCouponCount())); cg.setCouponTotalCount(Integer.parseInt(goods.getCouponInfo().getCouponCount())); } // 分类信息 CategoryInfoDTO categoryInfo = new CategoryInfoDTO(); categoryInfo.setCid1(Long.parseLong(goods.getCategoryInfo().getFirstSaleCategoryId())); categoryInfo.setCid1Name(goods.getCategoryInfo().getFirstSaleCategoryName()); cg.setCouponStartPrice(new BigDecimal(goods.getCouponInfo().getBounsLimit())); } else { cg.setCouponLeftCount(0); cg.setCouponTotalCount(0); cg.setCouponAmount(new BigDecimal(0)); } categoryInfo.setCid2(Long.parseLong(goods.getCategoryInfo().getSecondSaleCategoryId())); categoryInfo.setCid2Name(goods.getCategoryInfo().getSecondSaleCategoryName()); cg.setGoodsId(Long.parseLong(goods.getCommodityInfo().getCommodityCode())); cg.setGoodsType(CommonGoods.GOODS_TYPE_SUNING); if (goods.getCommodityInfo().getPictureUrl() != null && goods.getCommodityInfo().getPictureUrl().size() > 0) cg.setPicture(goods.getCommodityInfo().getPictureUrl().get(0).getPicUrl()); cg.setPictureWhite(null); cg.setPrice(new BigDecimal(goods.getCommodityInfo().getSnPrice())); cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString()); cg.setSales(Integer.parseInt(goods.getCommodityInfo().getMonthSales())); cg.setRate(new BigDecimal(goods.getCommodityInfo().getRate())); cg.setSellerId(Long.parseLong(goods.getCommodityInfo().getSupplierCode())); cg.setSellerName(goods.getCommodityInfo().getSupplierName()); cg.setShopType(CommonGoods.SHOP_TYPE_SUNING); cg.setState(CommonGoods.STATE_NORMAL); cg.setTitle(goods.getCommodityInfo().getCommodityName()); // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); cg.setState(0); cg.setMaterialLibType(1); return cg; } // 分类信息 CategoryInfoDTO categoryInfo = new CategoryInfoDTO(); categoryInfo.setCid1(Long.parseLong(goods.getCategoryInfo().getFirstSaleCategoryId())); categoryInfo.setCid1Name(goods.getCategoryInfo().getFirstSaleCategoryName()); categoryInfo.setCid2(Long.parseLong(goods.getCategoryInfo().getSecondSaleCategoryId())); categoryInfo.setCid2Name(goods.getCategoryInfo().getSecondSaleCategoryName()); cg.setCategoryInfo(JSONObject.toJSON(categoryInfo).toString()); return cg; } public static CommonGoods create(HaoDanKuPDDGoodsInfo goods) { if (goods == null) return null; CommonGoods cg = new CommonGoods(); if (goods.getCouponmoney() != null) { cg.setCouponAmount(goods.getCouponmoney()); cg.setCouponStartPrice(goods.getItemprice()); cg.setCouponInfo(String.format("满%s元减%s元", MoneyBigDecimalUtil.getWithNoZera(goods.getItemprice()) + "", MoneyBigDecimalUtil.getWithNoZera(cg.getCouponAmount()) + "")); } if (StringUtil.isNullOrEmpty(goods.getCouponnum())) cg.setCouponLeftCount(0); else cg.setCouponLeftCount(Integer.parseInt(goods.getCouponnum())); cg.setCouponTotalCount(1); cg.setRate(goods.getPromotion_rate()); cg.setSellerName(goods.getShopname()); cg.setGoodsId(Long.parseLong(goods.getGoods_id())); cg.setTitle(goods.getGoodsname()); cg.setGoodsType(CommonGoods.GOODS_TYPE_PDD); cg.setPicture(goods.getItempic()); cg.setPrice(goods.getItemprice()); cg.setSales(Integer.parseInt(goods.getItemsale())); cg.setShopType(CommonGoods.SHOP_TYPE_PDD); // 拼多多 cg.setState(CommonGoods.STATE_NORMAL); // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); return cg; } public static CommonGoods create(HaoDanKuJDGoodsInfo goods) { if (goods == null) return null; CommonGoods cg = new CommonGoods(); if (goods.getCouponmoney() != null) { cg.setCouponAmount(goods.getCouponmoney()); cg.setCouponStartPrice(goods.getItemprice()); cg.setCouponInfo(String.format("满%s元减%s元", MoneyBigDecimalUtil.getWithNoZera(goods.getItemprice()) + "", MoneyBigDecimalUtil.getWithNoZera(cg.getCouponAmount()) + "")); } cg.setCouponLeftCount(goods.getCouponnum()); cg.setCouponTotalCount(1); cg.setRate(goods.getCommissionshare()); cg.setSellerName(goods.getShopname()); cg.setGoodsId(Long.parseLong(goods.getSkuid())); cg.setTitle(goods.getGoodsname()); cg.setGoodsType(CommonGoods.GOODS_TYPE_JD); cg.setPicture(goods.getItempic()); cg.setPrice(goods.getItemprice()); cg.setSales(Integer.parseInt(goods.getItemsale())); cg.setShopType(CommonGoods.SHOP_TYPE_JD); // 拼多多 cg.setState(CommonGoods.STATE_NORMAL); // 保留字段 cg.setVideoCover(null); cg.setVideoUrl(null); return cg; } public static CommonGoods create(HDKGoodsDetail goods) { if (goods == null) return null; return CommonGoodsFactory.create(TaoBaoGoodsFactory.create(goods)); } } fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java
@@ -96,32 +96,35 @@ if (goodsType == Constant.SOURCE_TYPE_JD) { // 月销量 goodsInfo.setSalesType(1); Integer isFreeShipping = otherDTO.getIsFreeShipping(); if (isFreeShipping != null && isFreeShipping == 1) { goodsInfo.setBaoyou(true); } List<ClientTextStyleVO> labels = goodsInfo.getLabels(); // 自营 String owner = otherDTO.getOwner(); if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) { if (labels == null) { labels = new ArrayList<ClientTextStyleVO>(); JDPingouInfo pinGouInfo = null; List<ClientTextStyleVO> labels =null; if (otherDTO != null) { Integer isFreeShipping = otherDTO.getIsFreeShipping(); if (isFreeShipping != null && isFreeShipping == 1) { goodsInfo.setBaoyou(true); } ClientTextStyleVO textStyleVO = new ClientTextStyleVO(); textStyleVO.setContent("京东自营"); textStyleVO.setColor("#E42219"); labels.add(textStyleVO); labels = goodsInfo.getLabels(); // 自营 String owner = otherDTO.getOwner(); if (!StringUtil.isNullOrEmpty(owner) && "g".equalsIgnoreCase(owner)) { if (labels == null) { labels = new ArrayList<ClientTextStyleVO>(); } ClientTextStyleVO textStyleVO = new ClientTextStyleVO(); textStyleVO.setContent("京东自营"); textStyleVO.setColor("#E42219"); labels.add(textStyleVO); } // 拼团价 pinGouInfo = otherDTO.getPinGouInfo(); } // 拼团价 JDPingouInfo pinGouInfo = otherDTO.getPinGouInfo(); if (pinGouInfo != null) { goods.setPrice(pinGouInfo.getPingouPrice()); goodsInfo.setPriceName("拼购价"); if (labels == null) { labels = new ArrayList<ClientTextStyleVO>(); labels = new ArrayList<>(); } ClientTextStyleVO textStyleVO = new ClientTextStyleVO(); textStyleVO.setContent("拼购"); @@ -435,7 +438,7 @@ BigDecimal baseCommisstion = null; if (params.getBaseFanliRate() != null) baseCommisstion = TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getBaseFanliRate(), !isSpecialGoods); baseCommisstion = TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getBaseFanliRate(), !isSpecialGoods); moneyInfoVO.setFanliMoney("¥" + buyCommission); if (params.getMaxRewardRate() != null) moneyInfoVO @@ -446,7 +449,7 @@ BigDecimal rate = MoneyBigDecimalUtil.div(buyCommission.multiply(new BigDecimal(100)), price); moneyInfoVO.setRateInfo("返利比 " + rate + "%"); BigDecimal maxCommission = TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getVipFanLiRate(), !isSpecialGoods); BigDecimal maxCommission = TaoBaoUtil.getGoodsHongBaoMoney(goods, params.getVipFanLiRate(), !isSpecialGoods); BigDecimal maxRate = MoneyBigDecimalUtil.div(maxCommission.multiply(new BigDecimal(100)), price); moneyInfoVO.setMaxRateInfo("返利比 " + maxRate + "%"); moneyInfoVO.setMaxMoney("¥" + maxCommission); fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
@@ -323,16 +323,90 @@ } public static PDDPromotionUrl convertResourceUrl(String pid) { /** * 活动转链 https://open.pinduoduo.com/application/document/api?id=pdd.ddk.resource.url.gen * * @param resourceType * @param url * @param pid * @param customParams * @return */ public static PDDConvertLinkResultVO convertActivity(String resourceType, String url, String pid, String customParams) { Map<String, String> map = new HashMap<>(); map.put("type", "pdd.ddk.resource.url.gen"); map.put("pid", pid); map.put("resource_type", "39998"); map.put("url", "https://mobile.yangkeduo.com/attendance.html?_pdd_fs=1&_pdd_tc=ffffff&_pdd_sbs=1&type=1&id=155075"); if (customParams != null) { map.put("custom_parameters", customParams); } map.put("resource_type", resourceType); if (url != null) { map.put("url", url); } String result = baseRequest(map); JSONObject root = JSONObject.fromObject(result); JSONObject json = root.optJSONObject("resource_url_response"); if (json == null) { return null; } JSONObject urlJSON = json.optJSONObject("single_url_list"); PDDConvertLinkResultVO vo = null; Gson gson = new GsonBuilder().disableHtmlEscaping().create(); if (urlJSON != null) { vo = gson.fromJson(urlJSON.toString(), PDDConvertLinkResultVO.class); } JSONObject weAppInfo = json.optJSONObject("we_app_info"); if (weAppInfo != null && vo != null) { PDDConvertLinkResultVO.WeAppInfoBean weAppInfoBean = gson.fromJson(weAppInfo.toString(), PDDConvertLinkResultVO.WeAppInfoBean.class); vo.setWe_app_info(weAppInfoBean); } return vo; } /** * 频道推广(https://open.pinduoduo.com/application/document/api?id=pdd.ddk.cms.prom.url.generate) * * @param channelType * @param pid * @param customParams * @return */ public static PDDConvertLinkResultVO convertChannel(String channelType, String pid, String customParams) { Map<String, String> map = new HashMap<>(); map.put("type", "pdd.ddk.cms.prom.url.generate"); map.put("p_id_list", "[\"" + pid + "\"]"); if (customParams != null) { map.put("custom_parameters", customParams); } map.put("channel_type", channelType); map.put("generate_mobile", true+""); map.put("generate_short_url", true+""); map.put("generate_we_app", true+""); String result = baseRequest(map); System.out.println(result); return null; JSONObject root = JSONObject.fromObject(result); JSONObject json = root.optJSONObject("cms_promotion_url_generate_response"); if (json == null) { return null; } JSONObject urlJSON = json.optJSONArray("url_list").optJSONObject(0); PDDConvertLinkResultVO vo = null; Gson gson = new GsonBuilder().disableHtmlEscaping().create(); if (urlJSON != null) { vo = gson.fromJson(urlJSON.toString(), PDDConvertLinkResultVO.class); } return vo; } /** * 微信小程序转链 @Title: convertWXMP @Description: @param goodsId @param @@ -628,9 +702,11 @@ // PDDConvertLinkResultVO vo = getAuthLink(PID_SHARE, PinDuoDuoUtil.getCustomParams(437032l)); // // System.out.println(vo); PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(227873724698L); // PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(227873724698L); PDDConvertLinkResultVO vo = convertChannel("0", PID_DEFAULT, null); PinDuoDuoApiUtil.convert(goods.getGoodsSign(), PID_DEFAULT + "","437032", false); System.out.println(vo); // PinDuoDuoApiUtil.convert(goods.getGoodsSign(), PID_DEFAULT + "", "437032", false); } } fanli/src/main/java/com/yeshi/fanli/vo/goods/GoodsJumpLinkVO.java
@@ -5,7 +5,8 @@ /** * 跳转链接 */ public class GoodsJumpLinkVO { public class GoodsJumpLinkVO { private String jumpLink; private boolean _native; private String nativeJumpLink; fanli/src/main/resource/dubbo/consumer.xml
@@ -12,8 +12,15 @@ <dubbo:annotation package="com.yeshi.fanli"></dubbo:annotation> <dubbo:registry address="zookeeper://172.16.16.46:2181"/> <!--<dubbo:registry address="zookeeper://193.112.35.168:2182"/>--> <!-- url=dubbo://192.168.3.122:20882/com.yeshi.goods.facade.service.TaoBaoCouponCacheService --> <dubbo:reference id="taoBaoCouponCacheService" interface="com.yeshi.goods.facade.service.TaoBaoCouponCacheService" check="false" version="1.0.0"/> <dubbo:reference id="taoBaoCouponCacheService" interface="com.yeshi.goods.facade.service.TaoBaoCouponCacheService" check="false" version="1.0.0"/> <dubbo:consumer> </dubbo:consumer> </beans> fanli/src/main/resource/env-dev/consumer.xml
@@ -11,7 +11,7 @@ <dubbo:annotation package="com.yeshi.fanli"></dubbo:annotation> <dubbo:registry address="zookeeper://193.112.35.168:2181"/> <dubbo:registry address="zookeeper://193.112.35.168:2182"/> <!-- url=dubbo://192.168.3.122:20882/com.yeshi.goods.facade.service.TaoBaoCouponCacheService --> fanli/src/main/resource/env-pro/consumer.xml
@@ -11,9 +11,10 @@ <dubbo:annotation package="com.yeshi.fanli"></dubbo:annotation> <dubbo:registry address="zookeeper://172.16.16.46:2181"/> <dubbo:registry address="zookeeper://172.16.16.46:2181"/> <!-- url=dubbo://192.168.3.122:20882/com.yeshi.goods.facade.service.TaoBaoCouponCacheService --> <dubbo:reference id="taoBaoCouponCacheService" interface="com.yeshi.goods.facade.service.TaoBaoCouponCacheService" check="false" version="1.0.0"/> <dubbo:reference id="taoBaoCouponCacheService" interface="com.yeshi.goods.facade.service.TaoBaoCouponCacheService" check="false" version="1.0.0"/> </beans> fanli/src/main/resource/kafka_log.properties
New file @@ -0,0 +1,9 @@ log.config.kafka.isSend=true log.config.kafka.bootstrapServers= 134.175.68.214:9092 log.config.kafka.topic= log_fanli_error log.config.kafka.batchSize=5 log.config.kafka.lingerMs=1000 log.config.kafka.compressionType=gzip log.config.kafka.retries=3 log.config.kafka.maxRequestSize=5242880 fanli/src/main/resource/log4j.properties
File was deleted fanli/src/main/resource/logback.xml
@@ -11,12 +11,16 @@ <property name="log.level" value="debug"/> <!--归档日志文件保存的最大时间(单位跟按什么轮转有关,比如按天轮转那么单位就为天) --> <property name="log.maxHistory" value="30"/> <!-- 单个日志的文件大小 --> <property name="log.maxSize" value="20MB"/> <!--日志存储的根路径 ${catalina.base}指向每个Tomcat目录私有信息的位置, 就是conf、logs、temp、webapps和work的父目录--> <property name="log.filePath" value="/usr/local/tomcat/logs"/> <property name="log.filePath" value="/tmp/logs"/> <!--日志展示的格式--> <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n"/> <property resource="kafka_log.properties"></property> <!--appender是为了配置日志信息输出到哪个地方--> <!--控制台设置,输出到控制台中--> @@ -31,9 +35,47 @@ <!-- ERROR --> <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/error/error.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/error/error.%d{yyyy-MM-dd}.log.zip</fileNamePattern> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/error/error.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>ERROR</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> </appender> <appender name="USER_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/user/user.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/user/user.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="ORDER" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/order/order.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/order/order.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> @@ -43,10 +85,344 @@ </layout> </appender> <appender name="USER_ORDER" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/user_order/user_order.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/user_order/user_order.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="TEST" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/test/test.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/test/test.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="HTTP" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/http/http.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/http/http.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="TAOBAO_LINK" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/taobao_link/taobao_link.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/taobao_link/taobao_link.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="SHARE_GOODS" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/share-goods/share-goods.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/share-goods/share-goods.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="LOGIN" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/login/login.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/login/login.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="SMS" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/sms/sms.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/sms/sms.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="REQUEST" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/request/request.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/request/request.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="REQUEST_TIME" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/request_time/request_time.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/request_time/request_time.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="JOB" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/job/job.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/job/job.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="MQ" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/mq/mq.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/mq/mq.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="VIP_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/vip_info/vip_info.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/vip_info/vip_info.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="TEAM" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/team/team.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/team/team.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="CLOUD" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/cloud/cloud.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/cloud/cloud.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <appender name="PUSH" class="ch.qos.logback.core.rolling.RollingFileAppender"> <file>${log.filePath}/push/push.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <fileNamePattern>${log.filePath}/push/push.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern> <maxHistory>${log.maxHistory}</maxHistory> <maxFileSize>${log.maxSize}</maxFileSize> </rollingPolicy> <layout class="ch.qos.logback.classic.PatternLayout"> <pattern> ${log.pattern} </pattern> </layout> </appender> <!-- 读取配置文件中kafka的信息 --> <property name="isSend" value="${log.config.kafka.isSend}"/> <property name="bootstrapServers" value="${log.config.kafka.bootstrapServers}"/> <property name="topic" value="${log.config.kafka.topic}"/> <property name="batchSize" value="${log.config.kafka.batchSize}"/> <property name="lingerMs" value="${log.config.kafka.lingerMs}"/> <property name="compressionType" value="${log.config.kafka.compressionType}"/> <property name="retries" value="${log.config.kafka.retries}"/> <property name="maxRequestSize" value="${log.config.kafka.maxRequestSize}"/> <appender name="KAFKA_ERROR" class="com.yeshi.fanli.log.KafkaAppender"> <!-- encoder必须配置, 日志格式 --> <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> <!--<pattern>--> <!--%red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %highlight(%-5level) %green([%thread]) %boldMagenta(%logger{10}) - %cyan(%msg%n)--> <!--</pattern>--> <!--为了便于分析将日志数据转为json格式--> <pattern>${log.pattern}</pattern> <!-- 控制台也要使用UTF-8,不要使用GBK,否则会中文乱码 --> <charset>UTF-8</charset> </encoder> <bootstrapServers>${bootstrapServers}</bootstrapServers> <topic>${topic}</topic> <batchSize>${batchSize}</batchSize> <lingerMs>${lingerMs}</lingerMs> <compressionType>${compressionType}</compressionType> <retries>${retries}</retries> <maxRequestSize>${maxRequestSize}</maxRequestSize> <isSend>${isSend}</isSend> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>ERROR</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> </appender> <!--name表示为哪一个logger指定层级和输出的方式 additivity表示叠加祖先的输出方式(默认为true,会叠加),所以com.lxc.o2o以及其子类都会输出在控制台中,因为这个logger继承了root中的appender level表示级别大于等于${log.level}的信息才会输出,输出方式为配置的appender, 由于这里level为debug(重写了,就不会继承root的level了), 所以控制台中会输出大于等于debug等级的日志(包括持久层执行的mysql) 并且 debug日志会输出到debugAppender指定的文件中 info日志会输出到infoAppender指定的文件中 error日志会输出到errorAppender指定的文件中--> <logger name="userInfoLog" level="INFO" additivity="false"> <appender-ref ref="USER_INFO"></appender-ref> </logger> <logger name="orderLog" level="INFO" additivity="false"> <appender-ref ref="ORDER"></appender-ref> </logger> <logger name="userOrderLog" level="INFO" additivity="false"> <appender-ref ref="USER_ORDER"></appender-ref> </logger> <logger name="testLog" level="INFO" additivity="false"> <appender-ref ref="TEST"></appender-ref> </logger> <logger name="httpLog" level="INFO" additivity="false"> <appender-ref ref="HTTP"></appender-ref> </logger> <logger name="taoBaoLinkLog" level="INFO" additivity="false"> <appender-ref ref="TAOBAO_LINK"></appender-ref> </logger> <logger name="shareGoodsLog" level="INFO" additivity="false"> <appender-ref ref="SHARE_GOODS"></appender-ref> </logger> <logger name="loginLog" level="INFO" additivity="false"> <appender-ref ref="LOGIN"></appender-ref> </logger> <logger name="smsLog" level="INFO" additivity="false"> <appender-ref ref="SMS"></appender-ref> </logger> <logger name="requestLog" level="INFO" additivity="false"> <appender-ref ref="REQUEST"></appender-ref> </logger> <logger name="requestTimeLog" level="INFO" additivity="false"> <appender-ref ref="REQUEST_TIME"></appender-ref> </logger> <logger name="jobLog" level="INFO" additivity="false"> <appender-ref ref="JOB"></appender-ref> </logger> <logger name="mqLog" level="INFO" additivity="false"> <appender-ref ref="MQ"></appender-ref> </logger> <logger name="vipInfoLog" level="INFO" additivity="false"> <appender-ref ref="VIP_INFO"></appender-ref> </logger> <logger name="teamLog" level="INFO" additivity="false"> <appender-ref ref="TEAM"></appender-ref> </logger> <logger name="cloudLog" level="INFO" additivity="false"> <appender-ref ref="CLOUD"></appender-ref> </logger> <logger name="pushLog" level="INFO" additivity="false"> <appender-ref ref="PUSH"></appender-ref> </logger> <!-- 一切logger都会继承自root,root默认的层级level为debug --> <root> <level value="INFO"/> <!--在控制台中输出所在层级对应level(以及大于level)的日志信息,因为这里并没有设置LevelFilter--> <appender-ref ref="STDOUT"></appender-ref> <appender-ref ref="ERROR_FILE"></appender-ref> <appender-ref ref="KAFKA_ERROR"></appender-ref> </root> </configuration> fanli/src/main/resource/mapping/HistorySearchMapper.xml
File was deleted fanli/src/main/resource/mapping/homemodule/SpecialMapper.xml
@@ -492,7 +492,7 @@ AND IF(sp.`b_min_ios_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_ios_version_code,TRUE) </if> <include refid="Sex_Screen" /> <if test="sex == null"> ORDER BY sp.`b_orderby`</if> <if test="sex == null"> ORDER BY sp.b_end_time,sp.`b_orderby`</if> LIMIT ${start},${count} </select> fanli/src/main/resource/spring.xml
@@ -40,6 +40,7 @@ <value>classpath:rocketmq.properties</value> <value>classpath:xxl-job-executor.properties</value> <value>classpath:elasticsearch.properties</value> <value>classpath:kafka_log.properties</value> </array> </property> </bean> pom.xml
@@ -357,6 +357,16 @@ <groupId>com.qcloud</groupId> <artifactId>cos_api</artifactId> <version>5.2.4</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> </exclusions> </dependency> <dependency> @@ -391,6 +401,16 @@ <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>1.0.2.RELEASE</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> <exclusion> <groupId>log4j</groupId> <artifactId>log4j</artifactId> </exclusion> </exclusions> </dependency>