chenlu
2024-08-20 2b49c5d247ca32b5aaa47e50749f8b17efa3f408
north-glass-erp/src/main/java/com/example/erp/service/sd/OrderService.java
@@ -23,6 +23,8 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
@@ -169,6 +171,13 @@
            String formattedDate = dateFormat.format(currentDate);
            orderId =  "NG"+formattedDate+formattedNumber;
        }else if(dateType.equals("year")){
            Integer maxOrderId = orderMapper.selectMaxOrderIdByYear();
            String formattedNumber = String.format("%06d", maxOrderId+1);
            Date currentDate = new Date();
            SimpleDateFormat dateFormat = new SimpleDateFormat("yy");
            String formattedDate = dateFormat.format(currentDate);
            orderId =  "NG"+formattedDate+formattedNumber;
        }
        return orderId;
@@ -370,8 +379,10 @@
        double money = 0;
        for (OrderDetail orderDetail : OrderDetails) {
            orderDetail =  updateOrderMoneyComputed(orderDetail,order.getCalculateType());
            money+= orderDetail.getGrossAmount();
            BigDecimal getGrossAmount= BigDecimal.valueOf(orderDetail.getGrossAmount());
            money+=getGrossAmount.doubleValue();
        }
        orderOtherMoneyList.forEach(orderOtherMoney -> {
            if(orderOtherMoney.getQuantity()!=null && orderOtherMoney.getPrice()!=null){
                orderOtherMoney.setMoney((orderOtherMoney.getQuantity()*orderOtherMoney.getPrice()));
@@ -388,10 +399,13 @@
    }
    private OrderDetail updateOrderMoneyComputed(OrderDetail orderDetail, Integer calculateType) {
        BigDecimal getPrice= BigDecimal.valueOf(orderDetail.getPrice());
        BigDecimal getQuantity= BigDecimal.valueOf(orderDetail.getQuantity());
        BigDecimal getComputeGrossArea= BigDecimal.valueOf(orderDetail.getComputeGrossArea());
        if (calculateType == 3) {
            orderDetail.setGrossAmount(orderDetail.getPrice() * orderDetail.getQuantity());
            orderDetail.setGrossAmount(getPrice.multiply(getQuantity).setScale(2, RoundingMode.HALF_UP).doubleValue());
        } else {
            orderDetail.setGrossAmount(orderDetail.getComputeGrossArea() * orderDetail.getPrice());
            orderDetail.setGrossAmount(getPrice.multiply(getComputeGrossArea).setScale(2, RoundingMode.HALF_UP).doubleValue());
        }
        return orderDetail;
    }