admin
2021-01-27 e1a62ec62e7331d97af9302e90e1ce44af8235eb
fanli/src/main/java/com/yeshi/fanli/controller/wxmp/v1/GoodsController.java
@@ -10,6 +10,8 @@
import javax.annotation.Resource;
import com.yeshi.fanli.entity.SystemEnum;
import com.yeshi.fanli.util.*;
import org.json.simple.JSONArray;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -32,10 +34,10 @@
import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
import com.yeshi.fanli.dto.pdd.PDDPromotionUrl;
import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
import com.yeshi.fanli.entity.bus.user.ShamUser;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.jd.JDGoodsClass;
@@ -51,6 +53,7 @@
import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
import com.yeshi.fanli.service.inter.jd.JDGoodsClassService;
import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.user.QrCodeService;
import com.yeshi.fanli.service.inter.user.ShamUserService;
@@ -58,12 +61,7 @@
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.JumpDetailUtil;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.ThreadUtil;
import com.yeshi.fanli.util.VersionUtil;
import com.yeshi.common.entity.PageEntity;
import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
import com.yeshi.fanli.util.factory.CommonGoodsFactory;
@@ -80,6 +78,7 @@
import com.yeshi.fanli.vo.goods.RewardCouponVO;
import com.yeshi.fanli.vo.goods.ShareVO;
import com.yeshi.fanli.vo.goods.ShopInfoVO;
import com.yeshi.fanli.vo.homemodule.BannerVO;
import net.sf.json.JSONObject;
@@ -98,6 +97,9 @@
   @Resource
   private HongBaoManageService hongBaoManageService;
   @Resource
   private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
   @Resource
   private UserInfoExtraService userInfoExtraService;
@@ -146,12 +148,14 @@
    */
   @RequestMapping(value = "getTopCategory", method = RequestMethod.POST)
   public void getTopCategory(WXMPAcceptData acceptData, Long uid, PrintWriter out) {
      SystemEnum system= SystemInfoUtil.getSystemByWXCXCAppId(acceptData.getAppId());
      JSONObject data = new JSONObject();
      data.put("list", configService.get(ConfigKeyEnum.jdWXMPClass.getKey()));
      data.put("list", configService.getValue(ConfigKeyEnum.jdWXMPClass.getKey(),system));
      String tips = null;
      if (uid == null || uid <= 0) {
         tips = configService.get(ConfigKeyEnum.tipGuideNewUser.getKey());
         tips = configService.getValue(ConfigKeyEnum.tipGuideNewUser.getKey(),system);
      } else {
         long rebateOrder = hongBaoV2CountService.countRebateOrder(uid);
         long shareOrInviteOrder = hongBaoV2CountService.countShareOrInviteOrder(uid);
@@ -159,13 +163,13 @@
            // 熟客版
         } else if (rebateOrder <= 0 && shareOrInviteOrder <= 0) {
            // 新人版
            tips = configService.get(ConfigKeyEnum.tipGuideNewUser.getKey());
            tips = configService.getValue(ConfigKeyEnum.tipGuideNewUser.getKey(),system);
         } else if (rebateOrder > 0 && shareOrInviteOrder <= 0) {
            // 省钱版
            tips = configService.get(ConfigKeyEnum.tipGuideSaveMoney.getKey());
            tips = configService.getValue(ConfigKeyEnum.tipGuideSaveMoney.getKey(),system);
         } else {
            // 赚钱版
            tips = configService.get(ConfigKeyEnum.tipGuideShareInvite.getKey());
            tips = configService.getValue(ConfigKeyEnum.tipGuideShareInvite.getKey(),system);
         }
      }
@@ -195,13 +199,13 @@
         // 轮播图
         String platform = acceptData.getPlatform();
         int version = Integer.parseInt(acceptData.getVersion());
         List<SwiperPicture> picList = swiperPictureService.getByBannerCardAndVersion("index_top", platform,
               version);
         List<BannerVO> picList = swiperPictureService.getByBannerCardAndVersion("index_top", platform,
               version,acceptData.getSystem());
         if (picList == null) {
            picList = new ArrayList<>();
         }
         for (SwiperPicture swiper : picList) {
         for (BannerVO swiper : picList) {
            JSONObject params = null;
            if (StringUtil.isNullOrEmpty(swiper.getParams())) {
               params = JSONObject.fromObject(swiper.getParams());
@@ -231,8 +235,8 @@
         if (goodsList != null && goodsList.size() > 0) {
            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
                  .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
            ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
                  acceptData.getVersion());
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                  acceptData.getVersion(),acceptData.getSystem());
            for (JDGoods goods : goodsList) {
               GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO);
               if (goodsDetailVO.isHasCoupon()) {
@@ -254,7 +258,6 @@
    * @param goodsId
    *            商品id
    * @param uid
    * @param code
    *            邀请码
    * @param goodsType
    *            商品类型
@@ -313,14 +316,20 @@
      // 保存缓存
      jdGoodsCacheUtil.saveGoodsInfo(jdGoods);
      ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
            acceptData.getVersion());
      ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
            acceptData.getVersion(),acceptData.getSystem());
      paramsDTO.setMaxRewardRate(null);
      GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
      if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
         goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
         goodsDetail.getMoneyInfo()
               .setShareMoney("¥" + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getVIPShareRate()));
               .setShareMoney("¥" + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate(UserLevelEnum.superVIP,acceptData.getSystem())));
         goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
         goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
      }
      goodsDetail.getMoneyInfo()
            .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(),acceptData.getSystem()));
      // 附加信息
      OtherInfo otherInfo = new OtherInfo();
@@ -339,12 +348,12 @@
               jdGoods.setCommissionPlus(threeClass.getSelfComm());
               // plus返利
               BigDecimal fanliMoneyPlus = JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
                     hongBaoManageService.getFanLiRate());
                     hongBaoManageService.getFanLiRate(acceptData.getSystem()));
               otherInfo.setFanliMoneyPlus("京东plus返¥" + fanliMoneyPlus);
               // 使用奖励券最高返
               maxMoneyPlus = "(京东plus返¥"
                     + JDUtil.getGoodsFanLiMoneyPlus(jdGoods, hongBaoManageService.getVIPFanLiRate()) + ")";
                     + JDUtil.getGoodsFanLiMoneyPlus(jdGoods, hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem())) + ")";
            }
         }
@@ -364,7 +373,7 @@
         // 券链接处理
         String materialId = "https://item.jd.com/" + id + ".html";
         String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(),
               JDApiUtil.POSITION_COUPON + "", null);
               null,JDApiUtil.POSITION_COUPON + "", null);
         couponInfo.setLink(url);
      }
@@ -381,14 +390,14 @@
      // IOS是否正在上线
      if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
         String version = acceptData.getVersion();
         extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
         extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version),acceptData.getSystem()));
      }
      Long inOrderCount30Days = jdGoods.getInOrderCount30Days();
      List<ShamUser> listShareUser = new ArrayList<ShamUser>();
      // 京东开启分享
      String open = configService.get(ConfigKeyEnum.shareOpenJD.getKey());
      String open = configService.getValue(ConfigKeyEnum.shareOpenJD.getKey(),acceptData.getSystem());
      if ("1".equals(open.trim())) {
         extraVO.setShareValid(true);
         MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
@@ -420,7 +429,7 @@
      extraVO.setDetailUrl("https://in.m.jd.com/product/jieshao/video/" + id + ".html");
      // 商品链接
      String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
      String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()),
            Constant.systemCommonConfig.getShareGoodsPagePathJD(), "", id + "");
      try {
         extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
@@ -432,7 +441,7 @@
      extraVO.setFanliValid(true);
      if (StringUtil.isNullOrEmpty(helpLink)) {
         helpLink = configService.get(ConfigKeyEnum.noRebateHelpLink.getKey());
         helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(),acceptData.getSystem());
      }
      ShareVO shareInfoVO = new ShareVO();
@@ -477,13 +486,14 @@
         return;
      }
      ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
            acceptData.getVersion());
      ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
            acceptData.getVersion(),acceptData.getSystem());
      paramsDTO.setMaxRewardRate(null);
      GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
      if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
         goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
         goodsDetail.getMoneyInfo().setShareMoney(
               "¥" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, hongBaoManageService.getVIPShareRate()));
               "¥" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, hongBaoManageService.getShareRate(UserLevelEnum.superVIP,acceptData.getSystem())));
      }
      if (goodsDetail.getCouponInfo() != null) {
@@ -505,7 +515,7 @@
      CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
      PDDPromotionUrl convertUrl = null;
      if (couponInfo != null) {
         convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_COUPON + "", null);
         convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_COUPON + "", null,false);
         if (convertUrl != null)
            couponInfo.setLink(convertUrl.getUrl());
      }
@@ -562,7 +572,7 @@
      }
      // 分享路径
      String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
      String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()),
            Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
      try {
         extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
@@ -575,7 +585,7 @@
      extraVO.setShareValid(true);
      if (StringUtil.isNullOrEmpty(helpLink)) {
         helpLink = configService.get(ConfigKeyEnum.noRebateHelpLink.getKey());
         helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(),acceptData.getSystem());
      }
      ShareVO shareInfoVO = new ShareVO();
@@ -635,8 +645,8 @@
               list = list.subList(0, 10);
            }
            ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
                  acceptData.getVersion());
            ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
                  acceptData.getVersion(),acceptData.getSystem());
            List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
            for (JDGoods goods : list) {
@@ -668,7 +678,7 @@
               Long[] strings = new Long[goodsIdList.size()];
               pddfilter.setGoodsIdList(goodsIdList.toArray(strings));
               PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
               PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter,Constant.PDD_SEARCH_CUSTOMER_PARAMS);
               if (result != null) {
                  List<PDDGoodsDetail> goodsList = result.getGoodsList();
                  if (goodsList != null && goodsList.size() > 0) {
@@ -677,8 +687,8 @@
                        goodsList = goodsList.subList(0, 10);
                     }
                     ConfigParamsDTO paramsDTO = hongBaoManageService
                           .getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion());
                     ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService
                           .getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion(),acceptData.getSystem());
                     for (PDDGoodsDetail goods : goodsList) {
                        listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO));
                     }
@@ -711,7 +721,6 @@
    * @param goodsId
    *            商品id
    * @param uid
    * @param code
    *            邀请码
    * @param goodsType
    *            商品类型
@@ -770,7 +779,7 @@
         if (share) {
            position = JDApiUtil.POSITION_SHARE;
         }
         String jdLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, position + "", subUnionId);
         String jdLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null,position + "", subUnionId);
         try {
            jumpLink = "/pages/union/proxy/proxy?spreadUrl=" + URLEncoder.encode(jdLink, "UTF-8");
         } catch (Exception e) {
@@ -864,8 +873,8 @@
         out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
         return;
      }
      ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
            acceptData.getVersion());
      ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
            acceptData.getVersion(),acceptData.getSystem());
      GoodsDetailVO goods = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
      String scene = goodsType + "#" + goodsId + "#" + inviteCode;
@@ -922,8 +931,8 @@
         out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
         return;
      }
      ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
            acceptData.getVersion());
      ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
            acceptData.getVersion(),acceptData.getSystem());
      GoodsDetailVO goods = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
      String scene = goodsType + "#" + goodsId + "#" + inviteCode;