|
@@ -11,6 +11,7 @@ import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.flow.enums.FlowStatusEnum;
|
|
|
import com.ruoyi.common.constant.StatusConstant;
|
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
+import com.ruoyi.common.core.domain.BasePo;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.system.service.ISysRoleService;
|
|
@@ -27,6 +28,7 @@ import com.sd.business.entity.order.dto.OrderInfoDto;
|
|
|
import com.sd.business.entity.order.dto.OrderInfoSelectDto;
|
|
|
import com.sd.business.entity.order.dto.OrderPackageBomDto;
|
|
|
import com.sd.business.entity.order.dto.OrderSkuDto;
|
|
|
+import com.sd.business.entity.order.dto.SkuSpecPriceDto;
|
|
|
import com.sd.business.entity.order.enums.OrderClassifyEnum;
|
|
|
import com.sd.business.entity.order.enums.OrderExceptionTypeEnum;
|
|
|
import com.sd.business.entity.order.enums.OrderStatusEnum;
|
|
@@ -39,11 +41,16 @@ import com.sd.business.entity.order.vo.OrderInfoVo;
|
|
|
import com.sd.business.entity.order.vo.OrderPackageBomVo;
|
|
|
import com.sd.business.entity.order.vo.OrderSkuBomVo;
|
|
|
import com.sd.business.entity.order.vo.OrderSkuVo;
|
|
|
+import com.sd.business.entity.order.vo.SkuSpecPriceVo;
|
|
|
+import com.sd.business.entity.price.po.PriceBillingStandard;
|
|
|
+import com.sd.business.entity.price.po.PriceBillingStandardDetail;
|
|
|
import com.sd.business.entity.production.po.ProductionWorkOrder;
|
|
|
import com.sd.business.entity.sku.po.SkuSpec;
|
|
|
import com.sd.business.entity.warehouse.constant.WarehouseConstant;
|
|
|
import com.sd.business.mapper.order.OrderInfoMapper;
|
|
|
+import com.sd.business.service.bom.BomService;
|
|
|
import com.sd.business.service.bom.BomSpecService;
|
|
|
+import com.sd.business.service.department.DepartmentService;
|
|
|
import com.sd.business.service.in.InOutStorageService;
|
|
|
import com.sd.business.service.inventory.InventoryFinishedService;
|
|
|
import com.sd.business.service.inventory.InventoryService;
|
|
@@ -52,7 +59,11 @@ import com.sd.business.service.order.OrderPackageBomService;
|
|
|
import com.sd.business.service.order.OrderSkuBomService;
|
|
|
import com.sd.business.service.order.OrderSkuProductionCostService;
|
|
|
import com.sd.business.service.order.OrderSkuService;
|
|
|
+import com.sd.business.service.price.PriceBillingStandardDetailService;
|
|
|
+import com.sd.business.service.price.PriceBillingStandardService;
|
|
|
import com.sd.business.service.production.ProductionWorkOrderService;
|
|
|
+import com.sd.business.service.sku.SkuSpecService;
|
|
|
+import com.sd.business.util.CodeEnum;
|
|
|
import com.sd.framework.util.Assert;
|
|
|
import com.sd.framework.util.sql.Sql;
|
|
|
import com.sd.framework.util.sql.Where;
|
|
@@ -119,6 +130,21 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
@Autowired
|
|
|
private ISysRoleService roleService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SkuSpecService skuSpecService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BomService bomService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DepartmentService departmentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PriceBillingStandardService priceBillingStandardService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PriceBillingStandardDetailService priceBillingStandardDetailService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<OrderInfoVo> getPage(OrderInfoSelectDto dto) {
|
|
|
|
|
@@ -718,6 +744,174 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
sendMq(dto);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public SkuSpecPriceVo getSkuSpecPrice(SkuSpecPriceDto dto) {
|
|
|
+ // 查询单价
|
|
|
+ Long skuSpecId = dto.getSkuSpecId();
|
|
|
+ SkuSpec skuSpec = skuSpecService.getById(skuSpecId);
|
|
|
+ Assert.notNull(skuSpec, "未知sku规格");
|
|
|
+ Long bomSpecId = skuSpec.getBomSpecId();
|
|
|
+ Assert.notNull(bomSpecId, "sku未绑定bom");
|
|
|
+ BomSpec bomSpec = bomSpecService.getById(bomSpecId);
|
|
|
+ Assert.notNull(bomSpec, "未知bom规格");
|
|
|
+ Bom bom = bomService.getById(bomSpec.getBomId());
|
|
|
+ Assert.notNull(bom, "未知bom");
|
|
|
+
|
|
|
+ // 其他价格查询
|
|
|
+ Long deptId = SecurityUtils.getDeptId();
|
|
|
+ Department department = departmentService.getById(deptId);
|
|
|
+ Assert.notNull(department, "未知事业部");
|
|
|
+ String priceBillingStandardIdStr = department.getPriceBillingStandardId();
|
|
|
+ Assert.notBlank(priceBillingStandardIdStr, "事业部未绑定加工计费标准");
|
|
|
+
|
|
|
+ List<String> priceBillingStandardIdList = Arrays.stream(priceBillingStandardIdStr.split(",")).collect(Collectors.toList());
|
|
|
+ List<PriceBillingStandard> priceBillingStandardList = priceBillingStandardService.listByIds(priceBillingStandardIdList);
|
|
|
+
|
|
|
+ List<PriceBillingStandardDetail> priceBillingStandardDetailList = null;
|
|
|
+
|
|
|
+ if (StrUtil.isBlank(bom.getSpecies())) {
|
|
|
+ priceBillingStandardDetailList = Collections.emptyList();
|
|
|
+ } else {
|
|
|
+ for (PriceBillingStandard priceBillingStandard : priceBillingStandardList) {
|
|
|
+ if (Objects.equals(bom.getSpecies(), priceBillingStandard.getSpecies())) {
|
|
|
+ priceBillingStandardDetailList = priceBillingStandardDetailService.list(
|
|
|
+ q -> q.eq(PriceBillingStandardDetail::getPriceBillingStandardId, priceBillingStandard.getId()));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (priceBillingStandardDetailList == null) {
|
|
|
+ throw new ServiceException("没有找到加工计费标准");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 赋值
|
|
|
+ SkuSpecPriceVo skuSpecPriceVo = new SkuSpecPriceVo();
|
|
|
+ skuSpecPriceVo.setUnitPrice(bomSpec.getInternalSellingPrice());
|
|
|
+ skuSpecPriceVo.setCustomProcessingFee(BigDecimal.ZERO);
|
|
|
+ skuSpecPriceVo.setLssueFee(BigDecimal.ZERO);
|
|
|
+ skuSpecPriceVo.setDeliveryMaterialsFee(BigDecimal.ZERO);
|
|
|
+ skuSpecPriceVo.setPackingLabor(BigDecimal.ZERO);
|
|
|
+ skuSpecPriceVo.setManagementFee(BigDecimal.ZERO);
|
|
|
+
|
|
|
+ for (PriceBillingStandardDetail priceBillingStandardDetail : priceBillingStandardDetailList) {
|
|
|
+ String chargeItem = priceBillingStandardDetail.getChargeItem();
|
|
|
+ BigDecimal chargePrice = ObjectUtil.defaultIfNull(priceBillingStandardDetail.getChargePrice(), BigDecimal.ZERO);
|
|
|
+ switch (chargeItem) {
|
|
|
+ case "40":
|
|
|
+ skuSpecPriceVo.setPackingLabor(chargePrice);
|
|
|
+ break;
|
|
|
+ case "50":
|
|
|
+ skuSpecPriceVo.setLssueFee(chargePrice);
|
|
|
+ break;
|
|
|
+ case "60":
|
|
|
+ skuSpecPriceVo.setDeliveryMaterialsFee(chargePrice);
|
|
|
+ break;
|
|
|
+ case "70":
|
|
|
+ skuSpecPriceVo.setManagementFee(chargePrice);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ if (Objects.equals(chargeItem, skuSpec.getMachinedPanel())
|
|
|
+ && dto.getQuantity().compareTo(priceBillingStandardDetail.getSectionMin()) >= 0
|
|
|
+ && dto.getQuantity().compareTo(priceBillingStandardDetail.getSectionMax()) < 0) {
|
|
|
+ skuSpecPriceVo.setCustomProcessingFee(chargePrice);
|
|
|
+ skuSpecPriceVo.setCustomProcessingType(chargeItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return skuSpecPriceVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void turnToRegularOrder(Long id) {
|
|
|
+ OrderInfo orderInfo = getById(id);
|
|
|
+ String exceptionType = orderInfo.getExceptionType();
|
|
|
+
|
|
|
+ if (Objects.equals(exceptionType, OrderExceptionTypeEnum.NORMAL.getKey().toString())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String s : exceptionType.split(",")) {
|
|
|
+ OrderExceptionTypeEnum orderExceptionTypeEnum = OrderExceptionTypeEnum.getEnum(Convert.toInt(s));
|
|
|
+ if (ObjectUtil.notEqual(orderExceptionTypeEnum, OrderExceptionTypeEnum.ORDER_CLOSURE)
|
|
|
+ && ObjectUtil.notEqual(orderExceptionTypeEnum, OrderExceptionTypeEnum.ORDER_ABORT)
|
|
|
+ && ObjectUtil.notEqual(orderExceptionTypeEnum, OrderExceptionTypeEnum.ORDER_EXCEPTION_HANDLING)) {
|
|
|
+ throw new ServiceException(orderExceptionTypeEnum.getValue() + ",无法转为正常订单");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtil.equal(orderInfo.getStatus(), OrderStatusEnum.STOCK_PREPARATION.getKey())) {
|
|
|
+ List<OrderSku> list = orderSkuService.list(q -> q.eq(OrderSku::getOrderId, orderInfo.getId()));
|
|
|
+ // 先判断成品是否能锁定
|
|
|
+ if (inventoryFinishedService.lockNoSourceStorage(list)) {
|
|
|
+ orderInfo.setStockType(StatusConstant.YES);
|
|
|
+ } else {
|
|
|
+ lockStorage(list);
|
|
|
+ orderInfo.setStockType(StatusConstant.NO);
|
|
|
+ }
|
|
|
+ update(q -> q
|
|
|
+ .eq(BaseIdPo::getId, orderInfo.getId())
|
|
|
+ .set(OrderInfo::getLockStorage, StatusConstant.YES)
|
|
|
+ .set(OrderInfo::getStockType, orderInfo.getStockType()));
|
|
|
+ }
|
|
|
+
|
|
|
+ update(q -> q
|
|
|
+ .eq(BaseIdPo::getId, orderInfo.getId())
|
|
|
+ .set(OrderInfo::getExceptionType, OrderExceptionTypeEnum.NORMAL.getKey().toString())
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+
|
|
|
+ // 转trade
|
|
|
+ if (Arrays.asList(exceptionType.split(",")).contains(OrderExceptionTypeEnum.ORDER_CLOSURE.getKey().toString())) {
|
|
|
+ // 订单分类修改为无理由订单
|
|
|
+ update(q -> q
|
|
|
+ .eq(BaseIdPo::getId, orderInfo.getId())
|
|
|
+ .set(OrderInfo::getClassify, OrderClassifyEnum.NO_REASON_ORDER.getKey())
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getOrderDeliveryCode() {
|
|
|
+ return CodeEnum.SH_CODE.getCode();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void saveOrderDeliveryCode(OrderInfoDto dto) {
|
|
|
+ OrderInfo orderInfo = this.getById(dto.getId());
|
|
|
+ if (orderInfo == null) {
|
|
|
+ throw new ServiceException("未找到订单");
|
|
|
+ }
|
|
|
+ if (StrUtil.isBlank(dto.getDeliveryCode())) {
|
|
|
+ throw new ServiceException("送货单号不能为空");
|
|
|
+ }
|
|
|
+ OrderInfo one = this.getOne(q -> q.eq(OrderInfo::getDeliveryCode, dto.getDeliveryCode()));
|
|
|
+ if (one != null) {
|
|
|
+ throw new ServiceException("送货单号重复,请重新生成!");
|
|
|
+ }
|
|
|
+ this.update(q -> q.set(OrderInfo::getDeliveryCode, dto.getDeliveryCode()).eq(BaseIdPo::getId, dto.getId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void suspendOrder(Long id) {
|
|
|
+ OrderInfo orderInfo = this.getById(id);
|
|
|
+ if (orderInfo == null) {
|
|
|
+ throw new ServiceException("未找到订单");
|
|
|
+ }
|
|
|
+ this.update(q -> q.set(OrderInfo::getStatus, OrderStatusEnum.SUSPEND.getKey()).eq(BaseIdPo::getId, id));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void cancelSuspendOrder(Long id) {
|
|
|
+ OrderInfo orderInfo = this.getById(id);
|
|
|
+ if (orderInfo == null) {
|
|
|
+ throw new ServiceException("未找到订单");
|
|
|
+ }
|
|
|
+ this.update(q -> q.set(OrderInfo::getStatus, OrderStatusEnum.STOCK_PREPARATION.getKey()).eq(BaseIdPo::getId, id));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 解锁库存
|
|
|
*/
|