yujian
2019-09-27 41aedac31eb4c5b9f7b98bacec18c45b3926d69c
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/GoodsControllerV2.java
@@ -3,6 +3,7 @@
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
@@ -24,6 +25,7 @@
import com.yeshi.fanli.entity.bus.user.ShamUser;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.UserMoneyExtra;
import com.yeshi.fanli.entity.common.JumpDetailV2;
import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
import com.yeshi.fanli.entity.jd.JDGoods;
import com.yeshi.fanli.entity.system.BusinessSystem;
@@ -38,13 +40,15 @@
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
import com.yeshi.fanli.service.inter.config.BusinessSystemService;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service;
import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service;
import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
import com.yeshi.fanli.service.inter.money.UserMoneyExtraService;
import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
@@ -58,8 +62,9 @@
import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.UserMoneyExtraService;
import com.yeshi.fanli.service.inter.user.integral.IntegralGetService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
import com.yeshi.fanli.util.TaoBaoConstant;
@@ -82,6 +87,7 @@
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.RewardCouponVO;
import com.yeshi.fanli.vo.goods.ShareVO;
import com.yeshi.fanli.vo.goods.ShopInfoVO;
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
@@ -168,6 +174,12 @@
   @Resource
   private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
   @Resource
   private IntegralGetService integralGetService;
   @Resource
   private JumpDetailV2Service jumpDetailV2Service;
   /**
    * 淘宝商品详情
@@ -412,7 +424,7 @@
      // 推广红包
      if (from != null && from.equals("taolijin")) {
         // 计算推广红包
         String warningRate = configTaoLiJinService.getValueByKey("warning_value");
         String warningRate = configTaoLiJinService.getValueByKey("warning_value", new Date());
         BigDecimal spreadMoney = TaoLiJinUtil.getSpreadMoney(warningRate, goods);
         // 推广红包 不能小于1
@@ -421,8 +433,8 @@
            return;
         }
         // 是否为新用户
         boolean isNewUser = userInfoExtraService.isNewUser(uid);
         // 取消新用户自购
         boolean isNewUser = false;// userInfoExtraService.isNewUser(uid);
         if (isNewUser) {
            // 判定为老用户: 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。
            long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
@@ -466,6 +478,20 @@
         otherInfo.setSpreadHongBao(spreadHongBao);
         goodsDetail.setOtherInfo(otherInfo);
         // 1.6.5后改为福利价
         if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
            if (goodsDetail.getCouponPrice() != null
                  && goodsDetail.getCouponPrice().compareTo(new BigDecimal(0)) > 0)
               goodsDetail.setCouponPrice(goodsDetail.getCouponPrice().subtract(spreadMoney));
            else
               goodsDetail.setZkPrice(goodsDetail.getZkPrice().subtract(spreadMoney));
         }
         goodsDetail.getMoneyInfo().setFanliMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods,
               hongBaoManageService.getTLJShareRate(System.currentTimeMillis())));
         goodsDetail.getMoneyInfo().setShareMoney(TaoBaoUtil.getGoodsHongBaoInfo(goods,
               hongBaoManageService.getTLJShareRate(System.currentTimeMillis())));
         // 用户淘礼金
         UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid);
         if (userMoneyExtra == null || userMoneyExtra.getTlj() == null) {
@@ -473,7 +499,7 @@
         } else {
            extraVO.setUserTLJ(userMoneyExtra.getTlj().setScale(2).toString());
         }
         helpLink = configTaoLiJinService.getValueByKey("share_goods_help_link");
         helpLink = configTaoLiJinService.getValueByKey("share_goods_help_link", new Date());
      } else if (from != null && from.equals("taolijin_buy")) {
         // 查询分享库
@@ -489,17 +515,38 @@
         shareValid = false;
         helpLink = configService.get("zigoulijian_nofanli_help");
         String tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, new BigDecimal(70)).toString();
         BigDecimal tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE);
         ReduceHongBao reduceHongBao = new ReduceHongBao();
         reduceHongBao.setLeft(buyGoods.getLeftHongBaoCount());
         reduceHongBao.setMoney(tljHongBao);
         reduceHongBao.setMoney(tljHongBao.toString());
         reduceHongBao.setName("付款立减 ");
         reduceHongBao.setTip("当日领取,当日内使用,过期失效");
         reduceHongBao.setTotal(buyGoods.getTotalHongBaoCount());
         OtherInfo otherInfo = new OtherInfo();
         otherInfo.setReduceHongBao(reduceHongBao);
         goodsDetail.setOtherInfo(otherInfo);
         // 1.6.5后改为福利价
         if (com.yeshi.fanli.util.VersionUtil.greaterThan_1_6_5(acceptData.getPlatform(), acceptData.getVersion())) {
            if (goodsDetail.getCouponPrice() != null
                  && goodsDetail.getCouponPrice().compareTo(new BigDecimal(0)) > 0)
               goodsDetail.setCouponPrice(goodsDetail.getCouponPrice().subtract(tljHongBao));
            else
               goodsDetail.setZkPrice(goodsDetail.getZkPrice().subtract(tljHongBao));
         }
      } else {// 普通购买
         OtherInfo otherInfo = new OtherInfo();
         RewardCouponVO rewardCoupon = new RewardCouponVO();
         rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("integralExchange"));
         JSONObject params1=new JSONObject();
         params1.put("balanceMore", true);
         rewardCoupon.setParams(params1.toString());
         rewardCoupon.setMaxMoney("¥" +TaoBaoUtil.getGoodsHongBaoMoney(goods, fanLiRate).add( MoneyBigDecimalUtil.mul(TaoBaoUtil.getGoodsHongBaoMoney(goods, fanLiRate),
               Constant.MAX_REWARD_RATE)));
         rewardCoupon.setDesc("用返利奖励券最高返");
         otherInfo.setRewardCoupon(rewardCoupon);
         goodsDetail.setOtherInfo(otherInfo);
      }
      extraVO.setFanliValid(fanliValid);
@@ -580,6 +627,19 @@
      BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
      BigDecimal shareRate = hongBaoManageService.getShareRate();
      GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, fanLiRate, shareRate);
      // 附加信息
      OtherInfo otherInfo = new OtherInfo();
      RewardCouponVO rewardCoupon = new RewardCouponVO();
      rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("integralExchange"));
      JSONObject params1=new JSONObject();
      params1.put("balanceMore", true);
      rewardCoupon.setParams(params1.toString());
      rewardCoupon.setMaxMoney(
            "¥" +JDUtil.getGoodsFanLiMoney(jdGoods, fanLiRate).add( MoneyBigDecimalUtil.mul(JDUtil.getGoodsFanLiMoney(jdGoods, fanLiRate), Constant.MAX_REWARD_RATE)));
      rewardCoupon.setDesc("用返利奖励券最高返");
      otherInfo.setRewardCoupon(rewardCoupon);
      goodsDetail.setOtherInfo(otherInfo);
      CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
      if (couponInfo != null) {
@@ -715,6 +775,20 @@
      BigDecimal fanLiRate = hongBaoManageService.getFanLiRate();
      BigDecimal shareRate = hongBaoManageService.getShareRate();
      GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, fanLiRate, shareRate);
      // 附加信息
      OtherInfo otherInfo = new OtherInfo();
      RewardCouponVO rewardCoupon = new RewardCouponVO();
      rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("integralExchange"));
      JSONObject params1=new JSONObject();
      params1.put("balanceMore", true);
      rewardCoupon.setParams(params1.toString());
      rewardCoupon.setMaxMoney("¥" +PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, fanLiRate).add(MoneyBigDecimalUtil.mul(PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, fanLiRate),
            Constant.MAX_REWARD_RATE)));
      rewardCoupon.setDesc("用返利奖励券最高返");
      otherInfo.setRewardCoupon(rewardCoupon);
      goodsDetail.setOtherInfo(otherInfo);
      CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
      PDDPromotionUrl convertUrl = null;
      if (couponInfo != null) {
@@ -937,9 +1011,7 @@
         try {
            goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids);
         } catch (TaoKeApiException e1) {
            e1.printStackTrace();
         } catch (TaobaoGoodsDownException e1) {
            e1.printStackTrace();
         }
         if (goodsList != null && goodsList.size() > 0) {
@@ -1042,6 +1114,9 @@
      data.put("native", true);
      data.put("jumpLink", jumpLink);
      out.print(JsonUtil.loadTrueResult(data));
      // 获得金币
      integralGetService.addCouponRebate(uid);
   }
   /**
@@ -1084,6 +1159,9 @@
      data.put("jumpLink", convertUrl.getUrl());
      data.put("nativeJumpLink", PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
      out.print(JsonUtil.loadTrueResult(data));
      // 获得金币
      integralGetService.addCouponRebate(uid);
   }
   /**