This commit is contained in:
van
2026-04-09 00:28:59 +08:00
parent e94f17973c
commit 16bcd45c63
3 changed files with 40 additions and 3 deletions

View File

@@ -5,8 +5,12 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.erp.request.ExpressCompaniesQueryRequest;
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 org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -20,6 +24,34 @@ public class ErpOpenConfigController extends BaseController {
@Resource
private IErpOpenConfigService erpOpenConfigService;
@Resource
private ErpAccountResolver erpAccountResolver;
/**
* 查询闲管家快递公司列表POST body 固定为 {},与签名规则一致)
*
* @param appKey 与配置中心一致;不传则按 {@link ErpAccountResolver#resolve(String)} 默认账号
*/
@PreAuthorize("@ss.hasPermi('jarvis:erpOpenConfig:list')")
@GetMapping("/expressCompanies")
public AjaxResult expressCompanies(@RequestParam(required = false) String appKey) {
try {
IERPAccount cred = erpAccountResolver.resolve(appKey);
ExpressCompaniesQueryRequest req = new ExpressCompaniesQueryRequest(cred);
String resp = req.getResponseBody();
JSONObject o = JSONObject.parseObject(resp);
if (o == null) {
return AjaxResult.error("开放平台返回空");
}
if (o.getIntValue("code") != 0) {
return AjaxResult.error(o.getString("msg") != null ? o.getString("msg") : resp);
}
return AjaxResult.success(o.get("data"));
} catch (Exception e) {
return AjaxResult.error("调用快递公司接口失败: " + e.getMessage());
}
}
@PreAuthorize("@ss.hasPermi('jarvis:erpOpenConfig:list')")
@GetMapping("/list")
public TableDataInfo list(ErpOpenConfig query) {

View File

@@ -8,7 +8,7 @@ CREATE TABLE IF NOT EXISTS erp_open_config (
app_key varchar(64) NOT NULL COMMENT '开放平台 AppKey(appid)',
app_secret varchar(128) NOT NULL COMMENT '开放平台 AppSecret',
xy_user_name varchar(128) DEFAULT NULL COMMENT '默认闲鱼会员名(展示)',
express_code varchar(64) DEFAULT NULL COMMENT '发货用快递公司编码(日日顺,以开放平台「查询快递公司」为准)',
express_code varchar(64) DEFAULT NULL COMMENT '发货用快递公司编码(日日顺物流在官方列表中为 rrs,以「查询快递公司」接口为准)',
express_name varchar(64) DEFAULT NULL COMMENT '快递公司名称(展示)',
status char(1) NOT NULL DEFAULT '0' COMMENT '0正常 1停用',
order_num int(11) NOT NULL DEFAULT 0 COMMENT '排序(小优先)',

View File

@@ -1,13 +1,18 @@
package com.ruoyi.erp.request;
import com.alibaba.fastjson2.JSONObject;
/**
* 查询快递公司请求
*
* 对应接口POST /api/open/express/companies
* <p>
* 对应接口POST /api/open/express/companies<br>
* 闲管家规定:无业务参数时应对 <strong>空 JSON 对象</strong> 做 {@code md5("{}")},且 POST 原文必须与之一致;
* Apifox 调试时请勿留空 body须填 {@code {}},否则签名与平台不一致会拉不到数据。
*/
public class ExpressCompaniesQueryRequest extends ERPRequestBase {
public ExpressCompaniesQueryRequest(IERPAccount erpAccount) {
super("https://open.goofish.pro/api/open/express/companies", erpAccount);
this.requestBody = new JSONObject();
}
}