| | |
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | 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.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.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.MonitorFactory;
|
| | |
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | | @Resource
|
| | | private MonitorService monitorService;
|
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | /**
|
| | | * 获取淘宝的分享链接
|
| | | *
|
| | |
| | | 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;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("native", true);
|
| | | boolean isNative = false;
|
| | | String pid = null;
|
| | |
|
| | | boolean specialConvert = false;
|
| | |
|
| | | String specialId = null;
|
| | | // 查询用户ID是否绑定了会员运营ID
|
| | | UserExtraTaoBaoInfo userInfo = userExtraTaoBaoInfoService.getByUid(uid);
|
| | | if (userInfo != null && !StringUtil.isNullOrEmpty(userInfo.getSpecialId()) && userInfo.getSpecialValid() != null
|
| | | && userInfo.getSpecialValid() == true) {
|
| | | specialId = userInfo.getSpecialId();
|
| | | // 已经绑定
|
| | | try {
|
| | | TaoBaoGoodsBrief goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
|
| | | if (goods.getMaterialLibType() != null && goods.getMaterialLibType() == 1) {
|
| | | isNative = true;
|
| | | specialConvert = true;
|
| | | } else
|
| | | isNative = false;
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | out.print(JsonUtil.loadFalseResult(3, "商品已下架"));
|
| | | return;
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "获取商品简版详情出错", auctionId + "");
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | pid = Constant.TAOBAO_SPECIAL_PID_DEFAULT;
|
| | |
|
| | | } else {// 尚未绑定
|
| | | isNative = true;
|
| | | }
|
| | |
|
| | | data.put("native", isNative);
|
| | | try {
|
| | | int pidType = PidUser.TYPE_FANLI_ANDROID;
|
| | | if (acceptData.getPlatform().equalsIgnoreCase("ios"))
|
| | | pidType = PidUser.TYPE_FANLI_IOS;
|
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForBuy(uid, auctionId, pidType);
|
| | |
|
| | | TaoBaoLink taoBaoLink = null;
|
| | | if (!StringUtil.isNullOrEmpty(specialId) && specialConvert) {
|
| | | taoBaoLink = shareGoodsService.getTaoBaoLinkForBuyWithSpecial(uid, specialId, auctionId);
|
| | | } 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);
|
| | | }
|
| | |
|
| | | JSONObject link = new JSONObject();
|
| | | link.put("clickUrl", taoBaoLink.getClickUrl());
|
| | | link.put("couponUrl", taoBaoLink.getCouponLink());
|
| | |
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | isNative = false;
|
| | | try {
|
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, 0, 0, "购买淘宝商品转链出错"));
|
| | | } catch (Exception e1) {
|
| | |
| | | } else {
|
| | | tbPid = tbPidService.getTBPid(uid, PidUser.TYPE_FANLI_IOS);
|
| | | }
|
| | |
|
| | | data.put("native", isNative);
|
| | |
|
| | | if (tbPid != null) {
|
| | | String siteId = tbPid.getPid().split("_")[2];
|
| | |
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 是否在参与推广
|
| | | */
|
| | |
|
| | | /**
|
| | | * 是否在参与推广
|
| | | * |
| | | * @param goodsId
|
| | | * -商品ID
|
| | | * @param goodsType
|
| | | * -TB/JD
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "isGoodsExtend")
|
| | | public void isGoodsExtend(AcceptData acceptData,String goodsId, String goodsType, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(goodsId)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "未参与推广"));
|
| | | return;
|
| | | }
|
| | | if (StringUtil.isNullOrEmpty(goodsType)) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "缺少goodsType"));
|
| | | return;
|
| | | }
|
| | | if ("TB".equalsIgnoreCase(goodsType)) {
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = TaoKeApiUtil.getSimpleGoodsInfo(Long.parseLong(goodsId));
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
|
| | | if (goods == null) {
|
| | | data.put("extend", false);
|
| | | data.put("url", "https://h5.m.taobao.com/awp/core/detail.htm?id=" + goodsId);
|
| | | } else {
|
| | | data.put("extend", true);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(3, "暂不支持其他商品类型"));
|
| | | }
|
| | | }
|
| | |
|
| | | }
|