| | |
| | | import com.ks.lijin.exception.LiJinGoodsException; |
| | | import com.ks.lijin.exception.LiJinUserException; |
| | | import com.ks.lijin.pojo.DO.LiJinExpendRecord; |
| | | import com.ks.lijin.pojo.DTO.MoneyInfo; |
| | | import com.ks.vip.pojo.Enums.VIPEnum; |
| | | import com.yeshi.common.entity.taobao.TaoBaoShop; |
| | | import com.yeshi.common.entity.taobao.TaoKeAppInfo; |
| | |
| | | import com.yeshi.fanli.entity.SystemPIDInfo; |
| | | 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.goods.CollectionGoodsV2; |
| | | import com.yeshi.fanli.entity.jd.JDGoods; |
| | | import com.yeshi.fanli.exception.goods.CommonGoodsException; |
| | |
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; |
| | | import com.yeshi.fanli.lijin.manager.GoodsLijinMnager; |
| | | import com.yeshi.fanli.lijin.manager.UserLijinMnager; |
| | | import com.yeshi.fanli.lijin.manager.UserLijinSendManager; |
| | | import com.yeshi.fanli.log.vo.UserGoodsScanLog; |
| | | import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service; |
| | | import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service; |
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService; |
| | | 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.service.inter.user.UserInfoService; |
| | | import com.yeshi.fanli.service.manger.PIDManager; |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil; |
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; |
| | | 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.lijin.vo.GoodsDetailVO; |
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; |
| | | import net.sf.json.JSONObject; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.JsonUtil; |
| | |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Controller |
| | | @RequestMapping("api/lijin/goods") |
| | | public class GoodsControllerLijin { |
| | | Logger userGoodsScanLogger = LoggerFactory.getLogger("userGoodsScanLog"); |
| | | |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil; |
| | |
| | | private UserLijinMnager userLijinMnager; |
| | | |
| | | @Resource |
| | | private UserLijinSendManager userLijinSendManager; |
| | | |
| | | @Resource |
| | | private PIDManager pidManager; |
| | | @Resource |
| | | private ScanHistoryV2Service scanHistoryV2Service; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; |
| | | |
| | | |
| | | /** |
| | |
| | | * @param from |
| | | * @return |
| | | */ |
| | | |
| | | @RequestMapping("getGoodsDetail") |
| | | 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(); |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(), |
| | | acceptData.getVersion(), acceptData.getSystem()); |
| | | |
| | | paramsDTO.setFanLiRate(goodsLijinMnager.getFanLiRate(uid)); |
| | | // 领券人列表 |
| | | List<ShamUser> listCouponUser = new ArrayList<>(); |
| | |
| | | switch (goodsType) { |
| | | case Constant |
| | | .SOURCE_TYPE_TAOBAO: |
| | | TaoBaoGoodsBrief goods = getTaoBaoGoods(Long.parseLong(goodsId)); |
| | | |
| | | if (uid != null) { |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | //小于10块自动发放奖金 |
| | | userLijinSendManager.autoSendLijin(uid, new BigDecimal(10)); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | TaoBaoGoodsBrief goods = getTaoBaoGoods(goodsId); |
| | | |
| | | //加载资金信息 |
| | | com.yeshi.fanli.vo.goods.GoodsDetailVO goodsDetailVO1 = GoodsDetailVOFactory.convertTaoBao(goods, paramsDTO); |
| | | goodsDetailVO1 = goodsLijinMnager.loadTBMoneyInfo(acceptData.getSystem(), uid, goods, goodsDetailVO1, true); |
| | | |
| | | goodsDetailVO.setGoods(GoodsDetailVOLijinFactory.convertTaoBao(goods, paramsDTO)); |
| | | BigDecimal lijinAmount = goodsLijinMnager.getTBLijin(uid, goods); |
| | | if (lijinAmount != null && lijinAmount.compareTo(new BigDecimal(0)) > 0) { |
| | | goodsDetailVO.getGoods().getMoneyInfo().setHongBaoMoney("¥" + lijinAmount); |
| | | GoodsDetailVOLijinFactory.fillRights(goodsDetailVO.getGoods()); |
| | | } |
| | | //重置资金信息 |
| | | goodsDetailVO.getGoods().setMoneyInfo(goodsDetailVO1.getMoneyInfo()); |
| | | |
| | | |
| | | GoodsDetailVOLijinFactory.fillRights(goodsDetailVO.getGoods()); |
| | | |
| | | // 店铺信息 |
| | | TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getId(), goods.getSellerId()); |
| | | TaoBaoShop shop = taoBaoShopService.getTaoBaoShop(goods.getAuctionId(), goods.getSellerId()); |
| | | if (shop != null) { |
| | | String shopLink = shop.getShopLink(); |
| | | if (StringUtil.isNullOrEmpty(shopLink)) { |
| | |
| | | goodsDetailVO.getGoods().setShopInfo(ShopInfoVOFactory.convertTaoBaoShop(shop)); |
| | | } |
| | | |
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img.html?id=" + goodsId); |
| | | extraVO.setDetailUrl("http://apph5.banliapp.com/apppage/goods_img_tb.html?id=" + goodsId); |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | |
| | | break; |
| | | } |
| | | |
| | | ThreadUtil.run(new Runnable() { |
| | | |
| | | |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | userGoodsScanLogger.info("{}", new Gson().toJson(UserGoodsScanLog.UserGoodsScanLogFactory.create(goodsDetailVO.getGoods(), uid, acceptData.getUtdid(), acceptData.getDevice()))); |
| | | }catch(Exception e){ |
| | | |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | //是否收藏 |
| | | extraVO.setCollected(false); |
| | | if (uid != null) { |
| | | CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Service.findByUidAndAuctionId(uid, goodsType == Constant.SOURCE_TYPE_SUNING ? goodsIdSuning : Long.parseLong(goodsDetailVO.getGoods().getGoodsId()), goodsType); |
| | | CollectionGoodsV2 collectionGoodsV2 = collectionGoodsV2Service.findByUidAndAuctionId(uid, goodsType == Constant.SOURCE_TYPE_SUNING ? goodsIdSuning+"" : goodsDetailVO.getGoods().getGoodsId(), goodsType); |
| | | if (collectionGoodsV2 != null) { |
| | | extraVO.setCollected(true); |
| | | } |
| | |
| | | extraVO.setBuyValid(true); |
| | | extraVO.setListCouponUser(listCouponUser); |
| | | goodsDetailVO.setExtra(extraVO); |
| | | loadLijinInfo(uid, goodsDetailVO); |
| | | loadLijinInfo(uid, acceptData.getSystem(), goodsDetailVO); |
| | | //清除临时信息 |
| | | goodsDetailVO.getGoods().setTempCoupon(null); |
| | | if (goodsDetailVO.getGoods().getLabels() == null) |
| | |
| | | //TODO 获取链接 |
| | | } else { |
| | | //商品本身礼金 |
| | | //获取用户注册时间 |
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid); |
| | | |
| | | try { |
| | | LiJinExpendRecord record = goodsLijinMnager.createTBLijin(Long.parseLong(goodsId), uid); |
| | | userLijinSendManager.autoSendLijin(uid, new BigDecimal(10)); |
| | | userLijinSendManager.autoRecieveLijin(acceptData.getSystem(), acceptData.getDevice(), uid); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | try { |
| | | LiJinExpendRecord record = goodsLijinMnager.createTBLijin(goodsId, uid, new Date(user.getCreatetime())); |
| | | String sendUrl = record.getSendUrl(); |
| | | if (StringUtil.isNullOrEmpty(sendUrl)) { |
| | | out.print(JsonUtil.loadFalseResult("礼金创建失败")); |
| | |
| | | data.put("link", link); |
| | | data.put("native", true); |
| | | data.put("userLevel", userLijinMnager.getUserLevelInfo(uid, acceptData.getSystem())); |
| | | //获取今日的剩余次数 |
| | | try { |
| | | int leftCount = goodsLijinMnager.getTodayLeftCount(uid, new Date(user.getCreatetime())); |
| | | data.put("todayLeftCount", "立减机会:-1次 今日剩余:" + leftCount + "次"); |
| | | } catch (Exception e) { |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } catch (LiJinException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | | return; |
| | | } catch (LiJinUserException e) { |
| | | if (e.getCode() == LiJinUserException.CODE_USER_BALANCE_NOT_ENOUGH) { |
| | | //TODO 余额不足 |
| | | } |
| | | out.print(JsonUtil.loadFalseResult(2001, "今日领取红包次数超限")); |
| | | return; |
| | | } |
| | |
| | | * |
| | | * @param goodsDetailVO |
| | | */ |
| | | private void loadLijinInfo(Long uid, GoodsDetailVO goodsDetailVO) { |
| | | private void loadLijinInfo(Long uid, SystemEnum system, GoodsDetailVO goodsDetailVO) { |
| | | VIPEnum vipRank = userLijinMnager.getVIPRank(uid); |
| | | GoodsDetailVO.GoodsHongBaoListVO.UserLevelVO userLevelVO = goodsLijinMnager.getUserLevel(vipRank); |
| | | GoodsDetailVO.GoodsHongBaoListVO.UserLevelVO userLevelVO = goodsLijinMnager.getUserLevel(system, vipRank, true); |
| | | //返利UserLevel |
| | | if (goodsDetailVO.getGoods().getPriceList() != null && goodsDetailVO.getGoods().getPriceList().size() > 0) |
| | | goodsDetailVO.getGoods().getPriceList().get(0).setUserLevel(userLevelVO); |
| | | //礼金UserLevel |
| | | userLevelVO = goodsLijinMnager.getUserLevel(system, vipRank, false); |
| | | goodsLijinMnager.loadLijinInfo(vipRank, goodsDetailVO, userLevelVO); |
| | | } |
| | | |
| | | |
| | | private TaoBaoGoodsBrief getTaoBaoGoods(Long id) { |
| | | private TaoBaoGoodsBrief getTaoBaoGoods(String id) { |
| | | try { |
| | | TaoBaoGoodsBrief goods = taoBaoGoodsCacheUtil.getCommonTaoBaoGoodsInfo(id); |
| | | if (goods != null) { |