| | |
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.goods.recommend.RecommendGoodsDeleteHistory;
|
| | | import com.yeshi.fanli.entity.taobao.ClientTBPid;
|
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.taobao.TBPid;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.exception.ShareGoodsException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.recommend.RecommendGoodsDeleteHistoryService;
|
| | | import com.yeshi.fanli.service.inter.monitor.BusinessEmergent110Service;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | @Resource
|
| | | private TaoBaoBuyRelationMapService taoBaoBuyRelationMapService;
|
| | |
|
| | | @Resource
|
| | | private BusinessEmergent110Service businessEmergent110Service;
|
| | |
|
| | | @Resource
|
| | | private RecommendGoodsDeleteHistoryService recommendGoodsDeleteHistoryService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinRecordService userTaoLiJinRecordService;
|
| | |
|
| | | private void doTaoLiJinBuy(Long uid, Long auctionId, PrintWriter out) {
|
| | | JSONObject data = new JSONObject();
|
| | | TaoBaoLink taoBaoLink;
|
| | | try {
|
| | | taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuyWithOutFanLi(uid, auctionId);
|
| | | } catch (ShareGoodsException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | return;
|
| | | }
|
| | | data.put("native", true);
|
| | | 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));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取淘宝的分享链接
|
| | | *
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "gettaobaolink")
|
| | | public void getTaoBaoLink(AcceptData acceptData, Long uid, Long auctionId,String from, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | | public void getTaoBaoLink(AcceptData acceptData, Long uid, Long auctionId, String from, String source,
|
| | | HttpServletRequest request, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
|
| | | return;
|
| | |
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | if ("taolijin_buy".equalsIgnoreCase(source)) {
|
| | | doTaoLiJinBuy(uid, auctionId, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | if (acceptData.getPlatform().equalsIgnoreCase("ios"))
|
| | | pidType = PidUser.TYPE_FANLI_IOS;
|
| | | try {
|
| | |
|
| | | TaoBaoLink taoBaoLink = null;
|
| | |
|
| | | // 是返利商品库的商品
|
| | | if (specialConvert) {
|
| | | if (!StringUtil.isNullOrEmpty(specialId)) {
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
|
| | | if (source != null && "taolijin".equals(source)) {
|
| | | boolean isNewUser = userInfoExtraService.isNewUser(uid);
|
| | | if (isNewUser) {
|
| | | // 判定为老用户:
|
| | | // 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。
|
| | | long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
|
| | | if (countRecord == 0) {
|
| | | taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuy(uid, specialId, auctionId, null);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (taoBaoLink == null) {
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
|
| | | }
|
| | |
|
| | | data.put("native", true);
|
| | | } else {
|
| | | if (!specialConvert && !isNative) {
|
| | |
| | | else
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
|
| | | tbPidService.getIOSDefault().getPid());
|
| | |
|
| | | } else
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLinkForBuy(uid, auctionId, pidType);
|
| | | LogHelper.test("购买转链:默认PID转链-" + uid + ":" + auctionId);
|
| | | }
|
| | | } else {// 不是返利库的商品,用特殊PID替代
|
| | | try {
|
| | |
| | | LogHelper.errorDetailInfo(e, "uid:" + uid, null);
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(relationId)) {//
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId,
|
| | | TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
|
| | | if (source != null && "taolijin".equals(source)) {
|
| | | boolean isNewUser = userInfoExtraService.isNewUser(uid);
|
| | | if (isNewUser) {
|
| | | // 判定为老用户:
|
| | | // 新人只要使用了新人红包,也就是那1块钱,那么,他看到的分享爆款中的商品-就只能分享。
|
| | | long countRecord = userTaoLiJinRecordService.countRecordByUid(uid);
|
| | | if (countRecord == 0) {
|
| | | taoBaoLink = shareGoodsService.getTaoLiJinLinkForBuy(uid, specialId, auctionId,
|
| | | TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
|
| | | }
|
| | | }
|
| | | } else {
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId, relationId,
|
| | | TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
|
| | | }
|
| | |
|
| | | data.put("native", true);
|
| | | } else {
|
| | | if (pidType == PidUser.TYPE_FANLI_ANDROID)
|
| | |
| | | else
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId,
|
| | | tbPidService.getIOSDefault().getPid());
|
| | |
|
| | | LogHelper.test("购买转链:默认PID转链-非返利库商品-" + uid + ":" + auctionId);
|
| | | }
|
| | | }
|
| | | JSONObject link = new JSONObject();
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | |
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
|
| | | isNative = false;
|
| | | try {
|
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "购买淘宝商品转链出错"));
|
| | |
| | | tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_FANLI_IOS);
|
| | | }
|
| | |
|
| | | LogHelper.test("购买转链:默认PID转链-异常商品-" + uid + ":" + auctionId);
|
| | |
|
| | | data.put("native", isNative);
|
| | |
|
| | | if (tbPid != null) {
|
| | | 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);
|
| | |
|
| | | 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 goodsId
|
| | | * @param source
|
| | | * @param uid
|
| | | * @param reason
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "deleteRecommendGoods")
|
| | | public void deleteRecommendGoods(AcceptData acceptData, Long goodsId, Integer source, Long uid, String reason,
|
| | | PrintWriter out) {
|
| | | if (goodsId == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请上传商品"));
|
| | | return;
|
| | | }
|
| | |
|
| | | RecommendGoodsDeleteHistory history = new RecommendGoodsDeleteHistory();
|
| | | history.setDevice(acceptData.getDevice());
|
| | | history.setReason(reason);
|
| | | history.setUid(uid);
|
| | | history.setGoodsSource(source == null ? Constant.SOURCE_TYPE_TAOBAO : source);
|
| | | history.setGoodsId(goodsId);
|
| | | recommendGoodsDeleteHistoryService.addRecommendGoodsDeleteHistory(history);
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | |
|
| | | }
|