1
This commit is contained in:
@@ -349,12 +349,21 @@ public class JDInnerController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
String giftKey = jdProductService.createGiftCoupon(idOrUrl, amount, quantity, owner, skuName);
|
String giftKey = jdProductService.createGiftCoupon(idOrUrl, amount, quantity, owner, skuName);
|
||||||
|
|
||||||
|
// 如果giftKey为null,返回错误而不是成功响应
|
||||||
|
if (giftKey == null || giftKey.trim().isEmpty()) {
|
||||||
|
String errorDetail = String.format("礼金创建失败,giftCouponKey为null。参数: idOrUrl=%s, amount=%.2f, quantity=%d, owner=%s, skuName=%s。可能原因:商品不支持创建礼金、商品类型错误、京东API调用失败。请查看JD项目日志获取详细信息。",
|
||||||
|
idOrUrl, amount, quantity, owner, skuName);
|
||||||
|
logger.error("礼金创建失败 - giftKey为null, {}", errorDetail);
|
||||||
|
return error(errorDetail);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建成功,保存到Redis
|
||||||
|
jdProductService.saveGiftCouponToRedis(idOrUrl, giftKey, skuName, owner);
|
||||||
|
logger.info("礼金创建成功 - giftKey={}, idOrUrl={}, owner={}, amount={}, quantity={}", giftKey, idOrUrl, owner, amount, quantity);
|
||||||
|
|
||||||
JSONObject resp = new JSONObject();
|
JSONObject resp = new JSONObject();
|
||||||
resp.put("giftCouponKey", giftKey);
|
resp.put("giftCouponKey", giftKey);
|
||||||
// 可选:入库/缓存
|
|
||||||
if (giftKey != null) {
|
|
||||||
jdProductService.saveGiftCouponToRedis(idOrUrl, giftKey, skuName, owner);
|
|
||||||
}
|
|
||||||
return resp;
|
return resp;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("createGiftCoupon error", e);
|
logger.error("createGiftCoupon error", e);
|
||||||
|
|||||||
@@ -289,7 +289,13 @@ public class JDProductService {
|
|||||||
log.debug("礼金创建成功:giftKey={}", giftKey);
|
log.debug("礼金创建成功:giftKey={}", giftKey);
|
||||||
return giftKey;
|
return giftKey;
|
||||||
}
|
}
|
||||||
log.error("礼金创建失败:code={}, msg={}", response != null ? response.getCode() : "null", response != null ? response.getMsg() : "null");
|
// 详细记录失败信息
|
||||||
|
String errorCode = response != null ? response.getCode() : "null";
|
||||||
|
String errorMsg = response != null ? response.getMsg() : "null";
|
||||||
|
Integer resultCode = response != null && response.getGetResult() != null ? response.getGetResult().getCode() : null;
|
||||||
|
String resultMsg = response != null && response.getGetResult() != null ? response.getGetResult().getMsg() : null;
|
||||||
|
log.error("礼金创建失败 - response.code={}, response.msg={}, result.code={}, result.msg={}, SKU={}, owner={}, amount={}, quantity={}",
|
||||||
|
errorCode, errorMsg, resultCode, resultMsg, skuId, owner, amount, quantity);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user