1
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user