| | |
| | | package com.yeshi.fanli.controller.client.v1; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.util.Date; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemFunction; |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | import com.yeshi.fanli.exception.taobao.TaoBaoConvertLinkException; |
| | | import com.yeshi.fanli.lijin.manager.UserLijinMnager; |
| | | import com.yeshi.fanli.service.inter.user.UserFunctionsLimitService; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.service.manger.goods.TaoBaoLinkManager; |
| | | import com.yeshi.fanli.util.SystemInfoUtil; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | @Resource |
| | | private TaoBaoLinkManager taoBaoLinkManager; |
| | | |
| | | private void doTaoLiJinBuy(AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) { |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | |
| | | @Resource |
| | | private UserLijinMnager userLijinMnager; |
| | | |
| | | @Resource |
| | | private UserFunctionsLimitService userFunctionsLimitService; |
| | | |
| | | private void doTaoLiJinBuy(AcceptData acceptData, Long uid, String auctionId, PrintWriter out) { |
| | | JSONObject data = new JSONObject(); |
| | | TaoBaoLink taoBaoLink = null; |
| | | try { |
| | |
| | | } |
| | | |
| | | |
| | | private void getTaoBaoLinkWithoutFanLi(AcceptData acceptData, Long auctionId, String from, String source, |
| | | private void getTaoBaoLinkWithoutFanLi(AcceptData acceptData, String auctionId, String from, String source, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | |
| | | try { |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForRecieveCoupon(auctionId, null, TaoBaoConstant.TAOBAO_COUPON_PID); |
| | | String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.coupon); |
| | | |
| | | TaoBaoLink taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForRecieveCoupon(acceptData.getSystem(), auctionId, null, pid); |
| | | JSONObject data = new JSONObject(); |
| | | JSONObject link = new JSONObject(); |
| | | link.put("clickUrl", taoBaoLink.getClickUrl()); |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "gettaobaolink") |
| | | public void getTaoBaoLink(AcceptData acceptData, Long uid, Long auctionId, String from, String source, |
| | | public void getTaoBaoLink(AcceptData acceptData, Long uid, String auctionId, String from, String source, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | |
| | | if (auctionId == null || auctionId <= 0) { |
| | | if (StringUtil.isNullOrEmpty(auctionId)) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (!SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.fanli)) { |
| | | getTaoBaoLinkWithoutFanLi(acceptData, auctionId, from, source, request, out); |
| | | return; |
| | | } |
| | | |
| | | //领券 |
| | | if (uid == null) { |
| | | getTaoBaoLinkWithoutFanLi(acceptData, auctionId, from, source, request, out); |
| | | return; |
| | | } |
| | |
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC)); |
| | | return; |
| | | } |
| | | if (userFunctionsLimitService.isLimit(uid, SystemFunction.fanli, new Date())) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该功能限制使用")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | // 日志记录 |
| | |
| | | TaoBaoGoodsBrief goods = null; |
| | | |
| | | try { |
| | | goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId); |
| | | goods = TaoKeApiUtil.getSimpleGoodsInfoForOwnBuy(auctionId); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | out.print(JsonUtil.loadFalseResult(3, "商品已下架")); |
| | | return; |
| | |
| | | |
| | | String dpid = null; |
| | | if (TaoBaoUtil.isSpecialGoods(goods.getMaterialLibType())) { |
| | | dpid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT; |
| | | dpid = pidManager.getPid(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanli); |
| | | } else { |
| | | dpid = TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID; |
| | | dpid = pidManager.getPid(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanliChannel); |
| | | } |
| | | String psiteId = dpid.split("_")[2]; |
| | | String padzoneId = dpid.split("_")[3]; |
| | |
| | | } else |
| | | isNative = false; |
| | | |
| | | pid = TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT; |
| | | pid = pidManager.getPid(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanli); |
| | | |
| | | } else {// 尚未绑定 |
| | | isNative = true; |
| | |
| | | } |
| | | |
| | | if (taoBaoLink == null) { |
| | | taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForBuy(uid, auctionId, specialId, null); |
| | | taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForBuy(acceptData.getSystem(), uid, auctionId, specialId, null); |
| | | if (taoBaoLink != null) |
| | | clientTBPid = null; |
| | | } |
| | |
| | | taoBaoLink = shareGoodsService.getTaoBaoLink(uid, auctionId, |
| | | tbPidService.getIOSDefault().getPid()); |
| | | } else |
| | | taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForBuy(uid, auctionId, specialId, null); |
| | | taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForBuy(acceptData.getSystem(), uid, auctionId, specialId, null); |
| | | LogHelper.test("购买转链:默认PID转链-" + uid + ":" + auctionId); |
| | | } |
| | | } else {// 不是返利库的商品,用特殊PID替代 |
| | |
| | | if (!StringUtil.isNullOrEmpty(relationId)) {// |
| | | if (source != null && "taolijin_free_buy".equals(source)) { |
| | | taoBaoLink = taoBaoLinkManager.getTaoLiJinLinkForBuy(uid, auctionId, |
| | | TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID); |
| | | pidManager.getPid(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanliChannel)); |
| | | } else { |
| | | taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(uid, auctionId, relationId, |
| | | TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID); |
| | | taoBaoLink = taoBaoLinkManager.getTaoBaoLinkForShare(acceptData.getSystem(), uid, auctionId, relationId, |
| | | pidManager.getPid(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanliChannel)); |
| | | } |
| | | |
| | | data.put("native", true); |
| | |
| | | data.put("link", link); |
| | | if (clientTBPid != null) |
| | | data.put("tbPidInfo", clientTBPid); |
| | | |
| | | data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem())); |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | TaoKeLogHelper.convertLinkInfo( |
| | |
| | | data.put("native", true); |
| | | } |
| | | |
| | | data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem())); |
| | | |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } else { |
| | | out.print(JsonUtil.loadFalseResult(1, "请求失败")); |
| | |
| | | if ("TB".equalsIgnoreCase(goodsType)) { |
| | | TaoBaoGoodsBrief goods = null; |
| | | try { |
| | | goods = TaoKeApiUtil.getSimpleGoodsInfo(Long.parseLong(goodsId)); |
| | | goods = TaoKeApiUtil.getSimpleGoodsInfo(goodsId); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "deleteRecommendGoods") |
| | | public void deleteRecommendGoods(AcceptData acceptData, Long goodsId, Integer source, Long uid, String reason, |
| | | public void deleteRecommendGoods(AcceptData acceptData, String goodsId, Integer source, Long uid, String reason, |
| | | PrintWriter out) { |
| | | if (goodsId == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "请上传商品")); |