| | |
| | | import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum; |
| | | import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.math.BigDecimal; |
| | |
| | | |
| | | default CrmReceivableDO selectByNo(String no) { |
| | | return selectOne(CrmReceivableDO::getNo, no); |
| | | } |
| | | |
| | | default int updateByIdAndStatus(Long id, Integer status, CrmReceivableDO updateObj) { |
| | | return update(updateObj, new LambdaUpdateWrapper<CrmReceivableDO>() |
| | | .eq(CrmReceivableDO::getId, id).eq(CrmReceivableDO::getAuditStatus, status)); |
| | | } |
| | | |
| | | default PageResult<CrmReceivableDO> selectPageByCustomerId(CrmReceivablePageReqVO reqVO) { |
| | |
| | | .in(CrmReceivableDO::getAuditStatus, auditStatuses)); |
| | | } |
| | | |
| | | default List<CrmReceivableDO> selectListByInvoiceIdAndStatus(Long invoiceId, Collection<Integer> auditStatuses) { |
| | | return selectList(new LambdaQueryWrapperX<CrmReceivableDO>() |
| | | .eq(CrmReceivableDO::getInvoiceId, invoiceId) |
| | | .in(CrmReceivableDO::getAuditStatus, auditStatuses)); |
| | | } |
| | | |
| | | default Map<Long, BigDecimal> selectReceivablePriceMapByInvoiceId(Collection<Long> invoiceIds) { |
| | | if (CollUtil.isEmpty(invoiceIds)) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | // SQL sum 查询 |
| | | List<Map<String, Object>> result = selectMaps(new QueryWrapper<CrmReceivableDO>() |
| | | .select("invoice_id, SUM(price) AS total_price") |
| | | .in("audit_status", CrmAuditStatusEnum.DRAFT.getStatus(), // 草稿 + 审批中 + 审批通过 |
| | | CrmAuditStatusEnum.PROCESS.getStatus(), CrmAuditStatusEnum.APPROVE.getStatus()) |
| | | .groupBy("invoice_id") |
| | | .in("invoice_id", invoiceIds)); |
| | | // 获得金额 |
| | | return convertMap(result, obj -> (Long) obj.get("invoice_id"), obj -> (BigDecimal) obj.get("total_price")); |
| | | } |
| | | |
| | | default Map<Long, BigDecimal> selectReceivablePriceMapByContractId(Collection<Long> contractIds) { |
| | | if (CollUtil.isEmpty(contractIds)) { |
| | | return Collections.emptyMap(); |