|
|
@@ -85,6 +85,7 @@ public class PromotionCalcServiceImpl implements IPromotionCalcService
|
|
|
Map<String, Object> m = new LinkedHashMap<>();
|
|
|
m.put("productId", ci.getProductId());
|
|
|
m.put("quantity", ci.getQuantity());
|
|
|
+ m.put("specPrice", ci.getSpecPrice());
|
|
|
items.add(m);
|
|
|
}
|
|
|
}
|
|
|
@@ -112,7 +113,14 @@ public class PromotionCalcServiceImpl implements IPromotionCalcService
|
|
|
{
|
|
|
Long productId = toLong(item.get("productId"));
|
|
|
int quantity = toInt(item.get("quantity"));
|
|
|
- BigDecimal unitPrice = priceMap.getOrDefault(productId, BigDecimal.ZERO);
|
|
|
+ // 实付单价 = 商品价格 + 规格价格(规格价可为0/不传), 按行计算以支持同商品多规格
|
|
|
+ BigDecimal basePrice = priceMap.getOrDefault(productId, BigDecimal.ZERO);
|
|
|
+ BigDecimal specPrice = (BigDecimal) item.get("specPrice");
|
|
|
+ if (specPrice == null)
|
|
|
+ {
|
|
|
+ specPrice = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ BigDecimal unitPrice = basePrice.add(specPrice);
|
|
|
originalAmount = originalAmount.add(unitPrice.multiply(BigDecimal.valueOf(quantity)));
|
|
|
|
|
|
Map<String, Object> ip = new LinkedHashMap<>();
|
|
|
@@ -768,17 +776,24 @@ public class PromotionCalcServiceImpl implements IPromotionCalcService
|
|
|
if (couponRule.getProductId() != null)
|
|
|
{
|
|
|
Long pid = couponRule.getProductId();
|
|
|
- BigDecimal productPrice = priceMap.getOrDefault(pid, BigDecimal.ZERO);
|
|
|
+ // 汇总购物车内该商品的所有行(支持同商品多规格): 每行实付单价=商品价格+规格价格
|
|
|
int quantity = 0;
|
|
|
+ BigDecimal productPrice = priceMap.getOrDefault(pid, BigDecimal.ZERO);
|
|
|
+ BigDecimal totalProductPrice = BigDecimal.ZERO;
|
|
|
for (Map<String, Object> item : itemsWithPrice)
|
|
|
{
|
|
|
if (pid.equals(toLong(item.get("productId"))))
|
|
|
{
|
|
|
- quantity = toInt(item.get("quantity"));
|
|
|
- break;
|
|
|
+ int qty = toInt(item.get("quantity"));
|
|
|
+ BigDecimal unitPrice = (BigDecimal) item.get("unitPrice");
|
|
|
+ if (quantity == 0)
|
|
|
+ {
|
|
|
+ productPrice = unitPrice; // 首行单价(展示用)
|
|
|
+ }
|
|
|
+ totalProductPrice = totalProductPrice.add(unitPrice.multiply(BigDecimal.valueOf(qty)));
|
|
|
+ quantity += qty;
|
|
|
}
|
|
|
}
|
|
|
- BigDecimal totalProductPrice = productPrice.multiply(BigDecimal.valueOf(quantity));
|
|
|
BigDecimal finalLineTotal = totalProductPrice;
|
|
|
if (couponRule.getDiscountRate() != null)
|
|
|
{
|