yujian
2019-07-22 44c965a94d5860af792f091462e739325544fb95
搜索京东、拼多多优化
9个文件已修改
131 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/SearchControllerV2.java
@@ -587,11 +587,19 @@
                
                String minPrice = jsonfilter.optString("minPrice");
                if (!StringUtil.isNullOrEmpty(minPrice)) {
                    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(".")) {
                        maxPrice = maxPrice.replace(".", "-");
                        maxPrice =  maxPrice.split("-")[0];
                    }
                    jdfilter.setToPrice(Integer.parseInt(maxPrice));
                }
            }
@@ -685,6 +693,7 @@
        PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
        if (result != null) {
            count = result.getTotalCount();
            Gson gson = JsonUtil.getApiCommonGson();
            List<PDDGoodsDetail> goodsList = result.getGoodsList();
            if (goodsList != null && goodsList.size() > 0) {
                BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
@@ -693,11 +702,11 @@
                for (PDDGoodsDetail goods : goodsList) {
                    GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, null, fanLiRate,
                            shareRate);
                    array.add(GsonUtil.toJsonExpose(goodsDetailVO));
                    array.add(gson.toJson(goodsDetailVO));
                }
            }
        }
        data.put("result", array);
        data.put("count", count);
        out.print(JsonUtil.loadTrueResult(data));
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/ShareControllerV2.java
@@ -705,7 +705,7 @@
        }
        shareText = shareText.replace("{店铺类型}", shopType)
                .replace("{月销量}", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity())).replace("{领券短链}", shortLink)
                .replace("{月销量}", goods.getSalesTip()).replace("{领券短链}", shortLink)
                .replace("{淘口令}", null);
        shareInfo.setShareText(shareText);
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsTextTemplateServiceImpl.java
@@ -353,10 +353,10 @@
            String shortLink, boolean hasCoupon, String token) {
        if (!hasCoupon) {
            template = template.replace("{标题}", goods.getGoodsName()).replace("{商品原价}",  BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())).toString())
                    .replace("{总销量}", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity())).replace("{短链接}", shortLink);
                    .replace("{总销量}", goods.getSalesTip()).replace("{短链接}", shortLink);
        } else {
            template = template.replace("{标题}", goods.getGoodsName()).replace("{商品原价}", BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getMinNormalPrice())).toString())
                    .replace("{总销量}", PinDuoDuoUtil.getSaleCount(goods.getSoldQuantity())).replace("{短链接}", shortLink)
                    .replace("{总销量}", goods.getSalesTip()).replace("{短链接}", shortLink)
                    .replace("{优惠券面额}", BigDecimalUtil.getWithNoZera(new BigDecimal(goods.getCouponDiscount())).toString())
                    .replace("{优惠券价}", BigDecimalUtil.getWithNoZera( PinDuoDuoUtil.getQuanPrice(goods)).toString());
        }
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -508,8 +508,12 @@
                }
            }
            
            // 邀请隐藏订单号
             if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
            // 邀请 隐藏订单号
            if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) {
                 String orderNo = order.getOrderNo();
                 orderNo = orderNo.substring(0, orderNo.length()-6);
                 order.setOrderNo(orderNo + "******");
            } else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType
                    || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType
                    || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
                 String orderNo = order.getOrderNo();
fanli/src/main/java/com/yeshi/fanli/util/factory/CommonGoodsFactory.java
@@ -148,7 +148,16 @@
        cg.setPicture(goods.getGoodsThumbnailUrl());
        cg.setPictureWhite(null);
        cg.setPrice(MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinNormalPrice()), new BigDecimal(100)));
        cg.setSales(Integer.parseInt(goods.getSoldQuantity() + ""));
        String salesTip = goods.getSalesTip();
        if (StringUtil.isNullOrEmpty(salesTip)) {
            salesTip = "0";
        }
        if (salesTip.contains("万")) {
            salesTip = salesTip.replace("万", "") + "0000";
        }
        cg.setSales(Integer.parseInt(salesTip));
        cg.setRate(MoneyBigDecimalUtil.div(new BigDecimal(goods.getPromotionRate()), new BigDecimal(10)));
        cg.setSellerId(goods.getMallId());
        cg.setSellerName(goods.getMallName());
fanli/src/main/java/com/yeshi/fanli/util/factory/goods/GoodsDetailVOFactory.java
@@ -423,8 +423,8 @@
        goodsInfo.setGoodsId(goods.getGoodsId());
        goodsInfo.setTitle(goods.getGoodsName());
        goodsInfo.setSalesType(4); // 总销量
        goodsInfo.setPicUrl(goods.getGoodsImageUrl());
        goodsInfo.setZkPrice(new BigDecimal(goods.getMinNormalPrice()));
        goodsInfo.setPicUrl(goods.getGoodsThumbnailUrl()); // 缩略图
        goodsInfo.setZkPrice(MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), new BigDecimal(100)).setScale(2));
        goodsInfo.setShopType(30); // 拼多多
        String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
@@ -440,19 +440,11 @@
        }
        // 总销量
        String salesCountMidea = null;
        Long soldQuantity = goods.getSoldQuantity();
        if (soldQuantity == null)
            soldQuantity = 0L;
        if (soldQuantity < 10000) {
            salesCountMidea = soldQuantity + "";
        } else {
            double sales = soldQuantity;
            salesCountMidea = String.format("%.1f", sales / 10000);
            salesCountMidea = salesCountMidea + "万";
        String salesTip = goods.getSalesTip();
        if (StringUtil.isNullOrEmpty(salesTip)) {
            salesTip = "0";
        }
        goodsInfo.setSalesCount(salesCountMidea);
        goodsInfo.setSalesCount(salesTip);
        // 资金信息
        MoneyInfoVO moneyInfoVO = new MoneyInfoVO();
@@ -463,10 +455,11 @@
        Boolean hasCoupon = goods.getHasCoupon();
        if (hasCoupon != null && hasCoupon) {
            BigDecimal amount = new BigDecimal(goods.getCouponDiscount());
            BigDecimal price = new BigDecimal(goods.getMinNormalPrice());
            BigDecimal startFree = new BigDecimal(goods.getCouponMinOrderAmount());
            BigDecimal hundred = new BigDecimal(100);
            BigDecimal amount = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred).setScale(2);
            BigDecimal price = MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), hundred).setScale(2);
            BigDecimal startFree = MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponMinOrderAmount()), hundred).setScale(2);
            // 计算券后价
            if (startFree.compareTo(price) <= 0) {
                BigDecimal quanPrice = MoneyBigDecimalUtil.sub(price, amount);
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java
@@ -239,9 +239,6 @@
        if (filter.getIsPG() != null)
            json.put("isPG", filter.getIsPG());
        if (filter.getIsCoupon() != null)
            json.put("isCoupon", filter.getIsCoupon());
        if (filter.getPingouPriceStart() != null)
            json.put("pingouPriceStart", filter.getPingouPriceStart());
@@ -256,6 +253,10 @@
        if (filter.getShopId() != null)
            json.put("shopId", filter.getShopId());
        if (filter.getOwner() != null)
            json.put("owner", filter.getOwner());
        System.out.println(json.toString());
        
        JSONObject jsonDTO = new JSONObject();
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
@@ -10,8 +10,6 @@
import java.util.List;
import java.util.Map;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.yeshi.utils.HttpUtil;
import com.google.gson.Gson;
@@ -98,7 +96,7 @@
        
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        List<PDDGoodsDetail> goodsList = gson.fromJson(array.toString(), type);
        int totalCount = json.optInt("total_count");
        int totalCount = root.optInt("total_count");
        return new PDDGoodsResult(totalCount, goodsList);
    }
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoUtil.java
@@ -35,30 +35,25 @@
     */
    public static BigDecimal getGoodsFanLiMoney(PDDGoodsDetail goods, BigDecimal rate) {
        BigDecimal money = null;
        BigDecimal price = new BigDecimal(goods.getMinNormalPrice());
        BigDecimal promotionRate = new BigDecimal(goods.getPromotionRate());
        BigDecimal hundred = new BigDecimal(100);
        rate = MoneyBigDecimalUtil.div(rate, hundred);
        BigDecimal price =  MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), hundred).setScale(2);
        BigDecimal promotionRate =  MoneyBigDecimalUtil.div(new BigDecimal(goods.getPromotionRate()), new BigDecimal(1000));
        
        Boolean hasCoupon = goods.getHasCoupon();
        if (hasCoupon == null || !hasCoupon) {
            money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
                    MoneyBigDecimalUtil.mul(price, promotionRate),new BigDecimal("0.001")),
                    MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
            money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(price, promotionRate), rate);
        } else {
            BigDecimal amount = new BigDecimal(goods.getCouponDiscount());
            BigDecimal startFree = new BigDecimal(goods.getCouponMinOrderAmount());
            BigDecimal amount =  MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred);
            BigDecimal startFree =  MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponMinOrderAmount()), hundred);
            if (startFree.compareTo(price) <= 0 && price.compareTo(amount) > 0) {
                BigDecimal finalPrice = price.subtract(amount);
                money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil
                        .mul(MoneyBigDecimalUtil.mul(finalPrice, promotionRate), new BigDecimal("0.001")),
                        MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
                money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(finalPrice, promotionRate),rate);
            } else {// 不能用券
                money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
                        MoneyBigDecimalUtil.mul(price,promotionRate), new BigDecimal("0.001")),
                        MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
                money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(price,promotionRate), rate);
            }
        }
        return BigDecimalUtil.getWithNoZera(money);
        return BigDecimalUtil.getWithNoZera(money).setScale(2);
    }
    
@@ -69,37 +64,23 @@
     * @return
     */
    public static BigDecimal getQuanPrice(PDDGoodsDetail goods) {
        BigDecimal price = new BigDecimal(goods.getMinNormalPrice());
        BigDecimal hundred = new BigDecimal(100);
        BigDecimal price =  MoneyBigDecimalUtil.div(new BigDecimal(goods.getMinGroupPrice()), hundred);
        Boolean hasCoupon = goods.getHasCoupon();
        if (hasCoupon == null || !hasCoupon) {
            return price;
            return price.setScale(2);
        }
        
        BigDecimal amount = new BigDecimal(goods.getCouponDiscount());
        BigDecimal startFree = new BigDecimal(goods.getCouponMinOrderAmount());
        BigDecimal amount =  MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponDiscount()), hundred);
        BigDecimal startFree =  MoneyBigDecimalUtil.div(new BigDecimal(goods.getCouponMinOrderAmount()), hundred);
        if (startFree.compareTo(price) <= 0) {
            BigDecimal quanPrice = MoneyBigDecimalUtil.sub(price, amount);
            return quanPrice;
            return quanPrice.setScale(2);
        } else {
            return price;
            return price.setScale(2);
        }
    }
    
    public static String getSaleCount(long count) {
        String salesCountMidea = null;
        if (count < 10000) {
            salesCountMidea = count + "";
        } else {
            double sales = count;
            salesCountMidea = String.format("%.1f", sales / 10000);
            salesCountMidea = salesCountMidea + "万";
        }
        return salesCountMidea;
    }
    public static List<String> getDetailImages(Long id) {
        List<String> imgList = new ArrayList<>();