|
|
@@ -15,6 +15,8 @@ import com.etotem.cfc.mapper.AfterSalesRequestMapper;
|
|
|
import com.etotem.cfc.mapper.ProductMapper;
|
|
|
import com.etotem.cfc.mapper.ProductOrderMapper;
|
|
|
import com.etotem.cfc.mapper.UserMapper;
|
|
|
+import com.etotem.cfc.entity.ProductSku;
|
|
|
+import com.etotem.cfc.service.ProductSkuService;
|
|
|
import com.etotem.cfc.service.CommissionService;
|
|
|
import com.etotem.cfc.service.AssessmentProductService;
|
|
|
import com.etotem.cfc.service.AssessmentQuotaService;
|
|
|
@@ -53,6 +55,9 @@ public class ProductOrderService {
|
|
|
@Resource
|
|
|
private ProductService productService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ProductSkuService productSkuService;
|
|
|
+
|
|
|
@Resource
|
|
|
private CommissionService commissionService;
|
|
|
|
|
|
@@ -147,6 +152,7 @@ public class ProductOrderService {
|
|
|
int totalQuantity = 0;
|
|
|
OrderItemVO firstItem = dto.getItems().get(0);
|
|
|
Product firstProduct = null;
|
|
|
+ int firstUnitPrice = 0;
|
|
|
|
|
|
for (OrderItemVO item : dto.getItems()) {
|
|
|
Product product = productMapper.selectById(item.getProductId());
|
|
|
@@ -162,10 +168,18 @@ public class ProductOrderService {
|
|
|
&& product.getStock() < item.getQuantity()) {
|
|
|
return Result.error("库存不足: " + product.getName());
|
|
|
}
|
|
|
- totalAmount += product.getPrice() * item.getQuantity();
|
|
|
+ int unitPrice = product.getPrice();
|
|
|
+ if (item.getSkuId() != null) {
|
|
|
+ ProductSku sku = productSkuService.getById(item.getSkuId());
|
|
|
+ if (sku != null && sku.getPrice() != null) {
|
|
|
+ unitPrice = sku.getPrice().multiply(new java.math.BigDecimal(100)).intValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ totalAmount += unitPrice * item.getQuantity();
|
|
|
totalQuantity += item.getQuantity();
|
|
|
if (firstProduct == null) {
|
|
|
firstProduct = product;
|
|
|
+ firstUnitPrice = unitPrice;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -178,7 +192,7 @@ public class ProductOrderService {
|
|
|
order.setBuyerId(buyerId);
|
|
|
order.setFamilyId(buyer != null ? buyer.getFamilyId() : null);
|
|
|
order.setQuantity(totalQuantity);
|
|
|
- order.setUnitPrice(firstProduct.getPrice());
|
|
|
+ order.setUnitPrice(firstUnitPrice);
|
|
|
order.setTotalAmount(totalAmount);
|
|
|
order.setPointsUsed(dto.getPointsUsed() != null ? dto.getPointsUsed() : 0);
|
|
|
int pointsCost = dto.getPointsUsed() != null ? dto.getPointsUsed() : 0;
|