yujian
2019-07-23 a39422f2a8ce45dd6cf65701ed5f9e65391c46c1
Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div
2个文件已修改
131 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -98,12 +98,10 @@
    @Resource
    private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
    @Resource(name = "taskExecutor")
    private TaskExecutor executor;
    /**
     * 粘贴板信息推荐
     * 
@@ -145,37 +143,13 @@
                out.print(JsonUtil.loadFalseResult("值过长"));
                return;
            }
            SearchFilter sf = new SearchFilter();
            sf.setKey(text);
            JSONObject root = new JSONObject();
            TaoBaoSearchResult result = TaoBaoUtil.search(sf);
            if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0)
                for (TaoBaoGoodsBrief goods : result.getTaoBaoGoodsBriefs()) {
                    // 是属于淘宝联盟商品
                    if (goods.getTitle().equalsIgnoreCase(text)) {
                        root.put("type", 2);
                        JSONObject data = new JSONObject();
                        data.put("title", goods.getTitle());
                        root.put("data", data);
                        out.print(JsonUtil.loadTrueResult(root));
                        return;
                    }
                }
            // 查询大淘客标题
            List<DaTaoKeDetail> list = daTaoKeGoodsDetailService.listByDtitle(text);
            if (list != null && list.size() > 0) {
                root.put("type", 2);
                JSONObject data = new JSONObject();
                data.put("title", list.get(0).getdTitle());
                root.put("data", data);
                out.print(JsonUtil.loadTrueResult(root));
                return;
            }
            out.print(JsonUtil.loadFalseResult("暂不支持该类型!"));
            root.put("type", 2);
            JSONObject data = new JSONObject();
            data.put("title", text);
            root.put("data", data);
            out.print(JsonUtil.loadTrueResult(root));
            return;
        }
@@ -236,9 +210,7 @@
        out.print(JsonUtil.loadTrueResult(root));
    }
    /**
     * 搜索候选词
     * 
@@ -281,32 +253,33 @@
     * @param kw
     * @param page
     * @param filter
     * @param order      销量由高到低:1 、 价格从高到低:2 、 价格从低到高:3 、 推广量高到低:4(综合默认)、返利比高到低:5
     *                   、返利比低到高:6 、推荐20
     * @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, Integer goodsType, String key, Integer page, String filter, Integer order,
            PrintWriter out) {
        if (goodsType == null || goodsType < 1 || goodsType >3) {
    public void searchGoods(AcceptData acceptData, Integer goodsType, String key, Integer page, String filter,
            Integer order, PrintWriter out) {
        if (goodsType == null || goodsType < 1 || goodsType > 3) {
            out.print(JsonUtil.loadFalseResult(1, "请传递正确平台参数"));
            return;
        }
        if (page == null || page < 1) {
            out.print(JsonUtil.loadFalseResult(1, "页码不能小于1"));
            return;
        }
        if (StringUtil.isNullOrEmpty(key)) {
            out.print(JsonUtil.loadFalseResult(1, "请输入搜索内容"));
            return;
        }
        final String searchkey = key.trim();
        executor.execute(new Runnable() {
            @Override
            public void run() {
@@ -317,12 +290,11 @@
                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);
            }
        });
        if (searchkey.startsWith("http://") || searchkey.startsWith("https://")) {
            JSONObject data = new JSONObject();
@@ -332,19 +304,19 @@
            return;
        }
        /*--------- 京东商品  -------*/
        /*--------- 京东商品  -------*/
        if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) {
            searchJDGoods(searchkey, page, filter, order, out);
            return;
        }
        /*-------- 拼多多商品  -------*/
        /*-------- 拼多多商品  -------*/
        if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) {
            searchPDDGoods(searchkey, page, filter, order, out);
            return;
        }
        /*-------- 淘宝商品  -------*/
        /*-------- 淘宝商品  -------*/
        searchTaoBaoGoods(searchkey, page, filter, order, out);
    }
@@ -375,25 +347,25 @@
            } else if (order == 4) { // 返利比高到低
                sf.setSort(TaoBaoUtil.SORT_TKRATE_HIGH_TO_LOW);
            }
        }
        }
        if (!StringUtil.isNullOrEmpty(filter)) {
            JSONObject jsonfilter = JSONObject.fromObject(filter);
            Boolean coupon = jsonfilter.optBoolean("coupon");
            if (coupon != null && coupon) {
                sf.setQuan(1); // 有券
            }
            Boolean tmall = jsonfilter.optBoolean("tmall");
            if (tmall != null && tmall) {
                sf.setTmall(true); // 天猫
            }
            String minPrice = jsonfilter.optString("minPrice");
            if (!StringUtil.isNullOrEmpty(minPrice)) {
                sf.setStartPrice(new BigDecimal(minPrice));
            }
            String maxPrice = jsonfilter.optString("maxPrice");
            if (!StringUtil.isNullOrEmpty(maxPrice)) {
                sf.setEndPrice(new BigDecimal(maxPrice));
@@ -405,10 +377,10 @@
        if (page == 1) {
            daTaoKeList = daTaoKeGoodsDetailService.listByDtitle(key);
        }
        // 淘宝api搜索商品
        TaoBaoSearchResult result = TaoBaoUtil.search(sf);
        // 搜索是否在营销主商品库
        if (result != null && result.getTaoBaoGoodsBriefs() != null && result.getTaoBaoGoodsBriefs().size() > 0) {
            ThreadUtil.run(new Runnable() {
@@ -420,7 +392,7 @@
                }
            });
        }
        List<TaoBaoGoodsBrief> taoBaoGoodsBriefs = null;
        if (result != null) {
            taoBaoGoodsBriefs = result.getTaoBaoGoodsBriefs();
@@ -428,7 +400,7 @@
        if (taoBaoGoodsBriefs == null) {
            taoBaoGoodsBriefs = new ArrayList<>();
        }
        if (daTaoKeList != null && daTaoKeList.size() > 0) {
            try {
                Collections.reverse(daTaoKeList);
@@ -438,7 +410,7 @@
            } catch (Exception e) {
            }
        }
        List<GoodsDetailVO> list = new ArrayList<GoodsDetailVO>();
        BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
        BigDecimal shareRate = hongBaoManageService.getShareRate();
@@ -448,7 +420,7 @@
        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                .excludeFieldsWithoutExposeAnnotation().create();
        JSONObject data = new JSONObject();
        data.put("result", gson.toJson(list));
        data.put("count", result.getTaoBaoHead().getDocsfound());
@@ -464,7 +436,6 @@
        out.print(JsonUtil.loadTrueResult(data));
    }
    /**
     * 京东
     * 
@@ -477,7 +448,7 @@
     * @return
     */
    private void searchJDGoods(String key, Integer page, String filter, Integer order, PrintWriter out) {
        JDSearchResult result = null;
        String way = configService.get("jd_api_search_key");
        if ("1".equals(way)) {
@@ -510,31 +481,29 @@
                }
            }
            if (!StringUtil.isNullOrEmpty(filter)) {
                JSONObject jsonfilter = JSONObject.fromObject(filter);
                Boolean coupon = jsonfilter.optBoolean("coupon");
                if (coupon != null && coupon) {
                    filterAPI.setIsCoupon(1); // 有券
                }
                Boolean zy = jsonfilter.optBoolean("zy");
                if (zy != null && zy) {
                    filterAPI.setOwner("g"); // 自营
                }
                String minPrice = jsonfilter.optString("minPrice");
                if (!StringUtil.isNullOrEmpty(minPrice)) {
                    filterAPI.setPricefrom(Double.parseDouble(minPrice));
                }
                String maxPrice = jsonfilter.optString("maxPrice");
                if (!StringUtil.isNullOrEmpty(maxPrice)) {
                    filterAPI.setPriceto(Double.parseDouble(maxPrice));
                }
            }
            result = JDApiUtil.queryByKey(filterAPI);
        } else {
            // 网页爬取
@@ -573,39 +542,39 @@
                if (coupon != null && coupon) {
                    jdfilter.setHasCoupon(1); // 有券
                }
                Boolean zy = jsonfilter.optBoolean("zy");
                if (zy != null && zy) {
                    jdfilter.setIsZY(1); // 自营
                }
                Boolean delivery = jsonfilter.optBoolean("delivery");
                if (delivery != null && delivery) {
                    jdfilter.setDeliveryType(1); // 京东配送
                }
                String minPrice = jsonfilter.optString("minPrice");
                if (!StringUtil.isNullOrEmpty(minPrice)) {
                    if(minPrice.contains(".")) {
                    if (minPrice.contains(".")) {
                        minPrice = minPrice.replace(".", "-");
                        minPrice = minPrice.split("-")[0];
                    }
                    jdfilter.setFromPrice(Integer.parseInt(minPrice));
                }
                String maxPrice = jsonfilter.optString("maxPrice");
                if (!StringUtil.isNullOrEmpty(maxPrice)) {
                    if(maxPrice.contains(".")) {
                    if (maxPrice.contains(".")) {
                        maxPrice = maxPrice.replace(".", "-");
                        maxPrice =  maxPrice.split("-")[0];
                        maxPrice = maxPrice.split("-")[0];
                    }
                    jdfilter.setToPrice(Integer.parseInt(maxPrice));
                }
            }
            result = JDUtil.searchByKey(jdfilter);
        }
        long count = 0;
        JSONObject data = new JSONObject();
        JSONArray array = new JSONArray();
@@ -671,14 +640,14 @@
                break;
            }
        }
        if (!StringUtil.isNullOrEmpty(filter)) {
            JSONObject jsonfilter = JSONObject.fromObject(filter);
            Boolean coupon = jsonfilter.optBoolean("coupon");
            if (coupon != null && coupon) {
                pddfilter.setHasCoupon(true); // 有券
            }
            Boolean brand = jsonfilter.optBoolean("brand");
            if (brand != null && brand) {
                pddfilter.setIsBrand(true); // 是否是品牌
@@ -697,7 +666,7 @@
            if (goodsList != null && goodsList.size() > 0) {
                BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
                BigDecimal shareRate = hongBaoManageService.getShareRate();
                for (PDDGoodsDetail goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate,
                            shareRate);
@@ -705,7 +674,7 @@
                }
            }
        }
        data.put("result", array);
        data.put("count", count);
        out.print(JsonUtil.loadTrueResult(data));
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
@@ -955,7 +955,7 @@
            hb.setMoney(hongBao.getMoney());
            try {
                userShareGoodsGroupService.updateOrderRecord(hb);
                userShareGoodsGroupService.updateOrderRecord(hb,commonOrder.getSourceType());
            } catch (UserShareGoodsRecordException e) {
                try {
                    LogHelper.errorDetailInfo(e);