1
This commit is contained in:
@@ -4,9 +4,11 @@ import com.ruoyi.common.annotation.Anonymous;
|
|||||||
import com.ruoyi.common.annotation.RateLimiter;
|
import com.ruoyi.common.annotation.RateLimiter;
|
||||||
import com.ruoyi.common.constant.CacheConstants;
|
import com.ruoyi.common.constant.CacheConstants;
|
||||||
import com.ruoyi.common.enums.LimitType;
|
import com.ruoyi.common.enums.LimitType;
|
||||||
|
import com.ruoyi.jarvis.domain.GoodsInfo;
|
||||||
import com.ruoyi.jarvis.domain.OrderRows;
|
import com.ruoyi.jarvis.domain.OrderRows;
|
||||||
import com.ruoyi.jarvis.domain.dto.PromoterOrderInfoVO;
|
import com.ruoyi.jarvis.domain.dto.PromoterOrderInfoVO;
|
||||||
import com.ruoyi.jarvis.enums.ValidCodeConverter;
|
import com.ruoyi.jarvis.enums.ValidCodeConverter;
|
||||||
|
import com.ruoyi.jarvis.service.IGoodsInfoService;
|
||||||
import com.ruoyi.jarvis.service.IOrderRowsService;
|
import com.ruoyi.jarvis.service.IOrderRowsService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -17,8 +19,10 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 京东开放接口(免登录,路径统一 /open/jd/)
|
* 京东开放接口(免登录,路径统一 /open/jd/)
|
||||||
@@ -34,6 +38,9 @@ public class PublicPromoterOrderController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IOrderRowsService orderRowsService;
|
private IOrderRowsService orderRowsService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IGoodsInfoService goodsInfoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跟团订单查询(兼容 jiadiantemai 接口格式)
|
* 跟团订单查询(兼容 jiadiantemai 接口格式)
|
||||||
*/
|
*/
|
||||||
@@ -59,10 +66,20 @@ public class PublicPromoterOrderController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set<Long> goodsInfoIds = new HashSet<>();
|
||||||
|
for (OrderRows row : rows) {
|
||||||
|
if (row.getGoodsInfoId() != null) {
|
||||||
|
goodsInfoIds.add(row.getGoodsInfoId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<Long, GoodsInfo> goodsInfoMap = goodsInfoService.selectGoodsInfoMapByIds(goodsInfoIds);
|
||||||
|
|
||||||
List<PromoterOrderInfoVO> orderInfoList = new ArrayList<>();
|
List<PromoterOrderInfoVO> orderInfoList = new ArrayList<>();
|
||||||
ValidCodeConverter validCodeConverter = new ValidCodeConverter();
|
ValidCodeConverter validCodeConverter = new ValidCodeConverter();
|
||||||
for (OrderRows row : rows) {
|
for (OrderRows row : rows) {
|
||||||
orderInfoList.add(toPromoterOrderInfo(row, validCodeConverter));
|
GoodsInfo goodsInfo = row.getGoodsInfoId() != null
|
||||||
|
? goodsInfoMap.get(row.getGoodsInfoId()) : null;
|
||||||
|
orderInfoList.add(toPromoterOrderInfo(row, goodsInfo, validCodeConverter));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orderInfoList.isEmpty()) {
|
if (orderInfoList.isEmpty()) {
|
||||||
@@ -78,10 +95,12 @@ public class PublicPromoterOrderController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PromoterOrderInfoVO toPromoterOrderInfo(OrderRows row, ValidCodeConverter validCodeConverter) {
|
private PromoterOrderInfoVO toPromoterOrderInfo(OrderRows row, GoodsInfo goodsInfo,
|
||||||
|
ValidCodeConverter validCodeConverter) {
|
||||||
PromoterOrderInfoVO vo = new PromoterOrderInfoVO();
|
PromoterOrderInfoVO vo = new PromoterOrderInfoVO();
|
||||||
vo.setShopName(row.getUnionAlias() != null && !row.getUnionAlias().isEmpty()
|
String shopName = goodsInfo != null && goodsInfo.getShopName() != null && !goodsInfo.getShopName().isEmpty()
|
||||||
? row.getUnionAlias() : "京东商城");
|
? goodsInfo.getShopName() : "京东商城";
|
||||||
|
vo.setShopName(shopName);
|
||||||
vo.setShopLogo(DEFAULT_SHOP_LOGO);
|
vo.setShopLogo(DEFAULT_SHOP_LOGO);
|
||||||
vo.setOrderSource("京东");
|
vo.setOrderSource("京东");
|
||||||
vo.setTraceTypeStr(row.getTraceType() != null && row.getTraceType() == 2 ? "同店" : "跨店");
|
vo.setTraceTypeStr(row.getTraceType() != null && row.getTraceType() == 2 ? "同店" : "跨店");
|
||||||
@@ -92,7 +111,9 @@ public class PublicPromoterOrderController {
|
|||||||
vo.setOrderId(String.valueOf(row.getOrderId()));
|
vo.setOrderId(String.valueOf(row.getOrderId()));
|
||||||
}
|
}
|
||||||
vo.setValidCodeMsg(validCodeConverter.getCodeDescription(row.getValidCode()));
|
vo.setValidCodeMsg(validCodeConverter.getCodeDescription(row.getValidCode()));
|
||||||
if (row.getSkuId() != null) {
|
if (goodsInfo != null && goodsInfo.getImageUrl() != null && !goodsInfo.getImageUrl().isEmpty()) {
|
||||||
|
vo.setSkuImageUrl(goodsInfo.getImageUrl());
|
||||||
|
} else if (row.getSkuId() != null) {
|
||||||
vo.setSkuImageUrl("https://img14.360buyimg.com/n5/s450x450_" + row.getSkuId() + ".jpg");
|
vo.setSkuImageUrl("https://img14.360buyimg.com/n5/s450x450_" + row.getSkuId() + ".jpg");
|
||||||
}
|
}
|
||||||
vo.setSkuName(row.getSkuName());
|
vo.setSkuName(row.getSkuName());
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package com.ruoyi.jarvis.domain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 京东订单商品信息 goods_info
|
||||||
|
*/
|
||||||
|
public class GoodsInfo {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String owner;
|
||||||
|
private String mainSkuId;
|
||||||
|
private String productId;
|
||||||
|
private String imageUrl;
|
||||||
|
private String shopName;
|
||||||
|
private String shopId;
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOwner(String owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMainSkuId() {
|
||||||
|
return mainSkuId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMainSkuId(String mainSkuId) {
|
||||||
|
this.mainSkuId = mainSkuId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(String productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImageUrl() {
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageUrl(String imageUrl) {
|
||||||
|
this.imageUrl = imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShopName() {
|
||||||
|
return shopName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShopName(String shopName) {
|
||||||
|
this.shopName = shopName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShopId() {
|
||||||
|
return shopId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShopId(String shopId) {
|
||||||
|
this.shopId = shopId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.ruoyi.jarvis.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.jarvis.domain.GoodsInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 京东订单商品信息 Mapper
|
||||||
|
*/
|
||||||
|
public interface GoodsInfoMapper {
|
||||||
|
|
||||||
|
GoodsInfo selectGoodsInfoById(Long id);
|
||||||
|
|
||||||
|
List<GoodsInfo> selectGoodsInfoByIds(Long[] ids);
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.jarvis.service;
|
||||||
|
|
||||||
|
import com.ruoyi.jarvis.domain.GoodsInfo;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 京东订单商品信息 Service
|
||||||
|
*/
|
||||||
|
public interface IGoodsInfoService {
|
||||||
|
|
||||||
|
GoodsInfo selectGoodsInfoById(Long id);
|
||||||
|
|
||||||
|
Map<Long, GoodsInfo> selectGoodsInfoMapByIds(Set<Long> ids);
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.ruoyi.jarvis.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.jarvis.domain.GoodsInfo;
|
||||||
|
import com.ruoyi.jarvis.mapper.GoodsInfoMapper;
|
||||||
|
import com.ruoyi.jarvis.service.IGoodsInfoService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GoodsInfoServiceImpl implements IGoodsInfoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GoodsInfoMapper goodsInfoMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoodsInfo selectGoodsInfoById(Long id) {
|
||||||
|
if (id == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return goodsInfoMapper.selectGoodsInfoById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<Long, GoodsInfo> selectGoodsInfoMapByIds(Set<Long> ids) {
|
||||||
|
if (ids == null || ids.isEmpty()) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
List<GoodsInfo> list = goodsInfoMapper.selectGoodsInfoByIds(ids.toArray(new Long[0]));
|
||||||
|
Map<Long, GoodsInfo> map = new HashMap<>();
|
||||||
|
if (list != null) {
|
||||||
|
for (GoodsInfo goodsInfo : list) {
|
||||||
|
if (goodsInfo != null && goodsInfo.getId() != null) {
|
||||||
|
map.put(goodsInfo.getId(), goodsInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ruoyi.jarvis.mapper.GoodsInfoMapper">
|
||||||
|
|
||||||
|
<resultMap type="GoodsInfo" id="GoodsInfoResult">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="owner" column="owner"/>
|
||||||
|
<result property="mainSkuId" column="main_sku_id"/>
|
||||||
|
<result property="productId" column="product_id"/>
|
||||||
|
<result property="imageUrl" column="image_url"/>
|
||||||
|
<result property="shopName" column="shop_name"/>
|
||||||
|
<result property="shopId" column="shop_id"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectGoodsInfoVo">
|
||||||
|
select id, owner, main_sku_id, product_id, image_url, shop_name, shop_id from goods_info
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectGoodsInfoById" parameterType="Long" resultMap="GoodsInfoResult">
|
||||||
|
<include refid="selectGoodsInfoVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectGoodsInfoByIds" resultMap="GoodsInfoResult">
|
||||||
|
<include refid="selectGoodsInfoVo"/>
|
||||||
|
where id in
|
||||||
|
<foreach collection="array" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
10
sql/goods_info.sql
Normal file
10
sql/goods_info.sql
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
-- 京东联盟订单商品信息(goodsInfo 字段入库)
|
||||||
|
CREATE TABLE IF NOT EXISTS goods_info (
|
||||||
|
id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '主键',
|
||||||
|
owner VARCHAR(16) DEFAULT NULL COMMENT 'g=自营 p=pop',
|
||||||
|
main_sku_id VARCHAR(64) DEFAULT NULL COMMENT '自营商品主Id',
|
||||||
|
product_id VARCHAR(64) DEFAULT NULL COMMENT 'POP商品主Id',
|
||||||
|
image_url VARCHAR(512) DEFAULT NULL COMMENT '商品主图',
|
||||||
|
shop_name VARCHAR(255) DEFAULT NULL COMMENT '店铺名称',
|
||||||
|
shop_id VARCHAR(64) DEFAULT NULL COMMENT '店铺Id'
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='京东订单商品信息';
|
||||||
Reference in New Issue
Block a user