admin
2020-11-28 dc5be7d38446f70e6ff86df311119c32b41fe7f8
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
@@ -29,15 +29,16 @@
import com.google.gson.stream.JsonWriter;
import com.yeshi.fanli.dto.ConfigParamsDTO;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail.TaoLiJinDetailTypeEnum;
import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinNewbies;
import com.yeshi.fanli.entity.bus.user.UserMoneyExtra;
import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.taobao.ShareHotGoods;
import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
import com.yeshi.fanli.entity.taobao.TLJFreeBuyGoods;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBriefExtra;
import com.yeshi.fanli.exception.user.UserInfoException;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.ConfigService;
@@ -48,6 +49,7 @@
import com.yeshi.fanli.service.inter.money.UserMoneyExtraService;
import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
import com.yeshi.fanli.service.inter.monitor.MonitorService;
import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.redpack.UserTaoLiJinNewbiesService;
import com.yeshi.fanli.service.inter.taobao.ShareHotGoodsService;
@@ -63,15 +65,16 @@
import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.TaoBaoConstant;
import com.yeshi.fanli.util.TimeUtil;
import org.yeshi.utils.TimeUtil;
import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
import com.yeshi.fanli.vo.goods.GoodsDetailVO;
import com.yeshi.fanli.vo.goods.MoneyInfoVO;
import com.yeshi.fanli.vo.goods.OtherInfo;
import com.yeshi.fanli.vo.goods.taobao.TLJBuyHongBaoVO;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import com.yeshi.goods.facade.entity.taobao.TLJBuyHongBaoVO;
import com.yeshi.fanli.vo.homemodule.BannerVO;
import com.yeshi.common.vo.ClientTextStyleVO;
import com.yeshi.fanli.vo.redpack.TaoLiJinWinDetailVO;
import com.yeshi.fanli.vo.tlj.ReduceHongBao;
import com.yeshi.fanli.vo.tlj.SpreadHongBao;
@@ -147,13 +150,15 @@
   @Resource
   private SwiperPictureService swiperPictureService;
   @Resource
   private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
   @Resource
   private TLJFreeBuyGoodsService tljFreeBuyGoodsService;
   
   @Resource
   private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
   /**
    * 获取淘礼金分享记录
@@ -379,8 +384,6 @@
      out.print(JsonUtil.loadTrueResult(data));
   }
   /**
    * 分享爆款商品-限于淘礼金
    * 
@@ -414,7 +417,7 @@
         }
      }
      BigDecimal proportion = hongBaoManageService.getTLJShareRate(System.currentTimeMillis());
      BigDecimal proportion = hongBaoManageService.getTLJShareRate(System.currentTimeMillis(),acceptData.getSystem());
      for (ShareHotGoods hotGoods : listHot) {
         TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods();
         if (taoBaoGoodsBrief == null) {
@@ -488,9 +491,8 @@
         }
      }
      BigDecimal fanLiRate = hongBaoManageService.getTLJShareRate(System.currentTimeMillis());
      BigDecimal shareRate = hongBaoManageService.getTLJShareRate(System.currentTimeMillis());
       ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate());
      ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
            acceptData.getVersion(),acceptData.getSystem());
      for (ShareHotGoods hotGoods : listHot) {
         TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods();
@@ -508,7 +510,7 @@
         }
         GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO);
         // 大于1.6.5的才会显示福利价
         if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
            if (detailVO.getCouponPrice() != null && detailVO.getCouponPrice().compareTo(new BigDecimal(0)) > 0)
@@ -516,7 +518,7 @@
            else
               detailVO.setZkPrice(detailVO.getZkPrice().subtract(spreadMoney));
         }
         // 去掉标签
         detailVO.setLabels(null);
@@ -558,7 +560,6 @@
    * 分享爆款商品-限于淘礼金
    * 
    * @param acceptData
    * @param uid
    * @param out
    */
   @RequestMapping(value = "getBuyGoods", method = RequestMethod.POST)
@@ -582,7 +583,7 @@
         }
         // 计算推广红包
         BigDecimal spreadMoney = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, proportion);
         BigDecimal spreadMoney = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, proportion,true);
         // 推广红包 不能小于1
         if (spreadMoney.compareTo(new BigDecimal(1.0)) < 0) {
@@ -616,14 +617,15 @@
      data.put("count", array.size());
      data.put("list", array);
      if (page == 1) {
         List<SwiperPicture> bannerList = swiperPictureService.getByBannerCard("zigoulijian_banner");
         List<BannerVO> bannerList = swiperPictureService.getByBannerCardAndVersion("zigoulijian_banner",
               acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()),acceptData.getSystem());
         if (bannerList != null && bannerList.size() > 0)
            data.put("topPicture", bannerList.get(0).getSrc());
         else
            data.put("topPicture", "");
         data.put("ruleUrl", configService.get("zigoulijian_rule"));
         data.put("ruleUrl", configService.getValue(ConfigKeyEnum.zigoulijianRule.getKey(),acceptData.getSystem()));
      }
      out.print(JsonUtil.loadTrueResult(data));
   }
@@ -632,7 +634,6 @@
    * 分享爆款商品-限于淘礼金
    * 
    * @param acceptData
    * @param uid
    * @param out
    */
   @RequestMapping(value = "getBuyGoodsV2", method = RequestMethod.POST)
@@ -649,7 +650,8 @@
            .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
      BigDecimal proportion = TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE;
      ConfigParamsDTO paramsDTO = new ConfigParamsDTO(proportion, proportion, Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate());
      ConfigParamsDTO paramsDTO = new ConfigParamsDTO(proportion, proportion, Constant.MAX_REWARD_RATE,
            hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP,acceptData.getSystem()));
      for (TLJBuyGoods hotGoods : listHot) {
         TaoBaoGoodsBrief taoBaoGoodsBrief = hotGoods.getGoods();
         if (taoBaoGoodsBrief == null) {
@@ -657,7 +659,7 @@
         }
         // 计算推广红包
         BigDecimal spreadMoney = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, proportion);
         BigDecimal spreadMoney = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, proportion,true);
         // 推广红包 不能小于1
         if (spreadMoney.compareTo(new BigDecimal(1.0)) < 0) {
@@ -703,14 +705,15 @@
      data.put("count", array.size());
      data.put("list", array);
      if (page == 1) {
         List<SwiperPicture> bannerList = swiperPictureService.getByBannerCard("zigoulijian_banner");
         List<BannerVO> bannerList = swiperPictureService.getByBannerCardAndVersion("zigoulijian_banner",
               acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()),acceptData.getSystem());
         if (bannerList != null && bannerList.size() > 0)
            data.put("topPicture", bannerList.get(0).getSrc());
         else
            data.put("topPicture", "");
         data.put("ruleUrl", configService.get("zigoulijian_rule"));
         data.put("ruleUrl", configService.getValue(ConfigKeyEnum.zigoulijianRule.getKey(),acceptData.getSystem()));
      }
      out.print(JsonUtil.loadTrueResult(data));
   }
@@ -728,8 +731,6 @@
      out.print(JsonUtil.loadFalseResult(1, "抱歉,推广红包相关功能已下线!"));
   }
   /**
    * 新人红包详情
    * 
@@ -752,8 +753,9 @@
         }
         // 2、顶部轮播图
         List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("redpack_win_detail_banner");
         List<SwiperPicture> topPicList = new ArrayList<>();
         List<BannerVO> oldtopPicList = swiperPictureService.getByBannerCardAndVersion(
               "redpack_win_detail_banner", acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()),acceptData.getSystem());
         List<BannerVO> topPicList = new ArrayList<>();
         if (oldtopPicList != null && oldtopPicList.size() > 0)
            topPicList.addAll(oldtopPicList);
@@ -765,8 +767,7 @@
         out.print(JsonUtil.loadFalseResult(1, "红包已被抢光啦"));
      }
   }
   /**
    * 新人免单列表
    * @param acceptData
@@ -779,31 +780,32 @@
         JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
         return;
      }
      String day = TimeUtil.getGernalTime(java.lang.System.currentTimeMillis());
      List<TLJFreeBuyGoods> listFree = tljFreeBuyGoodsService.listByDay(day);
      if (listFree == null) {
         listFree = new ArrayList<TLJFreeBuyGoods>();
      }
      JSONArray array = new JSONArray();
      Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
            .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
      BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
      ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, fanLiRate, Constant.MAX_REWARD_RATE,hongBaoManageService.getVIPFanLiRate());
      ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
            acceptData.getVersion(),acceptData.getSystem());
      for (TLJFreeBuyGoods freeGoods : listFree) {
         TaoBaoGoodsBrief goods = freeGoods.getGoods();
         if (goods == null)
            continue;
         // 计算券后价  1<= n <= 2
         // 计算券后价 1<= n <= 2
         BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(goods);
         if (couplePrice.compareTo(new BigDecimal(1.0)) < 0 && couplePrice.compareTo(new BigDecimal(2.0)) > 0)
            continue;
         GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
         // 专属标签
         List<ClientTextStyleVO> labels = new ArrayList<ClientTextStyleVO>();
         labels.add(new ClientTextStyleVO("新人专属", "#FE0014"));
@@ -825,12 +827,12 @@
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, e.getMsg()));
            return;
         }
         String state = "已过期";
         BigDecimal balance = new BigDecimal(0);
         UserTaoLiJinNewbies winDetail = userTaoLiJinNewbiesService.selectByPrimaryKey(uid);
         if (winDetail != null) {
            balance = winDetail.getMoney() ;
            balance = winDetail.getMoney();
            if (winDetail.getEndTime().getTime() > java.lang.System.currentTimeMillis()) {
               try {
                  String remaining = DateUtil.dateDiff2(new Date(), winDetail.getEndTime());
@@ -841,10 +843,13 @@
               }
            }
         }
         String rule = configTaoLiJinService.getValueByKey("new_user_free_buy_list_rule");
         rule = rule.replace("{链接}", configService.getValue(ConfigKeyEnum.customerServiceLink.getKey(),acceptData.getSystem()));
         data.put("state", state);
         data.put("balance","新人红包:" + balance.setScale(2) + "元");
         data.put("rule", configTaoLiJinService.getValueByKey("new_user_free_buy_list_rule"));
         data.put("balance", "新人红包:" + balance.setScale(2) + "元");
         data.put("rule", rule);
      }
      JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
   }