diff --git a/pom.xml b/pom.xml
index f795fad..a798321 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,6 +35,7 @@
1.2.13
5.7.12
5.3.39
+ 2.2.3
@@ -218,6 +219,12 @@
${ruoyi.version}
+
+ org.apache.rocketmq
+ rocketmq-spring-boot-starter
+ ${rocketmq-spring.version}
+
+
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
index b859aa5..96ff5cf 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
@@ -5,6 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
+import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
@@ -14,6 +15,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
*/
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@EnableScheduling
+@EnableAsync
public class RuoYiApplication
{
public static void main(String[] args)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/OpenCallbackController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/OpenCallbackController.java
index 56fc891..57b792f 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/OpenCallbackController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/OpenCallbackController.java
@@ -1,22 +1,32 @@
package com.ruoyi.web.controller.common;
import com.alibaba.fastjson2.JSONObject;
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.erp.request.IERPAccount;
+import com.ruoyi.jarvis.service.IErpGoofishOrderService;
+import com.ruoyi.jarvis.service.erp.ErpAccountResolver;
import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
- * 开放平台回调接收端
- * 注意:/product/receive 与 /order/receive 为示例路径,请在开放平台配置时使用你自己的正式回调地址
+ * 闲管家开放平台推送回调(请在开放平台填写真实 URL)
+ * 订单:建议 POST .../open/callback/order/receive
*/
+@Anonymous
@RestController
@RequestMapping("/open/callback")
-public class OpenCallbackController extends BaseController {
+public class OpenCallbackController {
+
+ @Resource
+ private ErpAccountResolver erpAccountResolver;
+
+ @Resource
+ private IErpGoofishOrderService erpGoofishOrderService;
@PostMapping("/product/receive")
public JSONObject receiveProductCallback(
@@ -25,7 +35,8 @@ public class OpenCallbackController extends BaseController {
@RequestParam("sign") String sign,
@RequestBody JSONObject body
) {
- if (!verifySign(appid, timestamp, sign, body)) {
+ IERPAccount account = erpAccountResolver.resolveStrict(appid);
+ if (!verifySign(account, timestamp, sign, body)) {
JSONObject fail = new JSONObject();
fail.put("result", "fail");
fail.put("msg", "签名失败");
@@ -44,26 +55,33 @@ public class OpenCallbackController extends BaseController {
@RequestParam("sign") String sign,
@RequestBody JSONObject body
) {
- if (!verifySign(appid, timestamp, sign, body)) {
+ IERPAccount account = erpAccountResolver.resolveStrict(appid);
+ if (!verifySign(account, timestamp, sign, body)) {
JSONObject fail = new JSONObject();
fail.put("result", "fail");
fail.put("msg", "签名失败");
return fail;
}
+ try {
+ erpGoofishOrderService.publishOrProcessNotify(appid, timestamp, body);
+ } catch (Exception e) {
+ JSONObject fail = new JSONObject();
+ fail.put("result", "fail");
+ fail.put("msg", "入队异常");
+ return fail;
+ }
JSONObject ok = new JSONObject();
ok.put("result", "success");
ok.put("msg", "接收成功");
return ok;
}
- private boolean verifySign(String appid, Long timestamp, String sign, JSONObject body) {
- // TODO: 这里需要根据appid查出对应的 appKey/appSecret
- // 为了示例,直接使用 ERPAccount.ACCOUNT_HUGE 的常量。生产请替换为从数据库/配置读取
- String appKey = "1016208368633221";
- String appSecret = "waLiRMgFcixLbcLjUSSwo370Hp1nBcBu";
-
+ private boolean verifySign(IERPAccount account, Long timestamp, String sign, JSONObject body) {
+ if (account == null || StringUtils.isEmpty(sign)) {
+ return false;
+ }
String json = body == null ? "{}" : body.toJSONString();
- String data = appKey + "," + md5(json) + "," + (timestamp == null ? 0 : timestamp) + "," + appSecret;
+ String data = account.getApiKey() + "," + md5(json) + "," + (timestamp == null ? 0 : timestamp) + "," + account.getApiKeySecret();
String local = md5(data);
return StringUtils.equalsIgnoreCase(local, sign);
}
@@ -82,5 +100,3 @@ public class OpenCallbackController extends BaseController {
}
}
}
-
-
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/erp/ProductController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/erp/ProductController.java
index 7ed9116..aa5dea9 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/erp/ProductController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/erp/ProductController.java
@@ -11,6 +11,10 @@ import com.ruoyi.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ruoyi.erp.request.ERPAccount;
+import com.ruoyi.erp.request.IERPAccount;
+import com.ruoyi.jarvis.domain.ErpOpenConfig;
+import com.ruoyi.jarvis.service.IErpOpenConfigService;
+import com.ruoyi.jarvis.service.erp.ErpAccountResolver;
import com.ruoyi.erp.request.ProductCreateRequest;
import com.ruoyi.erp.request.ProductCategoryListQueryRequest;
import com.ruoyi.erp.request.ProductPropertyListQueryRequest;
@@ -20,6 +24,7 @@ import com.ruoyi.erp.request.ProductDownShelfRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
import javax.validation.constraints.*;
import java.util.ArrayList;
import java.util.HashMap;
@@ -36,13 +41,19 @@ public class ProductController extends BaseController {
@Autowired
private IOuterIdGeneratorService outerIdGeneratorService;
+
+ @Resource
+ private ErpAccountResolver erpAccountResolver;
+
+ @Resource
+ private IErpOpenConfigService erpOpenConfigService;
private static final Logger log = LoggerFactory.getLogger(ProductController.class);
@PostMapping("/createByPromotion")
public R> createByPromotion(@RequestBody @Validated CreateProductFromPromotionRequest req) {
try {
- ERPAccount account = resolveAccount(req.getAppid());
+ IERPAccount account = resolveAccount(req.getAppid());
// 1) 组装 ERPShop
ERPShop erpShop = new ERPShop();
erpShop.setChannelCatid(req.getChannelCatId());
@@ -143,7 +154,7 @@ public class ProductController extends BaseController {
@PostMapping("/publish")
public R> publish(@RequestBody @Validated PublishRequest req) {
try {
- ERPAccount account = resolveAccount(req.getAppid());
+ IERPAccount account = resolveAccount(req.getAppid());
ProductPublishRequest publishRequest = new ProductPublishRequest(account);
publishRequest.setProductId(req.getProductId());
publishRequest.setUserName(req.getUserName());
@@ -344,10 +355,22 @@ public class ProductController extends BaseController {
String name = firstNonBlank(row.getString("user_name"), row.getString("xy_name"), row.getString("username"), row.getString("nick"));
if (name != null) {
String label = name;
- for (ERPAccount a : ERPAccount.values()) {
- if (name.equals(a.getXyName())) {
- label = name + "(" + a.getRemark() + ")";
- break;
+ List cfgs = erpOpenConfigService.selectEnabledOrderBySort();
+ if (cfgs != null) {
+ for (ErpOpenConfig c : cfgs) {
+ if (name.equals(c.getXyUserName())) {
+ String r = c.getRemark() != null ? c.getRemark() : c.getAppKey();
+ label = name + "(" + r + ")";
+ break;
+ }
+ }
+ }
+ if (label.equals(name)) {
+ for (ERPAccount a : ERPAccount.values()) {
+ if (name.equals(a.getXyName())) {
+ label = name + "(" + a.getRemark() + ")";
+ break;
+ }
}
}
options.add(new Option(name, label));
@@ -376,20 +399,24 @@ public class ProductController extends BaseController {
@GetMapping("/ERPAccount")
public R> erpAccounts() {
java.util.List