廖井涛
2024-07-19 12f2fd73462da331478fabc7eaa79fc35b1a59b3
north-glass-erp/src/main/java/com/example/erp/service/sd/OrderService.java
@@ -12,9 +12,11 @@
import com.example.erp.dto.sd.OrderDTO;
import com.example.erp.dto.sd.OrderDetailProductDTO;
import com.example.erp.entity.sd.*;
import com.example.erp.entity.userInfo.Log;
import com.example.erp.entity.userInfo.SysError;
import com.example.erp.exception.ServiceException;
import com.example.erp.mapper.sd.*;
import com.example.erp.service.userInfo.LogService;
import com.example.erp.service.userInfo.SysErrorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -36,9 +38,10 @@
    private final SysErrorService sysErrorService;
    private final OrderOtherMoneyMapper orderOtherMoneyMapper;
    private final ProductMapper productMapper;
    private final LogService logService;
    private final OrderProcessDetailMapper orderProcessDetailMapper;
    public OrderService(OrderMapper orderMapper, OrderDetailMapper orderDetailMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, SysErrorService sysErrorService, OrderOtherMoneyMapper orderOtherMoneyMapper, ProductMapper productMapper) {
    public OrderService(OrderMapper orderMapper, OrderDetailMapper orderDetailMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, SysErrorService sysErrorService, OrderOtherMoneyMapper orderOtherMoneyMapper, ProductMapper productMapper, LogService logService) {
        this.orderMapper = orderMapper;
        this.orderDetailMapper = orderDetailMapper;
        this.orderGlassDetailMapper = orderGlassDetailMapper;
@@ -46,6 +49,7 @@
        this.sysErrorService = sysErrorService;
        this.orderOtherMoneyMapper = orderOtherMoneyMapper;
        this.productMapper = productMapper;
        this.logService = logService;
    }
    public boolean saveOrder(Map<String,Object> orderMap) throws Exception {
@@ -63,11 +67,20 @@
        Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
        //判断传入id参数是否为空,未传入id为空插入订单表,传入更新表
        try{
            Log log = new Log();
            log.setOperator(orderJson.getString("creator"));
            log.setOperatorId(orderJson.getString("creatorId"));
            log.setContent(orderMap.toString());
            if(order.getOrderId() == null || order.getOrderId().isEmpty()){
                insertOrder(order,OrderDetails,orderOtherMoneyList,orderIdType);
                log.setFunction("saveOrder创建:"+order.getOrderId());
            }else {
                updateOrder(order,OrderDetails,orderOtherMoneyList);
                log.setFunction("saveOrder修改:"+order.getOrderId());
            }
            logService.saveLog(log);
        }catch (Exception e){
            TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint);
            //将异常传入数据库