|
@@ -2,6 +2,7 @@ package org.dromara.order.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
@@ -17,6 +18,7 @@ import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.enums.*;
|
|
import org.dromara.common.core.enums.*;
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.exception.api.ZhongcheException;
|
|
import org.dromara.common.core.exception.api.ZhongcheException;
|
|
|
|
|
+import org.dromara.common.core.utils.DateUtils;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.ObjectUtils;
|
|
import org.dromara.common.core.utils.ObjectUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
@@ -49,6 +51,9 @@ import org.dromara.order.utils.kd100.domain.TrackVO;
|
|
|
import org.dromara.product.api.RemoteProductService;
|
|
import org.dromara.product.api.RemoteProductService;
|
|
|
import org.dromara.product.api.RemoteProductShoppingCartService;
|
|
import org.dromara.product.api.RemoteProductShoppingCartService;
|
|
|
import org.dromara.product.api.domain.ProductVo;
|
|
import org.dromara.product.api.domain.ProductVo;
|
|
|
|
|
+import org.dromara.product.api.domain.push.SOComProd;
|
|
|
|
|
+import org.dromara.product.api.domain.push.SalSO;
|
|
|
|
|
+import org.dromara.product.api.domain.push.SalSODet;
|
|
|
import org.dromara.system.api.*;
|
|
import org.dromara.system.api.*;
|
|
|
import org.dromara.system.api.model.LoginUser;
|
|
import org.dromara.system.api.model.LoginUser;
|
|
|
import org.mybatis.spring.MyBatisSystemException;
|
|
import org.mybatis.spring.MyBatisSystemException;
|
|
@@ -99,6 +104,12 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
|
|
@DubboReference
|
|
@DubboReference
|
|
|
private RemoteComDeptService remoteComDeptService;
|
|
private RemoteComDeptService remoteComDeptService;
|
|
|
|
|
|
|
|
|
|
+ @DubboReference
|
|
|
|
|
+ private RemoteComCompanyService remoteComCompanyService;
|
|
|
|
|
+
|
|
|
|
|
+ @DubboReference
|
|
|
|
|
+ private RemoteComWarehouseService remoteComWarehouseService;
|
|
|
|
|
+
|
|
|
private RemoteErpStaffService remoteErpStaffService;
|
|
private RemoteErpStaffService remoteErpStaffService;
|
|
|
|
|
|
|
|
@DubboReference
|
|
@DubboReference
|
|
@@ -711,6 +722,7 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
|
|
// 5. 批量插入订单商品
|
|
// 5. 批量插入订单商品
|
|
|
orderProductMapper.insertBatch(orderProducts);
|
|
orderProductMapper.insertBatch(orderProducts);
|
|
|
|
|
|
|
|
|
|
+ orderMainInfoToJson(orderId);
|
|
|
log.info("成功新增订单,ID: {}", orderId);
|
|
log.info("成功新增订单,ID: {}", orderId);
|
|
|
return orderId;
|
|
return orderId;
|
|
|
} catch (RuntimeException e) {
|
|
} catch (RuntimeException e) {
|
|
@@ -817,7 +829,7 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
|
|
if (bo.getPlaceOrderType() == 1) {
|
|
if (bo.getPlaceOrderType() == 1) {
|
|
|
remoteProductShoppingCartService.deleteWithValidByIds(bo.getProductShoppingCartId());
|
|
remoteProductShoppingCartService.deleteWithValidByIds(bo.getProductShoppingCartId());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ orderMainInfoToJson(orderId);
|
|
|
return orderId;
|
|
return orderId;
|
|
|
} else {
|
|
} else {
|
|
|
// 插入失败,抛出异常触发事务回滚
|
|
// 插入失败,抛出异常触发事务回滚
|
|
@@ -2508,4 +2520,108 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
|
|
.setData(data3).setColor("#f4c542").setType("line"));
|
|
.setData(data3).setColor("#f4c542").setType("line"));
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String orderMainInfoToJson(Long orderId) {
|
|
|
|
|
+ OrderMainVo orderMain = queryById(orderId);
|
|
|
|
|
+ if (orderMain == null) {
|
|
|
|
|
+ return "{}";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询客户信息
|
|
|
|
|
+ CustomerInfoDTO customerInfo = null;
|
|
|
|
|
+ if (orderMain.getCustomerId() != null) {
|
|
|
|
|
+ customerInfo = remoteCustomerService.selectCustomerInfoById(orderMain.getCustomerId());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 1. 映射 SalSO
|
|
|
|
|
+ SalSO salSO = new SalSO();
|
|
|
|
|
+ if (orderMain.getOrderTime() != null) {
|
|
|
|
|
+ salSO.setBlDa(Integer.parseInt(DateUtils.parseDateToStr(FormatsType.YYYYMMDD, orderMain.getOrderTime())));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (customerInfo != null && customerInfo.getBelongCompanyId() != null) {
|
|
|
|
|
+ salSO.setCoId(remoteComCompanyService.selectCompanyCodeById(customerInfo.getBelongCompanyId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ salSO.setCurId(customerInfo != null && StringUtils.isNotBlank(customerInfo.getCurrencyCode()) ? customerInfo.getCurrencyCode() : "");
|
|
|
|
|
+ salSO.setCustId(orderMain.getCustomerCode() != null ? orderMain.getCustomerCode() : "");
|
|
|
|
|
+ if (customerInfo != null && customerInfo.getSalesPersonId() != null) {
|
|
|
|
|
+ salSO.setPerId(remoteComStaffService.selectStaffCodeById(customerInfo.getSalesPersonId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (orderMain.getShippingAddressId() != null) {
|
|
|
|
|
+ salSO.setAddrNo(remoteCustomerService.selectCustomerShippingAddressNoById(orderMain.getShippingAddressId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ salSO.setBlNo(orderMain.getOrderNo() != null ? orderMain.getOrderNo() : "");
|
|
|
|
|
+ if (orderMain.getOrderTime() != null) {
|
|
|
|
|
+ salSO.setCU_xdrq(Integer.parseInt(DateUtils.parseDateToStr(FormatsType.YYYYMMDD, orderMain.getOrderTime())));
|
|
|
|
|
+ }
|
|
|
|
|
+ salSO.setCustOrd(orderMain.getDataSource() != null ? orderMain.getDataSource() : "");
|
|
|
|
|
+ salSO.setIsPrWTax(true);
|
|
|
|
|
+ salSO.setProjId(orderMain.getProjectOrderNo() != null ? orderMain.getProjectOrderNo() : "");
|
|
|
|
|
+ salSO.setRemark(orderMain.getRemark() != null ? orderMain.getRemark() : "");
|
|
|
|
|
+ salSO.setTypeId(orderMain.getOrderType() != null ? orderMain.getOrderType() : "");
|
|
|
|
|
+ salSO.setX_WebOrdNo(orderMain.getOrderNo() != null ? orderMain.getOrderNo() : "");
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 映射 SalSODet 列表(主商品,parentItemId == null)
|
|
|
|
|
+ List<SalSODet> salSODetList = new ArrayList<>();
|
|
|
|
|
+ List<OrderProductVo> products = orderMain.getOrderProductList();
|
|
|
|
|
+ if (CollUtil.isNotEmpty(products)) {
|
|
|
|
|
+ int rowNo = 1;
|
|
|
|
|
+ for (OrderProductVo item : products) {
|
|
|
|
|
+ // 只处理主商品
|
|
|
|
|
+ if (item.getParentItemId() != null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ SalSODet det = new SalSODet();
|
|
|
|
|
+ det.setBlNo(orderMain.getOrderNo() != null ? orderMain.getOrderNo() : "");
|
|
|
|
|
+ if (item.getPreDeliveryDate() != null) {
|
|
|
|
|
+ det.setPreDlvDa(Integer.parseInt(DateUtils.parseDateToStr(FormatsType.YYYYMMDD, item.getPreDeliveryDate())));
|
|
|
|
|
+ }
|
|
|
|
|
+ det.setTaxId("");
|
|
|
|
|
+ det.setIsOutAllot(false);
|
|
|
|
|
+ det.setIxTy(1);
|
|
|
|
|
+ det.setProdId(item.getProductNo() != null ? item.getProductNo() : "");
|
|
|
|
|
+ det.setRemark(item.getRemark() != null ? item.getRemark() : "");
|
|
|
|
|
+ det.setRowCd(item.getId() != null ? item.getId().intValue() : null);
|
|
|
|
|
+ det.setRowNo(rowNo++);
|
|
|
|
|
+ det.setSPr(item.getOrderPrice() != null ? item.getOrderPrice() : BigDecimal.ZERO);
|
|
|
|
|
+ det.setSQty(item.getOrderQuantity() != null ? BigDecimal.valueOf(item.getOrderQuantity()) : BigDecimal.ZERO);
|
|
|
|
|
+ det.setSUiId(item.getProductUnit() != null ? item.getProductUnit() : "");
|
|
|
|
|
+ det.setQty(item.getOrderQuantity() != null ? BigDecimal.valueOf(item.getOrderQuantity()) : BigDecimal.ZERO);
|
|
|
|
|
+ if (orderMain.getWarehouseId() != null) {
|
|
|
|
|
+ det.setWhsId(remoteComWarehouseService.getWarehouseNoById(orderMain.getWarehouseId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ salSODetList.add(det);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 映射 SOComProd 列表(组合子件,parentItemId != null)
|
|
|
|
|
+ List<SOComProd> soComProdList = new ArrayList<>();
|
|
|
|
|
+ if (CollUtil.isNotEmpty(products)) {
|
|
|
|
|
+ int rowNo = 1;
|
|
|
|
|
+ for (OrderProductVo item : products) {
|
|
|
|
|
+ if (item.getRootItemId() == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ SOComProd com = new SOComProd();
|
|
|
|
|
+ com.setDiscRt(BigDecimal.ZERO);
|
|
|
|
|
+ com.setOAmt(item.getSubtotal() != null ? item.getSubtotal() : BigDecimal.ZERO);
|
|
|
|
|
+ com.setOAmtWTax(item.getSubtotal() != null ? item.getSubtotal() : BigDecimal.ZERO);
|
|
|
|
|
+ com.setRemark(item.getRemark() != null ? item.getRemark() : "");
|
|
|
|
|
+ com.setRowCd(item.getId() != null ? item.getId().intValue() : null);
|
|
|
|
|
+ com.setRowNo(rowNo++);
|
|
|
|
|
+ com.setSPr(item.getOrderPrice() != null ? item.getOrderPrice() : BigDecimal.ZERO);
|
|
|
|
|
+ com.setSQty(item.getOrderQuantity() != null ? BigDecimal.valueOf(item.getOrderQuantity()) : BigDecimal.ZERO);
|
|
|
|
|
+ com.setSubProdId(item.getProductNo() != null ? item.getProductNo() : "");
|
|
|
|
|
+ com.setSubProdSpec(item.getProductName() != null ? item.getProductName() : "");
|
|
|
|
|
+ soComProdList.add(com);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 组装返回JSON
|
|
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
|
|
+ result.put("salSO", salSO);
|
|
|
|
|
+ result.put("salSODet", salSODetList);
|
|
|
|
|
+ result.put("SOComProd", soComProdList);
|
|
|
|
|
+ return JSONUtil.toJsonStr(result);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|