feat:共富商城退款
This commit is contained in:
1 parent
385e2550da
commit
a8061efa2f
1 file changed
+35
-2
+35
-2
@@ -239,6 +239,37 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
}
|
||||
yield doorTotalPrice.get();
|
||||
}
|
||||
case FARMER -> {
|
||||
AtomicInteger doorTotalPrice = new AtomicInteger();
|
||||
List<MallProductDetailAppVo> spuList = remoteMallProductService.getSkusWithSpuBySkuIds(productIds).getData();
|
||||
for (HardCreateCarDto v : list) {
|
||||
spu:
|
||||
for (MallProductDetailAppVo spu : spuList) {
|
||||
if (ObjectUtil.isEmpty(spu) || ObjectUtil.isEmpty(spu.getSkuList())) {
|
||||
continue spu;
|
||||
}
|
||||
MallProductSkuAppVo sku = spu.getSkuList().stream().filter(_item -> ObjectUtil.equals(_item.getId(), v.getProductId())).findFirst().orElse(null);
|
||||
if (ObjectUtil.isEmpty(sku)) {
|
||||
continue spu;
|
||||
}
|
||||
if (ObjectUtil.isEmpty(spu.getSkuList())) {
|
||||
throw new RuntimeException("共富商城商品无SKU信息商品名字:" + spu.getTitle() + "商品ID:" + spu.getId() + "请联系管理员");
|
||||
}
|
||||
Integer price = sku.getPrice();
|
||||
if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) {
|
||||
// 按数量
|
||||
int itemTotalPrice = v.getProductCount() * price;
|
||||
doorTotalPrice.addAndGet(itemTotalPrice);
|
||||
} else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) {
|
||||
// 按重量
|
||||
// 向上取整
|
||||
int itemTotalPrice = v.getProductWeight().multiply(BigDecimal.valueOf(price)).setScale(0, RoundingMode.CEILING).intValue();
|
||||
doorTotalPrice.addAndGet(itemTotalPrice);
|
||||
}
|
||||
}
|
||||
}
|
||||
yield doorTotalPrice.get();
|
||||
}
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
@@ -452,8 +483,10 @@ public class HardCarServiceImpl extends ServiceImpl<HardCarMapper, HardCarEntity
|
||||
item.setProductPrice(price);
|
||||
item.setProductPic(spu.getCoverImage());
|
||||
item.setTotalPrice((long) totalPrice);
|
||||
if (ObjectUtil.isNotEmpty(v.getProductNature())) {
|
||||
item.setProductNature(v.getProductNature().getType());
|
||||
if (ObjectUtil.isNotEmpty(spu.getProductNature())) {
|
||||
item.setProductNature(spu.getProductNature());
|
||||
} else {
|
||||
item.setProductNature(HardProductNatureEnum.DEFAULT.getType());
|
||||
}
|
||||
item.setProductCount(v.getProductCount());
|
||||
item.setProductWeight(v.getProductWeight());
|
||||
|
||||
Reference in new issue
Block a user