diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/JDOrderListController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/JDOrderListController.java index dbb9c7d..5b1911d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/JDOrderListController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/JDOrderListController.java @@ -17,8 +17,12 @@ import com.ruoyi.jarvis.domain.OrderRows; import com.ruoyi.jarvis.service.IGroupRebateExcelUploadService; import com.ruoyi.jarvis.service.impl.GroupRebateExcelImportService; import com.ruoyi.jarvis.service.IOrderRowsService; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.file.FileUtils; +import com.ruoyi.common.utils.http.HttpUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -50,6 +54,14 @@ import com.ruoyi.common.core.page.TableDataInfo; public class JDOrderListController extends BaseController { + private static final String JARVIS_JAVA_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; + private final IJDOrderService jdOrderService; private final IJDOrderProfitService jdOrderProfitService; private final IOrderRowsService orderRowsService; @@ -749,4 +761,44 @@ public class JDOrderListController extends BaseController } return out; } + + /** + * 回填京粉订单 goodsInfo(店铺名、商品图) + * Body: { "orderIds": "352543902480387,3525433002460987" } + * 或: { "missing": true, "limit": 100 } + */ + @Log(title = "京粉订单goodsInfo回填", businessType = BusinessType.OTHER) + @PostMapping("/orderRows/backfillGoodsInfo") + public AjaxResult backfillGoodsInfo(@RequestBody Map body) { + try { + JSONObject param = new JSONObject(); + param.put("skey", JARVIS_JAVA_SKEY); + if (body != null) { + if (body.get("orderIds") != null) { + param.put("orderIds", body.get("orderIds")); + } + if (body.get("missing") != null) { + param.put("missing", body.get("missing")); + } + if (body.get("limit") != null) { + param.put("limit", body.get("limit")); + } + } + String url = jarvisJavaBaseUrl + jdApiPath + "/backfillGoodsInfo"; + String resp = HttpUtils.sendJsonPost(url, param.toJSONString()); + if (StringUtils.isEmpty(resp)) { + return AjaxResult.error("Jarvis 服务无响应,请检查 jarvis.server.jarvis-java.base-url"); + } + Object parsed = JSON.parse(resp); + if (parsed instanceof JSONObject) { + JSONObject obj = (JSONObject) parsed; + if (obj.containsKey("error")) { + return AjaxResult.error(String.valueOf(obj.get("error"))); + } + } + return AjaxResult.success(parsed); + } catch (Exception e) { + return AjaxResult.error("回填失败: " + e.getMessage()); + } + } } diff --git a/scripts/backfill_goods_info.ps1 b/scripts/backfill_goods_info.ps1 new file mode 100644 index 0000000..854af47 --- /dev/null +++ b/scripts/backfill_goods_info.ps1 @@ -0,0 +1,29 @@ +# 京粉订单 goodsInfo 回填脚本(需先部署 Jarvis_java + ruoyi-java,并已登录获取 token) +# 用法示例见下方 $body + +param( + [string]$BaseUrl = "https://jarvis.van333.cn/jarvis-api", + [string]$Token = "", + [string]$OrderIds = "", + [switch]$Missing, + [int]$Limit = 100 +) + +$body = @{} +if ($Missing) { + $body.missing = $true + $body.limit = $Limit +} elseif ($OrderIds) { + $body.orderIds = $OrderIds +} else { + Write-Host "请指定 -OrderIds '订单号1,订单号2' 或 -Missing" + exit 1 +} + +$headers = @{ "Content-Type" = "application/json" } +if ($Token) { + $headers.Authorization = "Bearer $Token" +} + +$uri = "$BaseUrl/system/jdorder/orderRows/backfillGoodsInfo" +Invoke-RestMethod -Method Post -Uri $uri -Headers $headers -Body ($body | ConvertTo-Json) diff --git a/sql/backfill_goods_info_preview.sql b/sql/backfill_goods_info_preview.sql new file mode 100644 index 0000000..1600f26 --- /dev/null +++ b/sql/backfill_goods_info_preview.sql @@ -0,0 +1,7 @@ +-- 预览:待回填 goods_info 的订单号(goods_info_id 为空) +SELECT DISTINCT order_id +FROM order_rows +WHERE goods_info_id IS NULL + AND order_id IS NOT NULL +ORDER BY order_time DESC +LIMIT 100;