admin
2023-04-12 651f2856e9ae10aacbfb8327d967aacbb6d58333
fanli/src/main/java/com/yeshi/fanli/controller/client/lijin/GoodsControllerLijin.java
@@ -6,6 +6,7 @@
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;
@@ -28,8 +29,10 @@
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;
@@ -38,6 +41,7 @@
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;
@@ -51,6 +55,8 @@
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;
@@ -66,6 +72,10 @@
@Controller
@RequestMapping("api/lijin/goods")
public class GoodsControllerLijin {
    Logger userGoodsScanLogger = LoggerFactory.getLogger("userGoodsScanLog");
    @Resource
    private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
@@ -103,6 +113,9 @@
    @Resource
    private UserInfoService userInfoService;
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
    /**
     * 获取商品详情
@@ -113,11 +126,14 @@
     * @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<>();
@@ -137,18 +153,21 @@
                }
                TaoBaoGoodsBrief goods = getTaoBaoGoods(Long.parseLong(goodsId));
                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);
                }
                //重置资金信息
                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)) {
@@ -255,11 +274,24 @@
                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);
            }
@@ -273,7 +305,7 @@
        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)
@@ -303,7 +335,7 @@
            try {
                LiJinExpendRecord record = goodsLijinMnager.createTBLijin(Long.parseLong(goodsId), uid, new Date(user.getCreatetime()));
                LiJinExpendRecord record = goodsLijinMnager.createTBLijin(goodsId, uid, new Date(user.getCreatetime()));
                String sendUrl = record.getSendUrl();
                if (StringUtil.isNullOrEmpty(sendUrl)) {
                    out.print(JsonUtil.loadFalseResult("礼金创建失败"));
@@ -317,6 +349,12 @@
                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()));
@@ -342,19 +380,19 @@
     *
     * @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, true);
        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(vipRank, false);
        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) {