| | |
| | | package com.yeshi.fanli.controller.client.lijin; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.common.entity.taobao.TaoBaoShop; |
| | | import com.yeshi.common.entity.taobao.TaoKeAppInfo; |
| | | import com.yeshi.common.vo.ClientTextStyleVO; |
| | | import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; |
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; |
| | | import com.yeshi.fanli.dto.suning.SuningGoodsInfo; |
| | | 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.goods.CollectionGoodsV2; |
| | | import com.yeshi.fanli.entity.jd.JDGoods; |
| | | import com.yeshi.fanli.exception.pdd.PDDApiException; |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; |
| | | import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service; |
| | | import com.yeshi.fanli.service.inter.pdd.PDDAuthService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService; |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService; |
| | | import com.yeshi.fanli.service.inter.user.ShamUserService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.TaoBaoConstant; |
| | | import com.yeshi.fanli.util.ThreadUtil; |
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil; |
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOLijinFactory; |
| | | 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.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.vipshop.VipShopApiUtil; |
| | | import com.yeshi.fanli.lijin.vo.GoodsDetailVO; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.MoneyBigDecimalUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/lijin/goods") |
| | |
| | | @Resource |
| | | private PDDAuthService pddAuthService; |
| | | |
| | | @Resource |
| | | private CollectionGoodsV2Service collectionGoodsV2Service; |
| | | |
| | | @Resource |
| | | private ShamUserService shamUserService; |
| | | |
| | | @Resource |
| | | private TaoBaoShopService taoBaoShopService; |
| | | |
| | | /** |
| | | * 获取商品详情 |
| | | * |
| | |
| | | * @return |
| | | */ |
| | | @RequestMapping("getGoodsDetail") |
| | | @ResponseBody |
| | | public String getGoodsDetail(AcceptData acceptData, int goodsType, String goodsId, Long uid, String from) { |
| | | |
| | | public void getGoodsDetail(AcceptData acceptData, int goodsType, String goodsId, Long uid, String from, PrintWriter out) { |
| | | GoodsDetailVO goodsDetailVO = new GoodsDetailVO(); |
| | | GoodsDetailVO.GoodsExtraVO extraVO = new GoodsDetailVO.GoodsExtraVO(); |
| | | GoodsMoneyConfigParamsDTO paramsDTO = new GoodsMoneyConfigParamsDTO(); |
| | | paramsDTO.setFanLiRate(new BigDecimal("60")); |
| | | // 领券人列表 |
| | | List<ShamUser> listCouponUser = new ArrayList<>(); |
| | | switch (goodsType) { |
| | | case Constant |
| | | .SOURCE_TYPE_TAOBAO: |
| | | TaoBaoGoodsBrief taobaoGoods = getTaoBaoGoods(Long.parseLong(goodsId)); |
| | | if (taobaoGoods == null) { |
| | | TaoBaoGoodsBrief goods = getTaoBaoGoods(Long.parseLong(goodsId)); |
| | | |
| | | |
| | | goodsDetailVO.setGoods(GoodsDetailVOLijinFactory.convertTaoBao(goods, paramsDTO)); |
| | | // 店铺信息 |
| | | TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getId(), goods.getSellerId()); |
| | | if (shop != null) { |
| | | String shopLink = shop.getShopLink(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | | shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId())); |
| | | } |
| | | goodsDetailVO.getGoods().setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop)); |
| | | } |
| | | |
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img.html?id=" + goodsId); |
| | | |
| | | break; |
| | | |
| | | case Constant |
| | | .SOURCE_TYPE_JD: |
| | | JDGoods jdGoods = getJDGoods(Long.parseLong(goodsId)); |
| | | goodsDetailVO.setGoods(GoodsDetailVOLijinFactory.convertJDGoods(jdGoods, paramsDTO)); |
| | | extraVO.setDetailUrl("https://in.m.jd.com/product/jieshao/video/" + goodsId + ".html"); |
| | | |
| | | break; |
| | | |
| | | case Constant |
| | | .SOURCE_TYPE_PDD: |
| | | PDDGoodsDetail pddGoodsDetail = getPDDGoods(Long.parseLong(goodsId), uid); |
| | | |
| | | goodsDetailVO.setGoods(GoodsDetailVOLijinFactory.convertPDDGoods(pddGoodsDetail, paramsDTO)); |
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_pdd.html?id=" + goodsId); |
| | | break; |
| | | |
| | | case Constant |
| | | .SOURCE_TYPE_VIP: |
| | | VIPGoodsInfo vipGoodsInfo = VipShopApiUtil.getGoodsDetail(goodsId); |
| | | |
| | | goodsDetailVO.setGoods(GoodsDetailVOLijinFactory.convertVIPGoods(vipGoodsInfo, paramsDTO)); |
| | | break; |
| | | |
| | | case Constant |
| | | .SOURCE_TYPE_SUNING: |
| | | String[] ids = SuningUtil.getGoodsIdDetail(goodsId); |
| | | SuningGoodsInfo suningGoodsInfo = SuningApiUtil.getGoodsDetail(ids[1], ids[0]); |
| | | |
| | | goodsDetailVO.setGoods(GoodsDetailVOLijinFactory.convertSuningGoods(suningGoodsInfo, paramsDTO)); |
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_suning.html?id=" |
| | | + suningGoodsInfo.getCommodityInfo().getCommodityCode() + "&supplierCode=" |
| | | + suningGoodsInfo.getCommodityInfo().getSupplierCode()); |
| | | break; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | return null; |
| | | //是否收藏 |
| | | extraVO.setCollected(false); |
| | | if (uid != null) { |
| | | CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Service.findByUidAndAuctionId(uid, Long.parseLong(goodsDetailVO.getGoods().getGoodsId()), goodsType); |
| | | if (collectionGoodsV2 != null) { |
| | | extraVO.setCollected(true); |
| | | } |
| | | } |
| | | |
| | | if (goodsDetailVO.getGoods().getTempCoupon() != null && goodsDetailVO.getGoods().getTempCoupon().getAmount() != null |
| | | && goodsDetailVO.getGoods().getTempCoupon().getAmount().compareTo(new BigDecimal(0)) > 0) { |
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300); |
| | | } |
| | | extraVO.setFanliValid(true); |
| | | extraVO.setBuyValid(true); |
| | | extraVO.setListCouponUser(listCouponUser); |
| | | goodsDetailVO.setExtra(extraVO); |
| | | loadLijinInfo(goodsDetailVO.getGoods()); |
| | | |
| | | |
| | | //清除临时信息 |
| | | goodsDetailVO.getGoods().setTempCoupon(null); |
| | | if (goodsDetailVO.getGoods().getLabels() == null) |
| | | goodsDetailVO.getGoods().setLabels(new ArrayList<>()); |
| | | goodsDetailVO.getGoods().getLabels().add(new ClientTextStyleVO("天猫", "#FF2C4A")); |
| | | out.print(JsonUtil.loadTrueResult(new Gson().toJson(goodsDetailVO))); |
| | | } |
| | | |
| | | /** |
| | | * 加载礼金信息 |
| | | * |
| | | * @param goodsInfoVO |
| | | */ |
| | | private void loadLijinInfo(GoodsDetailVO.GoodsInfoVO goodsInfoVO) { |
| | | //虚拟数据 |
| | | List<BigDecimal> lijinList = new ArrayList<>(); |
| | | lijinList.add(new BigDecimal("1")); |
| | | lijinList.add(new BigDecimal("2")); |
| | | lijinList.add(new BigDecimal("2.5")); |
| | | |
| | | GoodsDetailVO.GoodsHongBaoListVO.UserLevelVO userLevelVO = new GoodsDetailVO.GoodsHongBaoListVO.UserLevelVO(); |
| | | userLevelVO.setVipRank(1); |
| | | userLevelVO.setDesc("升级为铂金会员红包可提高100%"); |
| | | userLevelVO.setLink("http://www.baidu.com"); |
| | | |
| | | if (goodsInfoVO.getPriceList() == null) { |
| | | goodsInfoVO.setPriceList(new ArrayList<>()); |
| | | } |
| | | |
| | | goodsInfoVO.getPriceList().get(0).setUserLevel(userLevelVO); |
| | | |
| | | for (BigDecimal money : lijinList) { |
| | | GoodsDetailVO.GoodsHongBaoListVO price = new GoodsDetailVO.GoodsHongBaoListVO(); |
| | | price.setType(2); |
| | | price.setSubMoney("¥" + money); |
| | | price.setUserLevel(userLevelVO); |
| | | |
| | | //最终价格计算=券后价-礼金 |
| | | price.setFinalMoney("¥" + goodsInfoVO.getCouponPrice().subtract(money).toString()); |
| | | |
| | | List<GoodsDetailVO.GoodsHongBaoListVO.PriceInfo> priceInfos = new ArrayList<>(); |
| | | |
| | | priceInfos.add(new GoodsDetailVO.GoodsHongBaoListVO.PriceInfo("原价", goodsInfoVO.getZkPrice())); |
| | | |
| | | if (goodsInfoVO.getTempCoupon() != null) { |
| | | priceInfos.add(new GoodsDetailVO.GoodsHongBaoListVO.PriceInfo("优惠券", "-¥" + MoneyBigDecimalUtil.getWithNoZera(goodsInfoVO.getTempCoupon().getAmount()).toString())); |
| | | } |
| | | |
| | | priceInfos.add(new GoodsDetailVO.GoodsHongBaoListVO.PriceInfo("首单礼金", "-¥1")); |
| | | |
| | | priceInfos.add(new GoodsDetailVO.GoodsHongBaoListVO.PriceInfo("礼金", "-" + "¥" + money)); |
| | | price.setPriceDetails(priceInfos); |
| | | goodsInfoVO.getPriceList().add(0, price); |
| | | } |
| | | |
| | | //计算最大的礼金面额 |
| | | goodsInfoVO.getMoneyInfo().setHongBaoMoney("¥3"); |
| | | } |
| | | |
| | | |
| | | private TaoBaoGoodsBrief getTaoBaoGoods(Long id) { |
| | | try { |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | private JDGoods getJDGoods(Long id) { |
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); // 高级接口 |