1
This commit is contained in:
@@ -130,7 +130,6 @@ public class JDProductService {
|
|||||||
itemMap.put("spuid", String.valueOf(productInfo.getData()[0].getSpuid()));
|
itemMap.put("spuid", String.valueOf(productInfo.getData()[0].getSpuid()));
|
||||||
itemMap.put("commission", String.valueOf(productInfo.getData()[0].getCommissionInfo().getCommission()));
|
itemMap.put("commission", String.valueOf(productInfo.getData()[0].getCommissionInfo().getCommission()));
|
||||||
itemMap.put("commissionShare", String.valueOf(productInfo.getData()[0].getCommissionInfo().getCommissionShare()));
|
itemMap.put("commissionShare", String.valueOf(productInfo.getData()[0].getCommissionInfo().getCommissionShare()));
|
||||||
itemMap.put("price", String.valueOf(productInfo.getData()[0].getPriceInfo().getPrice()));
|
|
||||||
|
|
||||||
couponInfo.append("店铺: ").append(itemMap.get("shopName")).append("\n").append("标题: ").append(replaceAll).append("\n").append("自营 POP: ").append(itemMap.get("owner").equals("g") ? " 自营 " : " POP ").append("\n").append("佣金比例: ").append(itemMap.get("commissionShare")).append("\n").append("佣金: ").append(itemMap.get("commission")).append("\n");
|
couponInfo.append("店铺: ").append(itemMap.get("shopName")).append("\n").append("标题: ").append(replaceAll).append("\n").append("自营 POP: ").append(itemMap.get("owner").equals("g") ? " 自营 " : " POP ").append("\n").append("佣金比例: ").append(itemMap.get("commissionShare")).append("\n").append("佣金: ").append(itemMap.get("commission")).append("\n");
|
||||||
|
|
||||||
@@ -268,6 +267,7 @@ public class JDProductService {
|
|||||||
productObj.put("spuid", String.valueOf(productInfo.getData()[0].getSpuid()));
|
productObj.put("spuid", String.valueOf(productInfo.getData()[0].getSpuid()));
|
||||||
productObj.put("commission", String.valueOf(productInfo.getData()[0].getCommissionInfo().getCommission()));
|
productObj.put("commission", String.valueOf(productInfo.getData()[0].getCommissionInfo().getCommission()));
|
||||||
productObj.put("commissionShare", String.valueOf(productInfo.getData()[0].getCommissionInfo().getCommissionShare()));
|
productObj.put("commissionShare", String.valueOf(productInfo.getData()[0].getCommissionInfo().getCommissionShare()));
|
||||||
|
productObj.put("price", String.valueOf(productInfo.getData()[0].getPriceInfo().getPrice()));
|
||||||
|
|
||||||
// 图片信息
|
// 图片信息
|
||||||
JSONArray imageArray = new JSONArray();
|
JSONArray imageArray = new JSONArray();
|
||||||
@@ -538,12 +538,12 @@ public class JDProductService {
|
|||||||
*/
|
*/
|
||||||
public Map<String, Object> extractPriceInfo(GoodsQueryResult productInfo) {
|
public Map<String, Object> extractPriceInfo(GoodsQueryResult productInfo) {
|
||||||
Map<String, Object> priceMap = new HashMap<>();
|
Map<String, Object> priceMap = new HashMap<>();
|
||||||
|
|
||||||
if (productInfo == null || productInfo.getData() == null || productInfo.getData().length == 0) {
|
if (productInfo == null || productInfo.getData() == null || productInfo.getData().length == 0) {
|
||||||
priceMap.put("error", "商品信息为空");
|
priceMap.put("error", "商品信息为空");
|
||||||
return priceMap;
|
return priceMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 获取第一个商品的价格信息
|
// 获取第一个商品的价格信息
|
||||||
var priceInfo = productInfo.getData()[0].getPriceInfo();
|
var priceInfo = productInfo.getData()[0].getPriceInfo();
|
||||||
@@ -552,13 +552,13 @@ public class JDProductService {
|
|||||||
priceMap.put("lowestPrice", priceInfo.getLowestPrice()); // 最低价
|
priceMap.put("lowestPrice", priceInfo.getLowestPrice()); // 最低价
|
||||||
priceMap.put("lowestCouponPrice", priceInfo.getLowestCouponPrice()); // 最低券后价
|
priceMap.put("lowestCouponPrice", priceInfo.getLowestCouponPrice()); // 最低券后价
|
||||||
priceMap.put("lowestPriceType", priceInfo.getLowestPriceType()); // 最低价类型
|
priceMap.put("lowestPriceType", priceInfo.getLowestPriceType()); // 最低价类型
|
||||||
|
|
||||||
// 计算优惠金额
|
// 计算优惠金额
|
||||||
if (priceInfo.getPrice() != null && priceInfo.getLowestCouponPrice() != null) {
|
if (priceInfo.getPrice() != null && priceInfo.getLowestCouponPrice() != null) {
|
||||||
long discount = priceInfo.getPrice() - priceInfo.getLowestCouponPrice();
|
long discount = priceInfo.getPrice() - priceInfo.getLowestCouponPrice();
|
||||||
priceMap.put("discount", discount); // 优惠金额
|
priceMap.put("discount", discount); // 优惠金额
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化价格显示
|
// 格式化价格显示
|
||||||
priceMap.put("priceFormatted", "¥" + (priceInfo.getPrice() != null ? priceInfo.getPrice() / 100.0 : 0));
|
priceMap.put("priceFormatted", "¥" + (priceInfo.getPrice() != null ? priceInfo.getPrice() / 100.0 : 0));
|
||||||
priceMap.put("lowestPriceFormatted", "¥" + (priceInfo.getLowestPrice() != null ? priceInfo.getLowestPrice() / 100.0 : 0));
|
priceMap.put("lowestPriceFormatted", "¥" + (priceInfo.getLowestPrice() != null ? priceInfo.getLowestPrice() / 100.0 : 0));
|
||||||
@@ -570,7 +570,7 @@ public class JDProductService {
|
|||||||
log.error("提取价格信息时发生异常", e);
|
log.error("提取价格信息时发生异常", e);
|
||||||
priceMap.put("error", "提取价格信息时发生异常: " + e.getMessage());
|
priceMap.put("error", "提取价格信息时发生异常: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return priceMap;
|
return priceMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user