fanli/src/main/java/com/yeshi/fanli/controller/client/v1/ConfigController.java
@@ -111,7 +111,7 @@ // 无新人弹框 则查询默认 if (floatAD == null) { floatAD = floatADService.getEffectiveFloatAD(FloatAD.POSITION_INDEX, null); floatAD = floatADService.getEffectiveFloatAD(FloatAD.POSITION_INDEX, 0); } if (floatAD != null) { fanli/src/main/java/com/yeshi/fanli/controller/client/v1/GoodsController.java
@@ -153,199 +153,11 @@ // 是返利商品库的商品 if (specialConvert) { if (!StringUtil.isNullOrEmpty(specialId)) { taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId); data.put("native", true); } else { if (!specialConvert && !isNative) { if (pidType == PidUser.TYPE_FANLI_ANDROID) taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId, tbPidService.getAndroidDefault().getPid()); else taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId, tbPidService.getIOSDefault().getPid()); } else taoBaoLink = shareGoodsService.getTaoBaoLinkForBuy(uid, auctionId, pidType); LogHelper.test("购买转链:默认PID转链-" + uid + ":" + auctionId); } } else {// 不是返利库的商品,用特殊PID替代 try { relationId = taoBaoBuyRelationMapService.getRelationId(uid); } catch (Exception e) { LogHelper.errorDetailInfo(e, "uid:" + uid, null); } if (!StringUtil.isNullOrEmpty(relationId)) {// taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId, TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID); data.put("native", true); } else { if (pidType == PidUser.TYPE_FANLI_ANDROID) taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId, tbPidService.getAndroidDefault().getPid()); else taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId, tbPidService.getIOSDefault().getPid()); LogHelper.test("购买转链:默认PID转链-非返利库商品-" + uid + ":" + auctionId); } } JSONObject link = new JSONObject(); link.put("clickUrl", taoBaoLink.getClickUrl()); link.put("couponUrl", taoBaoLink.getCouponLink()); data.put("type", 1); data.put("link", link); out.print(JsonUtil.loadTrueResult(data)); } catch (Exception e) { isNative = false; try { monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "购买淘宝商品转链出错")); } catch (Exception e1) { e1.printStackTrace(); } TBPid tbPid = null; if (acceptData.getPlatform().equalsIgnoreCase("android")) { tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_FANLI_ANDROID); } else { tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_FANLI_IOS); } LogHelper.test("购买转链:默认PID转链-异常商品-" + uid + ":" + auctionId); data.put("native", isNative); if (tbPid != null) { try { TaoBaoLink taoBaoLink = null; if (pidType == PidUser.TYPE_FANLI_ANDROID) taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId, tbPidService.getAndroidDefault().getPid()); else taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId, tbPidService.getIOSDefault().getPid()); JSONObject link = new JSONObject(); link.put("clickUrl", taoBaoLink.getClickUrl()); link.put("couponUrl", taoBaoLink.getCouponLink()); data.put("type", 1); data.put("link", link); data.put("native", true); } catch (Exception e1) { String siteId = tbPid.getPid().split("_")[2]; String adzoneId = tbPid.getPid().split("_")[3]; TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId); ClientTBPid clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId); data.put("type", 2); data.put("tbPidInfo", clientTBPid); data.put("native", true); } out.print(JsonUtil.loadTrueResult(data)); } else { out.print(JsonUtil.loadFalseResult(1, "请求失败")); } businessEmergent110Service.buyTaoBaoGoodsError(StringUtil.Md5(auctionId + "")); } } /** * 获取淘宝的分享链接 (淘礼金新建) * * @param acceptData * @param uid * -用户ID * @param auctionId-商品ID * @param out */ @RequestMapping(value = "getTaoBaoGoodsLink") public void getTaoBaoGoodsLink(AcceptData acceptData, Long uid, Long auctionId, String from, HttpServletRequest request, PrintWriter out) { if (uid == null || uid <= 0) { out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空")); return; } UserInfo user = userInfoService.getUserByIdWithMybatis(uid); if (user != null && user.getState() != UserInfo.STATE_NORMAL) { out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC)); return; } if (auctionId == null || auctionId <= 0) { out.print(JsonUtil.loadFalseResult(2, "商品ID不能为空")); return; } TaoBaoGoodsBrief goods = null; try { goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId); } catch (TaobaoGoodsDownException e) { out.print(JsonUtil.loadFalseResult(3, "商品已下架")); return; } catch (Exception e) { try { LogHelper.errorDetailInfo(e, "获取商品简版详情出错", auctionId + ""); } catch (Exception e1) { e1.printStackTrace(); } } JSONObject data = new JSONObject(); boolean isNative = false; String pid = null; boolean specialConvert = false; if (goods.getMaterialLibType() != null && goods.getMaterialLibType() == 1) { specialConvert = true; } else specialConvert = false; String specialId = null; String relationId = null; // 查询用户ID是否绑定了会员运营ID UserExtraTaoBaoInfo userInfo = userExtraTaoBaoInfoService.getByUid(uid); if (userInfo != null && !StringUtil.isNullOrEmpty(userInfo.getSpecialId()) && userInfo.getSpecialValid() != null && userInfo.getSpecialValid() == true) { specialId = userInfo.getSpecialId(); relationId = userInfo.getRelationId(); // 已经绑定 if (specialConvert) { isNative = true; } else isNative = false; pid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT; } else {// 尚未绑定 isNative = true; } data.put("native", isNative); int pidType = PidUser.TYPE_FANLI_ANDROID; if (acceptData.getPlatform().equalsIgnoreCase("ios")) pidType = PidUser.TYPE_FANLI_IOS; try { TaoBaoLink taoBaoLink = null; // 是返利商品库的商品 if (specialConvert) { if (!StringUtil.isNullOrEmpty(specialId)) { if (from != null && from.equals("taolijin")) { if (source != null && "taolijin".equals(source)) { taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuy(uid, specialId, auctionId); } else { taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId); } data.put("native", true); } else { if (!specialConvert && !isNative) { @@ -442,10 +254,11 @@ businessEmergent110Service.buyTaoBaoGoodsError(StringUtil.Md5(auctionId + "")); } } /** * 是否在参与推广 */ fanli/src/main/java/com/yeshi/fanli/controller/client/v1/RecommendController.java
@@ -100,6 +100,7 @@ import com.yeshi.fanli.service.inter.tlj.DeviceTaoLiJinRecordService; import com.yeshi.fanli.service.inter.tlj.GoodsTaoLiJinRateService; import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService; import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService; import com.yeshi.fanli.service.inter.user.ShamUserService; import com.yeshi.fanli.service.inter.user.TBPidService; import com.yeshi.fanli.service.inter.user.UserCustomSettingsService; @@ -256,6 +257,10 @@ @Resource private DeviceSexService deviceSexService; @Resource private UserTaoLiJinRecordService userTaoLiJinRecordService; @@ -2180,9 +2185,29 @@ // 推广红包 if (from != null && from.equals("taolijin")) { BigDecimal spreadMoney = goodsTaoLiJinRateService.getGoodsSpreadMoney(goods); // 推广红包 不能小于1 if (spreadMoney.compareTo(new BigDecimal(1)) < 0) { out.print(JsonUtil.loadFalseResult(2, "商品不存在")); return; } // 是否为新用户 boolean isNewUser = userInfoExtraService.isNewUser(uid); if (!isNewUser) { if (isNewUser) { // 判定为老用户: 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。 long countRecord = userTaoLiJinRecordService.countRecordByUid(uid); if (countRecord > 0) { isNewUser = false; } } SpreadHongBao spreadHongBao = new SpreadHongBao(); if (isNewUser) { spreadHongBao.setMoney("1"); } else { spreadHongBao.setMoney(spreadMoney.toString()); moneyType = 2; fanliValid = false; ClientTextStyleVO textStyleVO1 = new ClientTextStyleVO(); @@ -2206,18 +2231,8 @@ data.put("listTip", listText); } BigDecimal spreadMoney = goodsTaoLiJinRateService.getGoodsSpreadMoney(goods); // 推广红包 不能小于1 if (spreadMoney.compareTo(new BigDecimal(1)) < 0) { out.print(JsonUtil.loadFalseResult(2, "商品不存在")); return; } SpreadHongBao spreadHongBao = new SpreadHongBao(); spreadHongBao.setMoney(spreadMoney.toString()); spreadHongBao.setTip("当日领取,两天内使用,过时无效"); goodsJson.put("spreadHongBao", spreadHongBao); // 用户剩余可以淘礼金验证 UserMoneyExtra userMoneyExtra = userMoneyExtraService.selectByPrimaryKey(uid); fanli/src/main/java/com/yeshi/fanli/controller/client/v2/TaoLiJinControllerV2.java
@@ -11,6 +11,7 @@ import javax.annotation.Resource; import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -31,7 +32,6 @@ import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinDetail.TaoLiJinDetailTypeEnum; import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin; import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinOrigin.TaoLiJinOriginEnum; import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.entity.bus.user.UserMoneyExtra; import com.yeshi.fanli.entity.bus.user.UserRank; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; @@ -128,6 +128,8 @@ @Resource private JumpDetailV2Service jumpDetailV2Service; @Resource(name = "taskExecutor") private TaskExecutor executor; /** * 获取淘礼金分享记录 @@ -372,7 +374,8 @@ data.put("content", "自购直接抵现,优惠真实可见!"); data.put("type", 1); data.put("money", money.setScale(2).toString()); data.put("usage", "领取成功,去“首页-分享爆款”使用>"); data.put("usage", "领取成功,已存入“我的-推广红包"); data.put("jumpName", "去使用"); data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_taolijin_goods")); data.put("tip", configTaoLiJinService.getValueByKey("hongbao_newbies_tip")); data.put("rules", configTaoLiJinService.getValueByKey("taolijin_rules")); @@ -406,7 +409,8 @@ data.put("content", "自购直接抵现,优惠真实可见!"); data.put("type", 1); data.put("money", hasMoney.setScale(2).toString()); data.put("usage", "领取成功,去“首页-分享爆款”使用>"); data.put("usage", "领取成功,已存入“我的-推广红包"); data.put("jumpName", "去使用"); data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_taolijin_goods")); data.put("tip", configTaoLiJinService.getValueByKey("hongbao_newbies_tip")); @@ -422,11 +426,12 @@ UserRank userRank = userInfoExtraService.gerUserRank(uid); if (userRank != null) { try { isRank = true; UserTaoLiJinOrigin origin = userTaoLiJinOriginService.addRankWinMoney(uid, userRank); hasMoney = origin.getMoney(); isRank = true; } catch (UserTaoLiJinOriginException e) { if (e.getCode() != 2) { isRank = false; out.print(JsonUtil.loadFalseResult(e.getMsg())); return; } @@ -440,7 +445,7 @@ data.put("content", "推广红包,好友福利!"); data.put("type", 2); data.put("money", "本月账户等级未达到\r\n继续加油"); data.put("usage", "去“我的-账户等级”查看 >"); data.put("jumpName", "去查看"); data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("user_rank")); data.put("tip", configTaoLiJinService.getValueByKey("hongbao_rank_not_enough_tip")); out.print(JsonUtil.loadTrueResult(data)); @@ -450,8 +455,9 @@ data.put("content", "推广红包,好友福利!"); data.put("type", 1); data.put("money", hasMoney.setScale(2).toString()); data.put("usage", "已存入“我的-推广红包”,去查看 >"); data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("user_taolijin")); data.put("usage", "领取成功,已存入“我的-推广红包"); data.put("jumpName", "去使用"); data.put("jumpDetail", jumpDetailV2Service.getByTypeCache("share_taolijin_goods")); data.put("tip", configTaoLiJinService.getValueByKey("hongbao_rank_tip")); } @@ -495,6 +501,14 @@ .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create(); boolean isNewUser = userInfoExtraService.isNewUser(uid); if (isNewUser) { // 判定为老用户: 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。 long countRecord = userTaoLiJinRecordService.countRecordByUid(uid); if (countRecord > 0) { isNewUser = false; } } BigDecimal proportion = hongBaoManageService.getFanLiRate(); for (QualityFactory qualityFactory : listFreeGoods) { @@ -505,28 +519,32 @@ TaoBaoGoodsBriefExtra extra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(taoBaoGoodsBrief, proportion.toString(), null); // 显示类型 if (isNewUser) { extra.setMoneyType(1); } else { extra.setMoneyType(2); } // 去掉标签 extra.setLabels(null); BigDecimal spreadMoney = goodsTaoLiJinRateService.getGoodsSpreadMoney(taoBaoGoodsBrief); // 推广红包 不能小于1 if (spreadMoney.compareTo(new BigDecimal(1)) < 0) { continue; } // 去掉标签 extra.setLabels(null); // 显示类型 if (isNewUser) { extra.setMoneyType(1); extra.setSpreadMoney("推广红包 ¥"+ 1); } else { extra.setMoneyType(2); extra.setSpreadMoney("推广红包 ¥"+ spreadMoney); } array.add(gson.toJson(extra)); } executor.execute(new Runnable() { @Override public void run() { // 过期 userTaoLiJinOriginService.overdueHongBao(uid); } }); JSONObject data = new JSONObject(); data.put("count", count); fanli/src/main/java/com/yeshi/fanli/service/impl/goods/ShareGoodsServiceImpl.java
@@ -689,6 +689,7 @@ String taoLiJinLink = null; try { goods.setAuctionId(auctionId); UserTaoLiJinRecord createUserTaoLiJin = userTaoLiJinRecordService.createSelfBuyTaoLiJin(uid, 1, goods); taoLiJinLink = createUserTaoLiJin.getSendUrl(); } catch (UserTaoLiJinRecordException e) { fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
@@ -34,6 +34,7 @@ import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService; import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService; import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinReportService; import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.service.inter.user.UserMoneyExtraService; import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.RedisManager; @@ -78,6 +79,8 @@ @Resource private UserOtherMsgNotificationService userOtherMsgNotificationService; @Resource private UserInfoExtraService userInfoExtraService; @Override @@ -108,7 +111,8 @@ } catch (ParseException e2) { e2.printStackTrace(); } BigDecimal perface = goodsTaoLiJinRateService.getGoodsSpreadMoney(goods); // 新人红包 自购一元 BigDecimal perface = new BigDecimal(1); return createUserTaoLiJin(1, uid, goods.getAuctionId(), perface, 1, name, sendStartTime, sendEndTime, null, useEndTime); @@ -138,7 +142,21 @@ e2.printStackTrace(); } BigDecimal perface = goodsTaoLiJinRateService.getGoodsSpreadMoney(goods); boolean isNewUser = userInfoExtraService.isNewUser(uid); if (isNewUser) { // 判定为老用户: 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。 long countRecord = userTaoLiJinRecordMapper.countRecordByUid(uid); if (countRecord > 0) { isNewUser = false; } } BigDecimal perface = null; if (isNewUser) { perface = new BigDecimal(1); } else { perface = goodsTaoLiJinRateService.getGoodsSpreadMoney(goods); } return createUserTaoLiJin(2, uid, goods.getAuctionId(), perface, totalNum, name, sendStartTime, sendEndTime, null, useEndTime);