This commit is contained in:
2025-10-31 16:54:58 +08:00
parent 1f33c167fd
commit 18afad120f

View File

@@ -187,6 +187,23 @@ public class JDOrderController extends BaseController {
try {
Object parsed = JSON.parse(result);
logger.info("创建礼金响应 - 解析后: {}", parsed);
// 检查返回结果中giftCouponKey是否为null
if (parsed instanceof JSONObject) {
JSONObject jsonObj = (JSONObject) parsed;
Object giftKey = jsonObj.get("giftCouponKey");
if (giftKey == null) {
// giftCouponKey为null说明创建失败
String errorMsg = jsonObj.getString("msg");
if (errorMsg == null || errorMsg.isEmpty()) {
errorMsg = "礼金创建失败返回的giftCouponKey为null。可能是商品不支持创建礼金、参数错误或京东API调用失败请查看JD项目日志";
}
logger.error("创建礼金失败 - giftCouponKey为null返回数据: {}", jsonObj.toJSONString());
return AjaxResult.error(errorMsg);
}
logger.info("创建礼金成功 - giftCouponKey: {}", giftKey);
}
return AjaxResult.success(parsed);
} catch (Exception ignore) {
logger.warn("创建礼金响应 - JSON解析失败返回字符串: {}", result);