This commit is contained in:
Leo
2025-11-13 23:55:25 +08:00
parent 9e69230948
commit b8981ffc98
2 changed files with 38 additions and 3 deletions

View File

@@ -116,12 +116,45 @@ public class ErpProductController extends BaseController
{
try {
int count = erpProductService.pullAndSaveProductList(appid, pageNo, pageSize, productStatus);
if (count > 0) {
return success("成功拉取并保存 " + count + " 个商品");
} else {
String statusText = getStatusText(productStatus);
String message = "拉取完成,但没有获取到商品数据";
if (productStatus != null) {
message += "(筛选条件:状态=" + statusText + "";
}
message += "。建议1.尝试不选择状态拉取全部商品2.尝试其他状态(下架、已售等)";
return success(message);
}
} catch (Exception e) {
return error("拉取商品列表失败: " + e.getMessage());
}
}
/**
* 获取状态文本(用于提示信息)
*/
private String getStatusText(Integer status) {
if (status == null) {
return "全部";
}
switch (status) {
case 1:
return "上架";
case 2:
return "下架";
case 3:
return "已售";
case 22:
return "草稿";
case 23:
return "审核中";
default:
return String.valueOf(status);
}
}
/**
* 批量上架商品
*/

View File

@@ -146,8 +146,10 @@ public class ErpProductServiceImpl implements IErpProductService
JSONObject response = JSONObject.parseObject(responseBody);
if (response == null || response.getInteger("code") == null || response.getInteger("code") != 0) {
log.error("拉取商品列表失败: {}", responseBody);
return 0;
String errorMsg = response != null ? response.getString("msg") : "未知错误";
log.error("拉取商品列表失败: code={}, msg={}, response={}",
response != null ? response.getInteger("code") : null, errorMsg, responseBody);
throw new RuntimeException("拉取商品列表失败: " + errorMsg);
}
// 解析商品列表