1
This commit is contained in:
@@ -164,10 +164,8 @@ public class OrderRow {
|
|||||||
@Column(name = "rid")
|
@Column(name = "rid")
|
||||||
private Long rid;
|
private Long rid;
|
||||||
|
|
||||||
//@OneToOne(cascade = CascadeType.ALL)
|
@Column(name = "goods_info_id")
|
||||||
//@JoinColumn(name = "goods_info_id", referencedColumnName = "id")
|
private Long goodsInfoId;
|
||||||
//private GoodsInfoVO goodsInfo;
|
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "express_status")
|
@Column(name = "express_status")
|
||||||
private Integer expressStatus;
|
private Integer expressStatus;
|
||||||
@@ -548,13 +546,13 @@ public class OrderRow {
|
|||||||
this.rid = rid;
|
this.rid = rid;
|
||||||
}
|
}
|
||||||
|
|
||||||
//public GoodsInfoVO getGoodsInfo() {
|
public Long getGoodsInfoId() {
|
||||||
// return goodsInfo;
|
return goodsInfoId;
|
||||||
//}
|
}
|
||||||
//
|
|
||||||
//public void setGoodsInfo(GoodsInfoVO goodsInfo) {
|
public void setGoodsInfoId(Long goodsInfoId) {
|
||||||
// this.goodsInfo = goodsInfo;
|
this.goodsInfoId = goodsInfoId;
|
||||||
//}
|
}
|
||||||
|
|
||||||
public Integer getExpressStatus() {
|
public Integer getExpressStatus() {
|
||||||
return expressStatus;
|
return expressStatus;
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package cn.van.business.repository;
|
||||||
|
|
||||||
|
import cn.van.business.model.jd.GoodsInfoVO;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface GoodsInfoRepository extends JpaRepository<GoodsInfoVO, Long> {
|
||||||
|
|
||||||
|
Optional<GoodsInfoVO> findFirstByImageUrlAndShopName(String imageUrl, String shopName);
|
||||||
|
}
|
||||||
@@ -2,11 +2,14 @@ package cn.van.business.util;
|
|||||||
|
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import cn.van.business.model.jd.GoodsInfoVO;
|
||||||
import cn.van.business.model.jd.OrderRow;
|
import cn.van.business.model.jd.OrderRow;
|
||||||
import cn.van.business.model.pl.Comment;
|
import cn.van.business.model.pl.Comment;
|
||||||
import cn.van.business.model.wx.SuperAdmin;
|
import cn.van.business.model.wx.SuperAdmin;
|
||||||
import cn.van.business.repository.CommentRepository;
|
import cn.van.business.repository.CommentRepository;
|
||||||
|
import cn.van.business.repository.GoodsInfoRepository;
|
||||||
import cn.van.business.repository.OrderRowRepository;
|
import cn.van.business.repository.OrderRowRepository;
|
||||||
|
import com.jd.open.api.sdk.domain.kplunion.OrderService.response.query.GoodsInfo;
|
||||||
import cn.van.business.util.jdReq.*;
|
import cn.van.business.util.jdReq.*;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
@@ -59,6 +62,7 @@ public class JDScheduleJob {
|
|||||||
private static final String JD_REFRESH_TAG = "jd:refresh:tag:";
|
private static final String JD_REFRESH_TAG = "jd:refresh:tag:";
|
||||||
private final StringRedisTemplate redisTemplate;
|
private final StringRedisTemplate redisTemplate;
|
||||||
private final OrderRowRepository orderRowRepository;
|
private final OrderRowRepository orderRowRepository;
|
||||||
|
private final GoodsInfoRepository goodsInfoRepository;
|
||||||
private final OrderUtil orderUtil;
|
private final OrderUtil orderUtil;
|
||||||
private final JDUtil jdUtil;
|
private final JDUtil jdUtil;
|
||||||
private final CommentRepository commentRepository;
|
private final CommentRepository commentRepository;
|
||||||
@@ -81,9 +85,10 @@ public class JDScheduleJob {
|
|||||||
|
|
||||||
// 构造函数中注入StringRedisTemplate
|
// 构造函数中注入StringRedisTemplate
|
||||||
@Autowired
|
@Autowired
|
||||||
public JDScheduleJob(WXUtil wxUtil, StringRedisTemplate redisTemplate, OrderRowRepository orderRowRepository, OrderUtil orderUtil, JDUtil jdUtil, CommentRepository commentRepository) {
|
public JDScheduleJob(WXUtil wxUtil, StringRedisTemplate redisTemplate, OrderRowRepository orderRowRepository, GoodsInfoRepository goodsInfoRepository, OrderUtil orderUtil, JDUtil jdUtil, CommentRepository commentRepository) {
|
||||||
this.redisTemplate = redisTemplate;
|
this.redisTemplate = redisTemplate;
|
||||||
this.orderRowRepository = orderRowRepository;
|
this.orderRowRepository = orderRowRepository;
|
||||||
|
this.goodsInfoRepository = goodsInfoRepository;
|
||||||
this.orderUtil = orderUtil;
|
this.orderUtil = orderUtil;
|
||||||
this.jdUtil = jdUtil;
|
this.jdUtil = jdUtil;
|
||||||
this.commentRepository = commentRepository;
|
this.commentRepository = commentRepository;
|
||||||
@@ -123,14 +128,10 @@ public class JDScheduleJob {
|
|||||||
orderRow.setPayMonth(orderRowResp.getPayMonth());
|
orderRow.setPayMonth(orderRowResp.getPayMonth());
|
||||||
orderRow.setSiteId(orderRowResp.getSiteId());
|
orderRow.setSiteId(orderRowResp.getSiteId());
|
||||||
orderRow.setParentId(orderRowResp.getParentId());
|
orderRow.setParentId(orderRowResp.getParentId());
|
||||||
//GoodsInfo goodsInfo = orderRowResp.getGoodsInfo();
|
GoodsInfoVO goodsInfoVO = resolveGoodsInfo(orderRowResp.getGoodsInfo(), orderRowResp.getSkuId());
|
||||||
//GoodsInfoVO goodsInfoVO = new GoodsInfoVO();
|
if (goodsInfoVO != null) {
|
||||||
//goodsInfoVO.setShopId(String.valueOf(goodsInfo.getShopId()));
|
orderRow.setGoodsInfoId(goodsInfoVO.getId());
|
||||||
//goodsInfoVO.setShopName(goodsInfo.getShopName());
|
}
|
||||||
//goodsInfoVO.setOwner(goodsInfo.getOwner());
|
|
||||||
//goodsInfoVO.setProductId(String.valueOf(goodsInfo.getProductId()));
|
|
||||||
//goodsInfoVO.setImageUrl(goodsInfo.getImageUrl());
|
|
||||||
//orderRow.setGoodsInfo(goodsInfoVO);
|
|
||||||
orderRow.setCallerItemId(orderRowResp.getCallerItemId());
|
orderRow.setCallerItemId(orderRowResp.getCallerItemId());
|
||||||
orderRow.setPid(orderRowResp.getPid());
|
orderRow.setPid(orderRowResp.getPid());
|
||||||
orderRow.setCid1(orderRowResp.getCid1());
|
orderRow.setCid1(orderRowResp.getCid1());
|
||||||
@@ -165,6 +166,39 @@ public class JDScheduleJob {
|
|||||||
return orderRow;
|
return orderRow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GoodsInfoVO resolveGoodsInfo(GoodsInfo goodsInfo, Long skuId) {
|
||||||
|
if (goodsInfo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String imageUrl = goodsInfo.getImageUrl();
|
||||||
|
String shopName = goodsInfo.getShopName();
|
||||||
|
if ((imageUrl == null || imageUrl.isBlank()) && (shopName == null || shopName.isBlank())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (imageUrl != null && shopName != null) {
|
||||||
|
Optional<GoodsInfoVO> existing = goodsInfoRepository.findFirstByImageUrlAndShopName(imageUrl, shopName);
|
||||||
|
if (existing.isPresent()) {
|
||||||
|
return existing.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GoodsInfoVO vo = new GoodsInfoVO();
|
||||||
|
vo.setImageUrl(imageUrl);
|
||||||
|
vo.setShopName(shopName);
|
||||||
|
vo.setOwner(goodsInfo.getOwner());
|
||||||
|
if (goodsInfo.getShopId() != null) {
|
||||||
|
vo.setShopId(String.valueOf(goodsInfo.getShopId()));
|
||||||
|
}
|
||||||
|
if (goodsInfo.getMainSkuId() != null) {
|
||||||
|
vo.setMainSkuId(String.valueOf(goodsInfo.getMainSkuId()));
|
||||||
|
} else if (skuId != null) {
|
||||||
|
vo.setMainSkuId(String.valueOf(skuId));
|
||||||
|
}
|
||||||
|
if (goodsInfo.getProductId() != null) {
|
||||||
|
vo.setProductId(String.valueOf(goodsInfo.getProductId()));
|
||||||
|
}
|
||||||
|
return goodsInfoRepository.save(vo);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据指定的日期时间拉取订单
|
* 根据指定的日期时间拉取订单
|
||||||
*
|
*
|
||||||
@@ -453,7 +487,7 @@ public class JDScheduleJob {
|
|||||||
orderReq.setStartTime(startTime);
|
orderReq.setStartTime(startTime);
|
||||||
orderReq.setEndTime(endTime);
|
orderReq.setEndTime(endTime);
|
||||||
orderReq.setType(1);
|
orderReq.setType(1);
|
||||||
|
orderReq.setFields("goodsInfo");
|
||||||
|
|
||||||
request.setOrderReq(orderReq);
|
request.setOrderReq(orderReq);
|
||||||
request.setVersion("1.0");
|
request.setVersion("1.0");
|
||||||
|
|||||||
Reference in New Issue
Block a user