1
This commit is contained in:
@@ -116,12 +116,45 @@ public class ErpProductController extends BaseController
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
int count = erpProductService.pullAndSaveProductList(appid, pageNo, pageSize, productStatus);
|
int count = erpProductService.pullAndSaveProductList(appid, pageNo, pageSize, productStatus);
|
||||||
|
if (count > 0) {
|
||||||
return success("成功拉取并保存 " + count + " 个商品");
|
return success("成功拉取并保存 " + count + " 个商品");
|
||||||
|
} else {
|
||||||
|
String statusText = getStatusText(productStatus);
|
||||||
|
String message = "拉取完成,但没有获取到商品数据";
|
||||||
|
if (productStatus != null) {
|
||||||
|
message += "(筛选条件:状态=" + statusText + ")";
|
||||||
|
}
|
||||||
|
message += "。建议:1.尝试不选择状态拉取全部商品;2.尝试其他状态(下架、已售等)";
|
||||||
|
return success(message);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return error("拉取商品列表失败: " + e.getMessage());
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量上架商品
|
* 批量上架商品
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -146,8 +146,10 @@ public class ErpProductServiceImpl implements IErpProductService
|
|||||||
JSONObject response = JSONObject.parseObject(responseBody);
|
JSONObject response = JSONObject.parseObject(responseBody);
|
||||||
|
|
||||||
if (response == null || response.getInteger("code") == null || response.getInteger("code") != 0) {
|
if (response == null || response.getInteger("code") == null || response.getInteger("code") != 0) {
|
||||||
log.error("拉取商品列表失败: {}", responseBody);
|
String errorMsg = response != null ? response.getString("msg") : "未知错误";
|
||||||
return 0;
|
log.error("拉取商品列表失败: code={}, msg={}, response={}",
|
||||||
|
response != null ? response.getInteger("code") : null, errorMsg, responseBody);
|
||||||
|
throw new RuntimeException("拉取商品列表失败: " + errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析商品列表
|
// 解析商品列表
|
||||||
|
|||||||
Reference in New Issue
Block a user