| | |
| | | import cn.iocoder.yudao.module.erp.api.sale.dto.ErpSaleOrderRespDTO; |
| | | import cn.iocoder.yudao.module.mdm.api.item.MdmItemApi; |
| | | import cn.iocoder.yudao.module.mdm.api.item.dto.MdmItemRespDTO; |
| | | import cn.iocoder.yudao.module.mdm.enums.MdmItemTypeEnum; |
| | | import cn.iocoder.yudao.module.system.api.approval.ApprovalConfigApi; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | |
| | | if (config == null || Boolean.FALSE.equals(config.getNotifyEnabled())) { |
| | | return 0L; |
| | | } |
| | | // 提醒天数未配置时按默认 7 天处理,避免 config.getNotifyDays() 为 null 时拆箱抛 NPE 导致接口 500 |
| | | if (config.getNotifyDays() == null) { |
| | | config = BeanUtils.toBean(config, CrmContractConfigDO.class); |
| | | config.setNotifyDays(DEFAULT_NOTIFY_DAYS); |
| | | } |
| | | return contractMapper.selectCountByRemind(userId, config); |
| | | } |
| | | |
| | | /** |
| | | * 合同到期提醒的默认提前天数:合同提醒未配置 notifyDays 时使用 |
| | | */ |
| | | private static final Integer DEFAULT_NOTIFY_DAYS = 7; |
| | | |
| | | @Override |
| | | public List<CrmContractDO> getContractListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { |
| | |
| | | createReqDTO.setRemark("由合同【" + contract.getNo() + "】自动生成"); |
| | | |
| | | // 5. 构建订单项 |
| | | Map<Long, MdmItemRespDTO> itemMap = mdmItemApi.getItemMap( |
| | | convertSet(contractProducts, CrmContractProductDO::getItemId)); |
| | | List<ErpSaleOrderCreateReqDTO.Item> items = contractProducts.stream() |
| | | .map(cp -> { |
| | | ErpSaleOrderCreateReqDTO.Item item = new ErpSaleOrderCreateReqDTO.Item(); |
| | | item.setProductId(cp.getItemId()); |
| | | item.setProductPrice(cp.getContractPrice()); |
| | | item.setCount(cp.getCount()); |
| | | // 合同产品默认需要生产:订单审批通过后才能自动创建 MPS, |
| | | // 否则「合同 → 订单 → 生产」链路在合同来源的订单上会断掉。 |
| | | // 若个别产品为外购/转售,可在销售订单明细中把「需要生产」改为否。 |
| | | item.setNeedProduction(1); |
| | | // 只有产品才进入生产计划;温控等外购物料可随合同进入销售订单, |
| | | // 但不能创建 MPS,否则会导致整笔销售订单审批回滚。 |
| | | MdmItemRespDTO mdmItem = itemMap.get(cp.getItemId()); |
| | | item.setNeedProduction(mdmItem != null && MdmItemTypeEnum.isProduct(mdmItem.getItemType()) ? 1 : 0); |
| | | return item; |
| | | }) |
| | | .toList(); |