|
|
@@ -73,6 +73,9 @@ public class UserOrderServiceImpl implements UserOrderService {
|
|
|
@Autowired
|
|
|
private OrderRepairMapper orderRepairMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ProductInfoMapper productInfoMapper;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<UserOrder> getUserOrderList(UserOrder record) {
|
|
|
@@ -141,41 +144,78 @@ public class UserOrderServiceImpl implements UserOrderService {
|
|
|
try {
|
|
|
record.setOrderCode(MbappUtil.getOrderIdByUUId());
|
|
|
if (record.getQuantity() != null && record.getUnitPrice() != null) {
|
|
|
- BigDecimal totlePrice = record.getUnitPrice().multiply(BigDecimal.valueOf(record.getQuantity()));
|
|
|
+ BigDecimal unitPrice = record.getUnitPrice();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 计算价格开始
|
|
|
+ */
|
|
|
+ ProductInfo productInfo = new ProductInfo();
|
|
|
+ productInfo.setId(record.getProductId());
|
|
|
+
|
|
|
+ productInfo = productInfoMapper.queryProductInfo(productInfo);
|
|
|
+
|
|
|
+ if (productInfo != null) {
|
|
|
+ unitPrice = productInfo.getPrice();
|
|
|
+
|
|
|
+ if (productInfo.getProductPriceList() != null && productInfo.getProductPriceList().size() > 0) {
|
|
|
+ for (ProductPrice productPrice : productInfo.getProductPriceList()) {
|
|
|
+ if (productPrice.getMaxCounts() != null
|
|
|
+ && productPrice.getMinCounts() != null
|
|
|
+ && record.getQuantity() <= productPrice.getMaxCounts()
|
|
|
+ && record.getQuantity() >= productPrice.getMinCounts()) {
|
|
|
+ unitPrice = productPrice.getPrice();
|
|
|
+ } else if (productPrice.getMaxCounts() == null
|
|
|
+ && productPrice.getMinCounts() != null
|
|
|
+ && record.getQuantity() >= productPrice.getMinCounts()) {
|
|
|
+ unitPrice = productPrice.getPrice();
|
|
|
+ } else if (productPrice.getMinCounts() == null
|
|
|
+ && productPrice.getMaxCounts() != null
|
|
|
+ && record.getQuantity() < productPrice.getMinCounts()) {
|
|
|
+ unitPrice = productPrice.getPrice();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 计算价格结束
|
|
|
+ */
|
|
|
+
|
|
|
+ BigDecimal totlePrice = unitPrice.multiply(BigDecimal.valueOf(record.getQuantity()));
|
|
|
record.setTotlePrice(totlePrice);
|
|
|
BigDecimal dealPrice = totlePrice;
|
|
|
record.setDealPrice(dealPrice);
|
|
|
record.setOffPrice(totlePrice.subtract(dealPrice));
|
|
|
- }
|
|
|
|
|
|
|
|
|
- int updates = userOrderMapper.insertSelective(record);
|
|
|
+ int updates = userOrderMapper.insertSelective(record);
|
|
|
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(record.getUserAddressId())) {
|
|
|
- UserAddress userAddress = userAddressMapper.selectByPrimaryKey(Integer.valueOf(record.getUserAddressId()));
|
|
|
+ if (StringUtils.isNotEmpty(record.getUserAddressId())) {
|
|
|
+ UserAddress userAddress = userAddressMapper.selectByPrimaryKey(Integer.valueOf(record.getUserAddressId()));
|
|
|
|
|
|
- if (userAddress != null) {
|
|
|
- OrderAddress orderAddress = new OrderAddress();
|
|
|
+ if (userAddress != null) {
|
|
|
+ OrderAddress orderAddress = new OrderAddress();
|
|
|
|
|
|
- orderAddress.setOrderId(record.getId());
|
|
|
- orderAddress.setUserId(record.getUserId());
|
|
|
- orderAddress.setRealName(userAddress.getRealName());
|
|
|
- orderAddress.setTelephone(userAddress.getTelephone());
|
|
|
- orderAddress.setPostcode(userAddress.getPostcode());
|
|
|
- orderAddress.setAddress(userAddress.getAddress());
|
|
|
- orderAddress.setAddressDetail(userAddress.getAddressDetail());
|
|
|
- orderAddress.setUserAddressId(record.getUserAddressId());
|
|
|
+ orderAddress.setOrderId(record.getId());
|
|
|
+ orderAddress.setUserId(record.getUserId());
|
|
|
+ orderAddress.setRealName(userAddress.getRealName());
|
|
|
+ orderAddress.setTelephone(userAddress.getTelephone());
|
|
|
+ orderAddress.setPostcode(userAddress.getPostcode());
|
|
|
+ orderAddress.setAddress(userAddress.getAddress());
|
|
|
+ orderAddress.setAddressDetail(userAddress.getAddressDetail());
|
|
|
+ orderAddress.setUserAddressId(record.getUserAddressId());
|
|
|
|
|
|
- orderAddressMapper.insertSelective(orderAddress);
|
|
|
+ orderAddressMapper.insertSelective(orderAddress);
|
|
|
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- if (updates > 0) {
|
|
|
- return true;
|
|
|
+ if (updates > 0) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.error("createUserOrder", e);
|