| | |
| | | package com.yeshi.fanli.controller.client.v2;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.InvocationTargetException;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.apache.commons.beanutils.PropertyUtils;
|
| | | import org.json.simple.JSONArray;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.jd.JDCategoryInfo;
|
| | | import com.yeshi.fanli.dto.jd.JDCouponInfo;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDPromotionUrl;
|
| | | import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.ShamUser;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.jd.JDGoodsClass;
|
| | | import com.yeshi.fanli.entity.system.BusinessSystem;
|
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum;
|
| | | import com.yeshi.fanli.entity.system.SystemClientParams;
|
| | | import com.yeshi.fanli.entity.taobao.ClientTBPid;
|
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TLJFreeBuyGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShop;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoKeAppInfo;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | 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.dynamic.GoodsEvaluateService;
|
| | | 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.jd.JDGoodsClassService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyExtraService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.redpack.UserTaoLiJinNewbiesService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TLJFreeBuyGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.tlj.ConfigTaoLiJinService;
|
| | | import com.yeshi.fanli.service.inter.user.ShamUserService;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | | 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.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
|
| | | import com.yeshi.fanli.service.manger.user.UserLevelManager;
|
| | | 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;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.factory.goods.ShopInfoVOFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.user.UserLevelUtil;
|
| | | import com.yeshi.fanli.vo.goods.CouponInfoVO;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailExtraVO;
|
| | | 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;
|
| | | import com.yeshi.fanli.vo.tlj.NewUserHongBao;
|
| | | import com.yeshi.fanli.vo.tlj.ReduceHongBao;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/v2/goods")
|
| | | public class GoodsControllerV2 {
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private TBPidService tbPidService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoShopService taoBaoShopService;
|
| | |
|
| | | @Resource
|
| | | private ShamUserService shamUserService;
|
| | |
|
| | | @Resource
|
| | | private CollectionGoodsV2Service collectionGoodsV2Service;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsBriefService taoBaoGoodsBriefService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | @Resource
|
| | | private SystemClientParamsService systemClientParamsService;
|
| | |
|
| | | @Resource
|
| | | private UserGoodsStorageService userGoodsStorageService;
|
| | |
|
| | | @Resource
|
| | | private ConfigTaoLiJinService configTaoLiJinService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyExtraService userMoneyExtraService;
|
| | |
|
| | | @Resource
|
| | | private ScanHistoryV2Service scanHistoryV2Service;
|
| | |
|
| | | @Resource
|
| | | private TLJBuyGoodsService tljBuyGoodsService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private JDGoodsCacheUtil jdGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private JDGoodsClassService jdGoodsClassService;
|
| | |
|
| | | @Resource
|
| | | private TLJFreeBuyGoodsService tljFreeBuyGoodsService;
|
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinNewbiesService userTaoLiJinNewbiesService;
|
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | |
|
| | | @Resource
|
| | | private GoodsEvaluateService goodsEvaluateService;
|
| | |
|
| | | @Resource
|
| | | private UserLevelManager userLevelManager;
|
| | | |
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | private ConfigParamsDTO getParamsDTO(String platform, String version, Long uid) {
|
| | | UserLevelEnum level = UserLevelEnum.daRen;
|
| | | if (uid != null && uid > 0) {
|
| | | level = userLevelManager.getUserLevel(uid);
|
| | | if (level != null) {
|
| | | if (System.currentTimeMillis() < Constant.NEW_ORDER_FANLI_RULE_TIME)
|
| | | level = UserLevelUtil.getOldLevel(level);
|
| | | }
|
| | | }
|
| | | if (level == null)
|
| | | level = UserLevelEnum.daRen;
|
| | | return orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, level);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 淘宝商品详情
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param uid
|
| | | * @param from
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getDetailTB", method = RequestMethod.POST)
|
| | | public void getDetialTB(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
|
| | | if (id == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "商品id不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
|
| | | acceptData.getPackages());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
|
| | | extraVO.setIsNative(false);
|
| | |
|
| | | // IOS是否正在上线
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
|
| | | String version = acceptData.getVersion();
|
| | | extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
|
| | | }
|
| | |
|
| | | long startTime = java.lang.System.currentTimeMillis();
|
| | |
|
| | | // 获取淘客参数
|
| | | ClientTBPid clientTBPid = null;
|
| | |
|
| | | // 用户未登录
|
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) {
|
| | | clientTBPid = tbPidService.getAndroidDefault();
|
| | | } else {
|
| | | clientTBPid = tbPidService.getIOSDefault();
|
| | | }
|
| | |
|
| | | LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime));
|
| | |
|
| | | // final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
|
| | | // 是否在服务端进行转链
|
| | | boolean convertInServer = configService.isConvertTaoBaoLinkInServer();
|
| | |
|
| | | TaoBaoGoodsBrief goods = null;
|
| | |
|
| | | if (!convertInServer) {
|
| | | try {
|
| | | goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id);
|
| | | if (goods == null) {
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_COMMON_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_COMMON_APPSECRET);
|
| | | app.setPid(TaoBaoConstant.TAOBAO_COMMON_PID);
|
| | | app.setAdzoneId(TaoBaoConstant.TAOBAO_COMMON_PID.split("_")[3]);
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(id, app);
|
| | |
|
| | | final TaoBaoGoodsBrief finalGoods = goods;
|
| | | if (goods != null) {
|
| | | ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(finalGoods);
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | // 商品下架
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
|
| | | public void run() {
|
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(id);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | } else {
|
| | | final String clientPid = clientTBPid.getPid();
|
| | | String appId = clientPid.split("_")[2];
|
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId);
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAdzoneId(clientPid.split("_")[3]);
|
| | | app.setAppKey(config.getAppKey());
|
| | | app.setAppSecret(config.getAppSecret());
|
| | | app.setPid(clientPid);
|
| | |
|
| | | try {
|
| | | goods = TaoKeApiUtil.searchGoodsDetail(id, app);
|
| | | if (goods.getTkRate() == null || new BigDecimal(0).compareTo(goods.getTkRate()) == 0) {
|
| | | TaoBaoGoodsBrief linkInfo = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
|
| | | if (linkInfo != null) {
|
| | | goods.setAuctionUrl(linkInfo.getAuctionUrl());
|
| | | goods.setCouponLink(linkInfo.getCouponLink());
|
| | | goods.setTkRate(linkInfo.getTkRate());
|
| | | }
|
| | | }
|
| | |
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(id);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | if (goods != null) {
|
| | | final TaoBaoGoodsBrief newGoods = goods;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | try {
|
| | | // 更新商品
|
| | | LogHelper.test("更新商品详情:" + newGoods.getAuctionId());
|
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods);
|
| | | } catch (TaobaoGoodsUpdateException e) {
|
| | |
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief tb = goods;
|
| | |
|
| | | if (tb == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (tb.getImgList() == null) {
|
| | | tb.setImgList(new ArrayList<>());
|
| | | }
|
| | |
|
| | | // tb.getImgList().add(0, tb.getPictUrl());
|
| | |
|
| | | List<String> finalImgList = new ArrayList<>();
|
| | | for (String img : tb.getImgList()) {
|
| | | finalImgList.add(TbImgUtil.getTBSizeImg(img, 600));
|
| | | }
|
| | |
|
| | | if (finalImgList.size() == 0) {
|
| | | finalImgList.add(tb.getPictUrl());
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite()))
|
| | | finalImgList.add(0, tb.getPictUrlWhite());
|
| | |
|
| | | // 移除相同图片
|
| | | if (finalImgList.size() > 0)
|
| | | for (int i = 0; i < finalImgList.size(); i++) {
|
| | | if (i < finalImgList.size() - 1)
|
| | | if (TbImgUtil.getTBSizeImg(finalImgList.get(i), 600)
|
| | | .equalsIgnoreCase(TbImgUtil.getTBSizeImg(finalImgList.get(i + 1), 600))) {
|
| | | finalImgList.remove(i--);
|
| | | }
|
| | | }
|
| | |
|
| | | tb.setImgList(finalImgList);
|
| | |
|
| | | // 大淘客商品过滤
|
| | | try {
|
| | | goods = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods, acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | |
|
| | | // goods = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods);
|
| | |
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | |
|
| | | ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
|
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
|
| | |
|
| | | GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO);
|
| | | if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
|
| | | goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
|
| | | goodsDetail.getMoneyInfo().setShareMoney("¥" + TaoBaoUtil.getGoodsHongBaoMoney(goods,
|
| | | hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
|
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
|
| | | goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
|
| | | }
|
| | | goodsDetail.getMoneyInfo()
|
| | | .setRateInfoHelpUrl(configService.get(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey()));
|
| | |
|
| | | if (TaoBaoUtil.isYUShou(goods)) {
|
| | | if (!StringUtil.isNullOrEmpty(goods.getPresaleDiscountFeeText())) {
|
| | | if (goodsDetail.getLabels() == null)
|
| | | goodsDetail.setLabels(new ArrayList<>());
|
| | | goodsDetail.getLabels().add(new ClientTextStyleVO(goods.getPresaleDiscountFeeText(), "#FF2B4E"));
|
| | | }
|
| | | }
|
| | | // 在标题添加优惠信息
|
| | |
|
| | | // 店铺信息
|
| | | TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(id, goods.getSellerId());
|
| | | if (shop != null) {
|
| | | String shopLink = shop.getShopLink();
|
| | | if (StringUtil.isNullOrEmpty(shopLink)) {
|
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
|
| | | }
|
| | | goodsDetail.setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop));
|
| | | }
|
| | |
|
| | | // 有券处理
|
| | | if (goodsDetail.isHasCoupon()) {
|
| | | if (!StringUtil.isNullOrEmpty(from)) {
|
| | | if ("miandan".equals(from)) { // 免单商品
|
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
|
| | | moneyInfo.setFanliMoney("¥" + goodsDetail.getCouponPrice());
|
| | | goodsDetail.setMoneyInfo(moneyInfo);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | extraVO.setTbPidInfo(clientTBPid);
|
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img.html?id=" + id);
|
| | |
|
| | | // 分享赚人提示
|
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
|
| | | List<ShamUser> listShareUser = new ArrayList<ShamUser>();
|
| | | if (moneyInfo != null) {
|
| | | String shareMoney = moneyInfo.getShareMoney();
|
| | | if (goods.getBiz30day() >= 1000) {
|
| | | listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney.replaceAll("¥", "")), 1,
|
| | | 5);
|
| | | }
|
| | | }
|
| | | extraVO.setListShareUser(listShareUser);
|
| | |
|
| | | // 领券人列表
|
| | | List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
|
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null
|
| | | && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) {
|
| | | if (goods.getBiz30day() >= 1000) {
|
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
|
| | | }
|
| | | }
|
| | | extraVO.setListCouponUser(listCouponUser);
|
| | |
|
| | | if (uid != null) {
|
| | | // 是否加入收藏
|
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
|
| | | Constant.SOURCE_TYPE_TAOBAO);
|
| | | extraVO.setCollected(collectionGoods != null ? true : false);
|
| | | // 是否加入选品库
|
| | | extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO));
|
| | | }
|
| | |
|
| | | // 测试
|
| | | SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
|
| | | "goods_detail_jump_taobao");
|
| | | if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
|
| | | extraVO.setIsNative(true);
|
| | | }
|
| | |
|
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), "", id + "");
|
| | | try {
|
| | | extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
|
| | | } catch (Exception e) {
|
| | | extraVO.setH5Url(h5Url);
|
| | | }
|
| | |
|
| | | String helpLink = null;
|
| | | boolean fanliValid = true;
|
| | | boolean shareValid = true;
|
| | | int moneyType = 1;
|
| | |
|
| | | if (from != null && from.equals("taolijin_buy")) {
|
| | | // 查询分享库
|
| | | TLJBuyGoods buyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(id,
|
| | | TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | | if (buyGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "自购立减红包过期"));
|
| | | return;
|
| | | }
|
| | |
|
| | | moneyType = 2;
|
| | | fanliValid = true;
|
| | | shareValid = false;
|
| | | helpLink = configService.get(ConfigKeyEnum.zigoulijianNofanliHelp.getKey());
|
| | |
|
| | | BigDecimal tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE);
|
| | |
|
| | | ReduceHongBao reduceHongBao = new ReduceHongBao();
|
| | | reduceHongBao.setLeft(buyGoods.getLeftHongBaoCount());
|
| | | 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 if (from != null && from.equals("taolijin_free_buy")) {
|
| | | TLJFreeBuyGoods freeGoods = tljFreeBuyGoodsService.selectByAuctionIdAndDay(id,
|
| | | TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"));
|
| | | if (freeGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "免单商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | fanliValid = true;
|
| | | shareValid = false;
|
| | | BigDecimal couponPrice = goodsDetail.getCouponPrice();
|
| | | if (couponPrice == null)
|
| | | couponPrice = goodsDetail.getZkPrice();
|
| | |
|
| | | NewUserHongBao newUserHongBao = new NewUserHongBao();
|
| | | newUserHongBao.setMoney(couponPrice.setScale(2).toString());
|
| | | newUserHongBao.setName("新人红包 ");
|
| | | newUserHongBao.setTip("当日领取,当日内使用,过期失效");
|
| | | newUserHongBao.setLeft(1);
|
| | | newUserHongBao.setTotal(1);
|
| | |
|
| | | OtherInfo otherInfo = new OtherInfo();
|
| | | otherInfo.setReduceHongBao(newUserHongBao);
|
| | | goodsDetail.setOtherInfo(otherInfo);
|
| | |
|
| | | // 专属标签
|
| | | List<ClientTextStyleVO> labels = new ArrayList<ClientTextStyleVO>();
|
| | | labels.add(new ClientTextStyleVO("新人专属", "#FE0014"));
|
| | | labels.add(new ClientTextStyleVO("实付0元", "#FF9600"));
|
| | | goodsDetail.setLabels(labels);
|
| | |
|
| | | } else {// 普通购买
|
| | | OtherInfo otherInfo = new OtherInfo();
|
| | | RewardCouponVO rewardCoupon = new RewardCouponVO();
|
| | | rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
|
| | | JSONObject params1 = new JSONObject();
|
| | | if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | params1.put("url", configService.get(ConfigKeyEnum.specialGuideRewardCouponLink.getKey()));
|
| | | else
|
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link"));
|
| | | rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
|
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | rewardCoupon.setDesc("返");
|
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link"));
|
| | | rewardCoupon.getJumpDetail().setNeedLogin(true);
|
| | | } else
|
| | | rewardCoupon.setDesc("用返利奖励券最高返");
|
| | | rewardCoupon.setParams(params1.toString());
|
| | |
|
| | | otherInfo.setRewardCoupon(rewardCoupon);
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
|
| | | otherInfo.setRewardCoupon(null);
|
| | |
|
| | | goodsDetail.setOtherInfo(otherInfo);
|
| | | }
|
| | | extraVO.setFanliValid(fanliValid);
|
| | | extraVO.setShareValid(shareValid);
|
| | |
|
| | | MoneyInfoVO goodsMoney = goodsDetail.getMoneyInfo();
|
| | | if (goodsMoney != null) {
|
| | | goodsMoney.setMoneyType(moneyType);
|
| | | }
|
| | |
|
| | | // 分享路径
|
| | | if (StringUtil.isNullOrEmpty(helpLink)) {
|
| | | helpLink = configService.get(ConfigKeyEnum.noRebateHelpLink.getKey());
|
| | | }
|
| | |
|
| | | // 分享路径
|
| | | ShareVO shareInfoVO = new ShareVO();
|
| | | shareInfoVO.setHelpLink(helpLink);
|
| | | extraVO.setShare(shareInfoVO);
|
| | |
|
| | | if (goodsDetail.isHasCoupon()) {
|
| | | // 设置couponList
|
| | | List<CouponInfoVO> couponInfoList = new ArrayList<>();
|
| | | couponInfoList.add(goodsDetail.getCouponInfo());
|
| | | if (Constant.IS_TEST) {
|
| | | CouponInfoVO coupon = new CouponInfoVO();
|
| | | try {
|
| | | PropertyUtils.copyProperties(coupon, goodsDetail.getCouponInfo());
|
| | | } catch (IllegalAccessException e) {
|
| | | e.printStackTrace();
|
| | | } catch (InvocationTargetException e) {
|
| | | e.printStackTrace();
|
| | | } catch (NoSuchMethodException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | coupon.setShopCoupon(true);
|
| | | coupon.setLink(
|
| | | "https://uland.taobao.com/quan/detail?sellerId=725677994&activityId=d03aa6d23a5a4040afb3942e7ea9a007");
|
| | | couponInfoList.add(coupon);
|
| | | }
|
| | | goodsDetail.setCouponInfoList(couponInfoList);
|
| | | }
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
|
| | | object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
|
| | | out.print(JsonUtil.loadTrueResult(object.toString()));
|
| | |
|
| | | final TaoBaoGoodsBrief goodsInfo = tb;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | // 添加浏览记录
|
| | | try {
|
| | | scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | | * 京东商品详情
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param uid
|
| | | * @param from
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getDetailJD")
|
| | | public void getDetialJD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
|
| | | // uid=2255993L;
|
| | | // 系统验证
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
|
| | | acceptData.getPackages());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); // 高级接口
|
| | | if (jdGoods == null) {
|
| | | jdGoods = JDUtil.getGoodsDetail(id); // 爬取网页
|
| | | // jdGoods = JDApiUtil.getGoodsDetail(id); // 普通接口
|
| | | }
|
| | |
|
| | | if (jdGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<String> imageList = jdGoods.getImageList();
|
| | | if (imageList == null) {
|
| | | imageList = new ArrayList<String>();
|
| | | imageList.add(jdGoods.getPicUrl());
|
| | | }
|
| | |
|
| | | // 保存缓存
|
| | | jdGoodsCacheUtil.saveGoodsInfo(jdGoods);
|
| | |
|
| | | ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
|
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
|
| | | GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
|
| | | if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
|
| | | goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
|
| | | goodsDetail.getMoneyInfo().setShareMoney("¥"
|
| | | + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
|
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
|
| | | goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
|
| | | }
|
| | | goodsDetail.getMoneyInfo()
|
| | | .setRateInfoHelpUrl(configService.get(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey()));
|
| | |
|
| | | // 附加信息
|
| | | OtherInfo otherInfo = new OtherInfo();
|
| | |
|
| | | // 京东plus返利
|
| | | String maxMoneyPlus = null;
|
| | | JDCategoryInfo categoryInfo = jdGoods.getCategoryInfo();
|
| | | if (categoryInfo != null && categoryInfo.getCid3() != null && jdGoods.getCommissionInfo() != null) {
|
| | | Long cid3 = categoryInfo.getCid3();
|
| | | JDGoodsClass threeClass = jdGoodsClassService.getThreeClassByCid(Integer.parseInt(cid3.toString()));
|
| | | if (threeClass != null && threeClass.getSelfComm() != null
|
| | | && threeClass.getSelfComm().compareTo(new BigDecimal(0)) > 0) {
|
| | | BigDecimal commissionShare = jdGoods.getCommissionInfo().getCommissionShare();
|
| | | // plus比例 小于正常比例
|
| | | if (commissionShare != null && commissionShare.compareTo(threeClass.getSelfComm()) > 0) {
|
| | | jdGoods.setCommissionPlus(threeClass.getSelfComm());
|
| | | // plus返利
|
| | | BigDecimal fanliMoneyPlus = JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
|
| | | hongBaoManageService.getFanLiRate());
|
| | | otherInfo.setFanliMoneyPlus("京东plus返¥" + fanliMoneyPlus);
|
| | | // 使用奖励券最高返
|
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | maxMoneyPlus = "(京东plus返¥" + JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
|
| | | hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP)) + ")";
|
| | | } else
|
| | | maxMoneyPlus = "(京东plus最高返¥"
|
| | | + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE))
|
| | | + ")";
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 奖励券返利
|
| | | RewardCouponVO rewardCoupon = new RewardCouponVO();
|
| | | rewardCoupon.setMaxMoneyPlus(maxMoneyPlus);
|
| | | rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
|
| | | JSONObject params1 = new JSONObject();
|
| | | if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | params1.put("url", configService.get(ConfigKeyEnum.specialGuideRewardCouponLink.getKey()));
|
| | | else
|
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link"));
|
| | |
|
| | | rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
|
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | rewardCoupon.setDesc("返");
|
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link"));
|
| | | rewardCoupon.getJumpDetail().setNeedLogin(true);
|
| | | } else {
|
| | | rewardCoupon.setDesc("用返利奖励券最高返");
|
| | | }
|
| | | rewardCoupon.setParams(params1.toString());
|
| | |
|
| | | otherInfo.setRewardCoupon(rewardCoupon);
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
|
| | | otherInfo.setRewardCoupon(null);
|
| | |
|
| | | goodsDetail.setOtherInfo(otherInfo);
|
| | |
|
| | | CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
|
| | | if (couponInfo != null) {
|
| | | // 券链接处理
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | | String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(),
|
| | | JDApiUtil.POSITION_COUPON + "", null);
|
| | | couponInfo.setLink(url);
|
| | | }
|
| | |
|
| | | ShopInfoVO shopInfo = goodsDetail.getShopInfo();
|
| | | if (shopInfo != null) {
|
| | | if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
|
| | | || shopInfo.getScoreSeller() == null) {
|
| | | goodsDetail.setShopInfo(null);
|
| | | }
|
| | | }
|
| | |
|
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
|
| | | extraVO.setIsNative(false);
|
| | | // IOS是否正在上线
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
|
| | | String version = acceptData.getVersion();
|
| | | extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
|
| | | }
|
| | |
|
| | | Long inOrderCount30Days = jdGoods.getInOrderCount30Days();
|
| | | List<ShamUser> listShareUser = new ArrayList<ShamUser>();
|
| | |
|
| | | // 京东开启分享
|
| | | String open = configService.get(ConfigKeyEnum.shareOpenJD.getKey());
|
| | | if ("1".equals(open.trim())) {
|
| | | extraVO.setShareValid(true);
|
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
|
| | | if (moneyInfo != null) {
|
| | | String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", "");
|
| | | if (Integer.parseInt(inOrderCount30Days.toString()) >= 1000) {
|
| | | listShareUser.addAll(shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | extraVO.setListShareUser(listShareUser);
|
| | |
|
| | | // 领券人列表
|
| | | List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
|
| | | if (goodsDetail.isHasCoupon() && Integer.parseInt(inOrderCount30Days.toString()) >= 1000) {
|
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
|
| | | }
|
| | | extraVO.setListCouponUser(listCouponUser);
|
| | |
|
| | | if (uid != null) {
|
| | | // 是否加入收藏
|
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
|
| | | Constant.SOURCE_TYPE_JD);
|
| | | extraVO.setCollected(collectionGoods != null ? true : false);
|
| | | // 是否加入选品库
|
| | | extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_JD));
|
| | | }
|
| | |
|
| | | // 图文详情
|
| | | extraVO.setDetailUrl("https://in.m.jd.com/product/jieshao/video/" + id + ".html");
|
| | |
|
| | | // 测试
|
| | | SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system,
|
| | | "goods_detail_jump_taobao");
|
| | | if ("1".equalsIgnoreCase((params.getValue() + "").trim())) {
|
| | | extraVO.setIsNative(true);
|
| | | }
|
| | |
|
| | | // 商品链接
|
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePathJD(), "", id + "");
|
| | | try {
|
| | | extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
|
| | | } catch (Exception e) {
|
| | | extraVO.setH5Url(h5Url);
|
| | | }
|
| | |
|
| | | String helpLink = null;
|
| | | extraVO.setFanliValid(true);
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(helpLink)) {
|
| | | helpLink = configService.get(ConfigKeyEnum.noRebateHelpLink.getKey());
|
| | | }
|
| | |
|
| | | ShareVO shareInfoVO = new ShareVO();
|
| | | shareInfoVO.setHelpLink(helpLink);
|
| | | extraVO.setShare(shareInfoVO);
|
| | |
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
|
| | | object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
|
| | | out.print(JsonUtil.loadTrueResult(object.toString()));
|
| | |
|
| | | final JDGoods goods = jdGoods;
|
| | | final Long fuid = uid;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | // 添加浏览记录
|
| | | try {
|
| | | scanHistoryV2Service.addJDScanHistory(fuid, acceptData.getDevice(), goods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | goodsEvaluateService.updateJDGoods(goods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | | * 拼多多商品详情
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param uid
|
| | | * @param from
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getDetailPDD", method = RequestMethod.POST)
|
| | | public void getDetialPDD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
|
| | | // 系统验证
|
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
|
| | | acceptData.getPackages());
|
| | | if (system == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id);
|
| | | if (pddGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid);
|
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
|
| | |
|
| | | GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
|
| | | if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
|
| | | goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
|
| | | goodsDetail.getMoneyInfo().setShareMoney("¥" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods,
|
| | | hongBaoManageService.getShareRate(UserLevelEnum.superVIP)));
|
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo());
|
| | | goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo());
|
| | | }
|
| | | goodsDetail.getMoneyInfo()
|
| | | .setRateInfoHelpUrl(configService.get(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey()));
|
| | |
|
| | | // 附加信息
|
| | | OtherInfo otherInfo = new OtherInfo();
|
| | | RewardCouponVO rewardCoupon = new RewardCouponVO();
|
| | | rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
|
| | | JSONObject params1 = new JSONObject();
|
| | | if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | params1.put("url", configService.get(ConfigKeyEnum.specialGuideRewardCouponLink.getKey()));
|
| | | else
|
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link"));
|
| | |
|
| | | rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney());
|
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | rewardCoupon.setDesc("返");
|
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link"));
|
| | | rewardCoupon.getJumpDetail().setNeedLogin(true);
|
| | | } else
|
| | | rewardCoupon.setDesc("用返利奖励券最高返");
|
| | | rewardCoupon.setParams(params1.toString());
|
| | | otherInfo.setRewardCoupon(rewardCoupon);
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())
|
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion())))
|
| | | otherInfo.setRewardCoupon(null);
|
| | | goodsDetail.setOtherInfo(otherInfo);
|
| | |
|
| | | CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
|
| | | PDDPromotionUrl convertUrl = null;
|
| | | if (couponInfo != null) {
|
| | | convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_COUPON + "", null);
|
| | | if (convertUrl != null)
|
| | | couponInfo.setLink(convertUrl.getUrl());
|
| | | }
|
| | |
|
| | | ShopInfoVO shopInfo = goodsDetail.getShopInfo();
|
| | | if (shopInfo != null) {
|
| | | if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
|
| | | || shopInfo.getScoreSeller() == null) {
|
| | | goodsDetail.setShopInfo(null);
|
| | | }
|
| | | }
|
| | |
|
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
|
| | | extraVO.setIsNative(false);
|
| | | // IOS是否正在上线
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
|
| | | String version = acceptData.getVersion();
|
| | | extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
|
| | | }
|
| | |
|
| | | // 图文详情
|
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + id);
|
| | |
|
| | | String salesTip = pddGoods.getSalesTip();
|
| | | if (!StringUtil.isNullOrEmpty(salesTip)) {
|
| | | int indexOf = salesTip.indexOf("+");
|
| | | if (indexOf > 0) {
|
| | | salesTip = salesTip.substring(0, indexOf);
|
| | | }
|
| | |
|
| | | int totalSales = 0;
|
| | | if (salesTip.contains("万")) {
|
| | | salesTip = salesTip.substring(0, salesTip.indexOf("万"));
|
| | | totalSales = (int) (Float.parseFloat(salesTip) * 10000);
|
| | | } else {
|
| | | totalSales = Integer.parseInt(salesTip);
|
| | | }
|
| | |
|
| | | List<ShamUser> listShareUser = new ArrayList<ShamUser>();
|
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
|
| | | if (moneyInfo != null) {
|
| | | String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", "");
|
| | | if (totalSales >= 50000) {
|
| | | listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5);
|
| | | }
|
| | | }
|
| | | extraVO.setListShareUser(listShareUser);
|
| | |
|
| | | // 领券人列表
|
| | | List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
|
| | | if (goodsDetail.isHasCoupon() && totalSales >= 50000) {
|
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
|
| | | }
|
| | | extraVO.setListCouponUser(listCouponUser);
|
| | | }
|
| | |
|
| | | if (uid != null) {
|
| | | // 是否加入收藏
|
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
|
| | | Constant.SOURCE_TYPE_PDD);
|
| | | extraVO.setCollected(collectionGoods != null ? true : false);
|
| | | // 是否加入选品库
|
| | | extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_PDD));
|
| | | }
|
| | |
|
| | | extraVO.setIsNative(true);
|
| | |
|
| | | // 分享路径
|
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
|
| | | try {
|
| | | extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
|
| | | } catch (Exception e) {
|
| | | extraVO.setH5Url(h5Url);
|
| | | }
|
| | |
|
| | | String helpLink = null;
|
| | | extraVO.setFanliValid(true);
|
| | | extraVO.setShareValid(true);
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(helpLink)) {
|
| | | helpLink = configService.get(ConfigKeyEnum.noRebateHelpLink.getKey());
|
| | | }
|
| | |
|
| | | ShareVO shareInfoVO = new ShareVO();
|
| | | shareInfoVO.setHelpLink(helpLink);
|
| | | extraVO.setShare(shareInfoVO);
|
| | |
|
| | | if (convertUrl != null) {
|
| | | extraVO.setCouponJumpLink(convertUrl.getUrl());
|
| | | extraVO.setNativeCouponJumpLink(PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
|
| | | }
|
| | |
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
|
| | | object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
|
| | | out.print(JsonUtil.loadTrueResult(object.toString()));
|
| | |
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | // 添加浏览记录
|
| | | try {
|
| | | scanHistoryV2Service.addPDDScanHistory(uid, acceptData.getDevice(), pddGoods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | goodsEvaluateService.updatePDDGoods(pddGoods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | | * 商品详情推荐(猜你喜欢 + 推荐)
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getRecommendGoods", method = RequestMethod.POST)
|
| | | public void getRecommendGoods(AcceptData acceptData, long id, Integer goodsType, PrintWriter out) {
|
| | | if (goodsType == null) {
|
| | | goodsType = Constant.SOURCE_TYPE_TAOBAO;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | // 京东
|
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
|
| | |
|
| | | List<JDGoods> list = JDUtil.getRecommendGoodsById(id);
|
| | | if (list == null) {
|
| | | list = new ArrayList<JDGoods>();
|
| | | } else if (list.size() > 10) {
|
| | | list = list.subList(0, 10);
|
| | | }
|
| | |
|
| | | ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null);
|
| | | List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
|
| | |
|
| | | for (JDGoods goods : list) {
|
| | | listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO));
|
| | | }
|
| | |
|
| | | // 取偶数个数据
|
| | | if (listDetailVO.size() % 2 != 0) {
|
| | | listDetailVO.remove(listDetailVO.size() - 1);
|
| | | }
|
| | |
|
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 拼多多
|
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
|
| | |
|
| | | List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
|
| | |
|
| | | List<Long> goodsIdList = PinDuoDuoUtil.getRecommendGoodsId(id);
|
| | | if (goodsIdList != null && goodsIdList.size() > 0) {
|
| | | PDDSearchFilter pddfilter = new PDDSearchFilter();
|
| | | pddfilter.setPage(1);
|
| | | pddfilter.setPageSize(Constant.PAGE_SIZE);
|
| | | Long[] strings = new Long[goodsIdList.size()];
|
| | | pddfilter.setGoodsIdList(goodsIdList.toArray(strings));
|
| | |
|
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
|
| | | if (result != null) {
|
| | | List<PDDGoodsDetail> goodsList = result.getGoodsList();
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | |
|
| | | if (goodsList.size() > 10) {
|
| | | goodsList = goodsList.subList(0, 10);
|
| | | }
|
| | |
|
| | | ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(),
|
| | | null);
|
| | | for (PDDGoodsDetail goods : goodsList) {
|
| | | listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 取偶数个数据
|
| | | if (listDetailVO.size() % 2 != 0) {
|
| | | listDetailVO.remove(listDetailVO.size() - 1);
|
| | | }
|
| | |
|
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10);
|
| | | // 初始化
|
| | | if (goodsList == null) {
|
| | | goodsList = new ArrayList<TaoBaoGoodsBrief>();
|
| | | }
|
| | |
|
| | | List<GoodsDetailVO> listExtra = new ArrayList<GoodsDetailVO>();
|
| | | TaoKeAppInfo app = new TaoKeAppInfo();
|
| | | app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
|
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | app.setAdzoneId(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]);
|
| | | app.setPid(TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
|
| | |
|
| | | List<Long> ids = new ArrayList<>();
|
| | | for (TaoBaoGoodsBrief goods : goodsList)
|
| | | ids.add(goods.getAuctionId());
|
| | |
|
| | | try {
|
| | | goodsList = TaoKeApiUtil.getBatchGoodsInfo(ids);
|
| | | } catch (TaoKeApiException e1) {
|
| | | } catch (TaobaoGoodsDownException e1) {
|
| | | }
|
| | |
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | |
|
| | | ConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null);
|
| | |
|
| | | goodsList.parallelStream().forEach(goods -> {
|
| | | if (goods != null) {
|
| | | // 获取详情
|
| | | TaoBaoGoodsBrief taoBaoGoodsBrief = null;
|
| | | try {
|
| | | taoBaoGoodsBrief = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(goods.getAuctionId());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | TaoBaoGoodsBrief newGoods = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app);
|
| | | goods.setCouponInfo(newGoods.getCouponInfo());
|
| | | goods.setCouponLink(newGoods.getCouponLink());
|
| | | goods.setTkRate(newGoods.getTkRate());
|
| | | taoBaoGoodsBrief = goods;
|
| | | }
|
| | |
|
| | | if (taoBaoGoodsBrief != null) {
|
| | | listExtra.add(GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, paramsDTO));
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | List<GoodsDetailVO> listQuality = new ArrayList<GoodsDetailVO>();
|
| | | // 取偶数个数据
|
| | | if (listExtra.size() % 2 != 0) {
|
| | | listExtra.remove(listExtra.size() - 1);
|
| | | }
|
| | |
|
| | | if (listQuality.size() % 2 != 0) {
|
| | | listQuality.remove(listQuality.size() - 1);
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra));
|
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("listQuality", new JSONArray());
|
| | | data.put("listGuess", new JSONArray());
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 京东购买链接
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | | * @param couponUrl
|
| | | * -优惠券链接
|
| | | * @param source
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getJDLink")
|
| | | public void getJDLink(AcceptData acceptData, Long uid, Long id, String couponUrl, String source, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (id == null || id <= 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;
|
| | | }
|
| | |
|
| | | JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(id);
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | String jumpLink = null;
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | | if (StringUtil.isNullOrEmpty(couponUrl)) {
|
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods.getCouponInfoList(), goods.getPrice());
|
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "",
|
| | | uid + "");
|
| | | if (jumpLink == null) {
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, JDApiUtil.POSITION_FANLI + "",
|
| | | uid + "");
|
| | | }
|
| | | } else {
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "",
|
| | | uid + "");
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("native", true);
|
| | | data.put("jumpLink", jumpLink);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | // 获得金币
|
| | | integralGetService.addCouponRebate(uid);
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getJDCouponLink")
|
| | | public void getJDCouponLink(AcceptData acceptData, Long id, String couponUrl, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(couponUrl)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "券链接不能为空"));
|
| | | return;
|
| | | }
|
| | | if (id == null || id <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | String jumpLink = null;
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | |
|
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, JDApiUtil.POSITION_FANLI + "", null);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("native", true);
|
| | | data.put("jumpLink", jumpLink);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 拼多多购买链接
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | | * @param source
|
| | | * @param request
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getPDDLink")
|
| | | public void getPDDLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (id == null || id <= 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;
|
| | | }
|
| | |
|
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(id);
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
|
| | | return;
|
| | | }
|
| | |
|
| | | PDDPromotionUrl convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_FANLI + "", uid + "");
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("native", true);
|
| | |
|
| | | data.put("jumpLink", convertUrl.getUrl());
|
| | | data.put("nativeJumpLink", PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | // 获得金币
|
| | | integralGetService.addCouponRebate(uid);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 是否在参与推广
|
| | | * |
| | | * @param goodsId
|
| | | * -商品ID
|
| | | * @param goodsType
|
| | | * -TB/JD
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "isGoodsExtend")
|
| | | public void isGoodsExtend(AcceptData acceptData, String goodsId, Integer goodsType, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(goodsId)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "未参与推广"));
|
| | | return;
|
| | | }
|
| | | if (goodsType == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "缺少goodsType"));
|
| | | return;
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | TaoBaoGoodsBrief goods = null;
|
| | | try {
|
| | | goods = TaoKeApiUtil.getSimpleGoodsInfo(Long.parseLong(goodsId));
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | 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);
|
| | | }
|
| | |
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(goodsId));
|
| | | if (goods == null) {
|
| | | data.put("extend", false);
|
| | | data.put("url", String.format("https://item.m.jd.com/product/%s.html", goodsId));
|
| | | } else {
|
| | | data.put("extend", true);
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId));
|
| | | if (goods == null) {
|
| | | data.put("extend", false);
|
| | | data.put("url", String.format("https://mobile.yangkeduo.com/goods.html?goods_id=%s", goodsId));
|
| | | } else {
|
| | | data.put("extend", true);
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "listSimpleGoods", method = RequestMethod.POST)
|
| | | public void listSimpleGoods(AcceptData acceptData, String goodsInfo, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(goodsInfo)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "商品信息为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | net.sf.json.JSONArray array = net.sf.json.JSONArray.fromObject(goodsInfo);
|
| | |
|
| | | List<CommonGoods> commonGoodsList = new ArrayList<>();
|
| | |
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject obj = array.optJSONObject(i);
|
| | | CommonGoods cg = new CommonGoods();
|
| | | cg.setGoodsId(obj.optLong("goodsId"));
|
| | | cg.setGoodsType(obj.optInt("goodsType"));
|
| | | commonGoodsList.add(cg);
|
| | | }
|
| | |
|
| | | if (commonGoodsList.size() > 9) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "最多同时获取9条数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 分离各个平台的商品信息
|
| | | List<Long> tbGoodsList = new ArrayList<>();
|
| | | List<Long> jdGoodsList = new ArrayList<>();
|
| | | List<Long> pddGoodsList = new ArrayList<>();
|
| | |
|
| | | List<String> keyList = new ArrayList<>();
|
| | |
|
| | | for (CommonGoods cg : commonGoodsList) {
|
| | | keyList.add(cg.getGoodsId() + "-" + cg.getGoodsType());
|
| | | if (cg.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | tbGoodsList.add(cg.getGoodsId());
|
| | | } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_JD) {
|
| | | jdGoodsList.add(cg.getGoodsId());
|
| | | } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_PDD) {
|
| | | pddGoodsList.add(cg.getGoodsId());
|
| | | }
|
| | | }
|
| | |
|
| | | Map<String, GoodsDetailVO> tempGoodsList = new HashMap<>();
|
| | |
|
| | | ConfigParamsDTO params = new ConfigParamsDTO(hongBaoManageService.getFanLiRate(),
|
| | | hongBaoManageService.getShareRate(), new BigDecimal(80),
|
| | | hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP));
|
| | |
|
| | | if (tbGoodsList.size() > 0) {
|
| | | List<TaoBaoGoodsBrief> goodsList = null;
|
| | | try {
|
| | | goodsList = TaoKeApiUtil.getBatchGoodsInfo(tbGoodsList);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (goodsList != null)
|
| | | for (TaoBaoGoodsBrief goods : goodsList) {
|
| | | goods.setTkRate(new BigDecimal(0));
|
| | | tempGoodsList.put(goods.getAuctionId() + "-" + Constant.SOURCE_TYPE_TAOBAO,
|
| | | GoodsDetailVOFactory.convertTaoBao(goods, params));
|
| | | }
|
| | | }
|
| | | if (jdGoodsList.size() > 0) {
|
| | | List<JDGoods> goodsList = JDApiUtil.getGoodsDetail(jdGoodsList);
|
| | | for (JDGoods goods : goodsList) {
|
| | | tempGoodsList.put(goods.getSkuId() + "-" + Constant.SOURCE_TYPE_JD,
|
| | | GoodsDetailVOFactory.convertJDGoods(goods, params));
|
| | | }
|
| | | }
|
| | | if (pddGoodsList.size() > 0) {
|
| | | List<PDDGoodsDetail> goodsList = PinDuoDuoApiUtil.listGoodsDetail(pddGoodsList);
|
| | | for (PDDGoodsDetail goods : goodsList) {
|
| | | tempGoodsList.put(goods.getGoodsId() + "-" + Constant.SOURCE_TYPE_PDD,
|
| | | GoodsDetailVOFactory.convertPDDGoods(goods, params));
|
| | | }
|
| | | }
|
| | | List<GoodsDetailVO> voList = new ArrayList<>();
|
| | | Gson gson = JsonUtil.getApiCommonGson();
|
| | | for (String key : keyList) {
|
| | | GoodsDetailVO vo = tempGoodsList.get(key);
|
| | | if (vo != null) {
|
| | | voList.add(vo);
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(gson.toJson(voList)));
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.controller.client.v2; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemFunction; |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | import com.yeshi.fanli.exception.pdd.PDDApiException; |
| | | import com.yeshi.fanli.lijin.manager.GoodsLijinMnager; |
| | | import com.yeshi.fanli.lijin.manager.UserLijinMnager; |
| | | import com.yeshi.fanli.service.inter.pdd.PDDAuthService; |
| | | import com.yeshi.fanli.service.inter.user.*; |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.util.goods.GoodsJumpUtil; |
| | | import com.yeshi.fanli.util.goods.douyin.CSJCPSApiUtil; |
| | | import com.yeshi.fanli.util.goods.douyin.DYUtil; |
| | | import com.yeshi.fanli.util.goods.douyin.vo.*; |
| | | import com.yeshi.fanli.vo.common.WXXCXJumpInfoVO; |
| | | import com.yeshi.fanli.vo.pdd.PDDConvertLinkResultVO; |
| | | import com.yeshi.fanli.vo.goods.GoodsJumpLinkVO; |
| | | import com.yeshi.fanli.vo.suning.SuningConvertLinkResult; |
| | | import com.yeshi.goods.facade.dto.taobao.TaoBaoGoodsImportantInfo; |
| | | import org.json.simple.JSONArray; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.taobao.TbImgUtil; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; |
| | | import com.yeshi.fanli.dto.jd.JDCategoryInfo; |
| | | import com.yeshi.fanli.dto.jd.JDCouponInfo; |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult; |
| | | import com.yeshi.fanli.dto.pdd.PDDSearchFilter; |
| | | import com.yeshi.fanli.dto.suning.SuningGoodsInfo; |
| | | import com.yeshi.fanli.dto.suning.SuningGoodsInfoRecommend; |
| | | import com.yeshi.goods.facade.dto.taobao.dataoke.DaTaoKeFilterResult; |
| | | import com.yeshi.fanli.dto.vip.VIPConvertResultDTO; |
| | | import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo; |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.user.ShamUser; |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo; |
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum; |
| | | import com.yeshi.fanli.entity.dynamic.CommentInfo; |
| | | import com.yeshi.fanli.entity.dynamic.GoodsEvaluate; |
| | | import com.yeshi.fanli.entity.dynamic.ImgInfo; |
| | | import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum; |
| | | import com.yeshi.fanli.entity.goods.CollectionGoodsV2; |
| | | import com.yeshi.fanli.entity.goods.CommonGoods; |
| | | import com.yeshi.fanli.entity.jd.JDGoods; |
| | | import com.yeshi.fanli.entity.jd.JDGoodsClass; |
| | | import com.yeshi.fanli.entity.system.BusinessSystem; |
| | | import com.yeshi.fanli.entity.system.ConfigKeyEnum; |
| | | import com.yeshi.fanli.entity.system.SystemClientParams; |
| | | import com.yeshi.fanli.entity.taobao.ClientTBPid; |
| | | import com.yeshi.fanli.entity.taobao.TLJBuyGoods; |
| | | import com.yeshi.fanli.entity.taobao.TLJFreeBuyGoods; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import com.yeshi.common.entity.taobao.TaoBaoShop; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; |
| | | import com.yeshi.common.entity.taobao.TaoKeAppInfo; |
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException; |
| | | 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.dynamic.GoodsEvaluateService; |
| | | import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service; |
| | | import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service; |
| | | import com.yeshi.fanli.service.inter.jd.JDGoodsClassService; |
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; |
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; |
| | | import com.yeshi.fanli.service.inter.taobao.TLJBuyGoodsService; |
| | | import com.yeshi.fanli.service.inter.taobao.TLJFreeBuyGoodsService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService; |
| | | import com.yeshi.goods.facade.service.DaTaoKeGoodsDetailV2Service; |
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralGetService; |
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; |
| | | import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService; |
| | | import com.yeshi.fanli.service.manger.user.UserLevelManager; |
| | | import org.yeshi.utils.MoneyBigDecimalUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import com.yeshi.fanli.util.cache.JDGoodsCacheUtil; |
| | | import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil; |
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil; |
| | | import com.yeshi.goods.facade.utils.taobao.DaTaoKeApiUtil; |
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; |
| | | import com.yeshi.fanli.util.factory.goods.ShopInfoVOFactory; |
| | | import com.yeshi.fanli.util.jd.JDApiUtil; |
| | | import com.yeshi.fanli.util.jd.JDUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; |
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil; |
| | | import com.yeshi.fanli.util.suning.SuningApiUtil; |
| | | import com.yeshi.fanli.util.suning.SuningUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil; |
| | | import com.yeshi.fanli.util.user.UserLevelUtil; |
| | | import com.yeshi.fanli.util.vipshop.VipShopApiUtil; |
| | | import com.yeshi.fanli.util.vipshop.VipShopUtil; |
| | | import com.yeshi.fanli.vo.goods.CouponInfoVO; |
| | | import com.yeshi.fanli.vo.goods.GoodsDetailExtraVO; |
| | | 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.common.vo.ClientTextStyleVO; |
| | | import com.yeshi.fanli.vo.tlj.NewUserHongBao; |
| | | import com.yeshi.fanli.vo.tlj.ReduceHongBao; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/v2/goods") |
| | | public class GoodsControllerV2 { |
| | | |
| | | |
| | | Logger logger = LoggerFactory.getLogger(GoodsControllerV2.class); |
| | | |
| | | @Resource |
| | | private BusinessSystemService businessSystemService; |
| | | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private TBPidService tbPidService; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; |
| | | |
| | | @Resource |
| | | private TaoBaoShopService taoBaoShopService; |
| | | |
| | | @Resource |
| | | private ShamUserService shamUserService; |
| | | |
| | | @Resource |
| | | private CollectionGoodsV2Service collectionGoodsV2Service; |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; |
| | | |
| | | @Resource |
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService; |
| | | |
| | | @Resource |
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; |
| | | |
| | | @Resource |
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; |
| | | |
| | | @Resource |
| | | private SystemClientParamsService systemClientParamsService; |
| | | |
| | | @Resource |
| | | private UserGoodsStorageService userGoodsStorageService; |
| | | |
| | | @Resource |
| | | private ScanHistoryV2Service scanHistoryV2Service; |
| | | |
| | | @Resource |
| | | private TLJBuyGoodsService tljBuyGoodsService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private JDGoodsCacheUtil jdGoodsCacheUtil; |
| | | |
| | | @Resource |
| | | private PinDuoDuoCacheUtil pinDuoDuoCacheUtil; |
| | | |
| | | @Resource |
| | | private IntegralGetService integralGetService; |
| | | |
| | | @Resource |
| | | private JumpDetailV2Service jumpDetailV2Service; |
| | | |
| | | @Resource |
| | | private JDGoodsClassService jdGoodsClassService; |
| | | |
| | | @Resource |
| | | private TLJFreeBuyGoodsService tljFreeBuyGoodsService; |
| | | |
| | | |
| | | @Resource |
| | | private UserVIPInfoService userVIPInfoService; |
| | | |
| | | @Resource |
| | | private UserVipConfigService userVipConfigService; |
| | | |
| | | @Resource |
| | | private GoodsEvaluateService goodsEvaluateService; |
| | | |
| | | @Resource |
| | | private UserLevelManager userLevelManager; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | |
| | | @Resource |
| | | private PDDAuthService pddAuthService; |
| | | |
| | | @Resource |
| | | private GoodsLijinMnager goodsLijinMnager; |
| | | |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | |
| | | @Resource |
| | | private UserLijinMnager userLijinMnager; |
| | | |
| | | @Resource |
| | | private UserFunctionsLimitService userFunctionsLimitService; |
| | | |
| | | private GoodsMoneyConfigParamsDTO getParamsDTO(String platform, String version, Long uid, SystemEnum system) { |
| | | UserLevelEnum level = UserLevelEnum.daRen; |
| | | if (uid != null && uid > 0) { |
| | | level = userLevelManager.getUserLevel(uid); |
| | | if (level != null) { |
| | | if (System.currentTimeMillis() < Constant.NEW_ORDER_FANLI_RULE_TIME) |
| | | level = UserLevelUtil.getOldLevel(level); |
| | | } |
| | | } |
| | | if (level == null) |
| | | level = UserLevelEnum.daRen; |
| | | |
| | | return orderHongBaoMoneyComputeService.getShowComputeRate(platform, version, level, system); |
| | | } |
| | | |
| | | private TaoBaoGoodsBrief filterDaTaoKeGoodsInfo(SystemEnum system, TaoBaoGoodsBrief goods) { |
| | | String specialPid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanli); |
| | | String relationPid = pidManager.getPidCache(system, Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanliChannel); |
| | | |
| | | try { |
| | | DaTaoKeFilterResult result = daTaoKeGoodsDetailV2Service.filterTaoBaoGoods(goods); |
| | | if (result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_COUPON |
| | | || result.getFilterType() == DaTaoKeFilterResult.FILTER_TYPE_PRICE_AND_COUPON) { |
| | | // 缓存基础链接 |
| | | String dpid = null; |
| | | if (TaoBaoUtil.isSpecialGoods(goods.getMaterialLibType())) { |
| | | dpid = specialPid; |
| | | } else { |
| | | dpid = relationPid; |
| | | } |
| | | String link = taoBaoGoodsCacheUtil.getBaseConvertLink(goods.getAuctionId(), dpid); |
| | | if (!StringUtil.isNullOrEmpty(link)) { |
| | | // result.getGoods().setCouponLink(link); |
| | | return result.getGoods(); |
| | | } else { |
| | | link = DaTaoKeApiUtil.convertLink(goods.getAuctionId(), dpid, false); |
| | | if (!StringUtil.isNullOrEmpty(link)) { |
| | | // result.getGoods().setCouponLink(link); |
| | | taoBaoGoodsCacheUtil.cacheBaseConvertLink(goods.getAuctionId(), dpid, link); |
| | | } |
| | | return result.getGoods(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | |
| | | return goods; |
| | | } |
| | | |
| | | /** |
| | | * 淘宝商品详情 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param uid |
| | | * @param from |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getDetailTB", method = RequestMethod.POST) |
| | | public void getDetialTB(AcceptData acceptData, String id, Long uid, String from, PrintWriter out) { |
| | | if (id == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品id不能为空")); |
| | | return; |
| | | } |
| | | |
| | | logger.debug("获取商品详情-开始:{}", id + ""); |
| | | |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO(); |
| | | extraVO.setIsNative(false); |
| | | |
| | | // IOS是否正在上线 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | String version = acceptData.getVersion(); |
| | | extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem())); |
| | | } |
| | | |
| | | long startTime = java.lang.System.currentTimeMillis(); |
| | | |
| | | // 获取淘客参数 |
| | | ClientTBPid clientTBPid = null; |
| | | |
| | | // 用户未登录 |
| | | if (acceptData.getPlatform().equalsIgnoreCase("android")) { |
| | | clientTBPid = tbPidService.getAndroidDefault(); |
| | | } else { |
| | | clientTBPid = tbPidService.getIOSDefault(); |
| | | } |
| | | |
| | | LogHelper.test("获取PID耗时:" + (java.lang.System.currentTimeMillis() - startTime)); |
| | | |
| | | // final List<TaoBaoGoodsBrief> goodsList = new ArrayList<>(); |
| | | // 是否在服务端进行转链 |
| | | boolean convertInServer = configService.isConvertTaoBaoLinkInServer(acceptData.getSystem()); |
| | | |
| | | TaoBaoGoodsBrief goods = null; |
| | | |
| | | if (!convertInServer) { |
| | | logger.debug("获取商品详情-不在服务端转链:{}", id + ""); |
| | | try { |
| | | goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id); |
| | | if (goods == null) { |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAppKey(TaoBaoConstant.TAOBAO_COMMON_APPKEY); |
| | | app.setAppSecret(TaoBaoConstant.TAOBAO_COMMON_APPSECRET); |
| | | app.setPid(TaoBaoConstant.TAOBAO_COMMON_PID); |
| | | app.setAdzoneId(TaoBaoConstant.TAOBAO_COMMON_PID.split("_")[3]); |
| | | goods = TaoKeApiUtil.searchGoodsDetail(id, app); |
| | | |
| | | final TaoBaoGoodsBrief finalGoods = goods; |
| | | if (goods != null) { |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | taoBaoGoodsCacheUtil.saveCommonTaoBaoGoodsInfo(finalGoods); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } catch (TaobaoGoodsDownException e) { |
| | | // 商品下架 |
| | | ThreadUtil.run(new Runnable() { |
| | | |
| | | public void run() { |
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(id); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } else { |
| | | final String clientPid = clientTBPid.getPid(); |
| | | String appId = clientPid.split("_")[2]; |
| | | TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(appId); |
| | | TaoKeAppInfo app = new TaoKeAppInfo(); |
| | | app.setAdzoneId(clientPid.split("_")[3]); |
| | | app.setAppKey(config.getAppKey()); |
| | | app.setAppSecret(config.getAppSecret()); |
| | | app.setPid(clientPid); |
| | | |
| | | try { |
| | | goods = TaoKeApiUtil.searchGoodsDetail(id, app); |
| | | if (goods.getTkRate() == null || new BigDecimal(0).compareTo(goods.getTkRate()) == 0) { |
| | | TaoBaoGoodsBrief linkInfo = TaoKeApiUtil.specialConvertCoupon(goods.getAuctionId(), app, null, null); |
| | | if (linkInfo != null) { |
| | | goods.setAuctionUrl(linkInfo.getAuctionUrl()); |
| | | goods.setCouponLink(linkInfo.getCouponLink()); |
| | | goods.setTkRate(linkInfo.getTkRate()); |
| | | } |
| | | } |
| | | |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | taoBaoGoodsUpdateService.offlineTaoBaoGoods(id); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (goods != null) { |
| | | final TaoBaoGoodsBrief newGoods = goods; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | try { |
| | | // 更新商品 |
| | | LogHelper.test("更新商品详情:" + newGoods.getAuctionId()); |
| | | taoBaoGoodsUpdateService.updateTaoBaoGoods(newGoods); |
| | | } catch (TaobaoGoodsUpdateException e) { |
| | | |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | logger.debug("获取商品详情-获取商品详情成功:{}", id + ""); |
| | | |
| | | TaoBaoGoodsBrief tb = goods; |
| | | |
| | | //创建时间设置为空,防止前端用long解析 |
| | | tb.setCreatetime(null); |
| | | |
| | | |
| | | if (tb == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | |
| | | if (tb.getImgList() == null) { |
| | | tb.setImgList(new ArrayList<>()); |
| | | } |
| | | |
| | | |
| | | if (uid != null && uid > 0) { |
| | | String specialId = userExtraTaoBaoInfoService.getSpecialIdByUid(uid); |
| | | //获取最新的比例 |
| | | TaoBaoGoodsBrief rateGoods = TaoKeApiUtil.specialConvertCoupon(tb.getAuctionId(), TaoBaoConstant.getSpecialAuthAppInfo(pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_TAOBAO, SystemPIDInfo.PidType.fanli)), specialId, null); |
| | | if (rateGoods != null) |
| | | tb.setMinTkRate(rateGoods.getTkRate()); |
| | | } |
| | | |
| | | List<String> finalImgList = new ArrayList<>(); |
| | | for (String img : tb.getImgList()) { |
| | | finalImgList.add(TbImgUtil.getTBSizeImg(img, 600)); |
| | | } |
| | | |
| | | if (finalImgList.size() == 0) { |
| | | finalImgList.add(tb.getPictUrl()); |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(tb.getPictUrlWhite())) |
| | | finalImgList.add(0, tb.getPictUrlWhite()); |
| | | |
| | | // 移除相同图片 |
| | | if (finalImgList.size() > 0) |
| | | for (int i = 0; i < finalImgList.size(); i++) { |
| | | if (i < finalImgList.size() - 1) |
| | | if (TbImgUtil.getTBSizeImg(finalImgList.get(i), 600) |
| | | .equalsIgnoreCase(TbImgUtil.getTBSizeImg(finalImgList.get(i + 1), 600))) { |
| | | finalImgList.remove(i--); |
| | | } |
| | | } |
| | | |
| | | tb.setImgList(finalImgList); |
| | | |
| | | logger.debug("获取商品详情-开始大淘客商品过滤:{}", id + ""); |
| | | |
| | | // 大淘客商品过滤 |
| | | try { |
| | | goods = filterDaTaoKeGoodsInfo(acceptData.getSystem(), goods); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | |
| | | logger.debug("获取商品详情-结束大淘客商品过滤:{}", id + ""); |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem()); |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); |
| | | |
| | | logger.debug("获取商品详情-获取到返利比例:{}", id + ""); |
| | | |
| | | GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); |
| | | if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) { |
| | | goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | goodsDetail.getMoneyInfo().setShareMoney("¥" + TaoBaoUtil.getGoodsHongBaoMoney(goods, |
| | | hongBaoManageService.getShareRate(UserLevelEnum.superVIP, acceptData.getSystem()), true)); |
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo()); |
| | | goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo()); |
| | | } |
| | | goodsDetail.getMoneyInfo() |
| | | .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem())); |
| | | |
| | | if (TaoBaoUtil.isYUShou(goods)) { |
| | | if (!StringUtil.isNullOrEmpty(goods.getPresaleDiscountFeeText())) { |
| | | if (goodsDetail.getLabels() == null) |
| | | goodsDetail.setLabels(new ArrayList<>()); |
| | | goodsDetail.getLabels().add(new ClientTextStyleVO(goods.getPresaleDiscountFeeText(), "#FF2B4E")); |
| | | } |
| | | } |
| | | // 在标题添加优惠信息 |
| | | |
| | | // 店铺信息 |
| | | TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(id, goods.getSellerId()); |
| | | if (shop != null) { |
| | | String shopLink = shop.getShopLink(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); |
| | | } |
| | | goodsDetail.setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop)); |
| | | } |
| | | logger.debug("获取商品详情-获取店铺信息结束:{}", id + ""); |
| | | |
| | | |
| | | // 免单商品 |
| | | if (!StringUtil.isNullOrEmpty(from) && "miandan".equals(from)) { |
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo(); |
| | | if (goodsDetail.isHasCoupon()) { |
| | | moneyInfo.setFanliMoney("¥" + goodsDetail.getCouponPrice()); |
| | | } else { |
| | | moneyInfo.setFanliMoney("¥" + goodsDetail.getZkPrice()); |
| | | } |
| | | goodsDetail.setMoneyInfo(moneyInfo); |
| | | } |
| | | |
| | | extraVO.setTbPidInfo(clientTBPid); |
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img.html?id=" + id); |
| | | |
| | | // 分享赚人提示 |
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo(); |
| | | List<ShamUser> listShareUser = new ArrayList<ShamUser>(); |
| | | if (moneyInfo != null) { |
| | | String shareMoney = moneyInfo.getShareMoney(); |
| | | if (goods.getBiz30day() >= 1000) { |
| | | listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney.replaceAll("¥", "")), 1, |
| | | 5); |
| | | } |
| | | } |
| | | extraVO.setListShareUser(listShareUser); |
| | | |
| | | logger.debug("获取商品详情-分享赚人提示结束:{}", id + ""); |
| | | |
| | | // 领券人列表 |
| | | List<ShamUser> listCouponUser = new ArrayList<ShamUser>(); |
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo()) && goods.getCouponAmount() != null |
| | | && goods.getCouponAmount().compareTo(new BigDecimal(0)) > 0) { |
| | | if (goods.getBiz30day() >= 1000) { |
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300); |
| | | } |
| | | } |
| | | extraVO.setListCouponUser(listCouponUser); |
| | | |
| | | logger.debug("获取商品详情- 领券人列表结束:{}", id + ""); |
| | | |
| | | if (uid != null) { |
| | | // 是否加入收藏 |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id, |
| | | Constant.SOURCE_TYPE_TAOBAO); |
| | | extraVO.setCollected(collectionGoods != null ? true : false); |
| | | logger.debug("获取商品详情- 收藏结束:{}", id + ""); |
| | | // 是否加入选品库 |
| | | extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id, Constant.SOURCE_TYPE_TAOBAO)); |
| | | logger.debug("获取商品详情- 选品库结束:{}", id + ""); |
| | | } |
| | | |
| | | // 测试 |
| | | SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, |
| | | "goods_detail_jump_taobao"); |
| | | if ("1".equalsIgnoreCase((params.getValue() + "").trim())) { |
| | | extraVO.setIsNative(true); |
| | | } |
| | | |
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), "", id + ""); |
| | | |
| | | extraVO.setH5Url(h5Url); |
| | | |
| | | String helpLink = null; |
| | | boolean fanliValid = true; |
| | | boolean shareValid = true; |
| | | int moneyType = 1; |
| | | |
| | | if (from != null && from.equals("taolijin_buy")) { |
| | | // 查询分享库 |
| | | TLJBuyGoods buyGoods = tljBuyGoodsService.selectByAuctionIdAndDay(id, |
| | | TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); |
| | | if (buyGoods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "自购立减红包过期")); |
| | | return; |
| | | } |
| | | |
| | | moneyType = 2; |
| | | fanliValid = true; |
| | | shareValid = false; |
| | | helpLink = configService.getValue(ConfigKeyEnum.zigoulijianNofanliHelp.getKey(), acceptData.getSystem()); |
| | | |
| | | BigDecimal tljHongBao = TaoBaoUtil.getGoodsHongBaoMoney(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE, |
| | | false); |
| | | |
| | | ReduceHongBao reduceHongBao = new ReduceHongBao(); |
| | | reduceHongBao.setLeft(buyGoods.getLeftHongBaoCount()); |
| | | 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 if (from != null && from.equals("taolijin_free_buy")) { |
| | | TLJFreeBuyGoods freeGoods = tljFreeBuyGoodsService.selectByAuctionIdAndDay(id, |
| | | TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd")); |
| | | if (freeGoods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "免单商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | fanliValid = true; |
| | | shareValid = false; |
| | | BigDecimal couponPrice = goodsDetail.getCouponPrice(); |
| | | if (couponPrice == null) |
| | | couponPrice = goodsDetail.getZkPrice(); |
| | | |
| | | NewUserHongBao newUserHongBao = new NewUserHongBao(); |
| | | newUserHongBao.setMoney(couponPrice.setScale(2).toString()); |
| | | newUserHongBao.setName("新人红包 "); |
| | | newUserHongBao.setTip("当日领取,当日内使用,过期失效"); |
| | | newUserHongBao.setLeft(1); |
| | | newUserHongBao.setTotal(1); |
| | | |
| | | OtherInfo otherInfo = new OtherInfo(); |
| | | otherInfo.setReduceHongBao(newUserHongBao); |
| | | goodsDetail.setOtherInfo(otherInfo); |
| | | |
| | | // 专属标签 |
| | | List<ClientTextStyleVO> labels = new ArrayList<ClientTextStyleVO>(); |
| | | labels.add(new ClientTextStyleVO("新人专属", "#FE0014")); |
| | | labels.add(new ClientTextStyleVO("实付0元", "#FF9600")); |
| | | goodsDetail.setLabels(labels); |
| | | |
| | | } else {// 普通购买 |
| | | logger.debug("获取商品详情- 奖励券开始:{}", id + ""); |
| | | OtherInfo otherInfo = new OtherInfo(); |
| | | RewardCouponVO rewardCoupon = new RewardCouponVO(); |
| | | rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web", acceptData.getSystem())); |
| | | JSONObject params1 = new JSONObject(); |
| | | if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) |
| | | params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(), acceptData.getSystem())); |
| | | else |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | rewardCoupon.setDesc("返"); |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | rewardCoupon.getJumpDetail().setNeedLogin(true); |
| | | } else |
| | | rewardCoupon.setDesc("用返利奖励券最高返"); |
| | | rewardCoupon.setParams(params1.toString()); |
| | | |
| | | otherInfo.setRewardCoupon(rewardCoupon); |
| | | logger.debug("获取商品详情- 奖励券结束:{}", id + ""); |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) |
| | | otherInfo.setRewardCoupon(null); |
| | | goodsDetail.setOtherInfo(otherInfo); |
| | | } |
| | | extraVO.setFanliValid(fanliValid); |
| | | extraVO.setShareValid(shareValid); |
| | | |
| | | MoneyInfoVO goodsMoney = goodsDetail.getMoneyInfo(); |
| | | if (goodsMoney != null) { |
| | | goodsMoney.setMoneyType(moneyType); |
| | | } |
| | | |
| | | // 分享路径 |
| | | if (StringUtil.isNullOrEmpty(helpLink)) { |
| | | helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem()); |
| | | } |
| | | |
| | | // 分享路径 |
| | | ShareVO shareInfoVO = new ShareVO(); |
| | | shareInfoVO.setHelpLink(helpLink); |
| | | extraVO.setShare(shareInfoVO); |
| | | |
| | | if (goodsDetail.isHasCoupon()) { |
| | | // 设置couponList |
| | | List<CouponInfoVO> couponInfoList = new ArrayList<>(); |
| | | couponInfoList.add(goodsDetail.getCouponInfo()); |
| | | goodsDetail.setCouponInfoList(couponInfoList); |
| | | } |
| | | |
| | | logger.debug("获取商品详情- 分享信息结束:{}", id + ""); |
| | | |
| | | //云发单关闭 |
| | | // if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | // getCloudInfo(acceptData, uid, goodsDetail, extraVO); // 云发单文案信息 |
| | | // logger.debug("获取商品详情- 云发单文案结束:{}", id + ""); |
| | | // } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); |
| | | object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail)); |
| | | out.print(JsonUtil.loadTrueResult(object.toString())); |
| | | |
| | | logger.debug("获取商品详情-详情结束:{}", id + ""); |
| | | |
| | | final TaoBaoGoodsBrief goodsInfo = tb; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addScanHistory(uid, acceptData.getDevice(), goodsInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 京东商品详情 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param uid |
| | | * @param from |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getDetailJD") |
| | | public void getDetialJD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { |
| | | // uid=2255993L; |
| | | // 系统验证 |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); // 高级接口 |
| | | if (jdGoods == null) { |
| | | jdGoods = JDUtil.getGoodsDetail(id); // 爬取网页 |
| | | // jdGoods = JDApiUtil.getGoodsDetail(id); // 普通接口 |
| | | } |
| | | |
| | | if (jdGoods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | |
| | | List<String> imageList = jdGoods.getImageList(); |
| | | if (imageList == null) { |
| | | imageList = new ArrayList<String>(); |
| | | imageList.add(jdGoods.getPicUrl()); |
| | | } |
| | | |
| | | // 保存缓存 |
| | | jdGoodsCacheUtil.saveGoodsInfo(jdGoods); |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem()); |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); |
| | | GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO); |
| | | if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) { |
| | | goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | goodsDetail.getMoneyInfo().setShareMoney("¥" |
| | | + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getShareRate(UserLevelEnum.superVIP, acceptData.getSystem()))); |
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo()); |
| | | goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo()); |
| | | } |
| | | goodsDetail.getMoneyInfo() |
| | | .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem())); |
| | | |
| | | // 附加信息 |
| | | OtherInfo otherInfo = new OtherInfo(); |
| | | |
| | | // 京东plus返利 |
| | | String maxMoneyPlus = null; |
| | | JDCategoryInfo categoryInfo = jdGoods.getCategoryInfo(); |
| | | if (categoryInfo != null && categoryInfo.getCid3() != null && jdGoods.getCommissionInfo() != null) { |
| | | Long cid3 = categoryInfo.getCid3(); |
| | | JDGoodsClass threeClass = jdGoodsClassService.getThreeClassByCid(Integer.parseInt(cid3.toString())); |
| | | if (threeClass != null && threeClass.getSelfComm() != null |
| | | && threeClass.getSelfComm().compareTo(new BigDecimal(0)) > 0) { |
| | | BigDecimal commissionShare = jdGoods.getCommissionInfo().getCommissionShare(); |
| | | // plus比例 小于正常比例 |
| | | if (commissionShare != null && commissionShare.compareTo(threeClass.getSelfComm()) > 0) { |
| | | jdGoods.setCommissionPlus(threeClass.getSelfComm()); |
| | | // plus返利 |
| | | BigDecimal fanliMoneyPlus = JDUtil.getGoodsFanLiMoneyPlus(jdGoods, |
| | | hongBaoManageService.getFanLiRate(acceptData.getSystem())); |
| | | otherInfo.setFanliMoneyPlus("京东plus返¥" + fanliMoneyPlus); |
| | | // 使用奖励券最高返 |
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | maxMoneyPlus = "(京东plus返¥" + JDUtil.getGoodsFanLiMoneyPlus(jdGoods, |
| | | hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem())) + ")"; |
| | | } else |
| | | maxMoneyPlus = "(京东plus最高返¥" |
| | | + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE)) |
| | | + ")"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 奖励券返利 |
| | | RewardCouponVO rewardCoupon = new RewardCouponVO(); |
| | | rewardCoupon.setMaxMoneyPlus(maxMoneyPlus); |
| | | rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web", acceptData.getSystem())); |
| | | JSONObject params1 = new JSONObject(); |
| | | if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) |
| | | params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(), acceptData.getSystem())); |
| | | else |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | |
| | | rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | rewardCoupon.setDesc("返"); |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | rewardCoupon.getJumpDetail().setNeedLogin(true); |
| | | } else { |
| | | rewardCoupon.setDesc("用返利奖励券最高返"); |
| | | } |
| | | rewardCoupon.setParams(params1.toString()); |
| | | |
| | | otherInfo.setRewardCoupon(rewardCoupon); |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) |
| | | otherInfo.setRewardCoupon(null); |
| | | |
| | | goodsDetail.setOtherInfo(otherInfo); |
| | | |
| | | CouponInfoVO couponInfo = goodsDetail.getCouponInfo(); |
| | | if (couponInfo != null) { |
| | | // 券链接处理 |
| | | String materialId = "https://item.jd.com/" + id + ".html"; |
| | | String url = null; |
| | | try { |
| | | url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(), null, |
| | | pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.coupon), null); |
| | | } catch (Exception e) { |
| | | logger.warn(String.format("京东转链出错:materialId-%s couponUrl-%s", materialId, couponInfo.getLink()), e); |
| | | } |
| | | couponInfo.setLink(url); |
| | | } |
| | | |
| | | ShopInfoVO shopInfo = goodsDetail.getShopInfo(); |
| | | if (shopInfo != null) { |
| | | if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null |
| | | || shopInfo.getScoreSeller() == null) { |
| | | goodsDetail.setShopInfo(null); |
| | | } |
| | | } |
| | | |
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO(); |
| | | extraVO.setIsNative(false); |
| | | // IOS是否正在上线 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | String version = acceptData.getVersion(); |
| | | extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem())); |
| | | } |
| | | |
| | | Long inOrderCount30Days = jdGoods.getInOrderCount30Days(); |
| | | List<ShamUser> listShareUser = new ArrayList<ShamUser>(); |
| | | |
| | | // 京东开启分享 |
| | | String open = configService.getValue(ConfigKeyEnum.shareOpenJD.getKey(), acceptData.getSystem()); |
| | | if ("1".equals(open.trim())) { |
| | | extraVO.setShareValid(true); |
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo(); |
| | | if (moneyInfo != null) { |
| | | String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", ""); |
| | | if (Integer.parseInt(inOrderCount30Days.toString()) >= 1000) { |
| | | listShareUser.addAll(shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | extraVO.setListShareUser(listShareUser); |
| | | |
| | | // 领券人列表 |
| | | List<ShamUser> listCouponUser = new ArrayList<ShamUser>(); |
| | | if (goodsDetail.isHasCoupon() && Integer.parseInt(inOrderCount30Days.toString()) >= 1000) { |
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300); |
| | | } |
| | | extraVO.setListCouponUser(listCouponUser); |
| | | |
| | | if (uid != null) { |
| | | // 是否加入收藏 |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id + "", |
| | | Constant.SOURCE_TYPE_JD); |
| | | extraVO.setCollected(collectionGoods != null ? true : false); |
| | | // 是否加入选品库 |
| | | extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id + "", Constant.SOURCE_TYPE_JD)); |
| | | } |
| | | |
| | | // 图文详情 |
| | | extraVO.setDetailUrl("https://in.m.jd.com/product/jieshao/video/" + id + ".html"); |
| | | |
| | | // 测试 |
| | | SystemClientParams params = systemClientParamsService.getSystemClientParamsBySystemAndKey(system, |
| | | "goods_detail_jump_taobao"); |
| | | if ("1".equalsIgnoreCase((params.getValue() + "").trim())) { |
| | | extraVO.setIsNative(true); |
| | | } |
| | | |
| | | // 商品链接 |
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePathJD(), "", id + ""); |
| | | // try { |
| | | // extraVO.setH5Url(HttpUtil.getShortLink(h5Url)); |
| | | // } catch (Exception e) { |
| | | extraVO.setH5Url(h5Url); |
| | | // } |
| | | |
| | | String helpLink = null; |
| | | extraVO.setFanliValid(true); |
| | | |
| | | if (StringUtil.isNullOrEmpty(helpLink)) { |
| | | helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem()); |
| | | } |
| | | |
| | | ShareVO shareInfoVO = new ShareVO(); |
| | | shareInfoVO.setHelpLink(helpLink); |
| | | extraVO.setShare(shareInfoVO); |
| | | |
| | | if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | getCloudInfo(acceptData, uid, goodsDetail, extraVO); // 云发单文案信息 |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); |
| | | object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail)); |
| | | out.print(JsonUtil.loadTrueResult(object.toString())); |
| | | |
| | | final JDGoods goods = jdGoods; |
| | | final Long fuid = uid; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addJDScanHistory(fuid, acceptData.getDevice(), goods); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | try { |
| | | goodsEvaluateService.updateJDGoods(goods); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 拼多多商品详情 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param uid |
| | | * @param from |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getDetailPDD", method = RequestMethod.POST) |
| | | public void getDetialPDD(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { |
| | | // 系统验证 |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.fanli); |
| | | |
| | | PDDGoodsDetail pddGoods = null; |
| | | try { |
| | | pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id, pid, pddAuthService.getFanliCustomParams(uid)); |
| | | } catch (PDDApiException e) { |
| | | e.printStackTrace(); |
| | | if (e.getCode() == PDDApiException.CODE_NOT_AUTH) { |
| | | try { |
| | | pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id, pid, Constant.PDD_SEARCH_CUSTOMER_PARAMS); |
| | | } catch (PDDApiException e1) { |
| | | } |
| | | } |
| | | } |
| | | if (pddGoods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem()); |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); |
| | | |
| | | GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO); |
| | | if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) { |
| | | goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | goodsDetail.getMoneyInfo().setShareMoney("¥" + PinDuoDuoUtil.getGoodsShareMoney(pddGoods, |
| | | hongBaoManageService.getShareRate(UserLevelEnum.superVIP, acceptData.getSystem()))); |
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo()); |
| | | goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo()); |
| | | } |
| | | goodsDetail.getMoneyInfo() |
| | | .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem())); |
| | | |
| | | // 附加信息 |
| | | OtherInfo otherInfo = new OtherInfo(); |
| | | RewardCouponVO rewardCoupon = new RewardCouponVO(); |
| | | rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web", acceptData.getSystem())); |
| | | JSONObject params1 = new JSONObject(); |
| | | if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) |
| | | params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(), acceptData.getSystem())); |
| | | else |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | |
| | | rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | rewardCoupon.setDesc("返"); |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | rewardCoupon.getJumpDetail().setNeedLogin(true); |
| | | } else |
| | | rewardCoupon.setDesc("用返利奖励券最高返"); |
| | | rewardCoupon.setParams(params1.toString()); |
| | | otherInfo.setRewardCoupon(rewardCoupon); |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) |
| | | otherInfo.setRewardCoupon(null); |
| | | goodsDetail.setOtherInfo(otherInfo); |
| | | |
| | | CouponInfoVO couponInfo = goodsDetail.getCouponInfo(); |
| | | PDDConvertLinkResultVO convertUrl = null; |
| | | if (couponInfo != null) { |
| | | convertUrl = PinDuoDuoApiUtil.convert(pddGoods.getGoodsSign(), pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.coupon), null, false); |
| | | if (convertUrl != null) |
| | | couponInfo.setLink(convertUrl.getUrl()); |
| | | } |
| | | |
| | | ShopInfoVO shopInfo = goodsDetail.getShopInfo(); |
| | | if (shopInfo != null) { |
| | | if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null |
| | | || shopInfo.getScoreSeller() == null) { |
| | | goodsDetail.setShopInfo(null); |
| | | } |
| | | } |
| | | |
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO(); |
| | | extraVO.setIsNative(false); |
| | | // IOS是否正在上线 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | String version = acceptData.getVersion(); |
| | | extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem())); |
| | | } |
| | | |
| | | // 图文详情 |
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + id); |
| | | |
| | | String salesTip = pddGoods.getSalesTip(); |
| | | if (!StringUtil.isNullOrEmpty(salesTip)) { |
| | | int indexOf = salesTip.indexOf("+"); |
| | | if (indexOf > 0) { |
| | | salesTip = salesTip.substring(0, indexOf); |
| | | } |
| | | |
| | | int totalSales = 0; |
| | | if (salesTip.contains("万")) { |
| | | salesTip = salesTip.substring(0, salesTip.indexOf("万")); |
| | | totalSales = (int) (Float.parseFloat(salesTip) * 10000); |
| | | } else { |
| | | totalSales = Integer.parseInt(salesTip); |
| | | } |
| | | |
| | | List<ShamUser> listShareUser = new ArrayList<ShamUser>(); |
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo(); |
| | | if (moneyInfo != null) { |
| | | String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", ""); |
| | | if (totalSales >= 50000) { |
| | | listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5); |
| | | } |
| | | } |
| | | extraVO.setListShareUser(listShareUser); |
| | | |
| | | // 领券人列表 |
| | | List<ShamUser> listCouponUser = new ArrayList<ShamUser>(); |
| | | if (goodsDetail.isHasCoupon() && totalSales >= 50000) { |
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300); |
| | | } |
| | | extraVO.setListCouponUser(listCouponUser); |
| | | } |
| | | |
| | | if (uid != null) { |
| | | // 是否加入收藏 |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id + "", |
| | | Constant.SOURCE_TYPE_PDD); |
| | | extraVO.setCollected(collectionGoods != null ? true : false); |
| | | // 是否加入选品库 |
| | | extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id + "", Constant.SOURCE_TYPE_PDD)); |
| | | } |
| | | |
| | | extraVO.setIsNative(true); |
| | | |
| | | // 分享路径 |
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + ""); |
| | | // try { |
| | | // extraVO.setH5Url(HttpUtil.getShortLink(h5Url)); |
| | | // } catch (Exception e) { |
| | | extraVO.setH5Url(h5Url); |
| | | // } |
| | | |
| | | String helpLink = null; |
| | | extraVO.setFanliValid(true); |
| | | extraVO.setShareValid(true); |
| | | |
| | | if (StringUtil.isNullOrEmpty(helpLink)) { |
| | | helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem()); |
| | | } |
| | | |
| | | ShareVO shareInfoVO = new ShareVO(); |
| | | shareInfoVO.setHelpLink(helpLink); |
| | | extraVO.setShare(shareInfoVO); |
| | | |
| | | if (convertUrl != null) { |
| | | extraVO.setCouponJumpLink(convertUrl.getUrl()); |
| | | extraVO.setNativeCouponJumpLink(PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl())); |
| | | } |
| | | |
| | | if (VersionUtil.greaterThan_2_1_2(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | getCloudInfo(acceptData, uid, goodsDetail, extraVO); // 云发单文案信息 |
| | | } |
| | | |
| | | if (extraVO.getListCouponUser() == null) { |
| | | extraVO.setListCouponUser(new ArrayList<>()); |
| | | } |
| | | |
| | | if (extraVO.getListShareUser() == null) { |
| | | extraVO.setListShareUser(new ArrayList<>()); |
| | | } |
| | | |
| | | // 免单商品 |
| | | if (!StringUtil.isNullOrEmpty(from) && "miandan".equals(from)) { |
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo(); |
| | | if (goodsDetail.isHasCoupon()) { |
| | | moneyInfo.setFanliMoney("¥" + goodsDetail.getCouponPrice()); |
| | | } else { |
| | | moneyInfo.setFanliMoney("¥" + goodsDetail.getZkPrice()); |
| | | } |
| | | goodsDetail.setMoneyInfo(moneyInfo); |
| | | } |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); |
| | | object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail)); |
| | | out.print(JsonUtil.loadTrueResult(object.toString())); |
| | | |
| | | final PDDGoodsDetail fGoods = pddGoods; |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addPDDScanHistory(uid, acceptData.getDevice(), fGoods); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | try { |
| | | goodsEvaluateService.updatePDDGoods(fGoods); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 唯品会详情 |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param uid |
| | | * @param from |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getDetailVIP", method = RequestMethod.POST) |
| | | public void getDetialVIP(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { |
| | | // 系统验证 |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | VIPGoodsInfo vipGoodsInfo = VipShopApiUtil.getGoodsDetail(id + ""); |
| | | if (vipGoodsInfo == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem()); |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); |
| | | |
| | | GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertVIPGoods(vipGoodsInfo, paramsDTO); |
| | | if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) { |
| | | goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | goodsDetail.getMoneyInfo().setShareMoney("¥" + VipShopUtil.getGoodsFanLiMoney(vipGoodsInfo, |
| | | hongBaoManageService.getShareRate(UserLevelEnum.superVIP, acceptData.getSystem()))); |
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo()); |
| | | goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo()); |
| | | } |
| | | goodsDetail.getMoneyInfo() |
| | | .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem())); |
| | | |
| | | // 附加信息 |
| | | OtherInfo otherInfo = new OtherInfo(); |
| | | RewardCouponVO rewardCoupon = new RewardCouponVO(); |
| | | rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web", acceptData.getSystem())); |
| | | JSONObject params1 = new JSONObject(); |
| | | if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) |
| | | params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(), acceptData.getSystem())); |
| | | else |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | |
| | | rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | rewardCoupon.setDesc("返"); |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | rewardCoupon.getJumpDetail().setNeedLogin(true); |
| | | |
| | | rewardCoupon.setParams(params1.toString()); |
| | | otherInfo.setRewardCoupon(rewardCoupon); |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) |
| | | otherInfo.setRewardCoupon(null); |
| | | goodsDetail.setOtherInfo(otherInfo); |
| | | |
| | | ShopInfoVO shopInfo = goodsDetail.getShopInfo(); |
| | | if (shopInfo != null) { |
| | | if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null |
| | | || shopInfo.getScoreSeller() == null) { |
| | | goodsDetail.setShopInfo(null); |
| | | } |
| | | } |
| | | |
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO(); |
| | | extraVO.setIsNative(false); |
| | | // IOS是否正在上线 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | String version = acceptData.getVersion(); |
| | | extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem())); |
| | | } |
| | | |
| | | // 图文详情 |
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + id); |
| | | |
| | | if (uid != null) { |
| | | // 是否加入收藏 |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id + "", |
| | | Constant.SOURCE_TYPE_VIP); |
| | | extraVO.setCollected(collectionGoods != null ? true : false); |
| | | // 是否加入选品库 |
| | | extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id + "", Constant.SOURCE_TYPE_VIP)); |
| | | } |
| | | |
| | | extraVO.setIsNative(true); |
| | | |
| | | // 分享路径 |
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + ""); |
| | | // try { |
| | | // extraVO.setH5Url(HttpUtil.getShortLink(h5Url)); |
| | | // } catch (Exception e) { |
| | | extraVO.setH5Url(h5Url); |
| | | // } |
| | | |
| | | String helpLink = null; |
| | | extraVO.setFanliValid(true); |
| | | extraVO.setShareValid(true); |
| | | |
| | | if (StringUtil.isNullOrEmpty(helpLink)) { |
| | | helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem()); |
| | | } |
| | | |
| | | ShareVO shareInfoVO = new ShareVO(); |
| | | shareInfoVO.setHelpLink(helpLink); |
| | | extraVO.setShare(shareInfoVO); |
| | | |
| | | if (extraVO.getListShareUser() == null) { |
| | | extraVO.setListShareUser(new ArrayList<>()); |
| | | } |
| | | |
| | | if (extraVO.getListCouponUser() == null) { |
| | | extraVO.setListCouponUser(new ArrayList<>()); |
| | | } |
| | | |
| | | // 云发单文案信息 |
| | | getCloudInfo(acceptData, uid, goodsDetail, extraVO); |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); |
| | | object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail)); |
| | | out.print(JsonUtil.loadTrueResult(object.toString())); |
| | | |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addVIPScanHistory(uid, acceptData.getDevice(), vipGoodsInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | try { |
| | | goodsEvaluateService.updateVIPGoods(vipGoodsInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @RequestMapping(value = "getDetailSuning", method = RequestMethod.POST) |
| | | public void getDetialSuning(AcceptData acceptData, String id, Long uid, String from, PrintWriter out) { |
| | | // 系统验证 |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | String[] ids = SuningUtil.getGoodsIdDetail(id); |
| | | |
| | | SuningGoodsInfo suningGoodsInfo = SuningApiUtil.getGoodsDetail(ids[1], ids[0]); |
| | | |
| | | if (suningGoodsInfo == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem()); |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); |
| | | |
| | | GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertSuningGoods(suningGoodsInfo, paramsDTO); |
| | | if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) { |
| | | goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | goodsDetail.getMoneyInfo().setShareMoney("¥" + SuningUtil.getGoodsFanLiMoney(suningGoodsInfo, |
| | | hongBaoManageService.getShareRate(UserLevelEnum.superVIP, acceptData.getSystem()))); |
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo()); |
| | | goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo()); |
| | | } |
| | | goodsDetail.getMoneyInfo() |
| | | .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem())); |
| | | |
| | | // 附加信息 |
| | | OtherInfo otherInfo = new OtherInfo(); |
| | | RewardCouponVO rewardCoupon = new RewardCouponVO(); |
| | | rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web", acceptData.getSystem())); |
| | | JSONObject params1 = new JSONObject(); |
| | | |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | |
| | | rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | rewardCoupon.setDesc("返"); |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | rewardCoupon.getJumpDetail().setNeedLogin(true); |
| | | |
| | | rewardCoupon.setParams(params1.toString()); |
| | | otherInfo.setRewardCoupon(rewardCoupon); |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) |
| | | otherInfo.setRewardCoupon(null); |
| | | goodsDetail.setOtherInfo(otherInfo); |
| | | |
| | | ShopInfoVO shopInfo = goodsDetail.getShopInfo(); |
| | | if (shopInfo != null) { |
| | | if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null |
| | | || shopInfo.getScoreSeller() == null) { |
| | | goodsDetail.setShopInfo(null); |
| | | } |
| | | } |
| | | |
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO(); |
| | | extraVO.setIsNative(false); |
| | | // IOS是否正在上线 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | String version = acceptData.getVersion(); |
| | | extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem())); |
| | | } |
| | | |
| | | // 图文详情 |
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_suning.html?id=" |
| | | + suningGoodsInfo.getCommodityInfo().getCommodityCode() + "&supplierCode=" |
| | | + suningGoodsInfo.getCommodityInfo().getSupplierCode()); |
| | | |
| | | if (uid != null) { |
| | | // 是否加入收藏 |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, |
| | | (suningGoodsInfo.getCommodityInfo().getCommodityCode()), Constant.SOURCE_TYPE_SUNING); |
| | | extraVO.setCollected(collectionGoods != null ? true : false); |
| | | // 是否加入选品库 |
| | | extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, |
| | | (suningGoodsInfo.getCommodityInfo().getCommodityCode()), |
| | | Constant.SOURCE_TYPE_SUNING)); |
| | | } |
| | | |
| | | extraVO.setIsNative(true); |
| | | |
| | | // 分享路径 |
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + ""); |
| | | // try { |
| | | // extraVO.setH5Url(HttpUtil.getShortLink(h5Url)); |
| | | // } catch (Exception e) { |
| | | extraVO.setH5Url(h5Url); |
| | | // } |
| | | |
| | | String helpLink = null; |
| | | extraVO.setFanliValid(true); |
| | | extraVO.setShareValid(true); |
| | | |
| | | if (StringUtil.isNullOrEmpty(helpLink)) { |
| | | helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem()); |
| | | } |
| | | |
| | | ShareVO shareInfoVO = new ShareVO(); |
| | | shareInfoVO.setHelpLink(helpLink); |
| | | extraVO.setShare(shareInfoVO); |
| | | |
| | | if (extraVO.getListShareUser() == null) { |
| | | extraVO.setListShareUser(new ArrayList<>()); |
| | | } |
| | | |
| | | if (extraVO.getListCouponUser() == null) { |
| | | extraVO.setListCouponUser(new ArrayList<>()); |
| | | } |
| | | |
| | | // 云发单文案信息 |
| | | getCloudInfo(acceptData, uid, goodsDetail, extraVO); |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); |
| | | object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail)); |
| | | out.print(JsonUtil.loadTrueResult(object.toString())); |
| | | |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addSuningScanHistory(uid, acceptData.getDevice(), suningGoodsInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | try { |
| | | goodsEvaluateService.updateSuningGoods(suningGoodsInfo); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "getDetailDY", method = RequestMethod.POST) |
| | | public void getDetailDY(AcceptData acceptData, Long id, Long uid, String from, PrintWriter out) { |
| | | // 系统验证 |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult(1, "系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | DYGoodsDetail dyGoodsDetail = CSJCPSApiUtil.goodsDetail(id); |
| | | if (dyGoodsDetail == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在")); |
| | | return; |
| | | } |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), uid, acceptData.getSystem()); |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(acceptData.getSystem())); |
| | | |
| | | GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertDYGoods(dyGoodsDetail, paramsDTO); |
| | | if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) { |
| | | goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | goodsDetail.getMoneyInfo().setShareMoney("¥" + DYUtil.getGoodsFanLiMoney(dyGoodsDetail, |
| | | hongBaoManageService.getShareRate(UserLevelEnum.superVIP, acceptData.getSystem()))); |
| | | goodsDetail.getMoneyInfo().setRateInfo(goodsDetail.getMoneyInfo().getMaxRateInfo()); |
| | | goodsDetail.getMoneyInfo().setCompositionInfo(goodsDetail.getMoneyInfo().getMaxCompositionInfo()); |
| | | } |
| | | goodsDetail.getMoneyInfo() |
| | | .setRateInfoHelpUrl(configService.getValue(ConfigKeyEnum.goodsDetailFanliRateHelpUrl.getKey(), acceptData.getSystem())); |
| | | |
| | | // 附加信息 |
| | | OtherInfo otherInfo = new OtherInfo(); |
| | | RewardCouponVO rewardCoupon = new RewardCouponVO(); |
| | | rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web", acceptData.getSystem())); |
| | | JSONObject params1 = new JSONObject(); |
| | | if (!VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) |
| | | params1.put("url", configService.getValue(ConfigKeyEnum.specialGuideRewardCouponLink.getKey(), acceptData.getSystem())); |
| | | else |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | |
| | | rewardCoupon.setMaxMoney(goodsDetail.getMoneyInfo().getMaxMoney()); |
| | | rewardCoupon.setDesc("返"); |
| | | params1.put("url", userVipConfigService.getValueByKey("vip_link")); |
| | | rewardCoupon.getJumpDetail().setNeedLogin(true); |
| | | |
| | | rewardCoupon.setParams(params1.toString()); |
| | | otherInfo.setRewardCoupon(rewardCoupon); |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform()) |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()), acceptData.getSystem())) |
| | | otherInfo.setRewardCoupon(null); |
| | | goodsDetail.setOtherInfo(otherInfo); |
| | | |
| | | ShopInfoVO shopInfo = goodsDetail.getShopInfo(); |
| | | if (shopInfo != null) { |
| | | if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null |
| | | || shopInfo.getScoreSeller() == null) { |
| | | goodsDetail.setShopInfo(null); |
| | | } |
| | | } |
| | | |
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO(); |
| | | extraVO.setIsNative(false); |
| | | // IOS是否正在上线 |
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) { |
| | | String version = acceptData.getVersion(); |
| | | extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version), acceptData.getSystem())); |
| | | } |
| | | |
| | | // TODO 图文详情 |
| | | extraVO.setDetailUrl(""); |
| | | |
| | | if (uid != null) { |
| | | // 是否加入收藏 |
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id + "", |
| | | Constant.SOURCE_TYPE_DY); |
| | | extraVO.setCollected(collectionGoods != null ? true : false); |
| | | // 是否加入选品库 |
| | | extraVO.setStorage(userGoodsStorageService.isExistStorage(uid, id + "", Constant.SOURCE_TYPE_DY)); |
| | | } |
| | | |
| | | extraVO.setIsNative(true); |
| | | |
| | | // 分享路径 |
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(acceptData.getSystem()), |
| | | Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + ""); |
| | | // try { |
| | | // extraVO.setH5Url(HttpUtil.getShortLink(h5Url)); |
| | | // } catch (Exception e) { |
| | | extraVO.setH5Url(h5Url); |
| | | // } |
| | | |
| | | String helpLink = null; |
| | | extraVO.setFanliValid(true); |
| | | extraVO.setShareValid(true); |
| | | |
| | | if (StringUtil.isNullOrEmpty(helpLink)) { |
| | | helpLink = configService.getValue(ConfigKeyEnum.noRebateHelpLink.getKey(), acceptData.getSystem()); |
| | | } |
| | | |
| | | ShareVO shareInfoVO = new ShareVO(); |
| | | shareInfoVO.setHelpLink(helpLink); |
| | | extraVO.setShare(shareInfoVO); |
| | | |
| | | if (extraVO.getListShareUser() == null) { |
| | | extraVO.setListShareUser(new ArrayList<>()); |
| | | } |
| | | |
| | | if (extraVO.getListCouponUser() == null) { |
| | | extraVO.setListCouponUser(new ArrayList<>()); |
| | | } |
| | | |
| | | // 云发单文案信息 |
| | | getCloudInfo(acceptData, uid, goodsDetail, extraVO); |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO)); |
| | | object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail)); |
| | | out.print(JsonUtil.loadTrueResult(object.toString())); |
| | | |
| | | ThreadUtil.run(new Runnable() { |
| | | public void run() { |
| | | // 添加浏览记录 |
| | | try { |
| | | scanHistoryV2Service.addDYScanHistory(uid, acceptData.getDevice(), dyGoodsDetail); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | try { |
| | | goodsEvaluateService.updateDYGoods(dyGoodsDetail); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * // 云发单文案信息 |
| | | * |
| | | * @param goodsDetail |
| | | */ |
| | | private void getCloudInfo(AcceptData acceptData, Long uid, GoodsDetailVO goodsDetail, GoodsDetailExtraVO extraVO) { |
| | | if (1 > 0) { |
| | | return; |
| | | } |
| | | // 云发单是否开启 |
| | | boolean cloudOpen = configService.isRobotCloudOpen(ConfigKeyEnum.robotCloudOpenGoodsDetail.getKey(), acceptData.getPlatform(), acceptData.getVersion(), acceptData.getSystem()); |
| | | if (!cloudOpen && uid != null) { |
| | | List<String> testUsers = configService.getTestUsers(acceptData.getSystem()); |
| | | if (testUsers != null && testUsers.contains(uid + "")) { |
| | | cloudOpen = true; |
| | | } |
| | | } |
| | | extraVO.setCloudOpen(cloudOpen); |
| | | |
| | | // 无券或者未开启发圈 |
| | | if (!goodsDetail.isHasCoupon() || !cloudOpen) { |
| | | return; |
| | | } |
| | | |
| | | GoodsEvaluate evaluate = goodsEvaluateService.queryExistSingle(goodsDetail.getGoodsId() + "", goodsDetail.getGoodsType(), acceptData.getSystem()); |
| | | if (evaluate != null) { |
| | | String cloudText = null; |
| | | List<CommentInfo> comments = evaluate.getComments(); |
| | | if (comments != null && comments.size() > 0) { |
| | | cloudText = comments.get(0).getContent(); |
| | | } |
| | | |
| | | String cloudPic = null; |
| | | List<ImgInfo> imgList = evaluate.getImgList(); |
| | | if (imgList != null && imgList.size() > 0) { |
| | | for (ImgInfo imgInfo : imgList) { |
| | | ImgEnum type = imgInfo.getType(); |
| | | if (type == ImgEnum.goods) { |
| | | cloudPic = imgInfo.getUrl(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(cloudText) && !StringUtil.isNullOrEmpty(cloudPic)) { |
| | | |
| | | cloudText = cloudText.replace("[原价]", MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getZkPrice()) + ""); |
| | | if (!goodsDetail.isHasCoupon()) { |
| | | cloudText = cloudText.replace("领券抢购", "抢购"); |
| | | cloudText = cloudText.replace("【券后价】[券后价]元", ""); |
| | | } else { |
| | | cloudText = cloudText.replace("[券后价]", MoneyBigDecimalUtil.getWithNoZera(goodsDetail.getCouponPrice()) + ""); |
| | | } |
| | | cloudText = cloudText.replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n").replace("\r\n\r\n", "\r\n"); |
| | | |
| | | extraVO.setCloudPic(cloudPic); |
| | | extraVO.setCloudText(cloudText); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 商品详情推荐(猜你喜欢 + 推荐) |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getRecommendGoods", method = RequestMethod.POST) |
| | | public void getRecommendGoods(AcceptData acceptData, String id, Long uid, Integer goodsType, PrintWriter out) { |
| | | if (goodsType == null) { |
| | | goodsType = Constant.SOURCE_TYPE_TAOBAO; |
| | | } |
| | | |
| | | try { |
| | | // 京东 |
| | | if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>())); |
| | | |
| | | List<JDGoods> list = JDUtil.getRecommendGoodsById(Long.parseLong(id)); |
| | | if (list == null) { |
| | | list = new ArrayList<>(); |
| | | } else if (list.size() > 10) { |
| | | list = list.subList(0, 10); |
| | | } |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null, acceptData.getSystem()); |
| | | List<GoodsDetailVO> listDetailVO = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, list, paramsDTO); //new ArrayList<GoodsDetailVO>(); |
| | | |
| | | // 取偶数个数据 |
| | | if (listDetailVO.size() % 2 != 0) { |
| | | listDetailVO.remove(listDetailVO.size() - 1); |
| | | } |
| | | |
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } |
| | | |
| | | // 拼多多 |
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>())); |
| | | |
| | | List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>(); |
| | | |
| | | List<Long> goodsIdList = PinDuoDuoUtil.getRecommendGoodsId(Long.parseLong(id)); |
| | | if (goodsIdList != null && goodsIdList.size() > 0) { |
| | | PDDSearchFilter pddfilter = new PDDSearchFilter(); |
| | | pddfilter.setPage(1); |
| | | pddfilter.setPageSize(Constant.PAGE_SIZE); |
| | | Long[] strings = new Long[goodsIdList.size()]; |
| | | pddfilter.setGoodsIdList(goodsIdList.toArray(strings)); |
| | | |
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter, Constant.PDD_SEARCH_CUSTOMER_PARAMS); |
| | | if (result != null) { |
| | | List<PDDGoodsDetail> goodsList = result.getGoodsList(); |
| | | if (goodsList != null && goodsList.size() > 0) { |
| | | |
| | | if (goodsList.size() > 10) { |
| | | goodsList = goodsList.subList(0, 10); |
| | | } |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), |
| | | null, acceptData.getSystem()); |
| | | listDetailVO = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 取偶数个数据 |
| | | if (listDetailVO.size() % 2 != 0) { |
| | | listDetailVO.remove(listDetailVO.size() - 1); |
| | | } |
| | | |
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } |
| | | |
| | | // 唯品会 |
| | | if (goodsType == Constant.SOURCE_TYPE_VIP) { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>())); |
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } |
| | | |
| | | // 苏宁 |
| | | if (goodsType == Constant.SOURCE_TYPE_SUNING) { |
| | | List<SuningGoodsInfo> resultList = null; |
| | | String[] ids = SuningUtil.getGoodsIdDetail(id); |
| | | List<SuningGoodsInfoRecommend> list = SuningApiUtil.getRecommendGoods(ids[1], ids[0]); |
| | | if (list != null && list.size() > 0) { |
| | | List<String> listId = new ArrayList<>(); |
| | | for (SuningGoodsInfoRecommend goodsInfo : list) { |
| | | if (goodsInfo != null) { |
| | | listId.add(goodsInfo.getCommodityCode() + "-" + goodsInfo.getSupplierCode()); |
| | | } |
| | | } |
| | | resultList = SuningApiUtil.getGoodsDetailList(listId); |
| | | } |
| | | |
| | | List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>(); |
| | | if (resultList != null) { |
| | | if (resultList != null && resultList.size() > 0) { |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(), acceptData.getSystem()); |
| | | listDetailVO = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, resultList, paramsDTO); |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO)); |
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } |
| | | |
| | | if (goodsType == Constant.SOURCE_TYPE_DY) { |
| | | DYGoodsDetail goods = CSJCPSApiUtil.goodsDetail(Long.parseLong(id)); |
| | | //goods.getThird_cid() |
| | | DYGoodsSearchFilter searchFilter = new DYGoodsSearchFilter(); |
| | | searchFilter.setPageSize(10); |
| | | searchFilter.setPage(1); |
| | | searchFilter.setThird_cids(Arrays.asList(new Integer[]{goods.getThird_cid()})); |
| | | ListResult listResult = CSJCPSApiUtil.searchGoods(searchFilter); |
| | | |
| | | |
| | | |
| | | List<GoodsDetailVO> listDetailVO = new ArrayList<>(); |
| | | if (listResult != null) { |
| | | if (listResult.getDataList() != null && listResult.getDataList() .size() > 0) { |
| | | List<DYGoods> dyGoodsList=new ArrayList<>(); |
| | | for(Object o:listResult.getDataList()){ |
| | | dyGoodsList.add((DYGoods)o); |
| | | } |
| | | |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(), acceptData.getSystem()); |
| | | listDetailVO = goodsLijinMnager.loadOtherMoneyInfo(acceptData.getSystem(), uid, dyGoodsList, paramsDTO); |
| | | } |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO)); |
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | return; |
| | | } |
| | | |
| | | List<TaoBaoGoodsBrief> goodsList = TaoKeApiUtil.guessLikeByAuctionId(id, 10); |
| | | // 初始化 |
| | | if (goodsList == null) { |
| | | goodsList = new ArrayList<>(); |
| | | } |
| | | |
| | | List<GoodsDetailVO> listExtra = new ArrayList<>(); |
| | | GoodsMoneyConfigParamsDTO paramsDTO = getParamsDTO(acceptData.getPlatform(), acceptData.getVersion(), null, acceptData.getSystem()); |
| | | |
| | | listExtra = goodsLijinMnager.loadTBMoneyInfo(acceptData.getSystem(), uid, goodsList, paramsDTO, false); |
| | | |
| | | List<GoodsDetailVO> listQuality = new ArrayList<GoodsDetailVO>(); |
| | | // 取偶数个数据 |
| | | if (listExtra.size() % 2 != 0) { |
| | | listExtra.remove(listExtra.size() - 1); |
| | | } |
| | | |
| | | if (listQuality.size() % 2 != 0) { |
| | | listQuality.remove(listQuality.size() - 1); |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listExtra)); |
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(listQuality)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("listQuality", new JSONArray()); |
| | | data.put("listGuess", new JSONArray()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取京东领券链接(不返利) |
| | | * |
| | | * @param acceptData |
| | | * @param id |
| | | * @param couponUrl |
| | | * @param source |
| | | * @param out |
| | | */ |
| | | private void getJDLinkWithoutFanLi(AcceptData acceptData, Long id, String couponUrl, String source, PrintWriter out) { |
| | | JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(id); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | return; |
| | | } |
| | | String jumpLink = null; |
| | | String materialId = "https://item.jd.com/" + id + ".html"; |
| | | String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.coupon); |
| | | if (StringUtil.isNullOrEmpty(couponUrl)) { |
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods.getCouponInfoList(), goods.getPrice()); |
| | | if (couponInfo != null) { |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | |
| | | try { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, |
| | | ""); |
| | | } catch (Exception e) { |
| | | logger.warn(String.format("京东转链出错:materialId-%s couponUrl-%s", materialId, couponUrl), e); |
| | | } |
| | | if (jumpLink == null) { |
| | | try { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid, |
| | | ""); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | logger.warn(String.format("京东转链出错:materialId-%s ", materialId), e); |
| | | } |
| | | } |
| | | } else { |
| | | try { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, |
| | | ""); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | logger.warn(String.format("京东转链出错:materialId-%s couponUrl-%s", materialId, couponUrl), e); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(jumpLink)) { |
| | | jumpLink = couponUrl; |
| | | } |
| | | } |
| | | |
| | | GoodsJumpLinkVO vo = GoodsJumpUtil.getJDJumpInfo(jumpLink); |
| | | vo.set_native(true); |
| | | vo.setJumpLink(jumpLink); |
| | | vo.setNativeJumpLink(jumpLink); |
| | | try { |
| | | String wxPage = "pages/union/proxy/proxy?spreadUrl=" + URLEncoder.encode(jumpLink, "UTF-8"); |
| | | WXXCXJumpInfoVO wxxcxJumpInfoVO = new WXXCXJumpInfoVO(); |
| | | wxxcxJumpInfoVO.setUserName("gh_45b306365c3d"); |
| | | wxxcxJumpInfoVO.setPath(wxPage); |
| | | vo.setWxxcxJumpInfo(wxxcxJumpInfoVO); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | JSONObject data = JSONObject.fromObject(new Gson().toJson(vo)); |
| | | data.put("native", vo.is_native()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 京东购买链接 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param id |
| | | * @param couponUrl -优惠券链接 |
| | | * @param source |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getJDLink") |
| | | public void getJDLink(AcceptData acceptData, Long uid, Long id, String couponUrl, String source, PrintWriter out) { |
| | | |
| | | |
| | | if (id == null || id <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (!SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.fanli)) { |
| | | getJDLinkWithoutFanLi(acceptData, id, couponUrl, source, out); |
| | | return; |
| | | } |
| | | //未登录领券 |
| | | if (uid == null) { |
| | | getJDLinkWithoutFanLi(acceptData, id, couponUrl, source, out); |
| | | return; |
| | | } |
| | | |
| | | 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 (userFunctionsLimitService.isLimit(uid, SystemFunction.fanli, new Date())) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该功能限制使用")); |
| | | return; |
| | | } |
| | | |
| | | JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(id); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | String jumpLink = null; |
| | | String materialId = "https://item.jd.com/" + id + ".html"; |
| | | |
| | | String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.fanli); |
| | | |
| | | if (StringUtil.isNullOrEmpty(couponUrl)) { |
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods.getCouponInfoList(), goods.getPrice()); |
| | | if (couponInfo != null) { |
| | | couponUrl = couponInfo.getLink(); |
| | | } |
| | | try { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, |
| | | uid + ""); |
| | | } catch (Exception e) { |
| | | logger.warn(String.format("京东转链出错:materialId-%s couponUrl-%s", materialId, couponUrl), e); |
| | | } |
| | | if (jumpLink == null) { |
| | | try { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, null, null, pid, |
| | | uid + ""); |
| | | } catch (Exception e) { |
| | | logger.warn(String.format("京东转链出错:materialId-%s", materialId), e); |
| | | } |
| | | } |
| | | } else { |
| | | try { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pid, |
| | | uid + ""); |
| | | } catch (Exception e) { |
| | | logger.warn(String.format("京东转链出错:materialId-%s couponUrl-%s", materialId, couponUrl), e); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(jumpLink)) { |
| | | jumpLink = couponUrl; |
| | | } |
| | | } |
| | | |
| | | GoodsJumpLinkVO vo = GoodsJumpUtil.getJDJumpInfo(jumpLink); |
| | | JSONObject data = JSONObject.fromObject(new Gson().toJson(vo)); |
| | | data.put("native", vo.is_native()); |
| | | if (uid != null) |
| | | data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | // 获得金币 |
| | | integralGetService.addCouponRebate(uid); |
| | | } |
| | | |
| | | @RequestMapping(value = "getJDCouponLink") |
| | | public void getJDCouponLink(AcceptData acceptData, Long id, String couponUrl, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(couponUrl)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "券链接不能为空")); |
| | | return; |
| | | } |
| | | if (id == null || id <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | String jumpLink = null; |
| | | String materialId = "https://item.jd.com/" + id + ".html"; |
| | | |
| | | try { |
| | | jumpLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, null, pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.fanli), null); |
| | | } catch (Exception e) { |
| | | logger.warn(String.format("京东转链出错:materialId-%s couponUrl-%s", materialId, couponUrl), e); |
| | | } |
| | | if (StringUtil.isNullOrEmpty(jumpLink)) { |
| | | jumpLink = couponUrl; |
| | | } |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("native", true); |
| | | data.put("jumpLink", jumpLink); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | /** |
| | | * 拼多多购买链接 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param id |
| | | * @param source |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getPDDLink") |
| | | public void getPDDLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) { |
| | | |
| | | if (id == null || id <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.fanli); |
| | | //只是领券 |
| | | if (!SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.fanli)) { |
| | | pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.coupon); |
| | | uid = null; |
| | | } else { |
| | | |
| | | if (uid == null) { |
| | | pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.coupon); |
| | | uid = null; |
| | | } else { |
| | | 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 (userFunctionsLimitService.isLimit(uid, SystemFunction.fanli, new Date())) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该功能限制使用")); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(id); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | String customParams = uid == null ? Constant.PDD_SEARCH_CUSTOMER_PARAMS : pddAuthService.getFanliCustomParams(uid); |
| | | boolean auth = PinDuoDuoApiUtil.isAuth(pid, customParams); |
| | | JSONObject data = new JSONObject(); |
| | | PDDConvertLinkResultVO convertUrl = null; |
| | | if (!auth) { |
| | | convertUrl = PinDuoDuoApiUtil.getAuthLink(pid, customParams); |
| | | } else { |
| | | convertUrl = PinDuoDuoApiUtil.convert(goods.getGoodsSign(), pid + "", customParams, !auth); |
| | | LogHelper.test(String.format("拼多多转链:uid:%s data:%s", uid + "", data.toString())); |
| | | } |
| | | |
| | | GoodsJumpLinkVO vo = GoodsJumpUtil.getPDDJumpInfo(convertUrl); |
| | | data = JSONObject.fromObject(new Gson().toJson(vo)); |
| | | data.put("native", vo.is_native()); |
| | | if (uid != null) |
| | | data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | // 获得金币 |
| | | integralGetService.addCouponRebate(uid); |
| | | } |
| | | |
| | | /** |
| | | * 唯品会购买链接 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param id |
| | | * @param source |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "getVIPLink") |
| | | public void getVIPLink(AcceptData acceptData, Long uid, Long id, String source, PrintWriter out) { |
| | | if (id == null || id <= 0) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | String tag = null; |
| | | //只是领券 |
| | | if (!SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.fanli)) { |
| | | tag = VipShopUtil.getCouponChanTag(); |
| | | } else { |
| | | //只是领券 |
| | | if (uid == null) { |
| | | tag = VipShopUtil.getCouponChanTag(); |
| | | } else { |
| | | 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 (userFunctionsLimitService.isLimit(uid, SystemFunction.fanli, new Date())) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该功能限制使用")); |
| | | return; |
| | | } |
| | | |
| | | tag = VipShopUtil.getBuyChanTag(uid); |
| | | } |
| | | } |
| | | |
| | | VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(id + ""); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | VIPConvertResultDTO convertUrl = VipShopApiUtil.convertLink(id + "", tag); |
| | | GoodsJumpLinkVO vo = GoodsJumpUtil.getVIPShopJumpInfo(convertUrl); |
| | | |
| | | JSONObject data = JSONObject.fromObject(new Gson().toJson(vo)); |
| | | data.put("native", vo.is_native()); |
| | | if (uid != null) |
| | | data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | // 获得金币 |
| | | integralGetService.addCouponRebate(uid); |
| | | } |
| | | |
| | | @RequestMapping(value = "getSuningLink") |
| | | public void getSuningLink(AcceptData acceptData, Long uid, String id, String source, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.fanli); |
| | | if (!SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.fanli)) { |
| | | pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.coupon); |
| | | uid = null; |
| | | } else { |
| | | if (uid == null) { |
| | | pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_SUNING, SystemPIDInfo.PidType.coupon); |
| | | uid = null; |
| | | } else { |
| | | 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 (userFunctionsLimitService.isLimit(uid, SystemFunction.fanli, new Date())) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该功能限制使用")); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | String[] sts = SuningUtil.getGoodsIdDetail(id); |
| | | String supplierCode = sts[0]; |
| | | String goodsCode = sts[1]; |
| | | |
| | | SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(goodsCode, supplierCode); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | String quanUrl = null; |
| | | if (!StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) |
| | | quanUrl = goods.getCouponInfo().getCouponUrl(); |
| | | SuningConvertLinkResult link = SuningApiUtil.convertLinkNew(goodsCode, supplierCode, |
| | | pid, uid + ""); |
| | | |
| | | GoodsJumpLinkVO vo = GoodsJumpUtil.getSuningJumpInfo(link); |
| | | |
| | | JSONObject data = JSONObject.fromObject(new Gson().toJson(vo)); |
| | | data.put("native", vo.is_native()); |
| | | if (uid != null) |
| | | data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | |
| | | // 获得金币 |
| | | integralGetService.addCouponRebate(uid); |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "getDYLink") |
| | | public void getDYLink(AcceptData acceptData, Long uid, String id, String source, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(id)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品ID不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (!SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.fanli)) { |
| | | uid = null; |
| | | } else { |
| | | if (uid == null) { |
| | | uid = null; |
| | | } else { |
| | | 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 (userFunctionsLimitService.isLimit(uid, SystemFunction.fanli, new Date())) { |
| | | out.print(JsonUtil.loadFalseResult(1, "该功能限制使用")); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | DYGoodsDetail goods = CSJCPSApiUtil.goodsDetail(Long.parseLong(id)); |
| | | if (goods == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架")); |
| | | return; |
| | | } |
| | | |
| | | DYConvertResult link = null; |
| | | try { |
| | | link = CSJCPSApiUtil.goodsConvert(goods.getDetail_url(), DYUtil.createFanLiExtraInfo(uid), |
| | | ""); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseResult(2, "商品转链失败")); |
| | | } |
| | | |
| | | GoodsJumpLinkVO vo = GoodsJumpUtil.getDYJumpInfo(link); |
| | | |
| | | JSONObject data = JSONObject.fromObject(new Gson().toJson(vo)); |
| | | data.put("native", vo.is_native()); |
| | | if (uid != null) |
| | | data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem())); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | |
| | | // 获得金币 |
| | | integralGetService.addCouponRebate(uid); |
| | | } |
| | | |
| | | /** |
| | | * 是否在参与推广 |
| | | * |
| | | * @param goodsId -商品ID |
| | | * @param goodsType -TB/JD |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "isGoodsExtend") |
| | | public void isGoodsExtend(AcceptData acceptData, String goodsId, Integer goodsType, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(goodsId)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "未参与推广")); |
| | | return; |
| | | } |
| | | if (goodsType == null) { |
| | | out.print(JsonUtil.loadFalseResult(2, "缺少goodsType")); |
| | | return; |
| | | } |
| | | JSONObject data = new JSONObject(); |
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) { |
| | | TaoBaoGoodsBrief goods = null; |
| | | try { |
| | | goods = TaoKeApiUtil.getSimpleGoodsInfo(goodsId); |
| | | } catch (NumberFormatException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | 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); |
| | | } |
| | | |
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) { |
| | | JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(goodsId)); |
| | | if (goods == null) { |
| | | data.put("extend", false); |
| | | data.put("url", String.format("https://item.m.jd.com/product/%s.html", goodsId)); |
| | | } else { |
| | | data.put("extend", true); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) { |
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(goodsId)); |
| | | if (goods == null) { |
| | | data.put("extend", false); |
| | | data.put("url", String.format("https://mobile.yangkeduo.com/goods.html?goods_id=%s", goodsId)); |
| | | } else { |
| | | data.put("extend", true); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_VIP) { |
| | | VIPGoodsInfo goods = VipShopApiUtil.getGoodsDetail(goodsId); |
| | | if (goods == null) { |
| | | data.put("extend", false); |
| | | data.put("url", ""); |
| | | } else { |
| | | data.put("extend", true); |
| | | } |
| | | } else if (goodsType == Constant.SOURCE_TYPE_SUNING) { |
| | | SuningGoodsInfo goods = SuningApiUtil.getGoodsDetail(goodsId.split("-")[1], goodsId.split("-")[0]); |
| | | if (goods == null) { |
| | | data.put("extend", false); |
| | | data.put("url", String.format("https://m.suning.com/product/%s/%s.html", goodsId.split("-")[0], goodsId.split("-")[1])); |
| | | } else { |
| | | data.put("extend", true); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping(value = "listSimpleGoods", method = RequestMethod.POST) |
| | | public void listSimpleGoods(AcceptData acceptData, String goodsInfo, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(goodsInfo)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "商品信息为空")); |
| | | return; |
| | | } |
| | | |
| | | net.sf.json.JSONArray array = net.sf.json.JSONArray.fromObject(goodsInfo); |
| | | |
| | | List<CommonGoods> commonGoodsList = new ArrayList<>(); |
| | | |
| | | for (int i = 0; i < array.size(); i++) { |
| | | JSONObject obj = array.optJSONObject(i); |
| | | CommonGoods cg = new CommonGoods(); |
| | | cg.setGoodsId(obj.optString("goodsId")); |
| | | cg.setGoodsType(obj.optInt("goodsType")); |
| | | commonGoodsList.add(cg); |
| | | } |
| | | |
| | | if (commonGoodsList.size() > 9) { |
| | | out.print(JsonUtil.loadFalseResult(1, "最多同时获取9条数据")); |
| | | return; |
| | | } |
| | | |
| | | // 分离各个平台的商品信息 |
| | | List<String> tbGoodsList = new ArrayList<>(); |
| | | List<Long> jdGoodsList = new ArrayList<>(); |
| | | List<Long> pddGoodsList = new ArrayList<>(); |
| | | |
| | | List<String> keyList = new ArrayList<>(); |
| | | |
| | | for (CommonGoods cg : commonGoodsList) { |
| | | keyList.add(cg.getGoodsId() + "-" + cg.getGoodsType()); |
| | | if (cg.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) { |
| | | tbGoodsList.add(cg.getGoodsId()); |
| | | } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_JD) { |
| | | jdGoodsList.add(Long.parseLong(cg.getGoodsId())); |
| | | } else if (cg.getGoodsType() == Constant.SOURCE_TYPE_PDD) { |
| | | pddGoodsList.add(Long.parseLong(cg.getGoodsId())); |
| | | } |
| | | } |
| | | |
| | | Map<String, GoodsDetailVO> tempGoodsList = new HashMap<>(); |
| | | |
| | | GoodsMoneyConfigParamsDTO params = new GoodsMoneyConfigParamsDTO(hongBaoManageService.getFanLiRate(acceptData.getSystem()), |
| | | hongBaoManageService.getShareRate(acceptData.getSystem()), new BigDecimal(80), |
| | | hongBaoManageService.getFanLiRate(UserLevelEnum.superVIP, acceptData.getSystem())); |
| | | |
| | | if (tbGoodsList.size() > 0) { |
| | | List<TaoBaoGoodsBrief> goodsList = null; |
| | | try { |
| | | goodsList = TaoKeApiUtil.getBatchGoodsInfo(tbGoodsList); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | } catch (TaoKeApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | if (goodsList != null) |
| | | for (TaoBaoGoodsBrief goods : goodsList) { |
| | | goods.setTkRate(new BigDecimal(0)); |
| | | tempGoodsList.put(goods.getAuctionId() + "-" + Constant.SOURCE_TYPE_TAOBAO, |
| | | GoodsDetailVOFactory.convertTaoBao(goods, params)); |
| | | } |
| | | } |
| | | if (jdGoodsList.size() > 0) { |
| | | List<JDGoods> goodsList = JDApiUtil.getGoodsDetail(jdGoodsList); |
| | | for (JDGoods goods : goodsList) { |
| | | tempGoodsList.put(goods.getSkuId() + "-" + Constant.SOURCE_TYPE_JD, |
| | | GoodsDetailVOFactory.convertJDGoods(goods, params)); |
| | | } |
| | | } |
| | | if (pddGoodsList.size() > 0) { |
| | | List<PDDGoodsDetail> goodsList = PinDuoDuoApiUtil.listGoodsDetail(pddGoodsList); |
| | | for (PDDGoodsDetail goods : goodsList) { |
| | | tempGoodsList.put(goods.getGoodsId() + "-" + Constant.SOURCE_TYPE_PDD, |
| | | GoodsDetailVOFactory.convertPDDGoods(goods, params)); |
| | | } |
| | | } |
| | | List<GoodsDetailVO> voList = new ArrayList<>(); |
| | | Gson gson = JsonUtil.getApiCommonGson(); |
| | | for (String key : keyList) { |
| | | GoodsDetailVO vo = tempGoodsList.get(key); |
| | | if (vo != null) { |
| | | voList.add(vo); |
| | | } |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(gson.toJson(voList))); |
| | | } |
| | | |
| | | /** |
| | | * 京东转链 |
| | | * |
| | | * @param acceptData |
| | | * @param link |
| | | * @param uid |
| | | * @param out void 返回类型 |
| | | * @throws |
| | | * @Title: getJDLink |
| | | * @Description: |
| | | */ |
| | | @RequestMapping(value = "convertJDLink") |
| | | public void convertJDLink(AcceptData acceptData, String link, Long uid, String callback, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(link)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "链接为空")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | link = JDApiUtil.convertLinkWithSubUnionId(link, null, null, pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_JD, SystemPIDInfo.PidType.fanli), uid + ""); |
| | | } catch (Exception e) { |
| | | logger.warn(String.format("京东转链出错:materialId-%s", link), e); |
| | | } |
| | | |
| | | |
| | | GoodsJumpLinkVO vo = GoodsJumpUtil.getJDJumpInfo(link); |
| | | JSONObject data = JSONObject.fromObject(new Gson().toJson(vo)); |
| | | data.put("native", vo.is_native()); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping(value = "convertPDDLink") |
| | | public void convertPDDLink(AcceptData acceptData, String resourceType, String channelType, Long uid, PrintWriter out) { |
| | | if (StringUtil.isNullOrEmpty(resourceType) && StringUtil.isNullOrEmpty(channelType)) { |
| | | out.print(JsonUtil.loadFalseResult(1, "resourceType|channelType为空")); |
| | | return; |
| | | } |
| | | String customParams = null; |
| | | if (uid != null) |
| | | customParams = pddAuthService.getFanliCustomParams(uid); |
| | | String pid = pidManager.getPidCache(acceptData.getSystem(), Constant.SOURCE_TYPE_PDD, SystemPIDInfo.PidType.fanli); |
| | | PDDConvertLinkResultVO pddConvertLinkResultVO = null; |
| | | if (!StringUtil.isNullOrEmpty(resourceType)) { |
| | | pddConvertLinkResultVO = PinDuoDuoApiUtil.convertActivity(resourceType, null, pid, customParams); |
| | | } else if (!StringUtil.isNullOrEmpty(channelType)) { |
| | | pddConvertLinkResultVO = PinDuoDuoApiUtil.convertChannel(channelType, pid, customParams); |
| | | } |
| | | |
| | | |
| | | GoodsJumpLinkVO vo = GoodsJumpUtil.getPDDJumpInfo(pddConvertLinkResultVO); |
| | | JSONObject data = JSONObject.fromObject(new Gson().toJson(vo)); |
| | | data.put("native", vo.is_native()); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | @RequestMapping(value = "getTaoBaoGoodsDetailImgs") |
| | | public void getTaoBaoGoodsDetailImgs(AcceptData acceptData, String id, PrintWriter out) { |
| | | TaoBaoGoodsImportantInfo info = DaTaoKeApiUtil.getGoodsImportantInfo(id); |
| | | if (info == null || info.getDetailImages() == null) { |
| | | out.print(JsonUtil.loadFalseResult("")); |
| | | return; |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(new Gson().toJson(info.getDetailImages()))); |
| | | } |
| | | |
| | | } |