1
This commit is contained in:
@@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -60,7 +61,25 @@ public class JDOrderController extends BaseController {
|
||||
}
|
||||
|
||||
private final static String skey = "2192057370ef8140c201079969c956a3";
|
||||
private final static String requestUrl = "http://192.168.8.88:6666/jd/";
|
||||
|
||||
@Value("${jarvis.server.jarvis-java.base-url:http://127.0.0.1:6666}")
|
||||
private String jarvisJavaBaseUrl;
|
||||
|
||||
@Value("${jarvis.server.jarvis-java.jd-api-path:/jd}")
|
||||
private String jdApiPath;
|
||||
|
||||
@Value("${jarvis.server.logistics.base-url:http://127.0.0.1:5001}")
|
||||
private String logisticsBaseUrl;
|
||||
|
||||
@Value("${jarvis.server.logistics.fetch-path:/fetch_logistics}")
|
||||
private String logisticsFetchPath;
|
||||
|
||||
/**
|
||||
* 获取JD接口请求URL
|
||||
*/
|
||||
private String getRequestUrl() {
|
||||
return jarvisJavaBaseUrl + jdApiPath + "/";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +89,7 @@ public class JDOrderController extends BaseController {
|
||||
String promotionContent = requestBody.get("promotionContent");
|
||||
String result = "";
|
||||
try {
|
||||
String url = requestUrl + "generatePromotionContent";
|
||||
String url = getRequestUrl() + "generatePromotionContent";
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("skey", skey);
|
||||
param.put("promotionContent", promotionContent);
|
||||
@@ -191,7 +210,7 @@ public class JDOrderController extends BaseController {
|
||||
body.get("materialUrl"), body.get("skuId"), body.get("amount"),
|
||||
body.get("quantity"), body.get("owner"), body.get("skuName"));
|
||||
|
||||
String url = requestUrl + "createGiftCoupon";
|
||||
String url = getRequestUrl() + "createGiftCoupon";
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("skey", skey);
|
||||
// 透传必要参数
|
||||
@@ -310,7 +329,7 @@ public class JDOrderController extends BaseController {
|
||||
@PostMapping("/transfer")
|
||||
public AjaxResult transfer(@RequestBody Map<String, Object> body) {
|
||||
try {
|
||||
String url = requestUrl + "transfer";
|
||||
String url = getRequestUrl() + "transfer";
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("skey", skey);
|
||||
if (body.get("materialUrl") != null) param.put("materialUrl", body.get("materialUrl"));
|
||||
@@ -340,7 +359,7 @@ public class JDOrderController extends BaseController {
|
||||
body.get("materialUrl"), body.get("skuId"), body.get("amount"),
|
||||
body.get("quantity"), body.get("batchSize"), body.get("owner"), body.get("skuName"));
|
||||
|
||||
String url = requestUrl + "batchCreateGiftCoupons";
|
||||
String url = getRequestUrl() + "batchCreateGiftCoupons";
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("skey", skey);
|
||||
if (body.get("materialUrl") != null) param.put("materialUrl", body.get("materialUrl"));
|
||||
@@ -496,7 +515,7 @@ public class JDOrderController extends BaseController {
|
||||
for (String url : urls) {
|
||||
try {
|
||||
logger.info("查询商品信息 - URL: {}", url);
|
||||
String queryUrl = requestUrl + "generatePromotionContent";
|
||||
String queryUrl = getRequestUrl() + "generatePromotionContent";
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("skey", skey);
|
||||
param.put("promotionContent", url);
|
||||
@@ -634,7 +653,7 @@ public class JDOrderController extends BaseController {
|
||||
}
|
||||
|
||||
// 1. 查询该URL的商品信息
|
||||
String queryUrl = requestUrl + "generatePromotionContent";
|
||||
String queryUrl = getRequestUrl() + "generatePromotionContent";
|
||||
JSONObject queryParam = new JSONObject();
|
||||
queryParam.put("skey", skey);
|
||||
queryParam.put("promotionContent", urlSegment.normalizedJdUrl);
|
||||
@@ -686,7 +705,7 @@ public class JDOrderController extends BaseController {
|
||||
}
|
||||
|
||||
// 2. 为该商品创建礼金券
|
||||
String createUrl = requestUrl + "createGiftCoupon";
|
||||
String createUrl = getRequestUrl() + "createGiftCoupon";
|
||||
JSONObject createParam = new JSONObject();
|
||||
createParam.put("skey", skey);
|
||||
createParam.put("amount", amount);
|
||||
@@ -797,7 +816,7 @@ public class JDOrderController extends BaseController {
|
||||
String giftCouponKey = createData.getString("giftCouponKey");
|
||||
|
||||
// 3. 转链(带礼金)
|
||||
String transferUrl = requestUrl + "transfer";
|
||||
String transferUrl = getRequestUrl() + "transfer";
|
||||
JSONObject transferParam = new JSONObject();
|
||||
transferParam.put("skey", skey);
|
||||
transferParam.put("materialUrl", urlSegment.normalizedJdUrl);
|
||||
@@ -929,7 +948,7 @@ public class JDOrderController extends BaseController {
|
||||
orderId, order.getOrderId(), distributionMark, logisticsLink);
|
||||
|
||||
// 构建外部接口URL
|
||||
String externalUrl = "http://192.168.8.88:5001/fetch_logistics?tracking_url=" +
|
||||
String externalUrl = logisticsBaseUrl + logisticsFetchPath + "?tracking_url=" +
|
||||
java.net.URLEncoder.encode(logisticsLink, "UTF-8");
|
||||
|
||||
logger.info("准备调用外部接口 - URL: {}", externalUrl);
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.jarvis.service.ICommentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
@@ -20,13 +21,24 @@ import java.util.*;
|
||||
@RequestMapping("/public/comment")
|
||||
public class CommentPublicController extends BaseController {
|
||||
|
||||
// TODO: 可改为读取配置
|
||||
private static final String JD_BASE = "http://192.168.8.88:6666/jd";
|
||||
private static final String SKEY = "2192057370ef8140c201079969c956a3";
|
||||
|
||||
@Value("${jarvis.server.jarvis-java.base-url:http://127.0.0.1:6666}")
|
||||
private String jarvisJavaBaseUrl;
|
||||
|
||||
@Value("${jarvis.server.jarvis-java.jd-api-path:/jd}")
|
||||
private String jdApiPath;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ICommentService commentService;
|
||||
|
||||
/**
|
||||
* 获取JD接口基础URL
|
||||
*/
|
||||
private String getJdBase() {
|
||||
return jarvisJavaBaseUrl + jdApiPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可选型号/类型(示例)
|
||||
*/
|
||||
@@ -34,7 +46,7 @@ public class CommentPublicController extends BaseController {
|
||||
public AjaxResult types() {
|
||||
boolean success = false;
|
||||
try {
|
||||
String url = JD_BASE + "/comment/types?skey=" + SKEY;
|
||||
String url = getJdBase() + "/comment/types?skey=" + SKEY;
|
||||
String result = HttpUtils.sendGet(url);
|
||||
Object parsed = JSON.parse(result);
|
||||
success = true;
|
||||
@@ -58,7 +70,7 @@ public class CommentPublicController extends BaseController {
|
||||
boolean success = false;
|
||||
String productType = null;
|
||||
try {
|
||||
String url = JD_BASE + "/comment/generate";
|
||||
String url = getJdBase() + "/comment/generate";
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("skey", SKEY);
|
||||
if (body != null && body.get("productType") != null) {
|
||||
|
||||
@@ -185,7 +185,20 @@ xss:
|
||||
excludes: /system/notice
|
||||
# 匹配链接
|
||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||
|
||||
# 服务地址配置(用于服务器迁移)
|
||||
jarvis:
|
||||
# 服务器基础地址(如果所有服务都在同一台服务器,可以使用127.0.0.1)
|
||||
# 开发环境:根据实际情况配置
|
||||
server:
|
||||
host: 192.168.8.88
|
||||
# Jarvis Java服务地址(JD相关接口)
|
||||
jarvis-java:
|
||||
base-url: http://192.168.8.88:6666
|
||||
jd-api-path: /jd
|
||||
# 物流接口服务地址
|
||||
logistics:
|
||||
base-url: http://192.168.8.88:5001
|
||||
fetch-path: /fetch_logistics
|
||||
# 腾讯文档开放平台配置
|
||||
# 文档地址:https://docs.qq.com/open/document/app/openapi/v3/sheet/model/spreadsheet.html
|
||||
tencent:
|
||||
|
||||
@@ -185,6 +185,20 @@ xss:
|
||||
excludes: /system/notice
|
||||
# 匹配链接
|
||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||
# 服务地址配置(用于服务器迁移)
|
||||
jarvis:
|
||||
# 服务器基础地址(如果所有服务都在同一台服务器,可以使用127.0.0.1)
|
||||
# 生产环境:192.168.8.88 或 127.0.0.1
|
||||
server:
|
||||
host: 127.0.0.1
|
||||
# Jarvis Java服务地址(JD相关接口)
|
||||
jarvis-java:
|
||||
base-url: http://127.0.0.1:6666
|
||||
jd-api-path: /jd
|
||||
# 物流接口服务地址
|
||||
logistics:
|
||||
base-url: http://127.0.0.1:5001
|
||||
fetch-path: /fetch_logistics
|
||||
# 腾讯文档开放平台配置
|
||||
# 文档地址:https://docs.qq.com/open/document/app/openapi/v3/sheet/model/spreadsheet.html
|
||||
tencent:
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -53,9 +54,20 @@ public class BatchPublishServiceImpl implements IBatchPublishService
|
||||
@Autowired
|
||||
private IJDOrderService jdOrderService;
|
||||
|
||||
// 京东接口配置
|
||||
private final static String requestUrl = "http://192.168.8.88:6666/jd/";
|
||||
@Value("${jarvis.server.jarvis-java.base-url:http://127.0.0.1:6666}")
|
||||
private String jarvisJavaBaseUrl;
|
||||
|
||||
@Value("${jarvis.server.jarvis-java.jd-api-path:/jd}")
|
||||
private String jdApiPath;
|
||||
|
||||
private final static String skey = "2192057370ef8140c201079969c956a3";
|
||||
|
||||
/**
|
||||
* 获取JD接口请求URL
|
||||
*/
|
||||
private String getRequestUrl() {
|
||||
return jarvisJavaBaseUrl + jdApiPath + "/";
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private IOuterIdGeneratorService outerIdGeneratorService;
|
||||
@@ -183,7 +195,7 @@ private String cleanForbiddenPhrases(String text) {
|
||||
*/
|
||||
private String generatePromotionContent(Map<String, String> requestBody) {
|
||||
try {
|
||||
String url = requestUrl + "generatePromotionContent";
|
||||
String url = getRequestUrl() + "generatePromotionContent";
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("skey", skey);
|
||||
param.put("promotionContent", requestBody.get("promotionContent"));
|
||||
|
||||
@@ -11,8 +11,10 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@@ -27,18 +29,31 @@ public class LogisticsServiceImpl implements ILogisticsService {
|
||||
|
||||
private static final String REDIS_WAYBILL_KEY_PREFIX = "logistics:waybill:order:";
|
||||
private static final String REDIS_LOCK_KEY_PREFIX = "logistics:lock:order:";
|
||||
private static final String EXTERNAL_API_URL = "http://192.168.8.88:5001/fetch_logistics?tracking_url=";
|
||||
private static final String PUSH_URL = "https://wxts.van333.cn/wx/send/pdd";
|
||||
private static final String PUSH_TOKEN = "super_token_b62190c26";
|
||||
private static final String CONFIG_KEY_PREFIX = "logistics.push.touser.";
|
||||
private static final long LOCK_EXPIRE_SECONDS = 300; // 锁过期时间5分钟,防止死锁
|
||||
|
||||
@Value("${jarvis.server.logistics.base-url:http://127.0.0.1:5001}")
|
||||
private String logisticsBaseUrl;
|
||||
|
||||
@Value("${jarvis.server.logistics.fetch-path:/fetch_logistics}")
|
||||
private String logisticsFetchPath;
|
||||
|
||||
private String externalApiUrlTemplate;
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private ISysConfigService sysConfigService;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
externalApiUrlTemplate = logisticsBaseUrl + logisticsFetchPath + "?tracking_url=";
|
||||
logger.info("物流服务地址已初始化: {}", externalApiUrlTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOrderProcessed(Long orderId) {
|
||||
if (orderId == null) {
|
||||
@@ -86,7 +101,7 @@ public class LogisticsServiceImpl implements ILogisticsService {
|
||||
return false;
|
||||
}
|
||||
// 构建外部接口URL
|
||||
String externalUrl = EXTERNAL_API_URL + URLEncoder.encode(logisticsLink, "UTF-8");
|
||||
String externalUrl = externalApiUrlTemplate + URLEncoder.encode(logisticsLink, "UTF-8");
|
||||
logger.info("调用外部接口获取物流信息 - 订单ID: {}, URL: {}", orderId, externalUrl);
|
||||
|
||||
// 在服务端执行HTTP请求
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.ruoyi.jarvis.service.ISocialMediaService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -29,8 +30,8 @@ public class SocialMediaServiceImpl implements ISocialMediaService
|
||||
@Autowired(required = false)
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
// jarvis_java 服务地址
|
||||
private final static String JARVIS_BASE_URL = "http://192.168.8.88:6666";
|
||||
@Value("${jarvis.server.jarvis-java.base-url:http://127.0.0.1:6666}")
|
||||
private String jarvisBaseUrl;
|
||||
|
||||
// Redis Key 前缀
|
||||
private static final String REDIS_KEY_PREFIX = "social_media:prompt:";
|
||||
@@ -66,7 +67,7 @@ public class SocialMediaServiceImpl implements ISocialMediaService
|
||||
|
||||
try {
|
||||
// 调用 jarvis_java 的接口
|
||||
String url = JARVIS_BASE_URL + "/jarvis/social-media/extract-keywords";
|
||||
String url = jarvisBaseUrl + "/jarvis/social-media/extract-keywords";
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("productName", productName);
|
||||
|
||||
@@ -125,7 +126,7 @@ public class SocialMediaServiceImpl implements ISocialMediaService
|
||||
|
||||
try {
|
||||
// 调用 jarvis_java 的接口
|
||||
String url = JARVIS_BASE_URL + "/jarvis/social-media/generate-content";
|
||||
String url = jarvisBaseUrl + "/jarvis/social-media/generate-content";
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("productName", productName);
|
||||
if (originalPrice != null) {
|
||||
@@ -196,7 +197,7 @@ public class SocialMediaServiceImpl implements ISocialMediaService
|
||||
|
||||
try {
|
||||
// 调用 jarvis_java 的接口
|
||||
String url = JARVIS_BASE_URL + "/jarvis/social-media/generate-complete";
|
||||
String url = jarvisBaseUrl + "/jarvis/social-media/generate-complete";
|
||||
JSONObject requestBody = new JSONObject();
|
||||
if (StringUtils.isNotEmpty(productImageUrl)) {
|
||||
requestBody.put("productImageUrl", productImageUrl);
|
||||
|
||||
Reference in New Issue
Block a user