first commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.linke.finance.application.rabbit;
|
||||
|
||||
import com.mhd.common.core.constant.RabbitMqConstants;
|
||||
import org.springframework.amqp.core.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class RabbitMqConfig {
|
||||
|
||||
|
||||
//队列
|
||||
@Bean
|
||||
public Queue queueA() {
|
||||
return new Queue(RabbitMqConstants.TEST_ONE_QUEUE);
|
||||
}
|
||||
|
||||
//广播模式
|
||||
@Bean
|
||||
public FanoutExchange publishSubscribeExchange() {
|
||||
return new FanoutExchange(RabbitMqConstants.TEST_ONE_EXCHANGE);
|
||||
}
|
||||
|
||||
//绑定
|
||||
@Bean
|
||||
public Binding bindingQueueA(Queue queueA, FanoutExchange fanoutExchange) {
|
||||
// 使用 BindingBuilder 提供的方法进行绑定,最后返回Binding对象
|
||||
return BindingBuilder.bind(queueA).to(fanoutExchange);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.linke.finance.application.rabbit.consumer;
|
||||
|
||||
|
||||
import com.mhd.common.core.constant.RabbitMqConstants;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TestLinstener {
|
||||
|
||||
@RabbitListener(queues = RabbitMqConstants.TEST_ONE_QUEUE)
|
||||
public void listenWorkMessage1(String message) {
|
||||
log.info("消费者接受消息:" + message + "-" + LocalDateTime.now());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
package com.linke.finance.application.server.approvalDocument;
|
||||
|
||||
|
||||
import com.linke.finance.domain.approvalDocument.entity.ApprovalDocument;
|
||||
import com.linke.finance.domain.approvalDocument.repository.po.ApprovalDocumentPO;
|
||||
import com.linke.finance.domain.approvalDocument.repository.todo.ApprovalDocumentDO;
|
||||
import com.linke.finance.domain.approvalDocument.repository.todo.WorkflowProcessInstancesByIdDO;
|
||||
import com.linke.finance.domain.approvalDocument.service.ApprovalDocumentDomainService;
|
||||
import com.linke.finance.interfaces.vo.ApprovalStatsVO;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 审批单据ApplicationService
|
||||
*
|
||||
* @author gen
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ApprovalDocumentApplicationService {
|
||||
@Autowired
|
||||
private ApprovalDocumentDomainService approvalDocumentDomainService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询审批单据列表
|
||||
*/
|
||||
|
||||
public List<ApprovalDocumentPO> queryList(ApprovalDocumentDO approvalDocumentDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
approvalDocumentDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
}
|
||||
return approvalDocumentDomainService.queryList(approvalDocumentDO);
|
||||
}
|
||||
public ApprovalStatsVO getApprovalStatistics(){
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long orgId = null;
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
orgId = loginUser.getUserPo().getTopOrganizationId();
|
||||
}
|
||||
}
|
||||
return approvalDocumentDomainService.getApprovalStatistics(orgId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 新增审批单据
|
||||
*/
|
||||
public Boolean insert(ApprovalDocumentDO approvalDocumentDO) {
|
||||
|
||||
return approvalDocumentDomainService.insert(approvalDocumentDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改审批单据
|
||||
*/
|
||||
public Boolean update(ApprovalDocumentDO approvalDocumentDO) {
|
||||
return approvalDocumentDomainService.update(approvalDocumentDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除审批单据
|
||||
*/
|
||||
public boolean delete(Long[] ids) {
|
||||
return approvalDocumentDomainService.delete(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审批单据详细信息
|
||||
*/
|
||||
public ApprovalDocumentPO getInfo(Long id)
|
||||
{
|
||||
return approvalDocumentDomainService.getInfo(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据钉钉审批id获取审批单据详细信息
|
||||
*/
|
||||
public ApprovalDocument getByProcessInstanceId(String processInstanceId)
|
||||
{
|
||||
return approvalDocumentDomainService.getByProcessInstanceId(processInstanceId);
|
||||
}
|
||||
/**
|
||||
* 获取单个审批实例详情
|
||||
*/
|
||||
public WorkflowProcessInstancesByIdDO workflowProcessInstancesById(Long businessDocumentDetaliId)
|
||||
{
|
||||
return approvalDocumentDomainService.workflowProcessInstancesById(businessDocumentDetaliId);
|
||||
}
|
||||
public void workflowProcessInstancesMore(String ids)
|
||||
{
|
||||
approvalDocumentDomainService.workflowProcessInstancesMore(ids);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package com.linke.finance.application.server.approvalDocumentDetail;
|
||||
|
||||
|
||||
import com.linke.finance.domain.approvalDocumentDetail.repository.po.ApprovalDocumentDetailPO;
|
||||
import com.linke.finance.domain.approvalDocumentDetail.repository.todo.ApprovalDocumentDetailDO;
|
||||
import com.linke.finance.domain.approvalDocumentDetail.service.ApprovalDocumentDetailDomainService;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 审批单据明细ApplicationService
|
||||
*
|
||||
* @author gen
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ApprovalDocumentDetailApplicationService {
|
||||
@Autowired
|
||||
private ApprovalDocumentDetailDomainService approvalDocumentDetailDomainService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询审批单据明细列表
|
||||
*/
|
||||
|
||||
public List<ApprovalDocumentDetailPO> queryList(ApprovalDocumentDetailDO approvalDocumentDetailDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
approvalDocumentDetailDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
}
|
||||
return approvalDocumentDetailDomainService.queryList(approvalDocumentDetailDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增审批单据明细
|
||||
*/
|
||||
public Boolean insert(ApprovalDocumentDetailDO approvalDocumentDetailDO) {
|
||||
|
||||
return approvalDocumentDetailDomainService.insert(approvalDocumentDetailDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改审批单据明细
|
||||
*/
|
||||
public Boolean update(ApprovalDocumentDetailDO approvalDocumentDetailDO) {
|
||||
return approvalDocumentDetailDomainService.update(approvalDocumentDetailDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除审批单据明细
|
||||
*/
|
||||
public boolean delete(Long[] ids) {
|
||||
return approvalDocumentDetailDomainService.delete(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审批单据明细详细信息
|
||||
*/
|
||||
public ApprovalDocumentDetailPO getInfo(Long id)
|
||||
{
|
||||
return approvalDocumentDetailDomainService.getInfo(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+1490
File diff suppressed because it is too large
Load Diff
+72
@@ -0,0 +1,72 @@
|
||||
package com.linke.finance.application.server.businessDocumentDetali;
|
||||
|
||||
import com.linke.finance.domain.businessDocumentDetali.repository.todo.AuditRecordsDO;
|
||||
import com.linke.finance.domain.businessDocumentDetali.service.AuditRecordsDomainService;
|
||||
import com.linke.finance.domain.businessDocumentDetali.repository.po.AuditRecordsPO;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 审核记录ApplicationService
|
||||
*
|
||||
* @author gen
|
||||
* @date 2024-03-04
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AuditRecordsApplicationService {
|
||||
@Autowired
|
||||
private AuditRecordsDomainService auditRecordsDomainService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询审核记录列表
|
||||
*/
|
||||
|
||||
public List<AuditRecordsPO> queryList(AuditRecordsDO auditRecordsDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long userId = loginUser.getUserPo().getUserId();
|
||||
if (userId != null && userId != 1L){
|
||||
auditRecordsDO.setCreateBy(userId);
|
||||
}
|
||||
}
|
||||
return auditRecordsDomainService.queryList(auditRecordsDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增审核记录
|
||||
*/
|
||||
public Boolean insert(AuditRecordsDO auditRecordsDO) {
|
||||
|
||||
return auditRecordsDomainService.insert(auditRecordsDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改审核记录
|
||||
*/
|
||||
public Boolean update(AuditRecordsDO auditRecordsDO) {
|
||||
return auditRecordsDomainService.update(auditRecordsDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除审核记录
|
||||
*/
|
||||
public boolean delete(Long[] auditRecordsIds) {
|
||||
return auditRecordsDomainService.delete(auditRecordsIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审核记录详细信息
|
||||
*/
|
||||
public AuditRecordsPO getInfo(Long auditRecordsId)
|
||||
{
|
||||
return auditRecordsDomainService.getInfo(auditRecordsId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package com.linke.finance.application.server.businessDocumentDetali;
|
||||
|
||||
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
|
||||
import com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceResponse;
|
||||
import com.linke.finance.domain.businessDocumentDetali.repository.po.BusinessDocumentDetaliAuditPO;
|
||||
import com.linke.finance.domain.businessDocumentDetali.repository.po.BusinessDocumentDetaliPO;
|
||||
import com.linke.finance.domain.businessDocumentDetali.repository.todo.BusinessDocumentDetaliDO;
|
||||
import com.linke.finance.domain.businessDocumentDetali.service.BusinessDocumentDetaliDomainService;
|
||||
import com.mhd.common.core.domain.po.UserPo;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 业务单据详情ApplicationService
|
||||
*
|
||||
* @author gen
|
||||
* @date 2024-01-23
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BusinessDocumentDetaliApplicationService {
|
||||
@Autowired
|
||||
private BusinessDocumentDetaliDomainService businessDocumentDetaliDomainService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询业务单据详情列表
|
||||
*/
|
||||
|
||||
public List<BusinessDocumentDetaliPO> queryList(BusinessDocumentDetaliDO businessDocumentDetaliDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
if (userPo.getUserAccountType() == 3){
|
||||
businessDocumentDetaliDO.setTopOrganizationId(userPo.getTopOrganizationId());
|
||||
}else {
|
||||
businessDocumentDetaliDO.setOrganizationId(userPo.getOrganizationId());
|
||||
}
|
||||
return businessDocumentDetaliDomainService.queryList(businessDocumentDetaliDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增业务单据详情
|
||||
*/
|
||||
public Boolean insert(BusinessDocumentDetaliDO businessDocumentDetaliDO) {
|
||||
|
||||
return businessDocumentDetaliDomainService.insert(businessDocumentDetaliDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改业务单据详情
|
||||
*/
|
||||
public Boolean update(BusinessDocumentDetaliDO businessDocumentDetaliDO) {
|
||||
return businessDocumentDetaliDomainService.update(businessDocumentDetaliDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除业务单据详情
|
||||
*/
|
||||
public boolean delete(Long[] businessDocumentDetaliIds) {
|
||||
return businessDocumentDetaliDomainService.delete(businessDocumentDetaliIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取业务单据详情详细信息
|
||||
*/
|
||||
public BusinessDocumentDetaliPO getInfo(Long businessDocumentDetaliId)
|
||||
{
|
||||
return businessDocumentDetaliDomainService.getInfo(businessDocumentDetaliId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起钉钉oa审批
|
||||
*/
|
||||
public StartProcessInstanceResponse workflowProcessInstances(String businessDocumentDetaliIds)
|
||||
{
|
||||
return businessDocumentDetaliDomainService.workflowProcessInstances(businessDocumentDetaliIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个审批实例详情
|
||||
*/
|
||||
public GetProcessInstanceResponse workflowProcessInstancesById(Long businessDocumentDetaliId)
|
||||
{
|
||||
return businessDocumentDetaliDomainService.workflowProcessInstancesById(businessDocumentDetaliId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单号及订单来源查询业务单据详情
|
||||
*/
|
||||
public List<BusinessDocumentDetaliPO> selectDetailsByOrderNo(String orderNo, String orderSource) {
|
||||
return businessDocumentDetaliDomainService.selectDetailsByOrderNo(orderNo,orderSource);
|
||||
}
|
||||
|
||||
public List<BusinessDocumentDetaliAuditPO> auditList(BusinessDocumentDetaliDO businessDocumentDetaliDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
// if (loginUser.getRoleIdList() != null && !loginUser.getRoleIdList().isEmpty()){
|
||||
// businessDocumentDetaliDO.setRoleIds(loginUser.getRoleIdList());
|
||||
// }
|
||||
if (StringUtils.isNotBlank(businessDocumentDetaliDO.getWaybillNumbers())){
|
||||
businessDocumentDetaliDO.setWaybillNumberList(Arrays.asList(businessDocumentDetaliDO.getWaybillNumbers().split(",")));
|
||||
}
|
||||
businessDocumentDetaliDO.setOrganizationId(loginUser.getOrganizationPo().getOrganizationId());
|
||||
//businessDocumentDetaliDO.setAuditStatus(0);//查询未审核的
|
||||
List<BusinessDocumentDetaliAuditPO> businessDocumentDetaliAuditPOS = businessDocumentDetaliDomainService.auditList(businessDocumentDetaliDO);
|
||||
// businessDocumentDetaliAuditPOS.forEach(e->{
|
||||
// if (e.getService() != null && e.getAmount() != null){
|
||||
// e.setTotalAmount(e.getAmount().add(e.getService()));
|
||||
// }
|
||||
// });
|
||||
return businessDocumentDetaliAuditPOS;
|
||||
}
|
||||
|
||||
public List<BusinessDocumentDetaliAuditPO> auditDetailList(BusinessDocumentDetaliDO businessDocumentDetaliDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser == null){
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
businessDocumentDetaliDO.setCreateBy(loginUser.getUserPo().getUserId());
|
||||
return businessDocumentDetaliDomainService.auditDetailList(businessDocumentDetaliDO);
|
||||
}
|
||||
|
||||
public Boolean deleteBusinessDocumentDetailById(Long businessDocumentDetaliId)
|
||||
{
|
||||
return businessDocumentDetaliDomainService.deleteBusinessDocumentDetailById(businessDocumentDetaliId);
|
||||
}
|
||||
}
|
||||
+617
@@ -0,0 +1,617 @@
|
||||
package com.linke.finance.application.server.reconciliation;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyun.dingtalkworkflow_1_0.models.StartProcessInstanceResponse;
|
||||
import com.linke.finance.domain.businessDocument.entity.BusinessDocument;
|
||||
import com.linke.finance.domain.businessDocument.service.BusinessDocumentDomainService;
|
||||
import com.linke.finance.domain.reconciliation.entity.Reconciliation;
|
||||
import com.linke.finance.domain.reconciliation.entity.ReconciliationBusinessDocument;
|
||||
import com.linke.finance.domain.reconciliation.entity.ReconciliationOrderDetail;
|
||||
import com.linke.finance.domain.reconciliation.repository.po.FinacialReconciliationListVO;
|
||||
import com.linke.finance.domain.reconciliation.repository.po.ReconciliationOrderDetailPO;
|
||||
import com.linke.finance.domain.reconciliation.repository.po.ReconciliationPO;
|
||||
import com.linke.finance.domain.reconciliation.repository.todo.ReconciliationDO;
|
||||
import com.linke.finance.domain.reconciliation.service.ReconciliationDomainService;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.entity.RevenueExpensesRecord;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.service.RevenueExpensesRecordDomainService;
|
||||
import com.linke.finance.domain.tmsReceipt.repository.po.TmsReceiptPO;
|
||||
import com.linke.finance.domain.tmsReceipt.service.TmsReceiptDomainService;
|
||||
import com.linke.finance.domain.verification.service.VerificationDomainService;
|
||||
import com.linke.finance.infrastructure.feign.ProductServiceFeign;
|
||||
import com.mhd.common.core.constant.SubjectConstants;
|
||||
import com.mhd.common.core.domain.dto.ReconciliationDTO;
|
||||
import com.mhd.common.core.domain.entity.Verification;
|
||||
import com.mhd.common.core.domain.po.OrganizationPo;
|
||||
import com.mhd.common.core.domain.po.UserPo;
|
||||
import com.mhd.common.core.enums.*;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.utils.OrderSequence;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.core.utils.bean.BeanUtils;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 对账单ApplicationService
|
||||
*
|
||||
* @author gen
|
||||
* @date 2024-01-23
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ReconciliationApplicationService {
|
||||
@Autowired
|
||||
private ReconciliationDomainService reconciliationDomainService;
|
||||
@Autowired
|
||||
private BusinessDocumentDomainService businessDocumentDomainService;
|
||||
@Autowired
|
||||
private ProductServiceFeign productServiceFeign;
|
||||
@Autowired
|
||||
private VerificationDomainService verificationDomainService;
|
||||
@Autowired
|
||||
private TmsReceiptDomainService tmsReceiptDomainService;
|
||||
@Autowired
|
||||
private RevenueExpensesRecordDomainService revenueExpensesRecordDomainService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询对账单列表
|
||||
*/
|
||||
|
||||
public List<ReconciliationPO> queryList(ReconciliationDO reconciliationDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
if (userPo.getUserAccountType() == 3) {
|
||||
reconciliationDO.setTopOrganizationId(userPo.getTopOrganizationId());
|
||||
} else if (userPo.getUserAccountType() == 2){
|
||||
reconciliationDO.setOrganizationId(userPo.getOrganizationId());
|
||||
} else {
|
||||
if (loginUser.getRoleList().contains(RoleEnum.SHIPPER.getCode()) || loginUser.getRoleList().contains(RoleEnum.COMPANY.getCode())){
|
||||
reconciliationDO.setUserId(userPo.getUserId());
|
||||
}else {
|
||||
reconciliationDO.setOrganizationId(userPo.getOrganizationId());
|
||||
}
|
||||
}
|
||||
return reconciliationDomainService.queryList(reconciliationDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口使用:返回应收账单及账单明细
|
||||
* @param reconciliationIds
|
||||
* @return
|
||||
*/
|
||||
public FinacialReconciliationListVO queryListByids(List<Long> reconciliationIds) {
|
||||
List<Reconciliation> reconciliationList = reconciliationDomainService.queryListByids(reconciliationIds);
|
||||
FinacialReconciliationListVO returnBean = new FinacialReconciliationListVO();
|
||||
List<FinacialReconciliationListVO.FinacialReconciliationVO> returnList = new ArrayList<FinacialReconciliationListVO.FinacialReconciliationVO>();
|
||||
for (Reconciliation reconciliation:reconciliationList) {
|
||||
FinacialReconciliationListVO bean = new FinacialReconciliationListVO();
|
||||
FinacialReconciliationListVO.FinacialReconciliationVO finacialBean = new FinacialReconciliationListVO.FinacialReconciliationVO();
|
||||
//查询明细
|
||||
List<ReconciliationOrderDetail> detailList = reconciliationDomainService.selectDetailListByReconciliationId(reconciliation.getReconciliationId());
|
||||
BeanUtils.copyProperties(reconciliation, finacialBean);
|
||||
List<ReconciliationOrderDetailPO> targetList = detailList.stream()
|
||||
.map(source -> {
|
||||
ReconciliationOrderDetailPO target = new ReconciliationOrderDetailPO();
|
||||
BeanUtils.copyProperties(source, target);
|
||||
return target;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
finacialBean.setFinacialReconciliationDetailList(targetList);
|
||||
returnList.add(finacialBean);
|
||||
}
|
||||
returnBean.setFinacialReconciliationList(returnList);
|
||||
return returnBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增对账单
|
||||
*/
|
||||
public ReconciliationDO insert(ReconciliationDO reconciliationDO) {
|
||||
|
||||
return reconciliationDomainService.insert(reconciliationDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改对账单
|
||||
*/
|
||||
public Boolean update(ReconciliationDO reconciliationDO) {
|
||||
return reconciliationDomainService.update(reconciliationDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除对账单
|
||||
*/
|
||||
public boolean delete(Long[] reconciliationIds) {
|
||||
return reconciliationDomainService.delete(reconciliationIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对账单详细信息
|
||||
*/
|
||||
public ReconciliationPO getInfo(Long reconciliationId) {
|
||||
ReconciliationPO info = reconciliationDomainService.getInfo(reconciliationId);
|
||||
List<BusinessDocument> list = reconciliationDomainService.selectBusinessByReconciliationId(reconciliationId);
|
||||
info.setBusinessDocumentList(list);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成对账单(调账对账)
|
||||
*
|
||||
* @param reconciliationDO
|
||||
*/
|
||||
@Transactional
|
||||
public void creatStatementAccount(ReconciliationDO reconciliationDO) {
|
||||
List<String> orderIdsList = reconciliationDO.getTmsOrderIdList();
|
||||
if (orderIdsList == null || orderIdsList.size() == 0) {
|
||||
throw new ServiceException("选择对账订单异常!");
|
||||
}
|
||||
|
||||
List<ReconciliationOrderDetail> reconciliationOrderDetailList = reconciliationDomainService.selectReconciliationOrderDetailListByIds(orderIdsList);
|
||||
reconciliationOrderDetailList.forEach(e -> {
|
||||
if (e.getReconciliationId() != null && e.getReconciliationId() != 0L) {
|
||||
throw new ServiceException("订单已创建对账单,请核对后再试!");
|
||||
}
|
||||
});
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
reconciliationDO = reconciliationDomainService.insert(reconciliationDO);
|
||||
if(reconciliationDO==null){
|
||||
throw new ServiceException("订单出账-生成应收账单失败!");
|
||||
}
|
||||
//生成应收挂账流水
|
||||
Date now = new Date();
|
||||
RevenueExpensesRecord record = new RevenueExpensesRecord();
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour;
|
||||
record.setInnerNumber(innerNumber);
|
||||
record.setDepartmentName(reconciliationDO.getDepartmentName());
|
||||
record.setMoney(reconciliationDO.getVerificationMoney());
|
||||
record.setFirstSubject(SubjectCodeEnum.first_sykh_ysfy.getCode());
|
||||
record.setFirstSubjectName(SubjectCodeEnum.first_sykh_ysfy.getItem());
|
||||
record.setSecondSubject(SubjectCodeEnum.second_sykh_khyf.getCode());
|
||||
record.setSecondSubjectName(SubjectCodeEnum.second_sykh_khyf.getItem());
|
||||
record.setPayType(PayTypeEnum.CASH.getValue());
|
||||
record.setExpenseItem(ExpenseItemEnum.SYKH.getItem());
|
||||
record.setPayee(ExpenseItemEnum.SYKH.getItem());//付款对象
|
||||
record.setPayId("");
|
||||
record.setPayName(reconciliationDO.getPartyName());
|
||||
record.setAccountingReasons("订单出账");
|
||||
record.setDepartmentId("");
|
||||
record.setBusinessDocumentId(reconciliationDO.getReconciliationId());
|
||||
record.setBusinessDocumentNumber(reconciliationDO.getInnerNumber());
|
||||
record.setBusinessTypeItem(BussinessEnum.ORDER.getValue());
|
||||
record.setVoucherImages("");
|
||||
record.setKingdee(KingdeeEnum.kingdee_ysgz.getItem());
|
||||
|
||||
|
||||
record.setPayChannel("");
|
||||
record.setPayChannelName("");
|
||||
record.setBankNumber("");
|
||||
record.setBankAccount("");
|
||||
record.setRevenueExpensesType(3);//挂账
|
||||
record.setRemark("");
|
||||
record.setDayToDayStatus(1);//流水状态:1.正常2.作废
|
||||
record.setEntryValue(1);//系统入账
|
||||
record.setOrganizationId(reconciliationDO.getOrganizationId());
|
||||
record.setTopOrganizationId(reconciliationDO.getTopOrganizationId());
|
||||
record.setCreateTime(now);
|
||||
record.setCreateBy(reconciliationDO.getCreateBy());
|
||||
record.setCreateByName(reconciliationDO.getCreateByName());
|
||||
int num = revenueExpensesRecordDomainService.insertRevenueExpensesRecord(record);
|
||||
if(num<=0){
|
||||
throw new ServiceException("订单出账-生成应收挂账流水失败!");
|
||||
}
|
||||
|
||||
List<ReconciliationOrderDetail> list = new ArrayList<>();
|
||||
for (String orderId : orderIdsList) {
|
||||
ReconciliationOrderDetail detailBean = new ReconciliationOrderDetail();
|
||||
detailBean.setReconciliationId(reconciliationDO.getReconciliationId());
|
||||
detailBean.setTmsOrderId(orderId);
|
||||
detailBean.setDelFlag(1);
|
||||
detailBean.setCreateTime(new Date());
|
||||
detailBean.setCreateBy(loginUser.getUserid());
|
||||
detailBean.setCreateByName(loginUser.getUsername());
|
||||
list.add(detailBean);
|
||||
}
|
||||
boolean flag = reconciliationDomainService.saveDetailBatch(list);
|
||||
if(!flag){
|
||||
throw new ServiceException("订单出账-生成应收账单明细失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 对账单申请、审核、拒绝审核
|
||||
*
|
||||
* @param reconciliationDO
|
||||
*/
|
||||
public void authReconciliation(ReconciliationDO reconciliationDO) {
|
||||
List<Long> reconciliationIdList = reconciliationDO.getReconciliationIdList();
|
||||
if (reconciliationIdList == null || reconciliationIdList.isEmpty()) {
|
||||
throw new ServiceException("至少选择一条记录进行操作!");
|
||||
}
|
||||
//获取登录人信息
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long auditor = reconciliationDO.getAuditState();
|
||||
if (auditor == null || auditor == 0L) {
|
||||
throw new ServiceException("审核状态异常!");
|
||||
}
|
||||
//收支核销集合
|
||||
List<Verification> verificationList = new ArrayList<>();
|
||||
for (Long reconsiliationId : reconciliationIdList) {
|
||||
reconciliationDO.setReconciliationId(reconsiliationId);
|
||||
ReconciliationPO info = this.getInfo(reconsiliationId);
|
||||
if (auditor == 2L) {
|
||||
if (info.getAuditState() != 1L) {
|
||||
throw new ServiceException("只能对未申请的对账单进行申请操作");
|
||||
}
|
||||
reconciliationDO.setCreateTime(new Date());
|
||||
reconciliationDO.setCreateBy(loginUser.getUserPo().getUserId());
|
||||
reconciliationDO.setCreateByName(loginUser.getUserPo().getUserName());
|
||||
reconciliationDomainService.update(reconciliationDO);
|
||||
}
|
||||
if (auditor == 3L) {
|
||||
if (info.getAuditState() != 2L) {
|
||||
throw new ServiceException("只能对已申请的对账单进行审核操作");
|
||||
}
|
||||
reconciliationDO.setAuthTime(new Date());
|
||||
reconciliationDO.setAuditor(loginUser.getUserPo().getUserId());
|
||||
reconciliationDO.setAuditorName(loginUser.getUserPo().getUserName());
|
||||
reconciliationDomainService.update(reconciliationDO);
|
||||
//生成收入核销记录
|
||||
Verification verification = packVerication(info);
|
||||
|
||||
verificationList.add(verification);
|
||||
|
||||
}
|
||||
if (auditor == 4L) {
|
||||
if (info.getAuditState() != 2L) {
|
||||
throw new ServiceException("只能对已申请的对账单进行审核拒绝操作");
|
||||
}
|
||||
List<BusinessDocument> businessDocumentList = info.getBusinessDocumentList();
|
||||
for (BusinessDocument businessDocument : businessDocumentList) {
|
||||
businessDocument.setReconciliationId(0L);
|
||||
}
|
||||
reconciliationDO.setAuthTime(new Date());
|
||||
reconciliationDO.setAuditor(loginUser.getUserPo().getUserId());
|
||||
reconciliationDO.setAuditorName(loginUser.getUserPo().getUserName());
|
||||
businessDocumentDomainService.updateBatchById(businessDocumentList);
|
||||
reconciliationDomainService.delReconciliationBusinessDocumentByReconciliationId(reconciliationDO.getReconciliationId());
|
||||
reconciliationDomainService.update(reconciliationDO);
|
||||
}
|
||||
}
|
||||
if (!verificationList.isEmpty()){
|
||||
//批量新增核销记录
|
||||
verificationDomainService.batchAddVerification(verificationList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 核实对账单
|
||||
*
|
||||
* @param reconciliationDO
|
||||
*/
|
||||
public void checkReconciliation(ReconciliationDO reconciliationDO) {
|
||||
//获取登录人
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
reconciliationDO.setWaybillVerifyFlag(reconciliationDO.getWaybillVerifyFlag());
|
||||
reconciliationDO.setWaybillVerifyTime(new Date());
|
||||
reconciliationDO.setUpdateBy(loginUser.getUserPo().getUserId());
|
||||
reconciliationDO.setUpdateByName(loginUser.getUserPo().getUserName());
|
||||
reconciliationDO.setUpdateTime(new Date());
|
||||
reconciliationDomainService.update(reconciliationDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装核销记录
|
||||
*
|
||||
* @param reconciliationPO
|
||||
* @return
|
||||
*/
|
||||
public Verification packVerication(ReconciliationPO reconciliationPO) {
|
||||
//获取登录人信息
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Verification verification = new Verification();
|
||||
// verification.setVerificationType(1);
|
||||
verification.setOrganizationId(reconciliationPO.getOrganizationId());
|
||||
verification.setTopOrganizationId(reconciliationPO.getTopOrganizationId());
|
||||
verification.setInnerNumber(OrderSequence.getOrderCode());
|
||||
// verification.setWaybillNumber(reconciliationPO.getInnerNumber());
|
||||
// verification.setWaybillSource(reconciliationPO.getWaybillSource());
|
||||
// verification.setWaybillSourceName(reconciliationPO.getWaybillSourceName());
|
||||
verification.setFirstSubject(SubjectConstants.FIRST_SUBJECT_DZ_ONE.getCode());
|
||||
verification.setFirstSubjectName(SubjectConstants.FIRST_SUBJECT_DZ_ONE.getName());
|
||||
verification.setSecondSubject(SubjectConstants.FIRST_SUBJECT_DZ_ONE_SECOUND.getCode());
|
||||
verification.setSecondSubjectName(SubjectConstants.FIRST_SUBJECT_DZ_ONE_SECOUND.getName());
|
||||
|
||||
verification.setVerificationMoney(reconciliationPO.getActualReceivable());
|
||||
verification.setPayPersonId(reconciliationPO.getUserId());
|
||||
verification.setPayPerson(reconciliationPO.getShipperName());
|
||||
|
||||
AjaxResult organizationInfo = productServiceFeign.getOrganizationInfo(reconciliationPO.getOrganizationId());
|
||||
OrganizationPo organizationPo = new OrganizationPo();
|
||||
if ("200".equals(String.valueOf(organizationInfo.get("code")))) {
|
||||
organizationPo = JSONObject.parseObject(JSONObject.toJSONString(organizationInfo.get("data")), OrganizationPo.class);
|
||||
}
|
||||
Long principalId = organizationPo.getPrincipalId();
|
||||
String principalName = organizationPo.getPrincipalName();
|
||||
// verification.setEnterAccountId(principalId);
|
||||
// verification.setEnterAccountName(principalName);
|
||||
|
||||
verification.setVerificationStatus(5);
|
||||
verification.setCreateTime(new Date());
|
||||
verification.setCreateBy(loginUser.getUserid());
|
||||
verification.setCreateByName(loginUser.getUsername());
|
||||
return verification;
|
||||
}
|
||||
public void deleteByNumbers(List<ReconciliationDTO> list) {
|
||||
//现查询验证权限
|
||||
List<String> innerNumbers = new ArrayList<>();
|
||||
for (ReconciliationDTO bean:list) {
|
||||
innerNumbers.add(bean.getInnerNumber());
|
||||
}
|
||||
List<Reconciliation> reconciliationList = reconciliationDomainService.selectReconciliationListByNumber(innerNumbers);
|
||||
for (Reconciliation reconciliation :reconciliationList) {
|
||||
if(reconciliation.getCollectionState()>1){
|
||||
throw new ServiceException(reconciliation.getInnerNumber()+"已结算,不可作废");
|
||||
}
|
||||
}
|
||||
//判断流水是否已经金蝶推送,只有未推送的允许作废(根据已知的应收账单单据号,赋值流水表的业务单据号进行关联查询)
|
||||
List<RevenueExpensesRecord> recordList = revenueExpensesRecordDomainService.selectRevenueExpensesRecordListByBusinessDocumentId(innerNumbers);
|
||||
for (RevenueExpensesRecord record :recordList) {
|
||||
if(record.getKingdeePushStatus()>0){
|
||||
throw new ServiceException(record.getBusinessDocumentNumber()+"已向金蝶推送数据,不可作废");
|
||||
}
|
||||
}
|
||||
//应收账单生成的挂账流水冲正
|
||||
List<RevenueExpensesRecord> recordSaveList = new ArrayList<>();
|
||||
for (RevenueExpensesRecord record :recordList) {
|
||||
RevenueExpensesRecord bean = new RevenueExpensesRecord();
|
||||
BeanUtils.copyProperties(record,bean,"revenueExpensesRecordId");
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour;
|
||||
bean.setInnerNumber(innerNumber);
|
||||
bean.setKingdee(KingdeeEnum.kingdee_gzhc.getItem());
|
||||
recordSaveList.add(bean);
|
||||
}
|
||||
if(recordSaveList.size()>0){
|
||||
boolean batchSaveFlag = revenueExpensesRecordDomainService.batchAddRevenueExpensesRecord(recordSaveList);
|
||||
if(!batchSaveFlag){
|
||||
throw new ServiceException("批量生成挂账对冲流水失败!");
|
||||
}
|
||||
|
||||
}
|
||||
//作废应收对账与明细
|
||||
for (Reconciliation reconciliation :reconciliationList) {
|
||||
reconciliationDomainService.delReconciliationByInnerNumber(reconciliation.getInnerNumber());
|
||||
reconciliationDomainService.delReconciliationDetailByInnerNumber(reconciliation.getReconciliationId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 运费结算-更新对账单
|
||||
* @param reconciliationDO
|
||||
*/
|
||||
@Transactional
|
||||
public void pushAccountSettlement(ReconciliationDO reconciliationDO,Long receiptId) {
|
||||
ReconciliationPO bean = reconciliationDomainService.getInfo(reconciliationDO.getReconciliationId());
|
||||
//应收账单:更新已收,少收,未收和结算状态
|
||||
BigDecimal collectionAmountOld = bean.getCollectionAmount();
|
||||
bean.setCollectionAmount(collectionAmountOld.add(reconciliationDO.getCollectionAmount()));//已收
|
||||
BigDecimal changeAmountOld = bean.getChangeAmount();
|
||||
bean.setChangeAmount(changeAmountOld.add(reconciliationDO.getChangeAmount()));
|
||||
BigDecimal uncollectedReceivable = bean.getReceivable().subtract(bean.getCollectionAmount()).subtract(bean.getChangeAmount()); //未收=应收-已收-少收
|
||||
bean.setUncollectedReceivable(uncollectedReceivable);
|
||||
Long collectionState = uncollectedReceivable.compareTo(BigDecimal.ZERO)>0?1L:2L;//有未收则为部分结算
|
||||
bean.setCollectionState(collectionState);//结算状态
|
||||
String oldSettlementRemark = bean.getSettlementRemark()==null?"":StringUtils.isBlank(bean.getSettlementRemark())?"":bean.getSettlementRemark();
|
||||
if(StringUtils.isNotBlank(reconciliationDO.getSettlementRemark())){
|
||||
bean.setSettlementRemark(oldSettlementRemark+","+reconciliationDO.getSettlementRemark());
|
||||
}
|
||||
|
||||
int num = reconciliationDomainService.updateAmountById(bean);
|
||||
if(num>0){
|
||||
//收款单:更新收款单相关信息:将可分配金额-本次收款合计
|
||||
Long receiptId1 = receiptId;
|
||||
TmsReceiptPO receiptPo = tmsReceiptDomainService.getInfo(receiptId);
|
||||
BigDecimal assignableAmount = receiptPo.getAssignableAmount().subtract(reconciliationDO.getCollectionAmount());
|
||||
if(assignableAmount.compareTo(BigDecimal.ZERO)<0){
|
||||
throw new ServiceException("收款合计大于可分配金额,处理异常!");
|
||||
}
|
||||
receiptPo.setAssignableAmount(assignableAmount);
|
||||
//分配状态(0未分配,1部分分配,2已分配)
|
||||
Integer assignmentStatus = receiptPo.getAssignmentStatus();
|
||||
if(assignableAmount.compareTo(BigDecimal.ZERO)>0){
|
||||
receiptPo.setAssignmentStatus(1);
|
||||
}else if(assignableAmount.compareTo(BigDecimal.ZERO)==0){
|
||||
receiptPo.setAssignmentStatus(2);
|
||||
}
|
||||
|
||||
int receiptNum = tmsReceiptDomainService.updateAssignableAmount(receiptPo);
|
||||
if(receiptNum<=0){
|
||||
throw new ServiceException("更新收款单可分配金额失败!");
|
||||
}
|
||||
|
||||
//生成流水:应收账单结算--应收减少
|
||||
Date now = new Date();
|
||||
RevenueExpensesRecord record = new RevenueExpensesRecord();
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour;
|
||||
record.setInnerNumber(innerNumber);
|
||||
record.setDepartmentName(bean.getDepartmentName());
|
||||
record.setMoney(reconciliationDO.getVerificationMoney());//本次收款金额
|
||||
record.setFirstSubject(SubjectCodeEnum.first_sykh_ysfy.getCode());
|
||||
record.setFirstSubjectName(SubjectCodeEnum.first_sykh_ysfy.getItem());
|
||||
record.setSecondSubject(SubjectCodeEnum.second_sykh_khyf.getCode());
|
||||
record.setSecondSubjectName(SubjectCodeEnum.second_sykh_khyf.getItem());
|
||||
record.setPayType(PayTypeEnum.CASH.getValue());
|
||||
record.setExpenseItem(ExpenseItemEnum.SYKH.getItem());
|
||||
record.setPayee(ExpenseItemEnum.SYKH.getItem());//付款对象
|
||||
record.setPayId("");
|
||||
record.setPayName(bean.getPartyName());
|
||||
record.setAccountingReasons("应收账单结算");
|
||||
record.setDepartmentId("");
|
||||
record.setBusinessDocumentId(bean.getReconciliationId());
|
||||
record.setBusinessDocumentNumber(bean.getInnerNumber());
|
||||
record.setBusinessTypeItem(BussinessEnum.ORDER.getValue());
|
||||
record.setVoucherImages("");
|
||||
record.setKingdee(KingdeeEnum.kingdee_ysjs.getItem());
|
||||
record.setPayChannel("");
|
||||
record.setPayChannelName("");
|
||||
record.setBankNumber("");
|
||||
record.setBankAccount("");
|
||||
record.setRevenueExpensesType(1);//收入
|
||||
record.setRemark("");
|
||||
record.setDayToDayStatus(1);//流水状态:1.正常2.作废
|
||||
record.setEntryValue(1);//系统入账
|
||||
record.setOrganizationId(reconciliationDO.getOrganizationId());
|
||||
record.setTopOrganizationId(reconciliationDO.getTopOrganizationId());
|
||||
record.setCreateTime(now);
|
||||
record.setCreateBy(reconciliationDO.getCreateBy());
|
||||
record.setCreateByName(reconciliationDO.getCreateByName());
|
||||
int recordSaveNum = revenueExpensesRecordDomainService.insertRevenueExpensesRecord(record);
|
||||
if(recordSaveNum<=0){
|
||||
throw new ServiceException("应收账单结算-生成应收减少流水失败!");
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
throw new ServiceException("更新应收账单失败!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* tms推送消息:批量结算
|
||||
* @param reconciliationList
|
||||
* @param receiptId
|
||||
*/
|
||||
@Transactional
|
||||
public void pushBatchAccountSettlement(List<FinacialReconciliationListVO.FinacialReconciliationVO> reconciliationList, Long receiptId) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if(loginUser==null){
|
||||
throw new ServiceException("未获取到登录用户信息!");
|
||||
}
|
||||
Date now = new Date();
|
||||
List<FinacialReconciliationListVO.FinacialReconciliationVO> reconciliationList2= reconciliationList;
|
||||
List<RevenueExpensesRecord> recordList = new ArrayList<>();
|
||||
//将所有对账单的已收更新为=原已收+未收,未收=0,少收不变,状态改为=已结算
|
||||
BigDecimal allUncollectedReceivable = BigDecimal.ZERO;
|
||||
for (FinacialReconciliationListVO.FinacialReconciliationVO reconciliation:reconciliationList) {
|
||||
Long reconciliationId = reconciliation.getReconciliationId();
|
||||
ReconciliationPO reconciliationPO = reconciliationDomainService.getInfo(reconciliationId);
|
||||
BigDecimal uncollectedReceivable = reconciliation.getUncollectedReceivable();//推送来的未收金额
|
||||
if(reconciliationPO.getUncollectedReceivable().compareTo(uncollectedReceivable)!=0){
|
||||
throw new ServiceException(reconciliationPO.getInnerNumber()+"未收金额发生了改变,请重新加载数据!");
|
||||
}
|
||||
allUncollectedReceivable = allUncollectedReceivable.add(uncollectedReceivable);
|
||||
//用于操作人更新
|
||||
reconciliationPO.setUpdateTime(new Date());
|
||||
reconciliationPO.setUpdateBy(loginUser.getUserid());
|
||||
reconciliationPO.setUpdateByName(loginUser.getUsername());
|
||||
reconciliationDomainService.updateReconcliationById(reconciliationPO);
|
||||
//批量结算:应收减少流水新增
|
||||
if(reconciliationPO.getUncollectedReceivable().compareTo(BigDecimal.ZERO)>0){
|
||||
RevenueExpensesRecord record = new RevenueExpensesRecord();
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour;
|
||||
record.setInnerNumber(innerNumber);
|
||||
record.setDepartmentName(reconciliationPO.getDepartmentName());
|
||||
record.setMoney(reconciliationPO.getUncollectedReceivable());//本次收款金额==》账单未收
|
||||
record.setFirstSubject(SubjectCodeEnum.first_sykh_ysfy.getCode());
|
||||
record.setFirstSubjectName(SubjectCodeEnum.first_sykh_ysfy.getItem());
|
||||
record.setSecondSubject(SubjectCodeEnum.second_sykh_khyf.getCode());
|
||||
record.setSecondSubjectName(SubjectCodeEnum.second_sykh_khyf.getItem());
|
||||
record.setPayType(PayTypeEnum.CASH.getValue());
|
||||
record.setExpenseItem(ExpenseItemEnum.SYKH.getItem());
|
||||
record.setPayee(ExpenseItemEnum.SYKH.getItem());//付款对象
|
||||
record.setPayId("");
|
||||
record.setPayName(reconciliationPO.getPartyName());
|
||||
record.setAccountingReasons("应收账单批量结算");
|
||||
record.setDepartmentId("");
|
||||
record.setBusinessDocumentId(reconciliationPO.getReconciliationId());
|
||||
record.setBusinessDocumentNumber(reconciliationPO.getInnerNumber());
|
||||
record.setBusinessTypeItem(BussinessEnum.ORDER.getValue());
|
||||
record.setVoucherImages("");
|
||||
record.setKingdee(KingdeeEnum.kingdee_ysjs.getItem());
|
||||
record.setPayChannel("");
|
||||
record.setPayChannelName("");
|
||||
record.setBankNumber("");
|
||||
record.setBankAccount("");
|
||||
record.setRevenueExpensesType(1);//收入
|
||||
record.setRemark("");
|
||||
record.setDayToDayStatus(1);//流水状态:1.正常2.作废
|
||||
record.setEntryValue(1);//系统入账
|
||||
record.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
record.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
record.setCreateTime(now);
|
||||
record.setCreateBy(loginUser.getUserid());
|
||||
record.setCreateByName(loginUser.getUsername());
|
||||
recordList.add(record);
|
||||
}
|
||||
|
||||
}
|
||||
if(recordList.size()>0){
|
||||
boolean batchSaveFlag = revenueExpensesRecordDomainService.batchAddRevenueExpensesRecord(recordList);
|
||||
if(!batchSaveFlag){
|
||||
throw new ServiceException("应收账单批量结算-生成应收减少流水失败!");
|
||||
}
|
||||
}
|
||||
//更新收款单的可分配金额=原可分配金额-应收账单所有未收金额,分配状态根据剩余可分配金额是否大于0赋值
|
||||
TmsReceiptPO receiptPo = tmsReceiptDomainService.getInfo(receiptId);
|
||||
BigDecimal assignableAmount = receiptPo.getAssignableAmount().subtract(allUncollectedReceivable);
|
||||
if(assignableAmount.compareTo(BigDecimal.ZERO)<0){
|
||||
throw new ServiceException("收款合计大于可分配金额,处理异常!");
|
||||
}
|
||||
receiptPo.setAssignableAmount(assignableAmount);
|
||||
//分配状态(0未分配,1部分分配,2已分配)
|
||||
Integer assignmentStatus = receiptPo.getAssignmentStatus();
|
||||
if(assignableAmount.compareTo(BigDecimal.ZERO)>0){
|
||||
receiptPo.setAssignmentStatus(1);
|
||||
}else if(assignableAmount.compareTo(BigDecimal.ZERO)==0){
|
||||
receiptPo.setAssignmentStatus(2);
|
||||
}
|
||||
|
||||
int receiptNum = tmsReceiptDomainService.updateAssignableAmount(receiptPo);
|
||||
if(receiptNum<=0){
|
||||
throw new ServiceException("更新收款单可分配金额失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起钉钉oa审批
|
||||
*/
|
||||
public StartProcessInstanceResponse workflowProcessInstances(String businessDocumentDetaliIds)
|
||||
{
|
||||
return reconciliationDomainService.workflowProcessInstances(businessDocumentDetaliIds);
|
||||
}
|
||||
|
||||
public int editIsInvoice(String innerNumber, Integer isInvoice, String invoiceId, String invoiceMakeTime,String applyNumber)
|
||||
{
|
||||
return reconciliationDomainService.editIsInvoice(innerNumber,isInvoice,invoiceId,invoiceMakeTime,applyNumber);
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
package com.linke.finance.application.server.tmsReceipt;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.entity.RevenueExpensesRecord;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.service.RevenueExpensesRecordDomainService;
|
||||
import com.linke.finance.domain.tmsReceipt.entity.TmsReceipt;
|
||||
import com.linke.finance.domain.tmsReceipt.repository.facade.ITmsReceiptService;
|
||||
import com.linke.finance.domain.tmsReceipt.repository.po.TmsReceiptPO;
|
||||
import com.linke.finance.domain.tmsReceipt.repository.todo.TmsReceiptDO;
|
||||
import com.linke.finance.domain.tmsReceipt.service.TmsReceiptDomainService;
|
||||
import com.linke.finance.interfaces.dto.TmsReceiptDTO;
|
||||
import com.mhd.common.core.enums.*;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
||||
import com.mhd.common.core.utils.IgnoreNullUtil;
|
||||
import com.mhd.common.core.utils.OrderSequence;
|
||||
import com.mhd.common.core.utils.bean.BeanUtils;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 收款单ApplicationService
|
||||
*
|
||||
* @author gen
|
||||
* @date 2025-04-28
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TmsReceiptApplicationService {
|
||||
@Autowired
|
||||
private TmsReceiptDomainService tmsReceiptDomainService;
|
||||
@Autowired
|
||||
private ITmsReceiptService tmsReceiptService;
|
||||
@Autowired
|
||||
private RevenueExpensesRecordDomainService revenueExpensesRecordDomainService;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询收款单列表
|
||||
*/
|
||||
|
||||
public List<TmsReceiptPO> queryList(TmsReceiptDO tmsReceiptDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
tmsReceiptDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
}
|
||||
return tmsReceiptDomainService.queryList(tmsReceiptDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增收款单
|
||||
*/
|
||||
public Boolean insert(TmsReceiptDO tmsReceiptDO) {
|
||||
|
||||
return tmsReceiptDomainService.insert(tmsReceiptDO);
|
||||
}
|
||||
/**
|
||||
* 修改收款单
|
||||
*/
|
||||
public Boolean update(TmsReceiptDO tmsReceiptDO) {
|
||||
return tmsReceiptDomainService.update(tmsReceiptDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除收款单
|
||||
*/
|
||||
public boolean delete(Long[] ids) {
|
||||
return tmsReceiptDomainService.delete(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取收款单详细信息
|
||||
*/
|
||||
public TmsReceiptPO getInfo(Long id)
|
||||
{
|
||||
return tmsReceiptDomainService.getInfo(id);
|
||||
}
|
||||
|
||||
public Boolean chargeOnAccount(TmsReceiptDTO tmsReceiptDTO) {
|
||||
return tmsReceiptDomainService.chargeOnAccount(tmsReceiptDTO);
|
||||
}
|
||||
@Transactional
|
||||
public boolean saveBatch(List<TmsReceiptDTO> tmsReceiptDTOList ) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
Date now = new Date();
|
||||
String userName = loginUser.getUsername();
|
||||
// 获取登录人id
|
||||
Long userId = loginUser.getUserid();
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
String organizationName = loginUser.getUserPo().getOrganizationName();
|
||||
List<RevenueExpensesRecord> revenueList = new ArrayList<>();
|
||||
for (TmsReceiptDTO dto:tmsReceiptDTOList){
|
||||
TmsReceiptDO tmsReceiptDO = new TmsReceiptDO();
|
||||
BeanUtils.copyProperties(dto, tmsReceiptDO, IgnoreNullUtil.getNullPropertyNames(dto));
|
||||
tmsReceiptDO.setTopOrganizationId(topOrganizationId);
|
||||
tmsReceiptDO.setOrganizationId(organizationId);
|
||||
tmsReceiptDO.setOrganizationName(organizationName);
|
||||
tmsReceiptDO.setCreateBy(userId);
|
||||
tmsReceiptDO.setCreateByName(userName);
|
||||
tmsReceiptDO.setReceivePaymentNumber(OrderSequence.getOrderCode());
|
||||
tmsReceiptDO.setCreateTime(now);
|
||||
tmsReceiptDO.setDelFlag(1);//1正常
|
||||
tmsReceiptDO.setAssignableAmount(tmsReceiptDO.getReceivePaymentAmount());//可分配金额
|
||||
tmsReceiptDO.setAssignmentStatus(0);//未分配
|
||||
//转化部门名称
|
||||
Integer orderShippingType = dto.getOrderShippingType();
|
||||
String departmentName = "";
|
||||
if(orderShippingType!=null){
|
||||
departmentName = OrderShippingTypeEnum.findByKey(orderShippingType);
|
||||
}
|
||||
|
||||
tmsReceiptDO.setDepartmentName(departmentName);
|
||||
|
||||
boolean isTrue= tmsReceiptService.insert(tmsReceiptDO);
|
||||
if (!isTrue) {
|
||||
throw new ServiceException("保存收款单失败!");
|
||||
}
|
||||
//2025-11-11:收款单不再生成收入流水,改为在订单结算时生成收入流水
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.linke.finance.application.server.tmsReceipt;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.linke.finance.domain.tmsReceipt.repository.todo.TmsReceiptDO;
|
||||
import com.linke.finance.interfaces.dto.TmsReceiptDTO;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
||||
import com.mhd.common.core.utils.bean.BeanUtils;
|
||||
import com.mhd.common.core.utils.IgnoreNullUtil;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 收款单Assembler
|
||||
*
|
||||
* @author gen
|
||||
* @date 2025-04-28
|
||||
*/
|
||||
@Component
|
||||
public class TmsReceiptAssembler {
|
||||
|
||||
/**
|
||||
* 转换实体
|
||||
*/
|
||||
public TmsReceiptDO toDO(TmsReceiptDTO tmsReceiptDTO) {
|
||||
TmsReceiptDO tmsReceiptDO = new TmsReceiptDO();
|
||||
// 拷贝
|
||||
BeanUtils.copyProperties(tmsReceiptDTO, tmsReceiptDO, IgnoreNullUtil.getNullPropertyNames(tmsReceiptDTO));
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
String userName = loginUser.getUsername();
|
||||
// 获取登录人id
|
||||
Long userId = loginUser.getUserid();
|
||||
if(tmsReceiptDTO.getId() != null){
|
||||
if(userId != null){
|
||||
tmsReceiptDO.setUpdateBy(userId);
|
||||
}else {
|
||||
tmsReceiptDO.setUpdateBy(new Long("0"));
|
||||
}
|
||||
tmsReceiptDO.setUpdateByName(userName);
|
||||
tmsReceiptDO.setUpdateTime(new Date());
|
||||
|
||||
}else {
|
||||
if(userId != null){
|
||||
tmsReceiptDO.setCreateBy(userId);
|
||||
tmsReceiptDO.setUpdateBy(userId);
|
||||
}else {
|
||||
tmsReceiptDO.setCreateBy(new Long("0"));
|
||||
tmsReceiptDO.setUpdateBy(new Long("0"));
|
||||
}
|
||||
tmsReceiptDO.setCreateByName(userName);
|
||||
tmsReceiptDO.setUpdateByName(userName);
|
||||
tmsReceiptDO.setCreateTime(new Date());
|
||||
tmsReceiptDO.setUpdateTime(new Date());
|
||||
tmsReceiptDO.setDelFlag(1);
|
||||
}
|
||||
return tmsReceiptDO;
|
||||
}
|
||||
|
||||
}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
package com.linke.finance.application.server.withdrawApplication;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.linke.finance.application.service.accountManage.AccountManageApplicationService;
|
||||
import com.linke.finance.domain.accountManage.entity.AccountExpendRecords;
|
||||
import com.linke.finance.domain.withdrawApplication.entity.WithdrawApplication;
|
||||
import com.linke.finance.domain.withdrawApplication.repository.po.WithdrawApplicationPO;
|
||||
import com.linke.finance.domain.withdrawApplication.repository.todo.WithdrawApplicationDO;
|
||||
import com.linke.finance.domain.withdrawApplication.service.WithdrawApplicationDomainService;
|
||||
import com.linke.finance.infrastructure.feign.UserServiceFeign;
|
||||
import com.linke.finance.interfaces.assemble.accountManage.AccountAssembler;
|
||||
import com.linke.finance.interfaces.dto.WithdrawApplicationDTO;
|
||||
import com.mhd.common.core.constant.SourceConstants;
|
||||
import com.mhd.common.core.domain.po.UserPo;
|
||||
import com.mhd.common.core.enums.MultistageDictCode;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.utils.AESUtil;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.common.security.utils.password.PasswordUtil;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 提现ApplicationService
|
||||
*
|
||||
* @author gen
|
||||
* @date 2024-03-14
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class WithdrawApplicationApplicationService {
|
||||
@Autowired
|
||||
private WithdrawApplicationDomainService withdrawApplicationDomainService;
|
||||
|
||||
@Autowired
|
||||
private AccountManageApplicationService accountManageApplicationService;
|
||||
|
||||
@Autowired
|
||||
private UserServiceFeign userServiceFeign;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询提现列表
|
||||
*/
|
||||
|
||||
public List<WithdrawApplicationPO> queryList(WithdrawApplicationDO withdrawApplicationDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1) {
|
||||
withdrawApplicationDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
}
|
||||
return withdrawApplicationDomainService.queryList(withdrawApplicationDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增提现
|
||||
*/
|
||||
public Boolean insert(WithdrawApplicationDO withdrawApplicationDO) {
|
||||
|
||||
return withdrawApplicationDomainService.insert(withdrawApplicationDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改提现
|
||||
*/
|
||||
public Boolean update(WithdrawApplicationDO withdrawApplicationDO) {
|
||||
return withdrawApplicationDomainService.update(withdrawApplicationDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除提现
|
||||
*/
|
||||
public boolean delete(Long[] ids) {
|
||||
return withdrawApplicationDomainService.delete(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取提现详细信息
|
||||
*/
|
||||
public WithdrawApplicationPO getInfo(Long id) {
|
||||
return withdrawApplicationDomainService.getInfo(id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 转账
|
||||
*/
|
||||
@Transactional
|
||||
public void transfer(WithdrawApplicationDTO withdrawApplicationDTO) {
|
||||
/*
|
||||
转账不涉及提现用户的消费记录生成,因为在提现操作后已生成,同时也不涉及平台的支出记录
|
||||
转账操作只对记录做状态修改
|
||||
*/
|
||||
String ids = withdrawApplicationDTO.getIds();
|
||||
List<Long> list = Convert.toList(Long.class, ids);
|
||||
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw new ServiceException("ids不能为空");
|
||||
}
|
||||
//首先校验支付密码(校验当前登录人)
|
||||
if(!checkPaypassword(withdrawApplicationDTO.getPayPassword())){
|
||||
throw new ServiceException("支付密码错误");
|
||||
}
|
||||
|
||||
List<WithdrawApplication> withdrawApplications = withdrawApplicationDomainService.getListById(list);
|
||||
|
||||
boolean anyMatch = withdrawApplications.stream().anyMatch(withdrawApplication -> withdrawApplication.getApplicationStatus() != 1);
|
||||
if (anyMatch) {
|
||||
throw new ServiceException("提现申请状态必须为已申请");
|
||||
}
|
||||
|
||||
//TODO 转账逻辑
|
||||
|
||||
//未对接三方支付,此处临时这样写
|
||||
for (WithdrawApplication withdrawApplication : withdrawApplications) {
|
||||
withdrawApplication.setApplicationStatus(2);
|
||||
}
|
||||
withdrawApplicationDomainService.updateBatch(withdrawApplications);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付密码校验 ,临时,后期封装工具类
|
||||
* 2023年3月18日
|
||||
* @param payPassword
|
||||
*/
|
||||
public boolean checkPaypassword(String payPassword) {
|
||||
//解密支付密码
|
||||
payPassword = AESUtil.decrypt(payPassword);
|
||||
//获取当前登录人
|
||||
//此处不用缓存中的数据,用数据库实时查询
|
||||
UserPo userPo = new UserPo();
|
||||
AjaxResult ajaxResult = userServiceFeign.getInfo(SecurityUtils.getLoginUser().getUserid());
|
||||
if("200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
Map<String,Object> map = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), Map.class);
|
||||
userPo = JSONObject.parseObject(JSONObject.toJSONString(map), UserPo.class);
|
||||
//根据当前用户组织信息获取到网点信息
|
||||
if(null == userPo){
|
||||
throw new ServiceException("未找到用户信息");
|
||||
}
|
||||
}
|
||||
if(StringUtils.isEmpty(userPo.getUserPayPassword())){
|
||||
throw new ServiceException("请设置支付密码");
|
||||
}
|
||||
//校验用户支付密码是否正确
|
||||
if (!PasswordUtil.matchesPassword(userPo.getUserAccount(), payPassword, userPo.getUserSalt(), userPo.getUserPayPassword())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 回调
|
||||
*/
|
||||
public void callback(WithdrawApplicationDTO withdrawApplicationDTO) {
|
||||
|
||||
String ids = withdrawApplicationDTO.getIds();
|
||||
List<Long> list = Convert.toList(Long.class, ids);
|
||||
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw new ServiceException("ids不能为空");
|
||||
}
|
||||
|
||||
List<WithdrawApplication> withdrawApplications = withdrawApplicationDomainService.getListById(list);
|
||||
|
||||
for (WithdrawApplication withdrawApplication : withdrawApplications) {
|
||||
//生成消费记录
|
||||
//插入现金支付消费记录
|
||||
AccountExpendRecords accountExpendRecords = new AccountExpendRecords();
|
||||
//消费记录数据装配
|
||||
new AccountAssembler().toDo(accountExpendRecords);
|
||||
accountExpendRecords.setAccountFirstCode(MultistageDictCode.ready_money.getCode());
|
||||
accountExpendRecords.setAccountFirstValue(MultistageDictCode.ready_money.getInfo());
|
||||
accountExpendRecords.setAccountSecondCode(MultistageDictCode.available_balance.getCode());
|
||||
accountExpendRecords.setAccountSecondValue(MultistageDictCode.available_balance.getInfo());
|
||||
accountExpendRecords.setSubjectFirstCode(MultistageDictCode.cash_consume.getCode());
|
||||
accountExpendRecords.setSubjectFirstValue(MultistageDictCode.cash_consume.getInfo());
|
||||
accountExpendRecords.setSubjectSecondCode(MultistageDictCode.withdrawal.getCode());
|
||||
accountExpendRecords.setSubjectSecondValue(MultistageDictCode.withdrawal.getInfo());
|
||||
accountExpendRecords.setTransactionAmount(withdrawApplication.getApplyAmount());
|
||||
accountExpendRecords.setAccountExpenseType(2);
|
||||
accountExpendRecords.setUserId(withdrawApplication.getApplicantId());
|
||||
accountExpendRecords.setOrderSourceCode(SourceConstants.ZHUANXIAN.getCode());
|
||||
|
||||
accountManageApplicationService.insertAccountExpendRecords(accountExpendRecords);
|
||||
|
||||
//TODO 成功
|
||||
if (1 == 1) {
|
||||
//更新提现记录状态
|
||||
|
||||
//更新钱包金额
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+2575
File diff suppressed because it is too large
Load Diff
+148
@@ -0,0 +1,148 @@
|
||||
package com.linke.finance.application.service.auditConfiguration;
|
||||
|
||||
import com.linke.finance.domain.auditConfiguration.entity.AuditConfiguration;
|
||||
import com.mhd.common.core.domain.po.AuditConfigurationPO;
|
||||
import com.linke.finance.domain.auditConfiguration.repository.todo.AuditConfigurationDO;
|
||||
import com.linke.finance.domain.auditConfiguration.service.AuditConfigurationDomainService;
|
||||
import com.linke.finance.infrastructure.feign.UserServiceFeign;
|
||||
import com.mhd.common.core.domain.dto.RoleDTO;
|
||||
import com.mhd.common.core.domain.entity.R;
|
||||
import com.mhd.common.core.domain.po.UserPo;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 审核配置ApplicationService
|
||||
*
|
||||
* @author gen
|
||||
* @date 2024-02-28
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AuditConfigurationApplicationService {
|
||||
@Autowired
|
||||
private AuditConfigurationDomainService auditConfigurationDomainService;
|
||||
@Resource
|
||||
private UserServiceFeign userServiceFeign;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询审核配置列表
|
||||
*/
|
||||
|
||||
public List<AuditConfigurationPO> queryList(AuditConfigurationDO auditConfigurationDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
auditConfigurationDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
}else {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
if (auditConfigurationDO.getAuditType() == null){
|
||||
auditConfigurationDO.setAuditType(1);
|
||||
}
|
||||
return auditConfigurationDomainService.queryList(auditConfigurationDO);
|
||||
}
|
||||
|
||||
|
||||
public List<AuditConfigurationPO> listByAuditType(Integer auditType) {
|
||||
AuditConfigurationDO auditConfigurationDO = new AuditConfigurationDO();
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
auditConfigurationDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}else {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
auditConfigurationDO.setAuditType(auditType);
|
||||
auditConfigurationDO.setIsEnabled(1);
|
||||
return auditConfigurationDomainService.queryList(auditConfigurationDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增审核配置
|
||||
*/
|
||||
public Boolean insert(AuditConfigurationDO auditConfigurationDO) {
|
||||
|
||||
return auditConfigurationDomainService.insert(auditConfigurationDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改审核配置
|
||||
*/
|
||||
public Boolean update(AuditConfigurationDO auditConfigurationDO) {
|
||||
return auditConfigurationDomainService.update(auditConfigurationDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除审核配置
|
||||
*/
|
||||
public boolean delete(Long[] auditConfigurationIds) {
|
||||
return auditConfigurationDomainService.delete(auditConfigurationIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取审核配置详细信息
|
||||
*/
|
||||
public AuditConfigurationPO getInfo(Long auditConfigurationId)
|
||||
{
|
||||
return auditConfigurationDomainService.getInfo(auditConfigurationId);
|
||||
}
|
||||
|
||||
|
||||
public void editBatch(AuditConfigurationDO auditConfigurationDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
auditConfigurationDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
}else {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
List<AuditConfigurationDO> auditConfigurations = auditConfigurationDO.getAuditConfigurations();
|
||||
if (auditConfigurations == null || auditConfigurations.isEmpty()){
|
||||
throw new ServiceException("审核配置明细不能为空!");
|
||||
}
|
||||
if (auditConfigurationDO.getAuditType() == null){
|
||||
throw new ServiceException("审核类型有误!");
|
||||
}
|
||||
//先清空对应的组织对应的类型的审核配置
|
||||
auditConfigurationDomainService.deleteByAuditConfiguration(auditConfigurationDO);
|
||||
|
||||
R<List<UserPo>> roleListResult = userServiceFeign.getListByFeign(new RoleDTO());
|
||||
List<UserPo> roleList = roleListResult.getData();
|
||||
Map<Long, UserPo> roleMap = roleList.stream().collect(Collectors.toMap(UserPo::getRoleId, Function.identity(), (m, n) -> m));
|
||||
//封装审核配置进行批量保存
|
||||
List<AuditConfiguration> list = new ArrayList<>();
|
||||
for (AuditConfigurationDO auditConfiguration : auditConfigurations) {
|
||||
AuditConfiguration entity = new AuditConfiguration();
|
||||
BeanUtils.copyProperties(auditConfiguration, entity);
|
||||
entity.setAuditType(auditConfigurationDO.getAuditType());
|
||||
entity.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
entity.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
entity.setCreateBy(loginUser.getUserPo().getUserId());
|
||||
entity.setCreateByName(loginUser.getUserPo().getUserName());
|
||||
entity.setCreateTime(new Date());
|
||||
entity.setDelFlag(1);
|
||||
UserPo userPo = roleMap.get(entity.getRoleId());
|
||||
if (userPo != null){
|
||||
entity.setRoleCode(userPo.getRoleCode());
|
||||
entity.setRoleName(userPo.getRoleName());
|
||||
}
|
||||
list.add(entity);
|
||||
}
|
||||
auditConfigurationDomainService.saveBatch(list);
|
||||
}
|
||||
}
|
||||
+513
@@ -0,0 +1,513 @@
|
||||
package com.linke.finance.application.service.branchBill;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.linke.finance.application.service.accountManage.AccountManageApplicationService;
|
||||
import com.linke.finance.application.service.revenueExpensesRecord.RevenueExpensesRecordApplicationService;
|
||||
import com.linke.finance.domain.accountManage.entity.AccountCashWallet;
|
||||
import com.linke.finance.domain.accountManage.entity.AccountExpendRecords;
|
||||
import com.linke.finance.domain.accountManage.service.AccountCashWalletDomainService;
|
||||
import com.linke.finance.domain.branchBill.repository.po.BranchBillPO;
|
||||
import com.linke.finance.domain.branchBill.repository.po.BranchBillStatisticsRecordPo;
|
||||
import com.linke.finance.domain.branchBill.repository.todo.BranchBillDO;
|
||||
import com.linke.finance.domain.branchBill.service.BranchBillDomainService;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.entity.RevenueExpensesRecord;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.service.RevenueExpensesRecordDomainService;
|
||||
import com.linke.finance.infrastructure.feign.ProductServiceFeign;
|
||||
import com.linke.finance.infrastructure.feign.SpecialLogisticsServiceFeign;
|
||||
import com.linke.finance.infrastructure.util.UniqueKeyUtil;
|
||||
import com.linke.finance.interfaces.assemble.accountManage.AccountAssembler;
|
||||
import com.mhd.common.core.constant.PaymentChannelConstants;
|
||||
import com.mhd.common.core.constant.SourceConstants;
|
||||
import com.mhd.common.core.constant.SubjectConstants;
|
||||
import com.mhd.common.core.domain.po.BranchBusinessPO;
|
||||
import com.mhd.common.core.domain.po.BranchPo;
|
||||
import com.mhd.common.core.domain.po.OrganizationPo;
|
||||
import com.mhd.common.core.enums.MultistageDictCode;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
||||
import com.mhd.common.core.utils.OrderSequence;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.redis.enums.RedisLockTypeEnum;
|
||||
import com.mhd.common.redis.service.RedisLock;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.redisson.api.RLock;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.mhd.common.core.utils.PageUtils.startPage;
|
||||
|
||||
/**
|
||||
* 网点账单ApplicationService
|
||||
*
|
||||
* @author gen
|
||||
* @date 2023-11-04
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BranchBillApplicationService {
|
||||
@Autowired
|
||||
private BranchBillDomainService branchBillDomainService;
|
||||
@Autowired
|
||||
private SpecialLogisticsServiceFeign specialLogisticsServiceFeign;
|
||||
@Autowired
|
||||
private RevenueExpensesRecordApplicationService revenueExpensesRecordApplicationService;
|
||||
@Autowired
|
||||
private RedisLock redisLock;
|
||||
@Resource
|
||||
private AccountManageApplicationService accountManageApplicationService;
|
||||
@Resource
|
||||
private ProductServiceFeign productServiceFeign;
|
||||
@Autowired
|
||||
private RevenueExpensesRecordDomainService revenueExpensesRecordDomainService;
|
||||
@Autowired
|
||||
private AccountCashWalletDomainService accountCashWalletDomainService;
|
||||
|
||||
/**
|
||||
* 分页查询网点账单列表
|
||||
*/
|
||||
|
||||
public List<BranchBillPO> queryList(BranchBillDO branchBillDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
branchBillDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
//查询当前组织的网点
|
||||
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// AjaxResult info = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
||||
// if(!"200".equals(String.valueOf(info.get("code")))){
|
||||
// throw new ServiceException("获取当前登录用户网点失败,请联系管理员");
|
||||
// }
|
||||
// BranchPo branchPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), BranchPo.class);
|
||||
// branchBillDO.setBranchId(branchPo.getBranchId());
|
||||
}
|
||||
startPage();
|
||||
return branchBillDomainService.queryList(branchBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 统计收账、交账记录数
|
||||
* @author ZhouGY
|
||||
* @date 2023/11/6 16:35
|
||||
* @param branchBillDO
|
||||
* @return BranchBillPO
|
||||
*/
|
||||
public BranchBillPO countTabTotal(BranchBillDO branchBillDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
branchBillDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
//查询当前组织的网点
|
||||
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// AjaxResult info = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
||||
// if(!"200".equals(String.valueOf(info.get("code")))){
|
||||
// throw new ServiceException("获取当前登录用户网点失败,请联系管理员");
|
||||
// }
|
||||
// BranchPo branchPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), BranchPo.class);
|
||||
// branchBillDO.setBranchInId(branchPo.getBranchId());
|
||||
// branchBillDO.setBranchOutId(branchPo.getBranchId());
|
||||
}
|
||||
return branchBillDomainService.countTabTotal(branchBillDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增网点账单
|
||||
*/
|
||||
public Boolean insert(BranchBillDO branchBillDO) {
|
||||
|
||||
return branchBillDomainService.insert(branchBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改网点账单
|
||||
*/
|
||||
public Boolean update(BranchBillDO branchBillDO) {
|
||||
return branchBillDomainService.update(branchBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除网点账单
|
||||
*/
|
||||
public boolean delete(Long[] branchBillIds) {
|
||||
return branchBillDomainService.delete(branchBillIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取网点账单详细信息
|
||||
*/
|
||||
public BranchBillPO getInfo(Long branchBillId)
|
||||
{
|
||||
return branchBillDomainService.getInfo(branchBillId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取网点交账数据
|
||||
* @author ZhouGY
|
||||
* @date 2023/11/6 10:35
|
||||
*/
|
||||
|
||||
public BranchBillStatisticsRecordPo branchBillStatistics(BranchBillDO branchBillDO){
|
||||
//查询当前组织的网点
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// AjaxResult info = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
||||
// if(!"200".equals(String.valueOf(info.get("code")))){
|
||||
// throw new ServiceException("获取当前登录用户网点失败,请联系管理员");
|
||||
// }
|
||||
// BranchPo branchPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), BranchPo.class);
|
||||
// branchBillDO.setBranchOutId(branchPo.getBranchId());
|
||||
// if (branchBillDO.getDeadlineTime() == null){
|
||||
// branchBillDO.setDeadlineTime(new Date());
|
||||
// }
|
||||
return branchBillDomainService.branchBillStatistics(branchBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 网点交账
|
||||
* @author ZhouGY
|
||||
* @date 2023/11/6 11:46
|
||||
* @param branchBillDO
|
||||
*/
|
||||
public void branchPayment(BranchBillDO branchBillDO){
|
||||
//查询当前组织的网点
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// AjaxResult branchResult = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
||||
// if(!"200".equals(String.valueOf(branchResult.get("code")))){
|
||||
// throw new ServiceException("获取当前登录用户网点失败,请联系管理员");
|
||||
// }
|
||||
// BranchPo branchPo = JSONObject.parseObject(JSONObject.toJSONString(branchResult.get("data")), BranchPo.class);
|
||||
// branchBillDO.setBranchOutId(branchPo.getBranchId());
|
||||
// branchBillDO.setBranchOutName(branchPo.getBranchName());
|
||||
// AjaxResult branchBusinessResult = specialLogisticsServiceFeign.getBusinessInfo(branchPo.getBranchId());
|
||||
// if(!"200".equals(String.valueOf(branchBusinessResult.get("code")))){
|
||||
// throw new ServiceException("获取当前登录用户网点失败,请联系管理员");
|
||||
// }
|
||||
// BranchBusinessPO branchBusinessPO = JSONObject.parseObject(JSONObject.toJSONString(branchBusinessResult.get("data")), BranchBusinessPO.class);
|
||||
// branchBillDO.setBranchInId(branchBusinessPO.getPayBranchId());
|
||||
// branchBillDO.setBranchInName(branchBusinessPO.getPayBranchName());
|
||||
branchBillDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
|
||||
branchBillDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
|
||||
branchBillDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
RedisLockTypeEnum redisLockTypeEnum = RedisLockTypeEnum.FINANCE;
|
||||
String key = redisLockTypeEnum.getUniqueKey(UniqueKeyUtil.getBranchBillKey(String.valueOf(branchBillDO.getBranchInId())));
|
||||
RLock lock = null;
|
||||
try {
|
||||
lock = redisLock.getRLock(key);
|
||||
//尝试获取锁 不等待 持有锁10分钟
|
||||
if(!lock.tryLock(-1,10, TimeUnit.MINUTES)){
|
||||
lock = null;
|
||||
throw new ServiceException("网点【" + branchBillDO.getBranchInName() + "】正在进行交账,为避免同时交账,请稍后再尝试交账");
|
||||
}
|
||||
log.info("网点【{}】交账 加锁成功", branchBillDO.getBranchInName());
|
||||
branchBillDomainService.branchPayment(branchBillDO);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("网点【{}】交账 超时自动释放锁异常", branchBillDO.getBranchInName(), e);
|
||||
} finally {
|
||||
if (lock != null && lock.isHeldByCurrentThread()){
|
||||
lock.unlock();
|
||||
log.info("网点【{}】交账 释放锁成功", branchBillDO.getBranchInName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 确认账单金额
|
||||
* @author ZhouGY
|
||||
* @date 2023/11/6 15:09
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void confirmBranchBillAmount(BranchBillDO branchBillDO){
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
BranchBillPO branchBillPO = branchBillDomainService.getInfo(branchBillDO.getBranchBillId());
|
||||
if (branchBillPO.getBranchBillId() == null){
|
||||
throw new ServiceException("网点交账账单不存在");
|
||||
}
|
||||
branchBillDomainService.confirmBranchBillAmount(branchBillDO);
|
||||
//运营收入
|
||||
RevenueExpensesRecord revenueExpensesRecord = new RevenueExpensesRecord();
|
||||
// revenueExpensesRecord.setBranchId(branchBillPO.getBranchInId());
|
||||
revenueExpensesRecord.setInnerNumber(OrderSequence.getOrderCode());
|
||||
revenueExpensesRecord.setRevenueExpensesType(1);
|
||||
revenueExpensesRecord.setMoney(branchBillPO.getActualAmount());
|
||||
revenueExpensesRecord.setFirstSubject(SubjectConstants.OPERATING_EXPENSES.getCode());
|
||||
revenueExpensesRecord.setFirstSubjectName(SubjectConstants.OPERATING_EXPENSES.getName());
|
||||
revenueExpensesRecord.setSecondSubject(SubjectConstants.OPERATING_INCOME_ONE.getCode());
|
||||
revenueExpensesRecord.setSecondSubjectName(SubjectConstants.OPERATING_INCOME_ONE.getName());
|
||||
// revenueExpensesRecord.setPayChannel();
|
||||
// revenueExpensesRecord.setPayChannelName();
|
||||
revenueExpensesRecord.setEntryValue(1);
|
||||
revenueExpensesRecord.setDayToDayStatus(1);
|
||||
// revenueExpensesRecord.setWaybillId(branchBillPO.getBranchBillId());
|
||||
// revenueExpensesRecord.setWaybillNumber(branchBillPO.getBillCode());
|
||||
// revenueExpensesRecord.setSettleAccountsStatus(1);
|
||||
// revenueExpensesRecord.setWaybillSource(SourceConstants.CAIWUZHONGTAI.getCode());
|
||||
// revenueExpensesRecord.setWaybillSourceName(SourceConstants.CAIWUZHONGTAI.getName());
|
||||
revenueExpensesRecord.setCreateBy(loginUser.getUserid());
|
||||
revenueExpensesRecord.setCreateByName(loginUser.getUsername());
|
||||
revenueExpensesRecord.setCreateTime(new Date());
|
||||
revenueExpensesRecordApplicationService.insertRevenueExpensesRecord(revenueExpensesRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取网点交账详情
|
||||
* @author ZhouGY
|
||||
* @date 2023/11/6 14:22
|
||||
* @param branchBillId
|
||||
*/
|
||||
public BranchBillStatisticsRecordPo getBranchPaymentDetail(Long branchBillId){
|
||||
return branchBillDomainService.getBranchPaymentDetail(branchBillId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 网点转账支付
|
||||
* @param branchBillDO
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void branchPayBills(BranchBillDO branchBillDO) {
|
||||
/*
|
||||
扣除交账网点余额,增加收账网点余额,如果收账网点是一级组织,则不增加
|
||||
*/
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
if(branchBillDO.getBranchBillId()==null ){
|
||||
throw new ServiceException("账单id不能为空");
|
||||
}
|
||||
if (ObjectUtil.isNull(branchBillDO.getPayMethod())) {
|
||||
throw new ServiceException("上交方式不能为空");
|
||||
}
|
||||
|
||||
//网点交账保存默认为未交账状态
|
||||
//转账选择线下支付保存后为未确认状态,需要操作确认后变更为已确认状态
|
||||
//转账选择钱包支付保存后默认为已确认状态
|
||||
if (branchBillDO.getPayMethod() == 1) {
|
||||
branchBillDO.setBillStatus(1);
|
||||
}
|
||||
//修改账单的支付方式
|
||||
branchBillDomainService.updateBranchBillPayMethod(branchBillDO);
|
||||
//线上支付
|
||||
if (branchBillDO.getPayMethod() == 2){
|
||||
onlinePayment(branchBillDO, loginUser);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 线上支付
|
||||
* @author ZhouGY
|
||||
* @date 2023/11/24 15:00
|
||||
*/
|
||||
public void onlinePayment(BranchBillDO branchBillDO, LoginUser loginUser){
|
||||
if(!accountManageApplicationService.checkPaypassword(branchBillDO.getPayPassword())){
|
||||
throw new ServiceException("支付密码错误");
|
||||
}
|
||||
BranchBillPO branchBillPO = branchBillDomainService.getInfo(branchBillDO.getBranchBillId());
|
||||
if(null == branchBillPO){
|
||||
throw new ServiceException("网点账单未找到");
|
||||
}
|
||||
if(branchBillPO.getPayMethod()!=2){
|
||||
throw new ServiceException("账单支付方式错误");
|
||||
}
|
||||
//取上交金额支付
|
||||
final BigDecimal actualAmount = branchBillPO.getActualAmount();
|
||||
//支付方
|
||||
OrganizationPo payOrg = new OrganizationPo();
|
||||
//接收方
|
||||
OrganizationPo recOrg = new OrganizationPo();
|
||||
//获取支付方、接收方组织信息
|
||||
getOrgInfo(branchBillPO,payOrg,recOrg);
|
||||
//加锁
|
||||
RedisLockTypeEnum redisLockTypeEnum = RedisLockTypeEnum.FINANCE;
|
||||
String key = redisLockTypeEnum.getUniqueKey(UniqueKeyUtil.getBranchBillKey(String.valueOf(branchBillPO.getBranchOutId())));
|
||||
RLock lock = null;
|
||||
try {
|
||||
lock = redisLock.getRLock(key);
|
||||
//尝试获取锁 不等待 持有锁10分钟
|
||||
if (!lock.tryLock(-1, 10, TimeUnit.MINUTES)) {
|
||||
lock = null;
|
||||
throw new ServiceException("网点" + branchBillPO.getBranchOutName() + "正在支付中");
|
||||
}
|
||||
log.info("网点支付交账加锁成功");
|
||||
AccountCashWallet payAcc = accountCashWalletDomainService.selectByUserId(payOrg.getPrincipalId());
|
||||
if(null == payAcc){
|
||||
throw new ServiceException("交账网点未开通钱包");
|
||||
}
|
||||
if(actualAmount.compareTo(payAcc.getWalletAvailableBalance())>0){
|
||||
throw new ServiceException("余额不足");
|
||||
}
|
||||
//付款方扣除金额
|
||||
final BigDecimal lastBalance = payAcc.getWalletAvailableBalance();
|
||||
payAcc.setWalletAvailableBalance(lastBalance.subtract(actualAmount));
|
||||
//修改钱包余额
|
||||
payAcc.setWalletBalance(payAcc.getWalletAvailableBalance().add(payAcc.getWalletFreezeBalance()));
|
||||
|
||||
//==================生成收支流水=====================
|
||||
List<RevenueExpensesRecord> revenueExpensesRecordList = new ArrayList<>();
|
||||
RevenueExpensesRecord common = new RevenueExpensesRecord();
|
||||
common.setMoney(actualAmount);
|
||||
common.setFirstSubject(SubjectConstants.OPERATING_EXPENSES.getCode());
|
||||
common.setSecondSubject(SubjectConstants.OPERATING_INCOME_ONE.getCode());
|
||||
common.setFirstSubjectName(SubjectConstants.OPERATING_EXPENSES.getName());
|
||||
common.setSecondSubjectName(SubjectConstants.OPERATING_INCOME_ONE.getName());
|
||||
common.setPayChannel(PaymentChannelConstants.wallet_pay);
|
||||
common.setEntryValue(1);
|
||||
//流水状态设为作废
|
||||
common.setDayToDayStatus(1);
|
||||
// common.setSettleAccountsStatus(1);
|
||||
common.setDelFlag(1);
|
||||
common.setCreateTime(new Date());
|
||||
common.setCreateBy(loginUser.getUserid());
|
||||
common.setCreateByName(loginUser.getUsername());
|
||||
//=================付款方=========================
|
||||
RevenueExpensesRecord revenueExpensesRecordPay = new RevenueExpensesRecord();
|
||||
BeanUtils.copyProperties(common,revenueExpensesRecordPay);
|
||||
// revenueExpensesRecordPay.setBranchId(branchBillPO.getBranchOutId());
|
||||
revenueExpensesRecordPay.setInnerNumber(OrderSequence.getOrderCode());
|
||||
revenueExpensesRecordPay.setRevenueExpensesType(2);
|
||||
revenueExpensesRecordList.add(revenueExpensesRecordPay);
|
||||
//=================生成消费记录========================
|
||||
List<AccountExpendRecords> accountExpendRecordsList = new ArrayList<>();
|
||||
AccountExpendRecords commonTwo = new AccountAssembler().toDo(new AccountExpendRecords());
|
||||
commonTwo.setAccountFirstCode(MultistageDictCode.ready_money.getCode());
|
||||
commonTwo.setAccountFirstValue(MultistageDictCode.ready_money.getInfo());
|
||||
commonTwo.setAccountSecondCode(MultistageDictCode.available_balance.getCode());
|
||||
commonTwo.setAccountSecondValue(MultistageDictCode.available_balance.getInfo());
|
||||
commonTwo.setSubjectFirstCode(SubjectConstants.OPERATING_EXPENSES.getCode());
|
||||
commonTwo.setSubjectFirstValue(SubjectConstants.OPERATING_EXPENSES.getName());
|
||||
commonTwo.setSubjectSecondCode(SubjectConstants.OPERATING_INCOME_ONE.getCode());
|
||||
commonTwo.setSubjectSecondValue(SubjectConstants.OPERATING_INCOME_ONE.getName());
|
||||
commonTwo.setAccountExpendOperator(loginUser.getUsername());
|
||||
commonTwo.setAccountEnterType(1);
|
||||
commonTwo.setCapitalFlowStatus(1);
|
||||
commonTwo.setTransactionTime(new Date());
|
||||
//=================付款方==================
|
||||
AccountExpendRecords payRecords = new AccountAssembler().toDo(new AccountExpendRecords());
|
||||
BeanUtils.copyProperties(commonTwo,payRecords);
|
||||
payRecords.setAccountSerialNumber(OrderSequence.getOrderCode());
|
||||
payRecords.setAccountLastBalance(lastBalance);
|
||||
payRecords.setTransactionAmount(actualAmount);
|
||||
payRecords.setAccountBalance(payAcc.getWalletAvailableBalance());
|
||||
payRecords.setUserName(payAcc.getUserName());
|
||||
payRecords.setUserId(payAcc.getUserId());
|
||||
payRecords.setUserAccount(payAcc.getUserAccount());
|
||||
payRecords.setAccountCashWalletId(payAcc.getAccountCashWalletId());
|
||||
payRecords.setAccountWalletId(payAcc.getAccountWalletId());
|
||||
payRecords.setAccountExpenseType(2);
|
||||
accountExpendRecordsList.add(payRecords);
|
||||
//如果签收账网点是一级组织,则无需参与收款
|
||||
if(recOrg.getOrganizationState()!=1){
|
||||
//不是一级组织,参与收款
|
||||
AccountCashWallet recAcc = accountCashWalletDomainService.selectByUserId(recOrg.getPrincipalId());
|
||||
|
||||
//上交金额为负数时判断钱包余额是否充足
|
||||
if (actualAmount.compareTo(BigDecimal.ZERO) < 0) {
|
||||
BigDecimal abs = actualAmount.abs();
|
||||
if(abs.compareTo(recAcc.getWalletAvailableBalance())>0){
|
||||
throw new ServiceException("钱包余额不足");
|
||||
}
|
||||
}
|
||||
if(null == recAcc){
|
||||
throw new ServiceException("收账网点未开通钱包");
|
||||
}
|
||||
final BigDecimal lastRecBalance = recAcc.getWalletAvailableBalance();
|
||||
recAcc.setWalletAvailableBalance(lastRecBalance.add(actualAmount));
|
||||
//修改钱包余额
|
||||
recAcc.setWalletBalance(recAcc.getWalletAvailableBalance().add(recAcc.getWalletFreezeBalance()));
|
||||
//===================生成收支流水============================
|
||||
RevenueExpensesRecord revenueExpensesRecordRecive = new RevenueExpensesRecord();
|
||||
BeanUtils.copyProperties(common,revenueExpensesRecordRecive);
|
||||
// revenueExpensesRecordRecive.setBranchId(branchBillPO.getBranchInId());
|
||||
revenueExpensesRecordRecive.setInnerNumber(OrderSequence.getOrderCode());
|
||||
revenueExpensesRecordRecive.setRevenueExpensesType(1);
|
||||
revenueExpensesRecordList.add(revenueExpensesRecordRecive);
|
||||
//==================收款人消费记录=============
|
||||
AccountExpendRecords reciveRecords = new AccountAssembler().toDo(new AccountExpendRecords());
|
||||
BeanUtils.copyProperties(commonTwo,reciveRecords);
|
||||
reciveRecords.setAccountSerialNumber(OrderSequence.getOrderCode());
|
||||
reciveRecords.setAccountLastBalance(lastRecBalance);
|
||||
reciveRecords.setTransactionAmount(actualAmount);
|
||||
reciveRecords.setAccountBalance(recAcc.getWalletAvailableBalance());
|
||||
reciveRecords.setUserName(recAcc.getUserName());
|
||||
reciveRecords.setUserId(recAcc.getUserId());
|
||||
reciveRecords.setUserAccount(recAcc.getUserAccount());
|
||||
reciveRecords.setAccountCashWalletId(recAcc.getAccountCashWalletId());
|
||||
reciveRecords.setAccountWalletId(recAcc.getAccountWalletId());
|
||||
reciveRecords.setAccountExpenseType(1);
|
||||
accountExpendRecordsList.add(reciveRecords);
|
||||
accountCashWalletDomainService.updateAccountCashWalletById(recAcc);
|
||||
}
|
||||
//调用确认收款
|
||||
confirmBranchBillAmount(branchBillDO);
|
||||
revenueExpensesRecordDomainService.batchAddRevenueExpensesRecord(revenueExpensesRecordList);
|
||||
accountManageApplicationService.batchAddAccountExpendRecords(accountExpendRecordsList);
|
||||
accountCashWalletDomainService.updateAccountCashWalletById(payAcc);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("网点【{}】支付交账 超时自动释放锁异常", branchBillDO.getBranchInName(), e);
|
||||
} finally {
|
||||
if (lock != null && lock.isHeldByCurrentThread()){
|
||||
lock.unlock();
|
||||
log.info("网点【{}】支付交账 释放锁成功", branchBillDO.getBranchInName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付对象组织信息
|
||||
* @param branchBillPO
|
||||
*/
|
||||
public void getOrgInfo(BranchBillPO branchBillPO,OrganizationPo payOrg,OrganizationPo recOrg ) {
|
||||
//计算收账交账网点,对应的账户,且判断交账网点是否是一级组织
|
||||
BranchPo payBranchPo = new BranchPo();
|
||||
AjaxResult payAjx = specialLogisticsServiceFeign.getInfo(branchBillPO.getBranchOutId());
|
||||
if("200".equals(String.valueOf(payAjx.get("code")))){
|
||||
payBranchPo = com.alibaba.fastjson.JSONObject.parseObject(com.alibaba.fastjson.JSONObject.toJSONString(payAjx.get("data")), BranchPo.class);
|
||||
}
|
||||
BranchPo recBranchPo = new BranchPo();
|
||||
AjaxResult racAjx = specialLogisticsServiceFeign.getInfo(branchBillPO.getBranchInId());
|
||||
if("200".equals(String.valueOf(racAjx.get("code")))){
|
||||
recBranchPo = com.alibaba.fastjson.JSONObject.parseObject(com.alibaba.fastjson.JSONObject.toJSONString(racAjx.get("data")), BranchPo.class);
|
||||
}
|
||||
if(payBranchPo==null){
|
||||
throw new ServiceException("交账网点未找到");
|
||||
}
|
||||
if(recBranchPo==null){
|
||||
throw new ServiceException("收账网点未找到");
|
||||
}
|
||||
AjaxResult payAjax = productServiceFeign.getOrganizationInfo(payBranchPo.getOrganizationId());
|
||||
if("200".equals(String.valueOf(payAjax.get("code")))){
|
||||
OrganizationPo data = JSONUtil.toBean(JSONObject.toJSONString(payAjax.get("data")), OrganizationPo.class);
|
||||
BeanUtils.copyProperties(data, payOrg);
|
||||
}
|
||||
AjaxResult recAjax = productServiceFeign.getOrganizationInfo(recBranchPo.getOrganizationId());
|
||||
if("200".equals(String.valueOf(recAjax.get("code")))){
|
||||
OrganizationPo data = JSONUtil.toBean(JSONObject.toJSONString(recAjax.get("data")), OrganizationPo.class);
|
||||
BeanUtils.copyProperties(data, recOrg);
|
||||
}
|
||||
if(null == payOrg){
|
||||
throw new ServiceException("交账网点组织账号未找到");
|
||||
}
|
||||
if(null == recOrg){
|
||||
throw new ServiceException("收账网点组织账号未找到");
|
||||
}
|
||||
}
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
package com.linke.finance.application.service.branchFreightBill;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.linke.finance.domain.branchFreightBill.repository.po.BranchFreightBillPO;
|
||||
import com.linke.finance.domain.branchFreightBill.repository.todo.BranchFreightBillDO;
|
||||
import com.linke.finance.domain.branchFreightBill.service.BranchFreightBillDomainService;
|
||||
import com.linke.finance.infrastructure.feign.SpecialLogisticsServiceFeign;
|
||||
import com.mhd.common.core.domain.dto.WaybillSignFinanceDTO;
|
||||
import com.mhd.common.core.domain.po.BranchPo;
|
||||
import com.mhd.common.core.domain.po.UserPo;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mhd.common.core.utils.PageUtils.startPage;
|
||||
|
||||
/**
|
||||
* 网点费用账单ApplicationService
|
||||
*
|
||||
* @author gen
|
||||
* @date 2023-11-08
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BranchFreightBillApplicationService {
|
||||
@Autowired
|
||||
private BranchFreightBillDomainService branchFreightBillDomainService;
|
||||
|
||||
@Autowired
|
||||
private SpecialLogisticsServiceFeign specialLogisticsServiceFeign;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询网点费用账单列表
|
||||
*/
|
||||
|
||||
public List<BranchFreightBillPO> queryList(BranchFreightBillDO branchFreightBillDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
if (ObjectUtil.equals(userPo.getTopOrganizationId(), userPo.getOrganizationId())){
|
||||
branchFreightBillDO.setTopOrganizationId(userPo.getTopOrganizationId());
|
||||
}else {
|
||||
//查询当前组织的网点
|
||||
Long organizationId = userPo.getOrganizationId();
|
||||
// AjaxResult info = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
||||
// if(!"200".equals(String.valueOf(info.get("code")))){
|
||||
// throw new ServiceException("获取当前登录用户网点失败,请联系管理员");
|
||||
// }
|
||||
// BranchPo branchPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), BranchPo.class);
|
||||
// branchFreightBillDO.setBranchId(branchPo.getBranchId());
|
||||
}
|
||||
|
||||
/*if (loginUser != null){
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
if (userPo)
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
branchFreightBillDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
//查询当前组织的网点
|
||||
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
AjaxResult info = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
||||
if(!"200".equals(String.valueOf(info.get("code")))){
|
||||
throw new ServiceException("获取当前登录用户网点失败,请联系管理员");
|
||||
}
|
||||
BranchPo branchPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), BranchPo.class);
|
||||
branchFreightBillDO.setBranchId(branchPo.getBranchId());
|
||||
}*/
|
||||
startPage();
|
||||
return branchFreightBillDomainService.queryList(branchFreightBillDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增网点费用账单
|
||||
*/
|
||||
public Boolean insert(BranchFreightBillDO branchFreightBillDO) {
|
||||
|
||||
return branchFreightBillDomainService.insert(branchFreightBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增网点费用账单
|
||||
*/
|
||||
public Boolean insertBranchFreightBill(BranchFreightBillDO branchFreightBillDO) {
|
||||
|
||||
return branchFreightBillDomainService.insertBranchFreightBill(branchFreightBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改网点费用账单
|
||||
*/
|
||||
public Boolean update(BranchFreightBillDO branchFreightBillDO) {
|
||||
return branchFreightBillDomainService.update(branchFreightBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除网点费用账单
|
||||
*/
|
||||
public boolean delete(Long[] branchFreightIds) {
|
||||
return branchFreightBillDomainService.delete(branchFreightIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取网点费用账单详细信息
|
||||
*/
|
||||
public BranchFreightBillPO getInfo(Long branchFreightId)
|
||||
{
|
||||
return branchFreightBillDomainService.getInfo(branchFreightId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 确认网点运费账单
|
||||
* @author ZhouGY
|
||||
* @date 2023/11/9 8:20
|
||||
* @param branchFreightIds
|
||||
* @return int
|
||||
*/
|
||||
public int confirmBranchFreightBill(List<Long> branchFreightIds){
|
||||
return branchFreightBillDomainService.confirmBranchFreightBill(branchFreightIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 修改运费
|
||||
* @author ZhouGY
|
||||
* @date 2023/11/9 9:29
|
||||
* @param branchFreightBillDO
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean updateBranchFreightBill(BranchFreightBillDO branchFreightBillDO){
|
||||
return branchFreightBillDomainService.updateBranchFreightBill(branchFreightBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 新增网点费用账单和标记服务费状态
|
||||
* @author ZhouGY
|
||||
* @date 2023/11/9 13:35
|
||||
* @param waybillSignFinanceDTO
|
||||
* @return Boolean
|
||||
*/
|
||||
public Boolean insertOrUpdateWaybillSignFinance(WaybillSignFinanceDTO waybillSignFinanceDTO) {
|
||||
|
||||
return branchFreightBillDomainService.insertOrUpdateWaybillSignFinance(waybillSignFinanceDTO);
|
||||
}
|
||||
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
package com.linke.finance.application.service.common;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.linke.finance.domain.common.entity.DataPermission;
|
||||
import com.linke.finance.infrastructure.feign.ProductServiceFeign;
|
||||
import com.linke.finance.infrastructure.feign.UserServiceFeign;
|
||||
import com.mhd.common.core.domain.dto.UserDataPermissionQueryDTO;
|
||||
import com.mhd.common.core.domain.po.UserDataPermissionPO;
|
||||
import com.mhd.common.core.enums.RoleEnum;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公共 应用服务层
|
||||
* <p>
|
||||
* 本层可以综合应用各种业务间的组合
|
||||
* <p>
|
||||
* 2023-02-20
|
||||
*
|
||||
* @author 王子豪
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CommonApplicationService {
|
||||
|
||||
@Resource
|
||||
private ProductServiceFeign productServiceFeign;
|
||||
|
||||
@Resource
|
||||
private UserServiceFeign userServiceFeign;
|
||||
|
||||
/**
|
||||
* 判断当前登录人的数据权限
|
||||
*
|
||||
*/
|
||||
public DataPermission dataPermission(Long permissionMenuId) {
|
||||
DataPermission dataPermission = new DataPermission();
|
||||
//获取登录人信息
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Long userId = new Long("19");
|
||||
Long organizationId = new Long("2");
|
||||
if(loginUser.getUserPo() != null){
|
||||
userId = loginUser.getUserid();
|
||||
organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// UserPo userpo = new UserPo();
|
||||
// userpo.setRoleCode("plat_admin");
|
||||
// loginUser.setUserPo(userpo);
|
||||
//判断当前用户是否是超级管理员/租户管理员还是普通用户,如果是超级管理员则返回全部组织,租户管理员则返回租户所属组织的全部组织,普通用户需要判断数据权限
|
||||
if(RoleEnum.SUPER_ADMIN.getCode().equals(loginUser.getUserPo().getRoleCode())){
|
||||
//全部不加限制条件
|
||||
}else if(RoleEnum.PLAT_ADMIN.getCode().equals(loginUser.getUserPo().getRoleCode())) {
|
||||
//获取当前组织全部下级组织id
|
||||
AjaxResult ajaxResult = productServiceFeign.getOrganizationIdsByOrganizationId(organizationId);
|
||||
if("200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
List<Long> longs = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), Long.class);
|
||||
dataPermission.setOrganizationIdList(longs);
|
||||
}
|
||||
}else {
|
||||
//获取当前用户数据权限
|
||||
UserDataPermissionQueryDTO userDataPermissionQueryDTO = new UserDataPermissionQueryDTO();
|
||||
userDataPermissionQueryDTO.setMenuId(permissionMenuId);
|
||||
userDataPermissionQueryDTO.setOrganizationId(organizationId);
|
||||
userDataPermissionQueryDTO.setUserId(userId);
|
||||
AjaxResult info = userServiceFeign.findUserDataPermission(userDataPermissionQueryDTO);
|
||||
if("200".equals(String.valueOf(info.get("code")))){
|
||||
UserDataPermissionPO userDataPermissionPO = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), UserDataPermissionPO.class);
|
||||
if(userDataPermissionPO.getUserDataOrganizationStatus() != null){
|
||||
//1表示可以查询当前组织及下级组织的数据,反之只能看到自己创建的数据
|
||||
if(userDataPermissionPO.getUserDataOrganizationStatus() == 1){
|
||||
Long topOrganizationId = new Long("2");
|
||||
//获取当前组织最上级
|
||||
AjaxResult topId = productServiceFeign.selectTopId(organizationId);
|
||||
if("200".equals(String.valueOf(topId.get("code")))){
|
||||
topOrganizationId = JSONObject.parseObject(JSONObject.toJSONString(topId.get("data")), Long.class);
|
||||
}
|
||||
//获取当前组织全部下级组织id
|
||||
AjaxResult ajaxResult = productServiceFeign.getOrganizationIdsByOrganizationId(topOrganizationId);
|
||||
if("200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
List<Long> longs = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), Long.class);
|
||||
dataPermission.setOrganizationIdList(longs);
|
||||
}
|
||||
}else {
|
||||
dataPermission.setCreateBy(userId);
|
||||
}
|
||||
}else {
|
||||
dataPermission.setCreateBy(userId);
|
||||
}
|
||||
}else {
|
||||
dataPermission.setCreateBy(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
return dataPermission;
|
||||
}
|
||||
}
|
||||
+789
@@ -0,0 +1,789 @@
|
||||
package com.linke.finance.application.service.invoice;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.linke.finance.domain.address.entity.ReceivingAddressManage;
|
||||
import com.linke.finance.domain.address.repository.po.ReceivingAddressManagePo;
|
||||
import com.linke.finance.domain.address.repository.todo.ReceivingAddressManageDo;
|
||||
import com.linke.finance.domain.address.service.ReceivingAddressManageDomainService;
|
||||
import com.linke.finance.domain.businessDocument.entity.BusinessDocument;
|
||||
import com.linke.finance.domain.businessDocument.repository.po.BusinessDocumentAppPO;
|
||||
import com.linke.finance.domain.businessDocument.service.BusinessDocumentDomainService;
|
||||
import com.linke.finance.domain.common.entity.DataPermission;
|
||||
import com.linke.finance.domain.invoice.entity.InvoiceInfo;
|
||||
import com.linke.finance.domain.invoice.entity.InvoiceInfoDetails;
|
||||
import com.linke.finance.domain.invoice.entity.InvoiceInfoManage;
|
||||
import com.linke.finance.domain.invoice.entity.InvoiceOrder;
|
||||
import com.linke.finance.domain.invoice.repository.po.*;
|
||||
import com.linke.finance.domain.invoice.repository.todo.InvoiceInfoDo;
|
||||
import com.linke.finance.domain.invoice.repository.todo.InvoiceInfoManageDo;
|
||||
import com.linke.finance.domain.invoice.repository.todo.InvoiceOrderDo;
|
||||
import com.linke.finance.domain.invoice.service.InvoiceInfoDetailsDomainService;
|
||||
import com.linke.finance.domain.invoice.service.InvoiceInfoDomainService;
|
||||
import com.linke.finance.domain.invoice.service.InvoiceInfoManageDominService;
|
||||
import com.linke.finance.domain.invoice.service.InvoiceOrderDomainService;
|
||||
import com.linke.finance.domain.reconciliation.entity.Reconciliation;
|
||||
import com.linke.finance.domain.reconciliation.service.ReconciliationDomainService;
|
||||
import com.linke.finance.domain.wlhy.FinceWlhyDomainService;
|
||||
import com.linke.finance.infrastructure.feign.SystemServiceFeign;
|
||||
import com.linke.finance.infrastructure.util.annotation.DataPermissions;
|
||||
import com.linke.finance.infrastructure.vo.SysDictDataVo;
|
||||
import com.linke.finance.interfaces.assemble.invoice.InvoiceAssembler;
|
||||
import com.linke.finance.interfaces.dto.InvoiceInfoDto;
|
||||
import com.mhd.common.core.constant.SourceConstants;
|
||||
import com.mhd.common.core.domain.dto.SysProvinceCityCountyDTO;
|
||||
import com.mhd.common.core.domain.po.SysAreaPO;
|
||||
import com.mhd.common.core.domain.po.UserPo;
|
||||
import com.mhd.common.core.enums.DictCode;
|
||||
import com.mhd.common.core.enums.RoleEnum;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
||||
import com.mhd.common.core.utils.OrderSequence;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.core.utils.poi.WpsImg;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.domain.TmsTransportNote;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 发票信息管理Service业务层处理
|
||||
*
|
||||
* @author mhd
|
||||
* @date 2023-03-14
|
||||
*/
|
||||
@Service
|
||||
public class InvoiceInfoManageApplicationService {
|
||||
@Autowired
|
||||
private InvoiceInfoManageDominService invoiceInfoManageDominService;
|
||||
@Autowired
|
||||
private ReceivingAddressManageDomainService receivingAddressManageDomainService;
|
||||
@Autowired
|
||||
private InvoiceOrderDomainService invoiceOrderDomainService;
|
||||
@Autowired
|
||||
private InvoiceInfoDomainService invoiceInfoDomainService;
|
||||
@Autowired
|
||||
private InvoiceInfoDetailsDomainService invoiceInfoDetailsDomainService;
|
||||
@Autowired
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
@Autowired
|
||||
private BusinessDocumentDomainService businessDocumentDomainService;
|
||||
@Autowired
|
||||
private ReconciliationDomainService reconciliationDomainService;
|
||||
@Autowired
|
||||
private FinceWlhyDomainService finceWlhyDomainService;
|
||||
|
||||
/**
|
||||
* 查询发票信息管理
|
||||
*
|
||||
* @param invoiceInfoManageId 发票信息管理主键
|
||||
* @return 发票信息管理
|
||||
*/
|
||||
public InvoiceInfoManagePo selectInvoiceInfoManageByInvoiceInfoId(Long invoiceInfoManageId)
|
||||
{
|
||||
return invoiceInfoManageDominService.selectInvoiceInfoManageByInvoiceInfoId(invoiceInfoManageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询发票信息管理列表
|
||||
*
|
||||
* @param invoiceInfoManageDo 发票信息管理
|
||||
* @return 发票信息管理
|
||||
*/
|
||||
@DataPermissions(cacheName = "invoice_userId")
|
||||
public List<InvoiceInfoManagePo> selectInvoiceInfoManageList(InvoiceInfoManageDo invoiceInfoManageDo)
|
||||
{
|
||||
return invoiceInfoManageDominService.selectInvoiceInfoManageList(invoiceInfoManageDo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增发票信息管理
|
||||
*
|
||||
* @param invoiceInfoManage 发票信息管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertInvoiceInfoManage(InvoiceInfoManage invoiceInfoManage)
|
||||
{
|
||||
//根据当前登录人查询发票管理信息表,如果之前有,则不允许新增
|
||||
InvoiceInfoManage invoiceInfoManageHas = invoiceInfoManageDominService.selectInfoByUserId(SecurityUtils.getUserId());
|
||||
if(null != invoiceInfoManageHas){
|
||||
throw new ServiceException("暂不可维护多个发票抬头");
|
||||
}
|
||||
invoiceInfoManage.setOrganizationId(SecurityUtils.getLoginUser().getUserPo().getOrganizationId());
|
||||
invoiceInfoManage.setTopOrganizationId(SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
|
||||
return invoiceInfoManageDominService.insertInvoiceInfoManage(invoiceInfoManage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改发票信息管理
|
||||
*
|
||||
* @param invoiceInfoManage 发票信息管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateInvoiceInfoManage(InvoiceInfoManage invoiceInfoManage)
|
||||
{
|
||||
invoiceInfoManage.setUserId(null);
|
||||
return invoiceInfoManageDominService.updateInvoiceInfoManage(invoiceInfoManage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id删除发票信息
|
||||
*/
|
||||
public boolean deleteInvoiceByIds(Long[] invoiceInfoManageIds) {
|
||||
return invoiceInfoManageDominService.deleteInvoiceByIds(invoiceInfoManageIds);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据id查询收件地址信息
|
||||
* @param receivingAddressId
|
||||
* @return
|
||||
*/
|
||||
public ReceivingAddressManagePo selectReceivingAddressById(Long receivingAddressId)
|
||||
{
|
||||
return receivingAddressManageDomainService.selectByReceivingAddressId(receivingAddressId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询收件地址信息管理列表
|
||||
* @param receivingAddressManageDo
|
||||
* @param dataPermission
|
||||
* @return
|
||||
*/
|
||||
@DataPermissions(cacheName = "invoice_userId")
|
||||
public List<ReceivingAddressManagePo> selectReceivingAddressList(ReceivingAddressManageDo receivingAddressManageDo)
|
||||
{
|
||||
return receivingAddressManageDomainService.selectReceivingAddressManageList(receivingAddressManageDo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增收件地址信息
|
||||
* @param receivingAddressManage
|
||||
* @return
|
||||
*/
|
||||
public int insertReceivingAddressManage(ReceivingAddressManage receivingAddressManage)
|
||||
{
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
receivingAddressManage.setOrganizationId(userPo.getOrganizationId());
|
||||
receivingAddressManage.setTopOrganizationId(userPo.getTopOrganizationId());
|
||||
//调用数据字典拼接省市县信息
|
||||
if(receivingAddressManage.getCountyCode()!= null){
|
||||
SysProvinceCityCountyDTO sysProvinceCityCountyDTO = new SysProvinceCityCountyDTO();
|
||||
sysProvinceCityCountyDTO.setCountyCode(receivingAddressManage.getCountyCode());
|
||||
AjaxResult ajaxResult = systemServiceFeign.selectFindAreaInfoList(sysProvinceCityCountyDTO);
|
||||
if("200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
SysAreaPO sysAreaPO = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), SysAreaPO.class);
|
||||
receivingAddressManage.setCountyName(sysAreaPO.getProvinceCityCountyName());
|
||||
}
|
||||
}
|
||||
return receivingAddressManageDomainService.insertReceivingAddressManage(receivingAddressManage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑收件地址信息
|
||||
* @param receivingAddressManage
|
||||
* @return
|
||||
*/
|
||||
public int updateReceivingAddressManage(ReceivingAddressManage receivingAddressManage)
|
||||
{
|
||||
//调用数据字典拼接省市县信息
|
||||
if(receivingAddressManage.getCountyCode()!= null){
|
||||
SysProvinceCityCountyDTO sysProvinceCityCountyDTO = new SysProvinceCityCountyDTO();
|
||||
sysProvinceCityCountyDTO.setCountyCode(receivingAddressManage.getCountyCode());
|
||||
AjaxResult ajaxResult = systemServiceFeign.selectFindAreaInfoList(sysProvinceCityCountyDTO);
|
||||
if("200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
SysAreaPO sysAreaPO = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), SysAreaPO.class);
|
||||
receivingAddressManage.setCountyName(sysAreaPO.getProvinceCityCountyName());
|
||||
}
|
||||
}
|
||||
return receivingAddressManageDomainService.updateReceivingAddressManage(receivingAddressManage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id删除收件地址信息,可批量
|
||||
*/
|
||||
public boolean deleteReceivingAddressByIds(Long[] receivingAddressIds) {
|
||||
return receivingAddressManageDomainService.deleteByIds(receivingAddressIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记默认收件地址
|
||||
* @param receivingAddressManageDo
|
||||
* @return
|
||||
*/
|
||||
public boolean markDefault(ReceivingAddressManageDo receivingAddressManageDo) {
|
||||
return receivingAddressManageDomainService.markDefault(receivingAddressManageDo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取开票金额信息(总计可开票金额、历史已开票金额)
|
||||
* @return
|
||||
*/
|
||||
public Map<String, BigDecimal> getInvoicedAmountInfo() {
|
||||
Map<String, BigDecimal> res = new HashMap<>();
|
||||
InvoiceOrderDo invoiceOrderDo = new InvoiceOrderDo();
|
||||
//获取当前登陆人
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
if (userPo == null){
|
||||
throw new ServiceException("获取当前登陆人信息失败!");
|
||||
}
|
||||
String roleCode = userPo.getRoleCode();
|
||||
Long organizationId = userPo.getOrganizationId();
|
||||
if (roleCode.contains("plat_admin") || roleCode.contains("must")){
|
||||
invoiceOrderDo.setOrganizationId(organizationId);
|
||||
}else {
|
||||
invoiceOrderDo.setCreateBy(userPo.getUserId());
|
||||
}
|
||||
invoiceOrderDo.setApplyStatus(2);
|
||||
Map<String, BigDecimal> sqlRes = invoiceOrderDomainService.getInvoiceCostCan(invoiceOrderDo);
|
||||
if(sqlRes ==null || sqlRes.size()==0){
|
||||
res.put("invoiceCostCan",BigDecimal.ZERO);
|
||||
}else {
|
||||
res.put("invoiceCostCan",sqlRes.get("invoiceCostCan"));
|
||||
}
|
||||
invoiceOrderDo.setApplyStatus(1);
|
||||
Map<String, BigDecimal> sqlResHas = invoiceOrderDomainService.getInvoiceCostCan(invoiceOrderDo);
|
||||
if(sqlResHas ==null || sqlResHas.size()==0){
|
||||
res.put("invoiceCostHas",BigDecimal.ZERO);
|
||||
}else {
|
||||
res.put("invoiceCostHas",sqlResHas.get("invoiceCostHas"));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询可开票订单列表
|
||||
* @param invoiceOrderDo
|
||||
* @return
|
||||
*/
|
||||
public List<InvoiceOrderPo> selectInvoiceOrderList(InvoiceOrderDo invoiceOrderDo) {
|
||||
//获取当前登陆人
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
if (userPo == null){
|
||||
throw new ServiceException("获取当前登陆人信息失败!");
|
||||
}
|
||||
String roleCode = userPo.getRoleCode();
|
||||
Long organizationId = userPo.getOrganizationId();
|
||||
if (roleCode.contains("plat_admin") || roleCode.contains("must")){
|
||||
invoiceOrderDo.setOrganizationId(organizationId);
|
||||
}else {
|
||||
invoiceOrderDo.setCreateBy(userPo.getUserId());
|
||||
}
|
||||
invoiceOrderDo.setApplyStatus(2);
|
||||
return invoiceOrderDomainService.selectInvoiceOrderList(invoiceOrderDo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据运单id查询开票订单信息
|
||||
* @param waybillId
|
||||
* @return
|
||||
*/
|
||||
public InvoiceOrder selectInvoiceByWaybillId(Long waybillId) {
|
||||
return invoiceOrderDomainService.selectInvoiceByWaybillId(waybillId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改开票订单信息
|
||||
* @param invoiceOrder
|
||||
* @return
|
||||
*/
|
||||
public int updateInvoiceOrder(InvoiceOrder invoiceOrder) {
|
||||
return invoiceOrderDomainService.updateInvoiceOrder(invoiceOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增开票订单信息
|
||||
* @param invoiceOrder
|
||||
* @return
|
||||
*/
|
||||
public int insertInvoiceOrder(InvoiceOrder invoiceOrder) {
|
||||
return invoiceOrderDomainService.insertInvoiceOrder(invoiceOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开票订单标记未核实/核实 可批量
|
||||
* @param invoiceOrderDo
|
||||
* @return
|
||||
*/
|
||||
public boolean markVerify(InvoiceOrderDo invoiceOrderDo) {
|
||||
return invoiceOrderDomainService.markVerify(invoiceOrderDo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增开票记录
|
||||
* @param invoiceInfoDto
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertInvoiceInfo(InvoiceInfoDto invoiceInfoDto) {
|
||||
/*
|
||||
新增开票申请后,需要在开票订单表中将开票记录的id绑定在开票订单上
|
||||
*/
|
||||
if(invoiceInfoDto.getInvoiceOrderIds()==null || invoiceInfoDto.getInvoiceOrderIds().length==0){
|
||||
throw new ServiceException("选中开票订单不能为空");
|
||||
}
|
||||
if(invoiceInfoDto.getInvoiceInfoManageId()==null){
|
||||
throw new ServiceException("选中发票抬头信息不能为空");
|
||||
}
|
||||
if(invoiceInfoDto.getReceivingAddressId()== null){
|
||||
throw new ServiceException("选中收件地址不能为空");
|
||||
}
|
||||
InvoiceInfoManagePo invoiceInfoManagePo = invoiceInfoManageDominService.selectInvoiceInfoManageByInvoiceInfoId(invoiceInfoDto.getInvoiceInfoManageId());
|
||||
if(null == invoiceInfoManagePo){
|
||||
throw new ServiceException("发票抬头信息不存在或已被删除");
|
||||
}
|
||||
|
||||
//数据装配
|
||||
InvoiceInfo invoiceInfo = new InvoiceAssembler().toDo(invoiceInfoDto);
|
||||
invoiceInfo.setInvoiceStatus(1);
|
||||
invoiceInfo.setInvoiceHeader(invoiceInfoManagePo.getInvoiceHeader());
|
||||
invoiceInfo.setWaybillAmount(new BigDecimal(invoiceInfoDto.getInvoiceOrderIds().length));
|
||||
|
||||
ReceivingAddressManagePo receivingAddressManagePo = receivingAddressManageDomainService.selectByReceivingAddressId(invoiceInfoDto.getReceivingAddressId());
|
||||
invoiceInfo.setReceivingName(receivingAddressManagePo.getReceivingName());
|
||||
invoiceInfo.setPhone(receivingAddressManagePo.getPhone());
|
||||
invoiceInfo.setPostalCode(receivingAddressManagePo.getPostalCode());
|
||||
invoiceInfo.setAddress(receivingAddressManagePo.getCountyName() + receivingAddressManagePo.getAddress());
|
||||
|
||||
invoiceInfo.setInvoiceApplyNum(OrderSequence.getOrderCode());
|
||||
invoiceInfo.setInvoiceOrderIds(StringUtils.join(invoiceInfoDto.getInvoiceOrderIds(),","));
|
||||
invoiceInfo.setSourceType(invoiceInfoDto.getSourceType());
|
||||
|
||||
//同步网货使用
|
||||
List<TmsTransportNote> tmsTransportNoteList = new ArrayList<>();
|
||||
|
||||
BigDecimal invoiceCost = BigDecimal.ZERO;
|
||||
//操作开票数量
|
||||
int res = 0;
|
||||
//查询选中对账单可开票金额
|
||||
if (invoiceInfoDto.getSourceType() != null && ObjectUtil.equal(invoiceInfoDto.getSourceType(), 2)){
|
||||
List<Reconciliation> reconclilationList = reconciliationDomainService.selectBatchByIds(invoiceInfoDto.getInvoiceOrderIds());
|
||||
Long userId = reconclilationList.get(0).getUserId();
|
||||
reconclilationList.forEach(e->{
|
||||
if (ObjectUtil.notEqual(userId, e.getUserId())){
|
||||
throw new ServiceException("请选择相同货主的对账单进行开票!");
|
||||
}
|
||||
});
|
||||
invoiceInfo.setCreateBy(reconclilationList.get(0).getUserId());
|
||||
invoiceInfo.setOrganizationId(reconclilationList.get(0).getOrganizationId());
|
||||
invoiceCost = reconclilationList.stream().map(Reconciliation::getActualReceivable).reduce(BigDecimal.ZERO,BigDecimal::add);
|
||||
invoiceInfo.setInvoiceCost(invoiceCost);
|
||||
//插入开票数据
|
||||
res = invoiceInfoDomainService.insertInvoiceInfo(invoiceInfo);
|
||||
//插入成功后,将开票记录和订单关联
|
||||
reconciliationDomainService.bindInvoiceInfoId(reconclilationList,invoiceInfo.getInvoiceInfoId());
|
||||
//封装信息同步网货
|
||||
List<Long> wlhyReconciliationIdList = reconclilationList
|
||||
.stream()
|
||||
.filter(item -> Objects.equals(item.getWaybillSource(), SourceConstants.WNGHUOZHONGTAI.getCode()))
|
||||
.map(Reconciliation::getReconciliationId)
|
||||
.collect(Collectors.toList());
|
||||
if (!wlhyReconciliationIdList.isEmpty()){
|
||||
List<BusinessDocument> businessDocuments = businessDocumentDomainService.selectListByReconciliationIds(wlhyReconciliationIdList);
|
||||
if (businessDocuments != null && !businessDocuments.isEmpty()){
|
||||
for (BusinessDocument businessDocument : businessDocuments) {
|
||||
TmsTransportNote tmsTransportNote = new TmsTransportNote();
|
||||
tmsTransportNote.setId(businessDocument.getWaybillId());
|
||||
tmsTransportNote.setIsInvoice(1);
|
||||
tmsTransportNoteList.add(tmsTransportNote);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//查询选中运单可开票金额
|
||||
List<BusinessDocument> businessDocumentList = businessDocumentDomainService.selectListByIds(invoiceInfoDto.getInvoiceOrderIds());
|
||||
Long creatBy = 0L;
|
||||
if (CollectionUtil.isNotEmpty(businessDocumentList)){
|
||||
for (BusinessDocument businessDocument : businessDocumentList) {
|
||||
if (ObjectUtil.equals(creatBy,0L)){
|
||||
creatBy = businessDocument.getCreateBy();
|
||||
}else {
|
||||
if (!ObjectUtil.equals(businessDocument.getCreateBy(),creatBy)){
|
||||
throw new ServiceException("请选择相同托运人进行操作!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
invoiceCost = businessDocumentList.stream().map(BusinessDocument::getReceivableAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
|
||||
invoiceInfo.setCreateBy(businessDocumentList.get(0).getUserId());
|
||||
invoiceInfo.setOrganizationId(businessDocumentList.get(0).getOrganizationId());
|
||||
invoiceInfo.setInvoiceCost(invoiceCost);
|
||||
//插入开票数据
|
||||
res = invoiceInfoDomainService.insertInvoiceInfo(invoiceInfo);
|
||||
//插入成功后,将开票记录和订单关联
|
||||
businessDocumentDomainService.bindInvoiceInfoId(businessDocumentList,invoiceInfo.getInvoiceInfoId());
|
||||
//封装信息同步网货
|
||||
if (!businessDocumentList.isEmpty()){
|
||||
for (BusinessDocument businessDocument : businessDocumentList) {
|
||||
if (ObjectUtil.equal(businessDocument.getWaybillSource(), SourceConstants.WNGHUOZHONGTAI.getCode())){
|
||||
TmsTransportNote tmsTransportNote = new TmsTransportNote();
|
||||
tmsTransportNote.setId(businessDocument.getWaybillId());
|
||||
tmsTransportNote.setIsInvoice(1);
|
||||
tmsTransportNoteList.add(tmsTransportNote);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//同步网货
|
||||
if (!tmsTransportNoteList.isEmpty()){
|
||||
finceWlhyDomainService.updateBillingStatus(tmsTransportNoteList);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开票记录表查询
|
||||
* @param invoiceInfoDo
|
||||
* @return
|
||||
*/
|
||||
@DataPermissions(cacheName = "invoice_createBy")
|
||||
public List<InvoiceInfoPo> invoiceInfoList(InvoiceInfoDo invoiceInfoDo) {
|
||||
return invoiceInfoDomainService.selectInvoiceInfoList(invoiceInfoDo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开具发票
|
||||
* @param invoiceInfoDo
|
||||
* @return
|
||||
*/
|
||||
public boolean insertInvoiceInfoDetails(InvoiceInfoDo invoiceInfoDo) {
|
||||
if(invoiceInfoDo.getInvoiceInfoDetailsDtoList()==null || invoiceInfoDo.getInvoiceInfoDetailsDtoList().isEmpty()){
|
||||
throw new ServiceException("发票信息不能为空");
|
||||
}
|
||||
if(invoiceInfoDo.getInvoiceInfoId() ==null){
|
||||
throw new ServiceException("发票记录id不能为空");
|
||||
}
|
||||
//首先更改发票的状态及信息
|
||||
InvoiceInfoPo invoiceInfoPo = invoiceInfoDomainService.selectInvoiceInfoByInvoiceInfoId(invoiceInfoDo.getInvoiceInfoId());
|
||||
if(null == invoiceInfoPo){
|
||||
throw new ServiceException("发票信息不存在或已被删除");
|
||||
}
|
||||
InvoiceInfo invoiceInfo = new InvoiceInfo();
|
||||
invoiceInfo.setInvoiceInfoId(invoiceInfoPo.getInvoiceInfoId());
|
||||
invoiceInfo.setInvoiceStatus(4);
|
||||
invoiceInfo.setInvoiceMakeTime(new Date());
|
||||
List<InvoiceInfoDetails> invoiceInfoDetailsList = new ArrayList<>();
|
||||
invoiceInfoDo.getInvoiceInfoDetailsDtoList().forEach( info -> {
|
||||
info.setInvoiceInfoId(invoiceInfoDo.getInvoiceInfoId());
|
||||
//数据装配
|
||||
InvoiceInfoDetails invoiceInfoDetails = new InvoiceAssembler().toDo(info);
|
||||
invoiceInfoDetailsList.add(invoiceInfoDetails);
|
||||
});
|
||||
boolean detailsSave = invoiceInfoDetailsDomainService.insertInvoiceInfoDetailsBatch(invoiceInfoDetailsList);
|
||||
boolean infoSave = invoiceInfoDomainService.updateInvoiceInfo(invoiceInfo);
|
||||
if(!detailsSave || !infoSave){
|
||||
throw new ServiceException("开票失败");
|
||||
}
|
||||
//同步网货
|
||||
syncWlhyByInvoiceId(Collections.singletonList(invoiceInfo.getInvoiceInfoId()), 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param invoiceIdList
|
||||
* @param isInvoice
|
||||
*/
|
||||
public void syncWlhyByInvoiceId(List<Long> invoiceIdList, Integer isInvoice){
|
||||
//同步网货使用
|
||||
List<TmsTransportNote> tmsTransportNoteList = new ArrayList<>();
|
||||
List<InvoiceInfo> list = invoiceInfoDomainService.selectBatchByIds(invoiceIdList);
|
||||
if (list != null && !list.isEmpty()){
|
||||
//业务单据
|
||||
List<Long> businessDocumentInvoiceIdList = list.stream().filter(item -> Objects.equals(item.getSourceType(), 1)).map(InvoiceInfo::getInvoiceInfoId).collect(Collectors.toList());
|
||||
if (!businessDocumentInvoiceIdList.isEmpty()){
|
||||
List<BusinessDocument> businessDocuments = businessDocumentDomainService.selectListByInvoiceIds(businessDocumentInvoiceIdList);
|
||||
if (businessDocuments != null && !businessDocuments.isEmpty()){
|
||||
for (BusinessDocument businessDocument : businessDocuments) {
|
||||
if (ObjectUtil.equal(businessDocument.getWaybillSource(), SourceConstants.WNGHUOZHONGTAI.getCode())){
|
||||
TmsTransportNote tmsTransportNote = new TmsTransportNote();
|
||||
tmsTransportNote.setId(businessDocument.getWaybillId());
|
||||
tmsTransportNote.setIsInvoice(isInvoice);
|
||||
tmsTransportNoteList.add(tmsTransportNote);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//对账单
|
||||
List<Long> reconciliationInvoiceIdList = list.stream().filter(item -> Objects.equals(item.getSourceType(), 2)).map(InvoiceInfo::getInvoiceInfoId).collect(Collectors.toList());
|
||||
if (!reconciliationInvoiceIdList.isEmpty()){
|
||||
List<Reconciliation> reconciliations = reconciliationDomainService.selectBatchByInvoiceIds(reconciliationInvoiceIdList);
|
||||
if (reconciliations != null && !reconciliations.isEmpty()){
|
||||
List<Long> wlhyReconciliationIdList = reconciliations
|
||||
.stream()
|
||||
.filter(item -> Objects.equals(item.getWaybillSource(), SourceConstants.WNGHUOZHONGTAI.getCode()))
|
||||
.map(Reconciliation::getReconciliationId)
|
||||
.collect(Collectors.toList());
|
||||
if (!wlhyReconciliationIdList.isEmpty()){
|
||||
List<BusinessDocument> businessDocuments = businessDocumentDomainService.selectListByReconciliationIds(wlhyReconciliationIdList);
|
||||
if (businessDocuments != null && !businessDocuments.isEmpty()){
|
||||
for (BusinessDocument businessDocument : businessDocuments) {
|
||||
TmsTransportNote tmsTransportNote = new TmsTransportNote();
|
||||
tmsTransportNote.setId(businessDocument.getWaybillId());
|
||||
tmsTransportNote.setIsInvoice(isInvoice);
|
||||
tmsTransportNoteList.add(tmsTransportNote);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//同步网货
|
||||
if (!tmsTransportNoteList.isEmpty()){
|
||||
finceWlhyDomainService.updateBillingStatus(tmsTransportNoteList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询开票记录详情/发票详情
|
||||
* @param invoiceInfoId
|
||||
* @return
|
||||
*/
|
||||
public InvoiceInfoPo selectInvoiceInfoById(Long invoiceInfoId) {
|
||||
//发票信息主体
|
||||
InvoiceInfoPo invoiceInfoPo = invoiceInfoDomainService.selectInvoiceInfoByInvoiceInfoId(invoiceInfoId);
|
||||
if(null == invoiceInfoPo){
|
||||
throw new ServiceException("开票记录未找到或已被删除");
|
||||
}
|
||||
//发票信息明细
|
||||
List<InvoiceInfoDetailsPo> invoiceInfoDetailsPoList = invoiceInfoDetailsDomainService.selectDetailsListByInvoiceInfoId(invoiceInfoId);
|
||||
//查询开票运单表明细(查询业务单据表)
|
||||
List<InvoiceOrderPo> invoiceOrderPoList = new ArrayList<>();
|
||||
if(StringUtils.isNotEmpty(invoiceInfoPo.getInvoiceOrderIds())){
|
||||
Set<String> invoiceOrderIdList = Stream.of(invoiceInfoPo.getInvoiceOrderIds().split(",")).collect(Collectors.toSet());
|
||||
List<Long> ids = new ArrayList<>();
|
||||
if (!invoiceOrderIdList.isEmpty()){
|
||||
invoiceOrderIdList.forEach(e->ids.add(Long.valueOf(e)));
|
||||
List<BusinessDocument> businessDocumentList = new ArrayList<>();
|
||||
if (invoiceInfoPo.getSourceType() != null && ObjectUtil.equal(invoiceInfoPo.getSourceType(), 2)){
|
||||
List<Reconciliation> reconciliations = reconciliationDomainService.selectBatchByIds(ids);
|
||||
List<Long> reconciliationIdList = reconciliations.stream().map(Reconciliation::getReconciliationId).collect(Collectors.toList());
|
||||
businessDocumentList = businessDocumentDomainService.selectListByReconciliationIds(reconciliationIdList);
|
||||
}else {
|
||||
businessDocumentList = businessDocumentDomainService.selectListByIds(ids);
|
||||
}
|
||||
for (BusinessDocument businessDocument : businessDocumentList) {
|
||||
InvoiceOrderPo invoiceOrderPo = new InvoiceOrderPo();
|
||||
invoiceOrderPo.setWaybillNumber(businessDocument.getWaybillNumber());
|
||||
invoiceOrderPo.setFreight(businessDocument.getReceivableAmount());
|
||||
invoiceOrderPo.setInvoiceCostCan(businessDocument.getReceivableAmount());
|
||||
invoiceOrderPo.setInvoiceCostCanService(businessDocument.getPayableAmount());
|
||||
invoiceOrderPo.setWaybillPayTime(businessDocument.getPayTimeShipper());
|
||||
invoiceOrderPo.setDriverName(businessDocument.getDriverName());
|
||||
invoiceOrderPo.setDriverPhone(businessDocument.getPhone());
|
||||
invoiceOrderPo.setVehicleLicensePlateNumber(businessDocument.getVehicleLicensePlateNumber());
|
||||
invoiceOrderPo.setLoadAddress(businessDocument.getLoadingAdress());
|
||||
invoiceOrderPo.setUnloadAddress(businessDocument.getUnloadAdress());
|
||||
invoiceOrderPo.setFreightName(businessDocument.getFreightName());
|
||||
invoiceOrderPoList.add(invoiceOrderPo);
|
||||
}
|
||||
}
|
||||
}
|
||||
invoiceInfoPo.setInvoiceOrderPoList(invoiceOrderPoList);
|
||||
invoiceInfoPo.setInvoiceInfoDetailsPoList(invoiceInfoDetailsPoList);
|
||||
return invoiceInfoPo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询默认收件地址
|
||||
* @return
|
||||
*/
|
||||
public ReceivingAddressManage selectReceivingAddressMine() {
|
||||
return receivingAddressManageDomainService.selectReceivingAddressMine();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 标记开票记录状态
|
||||
* @param invoiceInfoDto
|
||||
* @return
|
||||
*/
|
||||
public boolean markInvoiceStatus(InvoiceInfoDto invoiceInfoDto) {
|
||||
//将开票订单表绑定的开票记录清空,并将申请开票金额清空
|
||||
invoiceOrderDomainService.unBindInvoiceInfo(invoiceInfoDto.getInvoiceInfoId());
|
||||
boolean b = invoiceInfoDomainService.markInvoiceStatus(invoiceInfoDto);
|
||||
if (b){
|
||||
//同步网货
|
||||
Integer isInvoice = 0;
|
||||
switch (invoiceInfoDto.getOperateType()){
|
||||
case 1:
|
||||
case 2:
|
||||
isInvoice = 0;
|
||||
break;
|
||||
case 3:
|
||||
isInvoice = 5;
|
||||
break;
|
||||
default:
|
||||
throw new ServiceException("未知操作类型");
|
||||
}
|
||||
//同步网货
|
||||
syncWlhyByInvoiceId(Collections.singletonList(invoiceInfoDto.getInvoiceInfoId()), isInvoice);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发票寄出
|
||||
* @param invoiceInfoDto
|
||||
* @return
|
||||
*/
|
||||
public boolean invoiceMail(InvoiceInfoDto invoiceInfoDto) {
|
||||
//快递公司填充
|
||||
if(StringUtils.isNotEmpty(invoiceInfoDto.getExpressDelivery())){
|
||||
List<SysDictDataVo> sysDictDataVoList = new ArrayList<>();
|
||||
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(DictCode.express_company.getCode());
|
||||
if("200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
sysDictDataVoList = JSON.parseArray(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
|
||||
}
|
||||
if(sysDictDataVoList!= null && !sysDictDataVoList.isEmpty()){
|
||||
Optional<SysDictDataVo> sysDictDataVo = sysDictDataVoList.stream().filter(info->ObjectUtil.equal(info.getDictValue(),invoiceInfoDto.getExpressDelivery())).findAny();
|
||||
if(sysDictDataVo.isPresent()){
|
||||
SysDictDataVo sysDictDataVo1 = sysDictDataVo.get();
|
||||
invoiceInfoDto.setExpressDeliveryValue(sysDictDataVo1.getDictLabel());
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean b = invoiceInfoDomainService.invoiceMail(invoiceInfoDto);
|
||||
if (b){
|
||||
//同步网货
|
||||
syncWlhyByInvoiceId(Arrays.asList(invoiceInfoDto.getInvoiceInfoIds()), 4);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开票订单列表查询金额统计
|
||||
* @param invoiceOrderDo
|
||||
* @param dataPermission
|
||||
* @return
|
||||
*/
|
||||
public AjaxResult selectOrderListCount(InvoiceOrderDo invoiceOrderDo, DataPermission dataPermission) {
|
||||
Map<String,String> res = new HashMap<>();
|
||||
if(ObjectUtil.isNotEmpty(dataPermission)){
|
||||
if(dataPermission.getOrganizationIdList() != null && dataPermission.getOrganizationIdList().size() > 0){
|
||||
invoiceOrderDo.setOrganizationIdList(dataPermission.getOrganizationIdList());
|
||||
}
|
||||
if(dataPermission.getCreateBy() != null){
|
||||
invoiceOrderDo.setCreateBy(dataPermission.getCreateBy());
|
||||
}
|
||||
}
|
||||
List<InvoiceOrderPo> invoiceOrderPoList = invoiceOrderDomainService.selectInvoiceOrderList(invoiceOrderDo);
|
||||
//统计全部未申请的订单
|
||||
List<InvoiceOrderPo> unApply = invoiceOrderPoList.stream().filter(item -> item.getApplyStatus()==2).collect(Collectors.toList());
|
||||
//统计全部已申请的订单
|
||||
List<InvoiceOrderPo> apply = invoiceOrderPoList.stream().filter(item -> item.getApplyStatus()==1).collect(Collectors.toList());
|
||||
//总计可开票金额
|
||||
BigDecimal countAll = invoiceOrderPoList.stream().map(InvoiceOrderPo::getInvoiceCostCan).reduce(BigDecimal.ZERO,BigDecimal::add);
|
||||
//历史已开票金额
|
||||
BigDecimal countHistory = apply.stream().map(InvoiceOrderPo::getInvoiceCostHas).reduce(BigDecimal.ZERO,BigDecimal::add);
|
||||
//可申请开票金额
|
||||
BigDecimal count = unApply.stream().map(InvoiceOrderPo::getInvoiceCostCan).reduce(BigDecimal.ZERO,BigDecimal::add);
|
||||
res.put("invoiceCostCan",count.toString());
|
||||
res.put("total",String.valueOf(invoiceOrderPoList.size()));
|
||||
res.put("invoiceCostHas",countHistory.toString());
|
||||
res.put("invoiceCostCanAll",countAll.toString());
|
||||
return AjaxResult.success(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* APP查询近期发票列表
|
||||
* @param invoiceInfoDo
|
||||
* @return
|
||||
*/
|
||||
public List<InvoiceInfoAppPo> invoiceInfoAppList(InvoiceInfoDo invoiceInfoDo) {
|
||||
//获取当前登陆人
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
if (userPo == null){
|
||||
throw new ServiceException("获取当前登陆人信息失败!");
|
||||
}
|
||||
String roleCode = userPo.getRoleCode();
|
||||
Long organizationId = userPo.getOrganizationId();
|
||||
if (roleCode.contains("plat_admin") || roleCode.contains("must")){
|
||||
invoiceInfoDo.setOrganizationId(organizationId);
|
||||
}else {
|
||||
invoiceInfoDo.setCreateBy(userPo.getUserId());
|
||||
}
|
||||
return invoiceInfoDomainService.invoiceInfoAppList(invoiceInfoDo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* APP申请开票运单列表查询
|
||||
* @param invoiceOrderDo
|
||||
* @return
|
||||
*/
|
||||
public List<InvoiceOrderAppPo> invoiceOrderAppList(InvoiceOrderDo invoiceOrderDo) {
|
||||
//获取当前登陆人
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
if (userPo == null){
|
||||
throw new ServiceException("获取当前登陆人信息失败!");
|
||||
}
|
||||
String roleCode = userPo.getRoleCode();
|
||||
Long organizationId = userPo.getOrganizationId();
|
||||
if (roleCode.contains(RoleEnum.PLAT_ADMIN.getCode()) || roleCode.contains(RoleEnum.MUST.getCode())){
|
||||
invoiceOrderDo.setOrganizationId(organizationId);
|
||||
}else {
|
||||
invoiceOrderDo.setCreateBy(userPo.getUserId());
|
||||
}
|
||||
invoiceOrderDo.setApplyStatus(2);
|
||||
return invoiceOrderDomainService.invoiceOrderAppList(invoiceOrderDo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户发票抬头
|
||||
* @return
|
||||
*/
|
||||
public List<InvoiceInfoManagePo> invoiceTitleList() {
|
||||
//获取当前登陆人
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
InvoiceInfoManageDo invoiceInfoManageDo = new InvoiceInfoManageDo();
|
||||
invoiceInfoManageDo.setUserId(loginUser.getUserPo().getUserId());
|
||||
return invoiceInfoManageDominService.selectInvoiceInfoManageList(invoiceInfoManageDo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询开票详情
|
||||
* @param invoiceInfoDo
|
||||
* @return
|
||||
*/
|
||||
public InvoiceInfoAppPo invoiceInfoDetailApp(InvoiceInfoDo invoiceInfoDo) {
|
||||
if(invoiceInfoDo.getInvoiceInfoId()==null){
|
||||
throw new ServiceException("开票记录表id不能为空");
|
||||
}
|
||||
InvoiceInfoAppPo invoiceInfoAppPo = invoiceInfoDomainService.invoiceInfoDetailApp(invoiceInfoDo.getInvoiceInfoId());
|
||||
List<BusinessDocumentAppPO> businessDocumentPOList = businessDocumentDomainService.queryListByInvoiceId(invoiceInfoDo.getInvoiceInfoId());
|
||||
invoiceInfoAppPo.setBusinessDocumentPOList(businessDocumentPOList);
|
||||
return invoiceInfoAppPo;
|
||||
}
|
||||
|
||||
public void getInvoiceByUserId(Long userId) {
|
||||
InvoiceInfoDo invoiceInfoDo = new InvoiceInfoDo();
|
||||
invoiceInfoDo.setCreateBy(userId);
|
||||
invoiceInfoDo.setInvoiceStatus(1);
|
||||
List<InvoiceInfoPo> invoiceInfoPos = invoiceInfoDomainService.selectInvoiceInfoList(invoiceInfoDo);
|
||||
if (invoiceInfoPos != null && !invoiceInfoPos.isEmpty()){
|
||||
throw new ServiceException("存在申请中的发票信息,请处理后再试;");
|
||||
}
|
||||
}
|
||||
}
|
||||
+952
@@ -0,0 +1,952 @@
|
||||
package com.linke.finance.application.service.loanManage;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.linke.finance.domain.loanManage.entity.LoanManage;
|
||||
import com.linke.finance.domain.loanManage.repository.po.LoanManagePo;
|
||||
import com.linke.finance.domain.loanManage.repository.todo.LoanManageDo;
|
||||
import com.linke.finance.domain.loanManage.service.LoanManageDomainService;
|
||||
import com.linke.finance.domain.report.repository.po.CollectionStatisticsPO;
|
||||
import com.linke.finance.domain.report.repository.po.LoanStatisticsPO;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.entity.RevenueExpensesRecord;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.service.RevenueExpensesRecordDomainService;
|
||||
import com.linke.finance.domain.verification.service.VerificationDomainService;
|
||||
import com.linke.finance.infrastructure.feign.SpecialLogisticsServiceFeign;
|
||||
import com.linke.finance.infrastructure.feign.SystemServiceFeign;
|
||||
import com.linke.finance.infrastructure.feign.UserServiceFeign;
|
||||
import com.linke.finance.infrastructure.util.annotation.DataPermissions;
|
||||
import com.linke.finance.infrastructure.vo.SysDictDataVo;
|
||||
import com.linke.finance.interfaces.assemble.loanManage.LoanManageAssembler;
|
||||
import com.linke.finance.interfaces.dto.LoanManageDto;
|
||||
import com.linke.finance.interfaces.dto.report.ReportDTO;
|
||||
import com.mhd.common.core.constant.PaymentChannelConstants;
|
||||
import com.mhd.common.core.constant.SubjectConstants;
|
||||
import com.mhd.common.core.domain.dto.WaybillDto;
|
||||
import com.mhd.common.core.domain.entity.Branch;
|
||||
import com.mhd.common.core.domain.entity.Verification;
|
||||
import com.mhd.common.core.domain.po.UserPo;
|
||||
import com.mhd.common.core.domain.po.VerificationPo;
|
||||
import com.mhd.common.core.enums.DictCode;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.core.utils.bean.BeanUtils;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.redis.service.RedisService;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.common.security.utils.password.PasswordCheckUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 货款管理 应用服务层
|
||||
*
|
||||
* 本层可以综合应用各种业务间的组合
|
||||
*
|
||||
* 2023-03-16
|
||||
*
|
||||
* @author 王子豪
|
||||
*/
|
||||
@Service
|
||||
public class LoanManageApplicationService
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private LoanManageDomainService loanManageDomainService;
|
||||
@Autowired
|
||||
private SpecialLogisticsServiceFeign specialLogisticsServiceFeign;
|
||||
@Autowired
|
||||
private VerificationDomainService verificationDomainService;
|
||||
@Autowired
|
||||
private RevenueExpensesRecordDomainService revenueExpensesRecordDomainService;
|
||||
@Autowired
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private UserServiceFeign userServiceFeign;
|
||||
|
||||
/**
|
||||
* 查询货款管理
|
||||
*
|
||||
* @param loanManageId 货款管理主键
|
||||
* @return 货款管理
|
||||
*/
|
||||
public LoanManagePo selectLoanManageByLoanManageId(Long loanManageId){
|
||||
LoanManagePo loanManagePo = loanManageDomainService.selectLoanManageByLoanManageId(loanManageId);
|
||||
return loanManagePo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询货款收回、发放管理列表
|
||||
*
|
||||
* @param loanManageDo 货款管理
|
||||
* @return 货款管理集合
|
||||
*/
|
||||
@DataPermissions(cacheName = "branch")
|
||||
public List<LoanManagePo> selectLoanManageList(LoanManageDo loanManageDo) {
|
||||
List<LoanManagePo> loanManagePos = new ArrayList<>();
|
||||
if (loanManageDo.getBranchId() != null || CollUtil.isNotEmpty(loanManageDo.getBranchIdList())) {
|
||||
loanManagePos = loanManageDomainService.selectLoanManageList(loanManageDo);
|
||||
}
|
||||
return loanManagePos;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询货款收回、发放管理列表
|
||||
*
|
||||
* @param loanManageDo 货款管理
|
||||
* @return 货款管理集合
|
||||
*/
|
||||
public List<LoanManagePo> selectAllLoanManageList(LoanManageDo loanManageDo) {
|
||||
return loanManageDomainService.selectLoanManageList(loanManageDo);
|
||||
}
|
||||
|
||||
public List<LoanManagePo> selectLoanManageListFeign(LoanManageDo loanManageDo) {
|
||||
return loanManageDomainService.selectLoanManageList(loanManageDo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇总管理列表
|
||||
*
|
||||
* @param loanManageDo 货款管理
|
||||
* @return 货款管理集合
|
||||
*/
|
||||
@DataPermissions(cacheName = "branch")
|
||||
public List<LoanManagePo> selectLoanManageprovideList(LoanManageDo loanManageDo) {
|
||||
List<LoanManagePo> list = new ArrayList<>();
|
||||
if (loanManageDo.getBranchId() != null || CollUtil.isNotEmpty(loanManageDo.getBranchIdList())) {
|
||||
list = loanManageDomainService.selectLoanManageprovideList(loanManageDo);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增货款管理
|
||||
*
|
||||
* @param loanManageDto 货款管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
public int insertLoanManage(LoanManageDto loanManageDto){
|
||||
LoanManage loanManage = new LoanManageAssembler().toDo(loanManageDto);
|
||||
//支付通道
|
||||
if(StringUtils.isNotEmpty(loanManage.getPayChannel())){
|
||||
List<SysDictDataVo> timeTagEndVos = selectListByDictType(DictCode.pay_channel.getCode());
|
||||
if(StringUtils.isNotEmpty(loanManage.getPayChannel()) && timeTagEndVos != null){
|
||||
List<SysDictDataVo> noticeMouldManagePos = timeTagEndVos.stream().filter(info -> ObjectUtil.equal(info.getDictValue(),loanManage.getPayChannel())).collect(Collectors.toList());
|
||||
if(noticeMouldManagePos != null && noticeMouldManagePos.size() > 0){
|
||||
loanManage.setPayChannelName(noticeMouldManagePos.get(0).getDictLabel());
|
||||
}else {
|
||||
throw new ServiceException("请先维护支付通道数据字典");
|
||||
}
|
||||
}
|
||||
}
|
||||
return loanManageDomainService.insertLoanManage(loanManage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量新增货款管理
|
||||
*
|
||||
* @param list 货款管理集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchAddLoanManage(List<LoanManage> list){
|
||||
return loanManageDomainService.batchAddLoanManage(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改货款管理
|
||||
*
|
||||
* @param loanManageDto 货款管理
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateLoanManage(LoanManageDto loanManageDto){
|
||||
LoanManage loanManage = new LoanManageAssembler().toDo(loanManageDto);
|
||||
return loanManageDomainService.updateLoanManage(loanManage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id批量修改货款管理
|
||||
*
|
||||
* @param loanManageDto 货款管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
public int updateLoanManages(LoanManageDto loanManageDto){
|
||||
if (StrUtil.isNotEmpty(loanManageDto.getPayPassword())){
|
||||
//校验支付密码
|
||||
//获取当前登录人
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
//临时方案,用户修改密码后,用token获取用户信息,数据不一致,需要重新获取用户信息
|
||||
AjaxResult ajaxResult = userServiceFeign.getInfo(userPo.getUserId());
|
||||
if("200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
userPo = JSONUtil.toBean(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
|
||||
}else {
|
||||
throw new ServiceException("用户信息获取失败");
|
||||
}
|
||||
boolean b = PasswordCheckUtils.payPasswordCheck(loanManageDto.getPayPassword(),userPo);
|
||||
if (!b) {
|
||||
throw new ServiceException("支付密码错误");
|
||||
}
|
||||
}
|
||||
if(loanManageDto.getLoanManageIds() != null && loanManageDto.getLoanManageIds().size() > 0){
|
||||
for (Long loanManageId : loanManageDto.getLoanManageIds()) {
|
||||
LoanManageDto loanManage= new LoanManageDto();
|
||||
BeanUtils.copyProperties(loanManageDto, loanManage);
|
||||
loanManage.setLoanManageId(loanManageId);
|
||||
updateLoanManageTwo(loanManage);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id批量修改货款管理
|
||||
*
|
||||
* @param loanManageDto 货款管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
public int updateLoanManageTwo(LoanManageDto loanManageDto){
|
||||
//存到redis里的数据
|
||||
Map<String,String> mapRedis = new HashMap();
|
||||
LoanManagePo loanManagePo = new LoanManagePo();
|
||||
BeanUtils.copyProperties(loanManageDto, loanManagePo);
|
||||
|
||||
loanManageDomainService.deleteLoanImageByLoanId(loanManagePo.getLoanManageId());
|
||||
LoanManagePo loanManage = loanManageDomainService.selectLoanManageByLoanManageId(loanManagePo.getLoanManageId());
|
||||
String loanManagePoContent = JSON.toJSONString(loanManage);
|
||||
mapRedis.put("loanManagePoContent",loanManagePoContent);
|
||||
// 获取登录人id
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
String userName = SecurityUtils.getLoginUser().getUsername();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
//更新运单状态
|
||||
WaybillDto waybillDto = new WaybillDto();
|
||||
List<Long> longs = new ArrayList<>();
|
||||
//放款
|
||||
if(loanManageDto.getGrantStatus() != null && loanManageDto.getGrantStatus() == 2){
|
||||
//支付通道
|
||||
if (StringUtils.isNotEmpty(loanManagePo.getPayChannel())) {
|
||||
List<SysDictDataVo> timeTagEndVos = selectListByDictType(DictCode.payment_channel.getCode());
|
||||
if (StringUtils.isNotEmpty(loanManagePo.getPayChannel()) && timeTagEndVos != null) {
|
||||
List<SysDictDataVo> noticeMouldManagePos = timeTagEndVos.stream().filter(info -> ObjectUtil.equal(info.getDictValue(), loanManagePo.getPayChannel())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(noticeMouldManagePos)) {
|
||||
loanManagePo.setPayChannel(null);
|
||||
loanManagePo.setPayWay(noticeMouldManagePos.get(0).getDictValue());
|
||||
loanManagePo.setPayWayName(noticeMouldManagePos.get(0).getDictLabel());
|
||||
} else {
|
||||
throw new ServiceException("请先维护支付通道数据字典");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//选择钱包支付的时候判断是否存在收款人
|
||||
if (StrUtil.equals(loanManagePo.getPayWay(), PaymentChannelConstants.wallet_pay)) {
|
||||
if (ObjectUtil.isNull(loanManage.getCollectionId())) {
|
||||
throw new ServiceException("支付失败,收款人为空!");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 货款放款类型是银行卡/现金时,收款核销后,再放款
|
||||
* 货款放款类型时垫付的,允许先放款
|
||||
*/
|
||||
if (loanManage.getLoanType() == 2 && loanManage.getLoanRequest() != 3){
|
||||
//查询货款收回记录
|
||||
LoanManageDo query = new LoanManageDo();
|
||||
query.setLoanNumber(loanManage.getLoanNumber());
|
||||
query.setLoanType(1);
|
||||
LoanManagePo loanManageInfo = loanManageDomainService.selectLoanManageInfo(query);
|
||||
if (ObjectUtil.isNull(loanManageInfo)){
|
||||
throw new ServiceException("货款收回记录查询失败");
|
||||
}
|
||||
if (loanManageInfo.getCollectionStatus() != 3){
|
||||
throw new ServiceException("货款收回未核销");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
waybillDto.setWaybillId(loanManage.getWaybillId());
|
||||
waybillDto.setLoanTime(new Date());
|
||||
// specialLogisticsServiceFeign.update(waybillDto);
|
||||
//放款时间
|
||||
loanManagePo.setLoanTime(new Date());
|
||||
loanManagePo.setInnerNumber("fangkuan"+sdf.format(new Date()));
|
||||
loanManagePo.setLoanId(userId);
|
||||
loanManagePo.setLoanName(userName);
|
||||
loanManagePo.setCommissionChargesStatus(6);
|
||||
RevenueExpensesRecord revenueExpensesRecord = new RevenueExpensesRecord();
|
||||
// revenueExpensesRecord.setBranchId(loanManage.getBranchId());
|
||||
//生成配载单号
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour + loanManage.getLoanManageId();
|
||||
revenueExpensesRecord.setInnerNumber(innerNumber);
|
||||
revenueExpensesRecord.setRevenueExpensesType(2);
|
||||
revenueExpensesRecord.setMoney(loanManage.getLoanMoney());
|
||||
revenueExpensesRecord.setFirstSubject(SubjectConstants.FIRST_SUBJECT_TWO.getCode());
|
||||
revenueExpensesRecord.setFirstSubjectName(SubjectConstants.FIRST_SUBJECT_TWO.getName());
|
||||
revenueExpensesRecord.setSecondSubject(SubjectConstants.SECOND_SUBJECT_TWO_THREE.getCode());
|
||||
revenueExpensesRecord.setSecondSubjectName(SubjectConstants.SECOND_SUBJECT_TWO_THREE.getName());
|
||||
revenueExpensesRecord.setPayChannel(loanManage.getPayChannel());
|
||||
revenueExpensesRecord.setPayChannelName(loanManage.getPayChannelName());
|
||||
revenueExpensesRecord.setEntryValue(1);
|
||||
revenueExpensesRecord.setDayToDayStatus(1);
|
||||
// revenueExpensesRecord.setWaybillId(loanManage.getWaybillId());
|
||||
// revenueExpensesRecord.setWaybillNumber(loanManage.getWaybillNumber());
|
||||
// revenueExpensesRecord.setWaybillSource(loanManage.getWaybillSource());
|
||||
// revenueExpensesRecord.setWaybillSourceName(loanManage.getWaybillSourceName());
|
||||
// revenueExpensesRecord.setSettleAccountsStatus(1);
|
||||
revenueExpensesRecord.setBankNumber(loanManage.getBankNumber());
|
||||
revenueExpensesRecord.setCreateTime(new Date());
|
||||
revenueExpensesRecord.setCreateBy(userId);
|
||||
revenueExpensesRecord.setCreateByName(userName);
|
||||
revenueExpensesRecordDomainService.insertRevenueExpensesRecord(revenueExpensesRecord);
|
||||
longs.add(revenueExpensesRecord.getRevenueExpensesRecordId());
|
||||
if(loanManage != null && loanManage.getCommissionCharges() != null && loanManage.getCommissionCharges().compareTo(BigDecimal.ZERO) != 0){
|
||||
//生成收入手续费的流水
|
||||
RevenueExpensesRecord revenueExpensesRecordTwo = new RevenueExpensesRecord();
|
||||
// revenueExpensesRecordTwo.setBranchId(loanManage.getBranchId());
|
||||
int random = (int) (Math.random()*9000+1000);
|
||||
String innerNumberTwo = format + random + loanManage.getLoanManageId();
|
||||
revenueExpensesRecordTwo.setInnerNumber(innerNumberTwo);
|
||||
revenueExpensesRecordTwo.setRevenueExpensesType(1);
|
||||
revenueExpensesRecordTwo.setMoney(loanManage.getCommissionCharges());
|
||||
revenueExpensesRecordTwo.setFirstSubject(SubjectConstants.FIRST_SUBJECT_TWO.getCode());
|
||||
revenueExpensesRecordTwo.setFirstSubjectName(SubjectConstants.FIRST_SUBJECT_TWO.getName());
|
||||
revenueExpensesRecordTwo.setSecondSubject(SubjectConstants.SECOND_SUBJECT_TWO_ONE.getCode());
|
||||
revenueExpensesRecordTwo.setSecondSubjectName(SubjectConstants.SECOND_SUBJECT_TWO_ONE.getName());
|
||||
revenueExpensesRecordTwo.setPayChannel(loanManage.getPayChannel());
|
||||
revenueExpensesRecordTwo.setPayChannelName(loanManage.getPayChannelName());
|
||||
revenueExpensesRecordTwo.setEntryValue(1);
|
||||
revenueExpensesRecordTwo.setDayToDayStatus(1);
|
||||
// revenueExpensesRecordTwo.setWaybillId(loanManage.getWaybillId());
|
||||
// revenueExpensesRecordTwo.setWaybillNumber(loanManage.getWaybillNumber());
|
||||
// revenueExpensesRecordTwo.setWaybillSource(loanManage.getWaybillSource());
|
||||
// revenueExpensesRecordTwo.setWaybillSourceName(loanManage.getWaybillSourceName());
|
||||
// revenueExpensesRecordTwo.setSettleAccountsStatus(1);
|
||||
revenueExpensesRecordTwo.setBankNumber(loanManage.getBankNumber());
|
||||
revenueExpensesRecordTwo.setCreateTime(new Date());
|
||||
revenueExpensesRecordTwo.setCreateBy(userId);
|
||||
revenueExpensesRecordTwo.setCreateByName(userName);
|
||||
revenueExpensesRecordDomainService.insertRevenueExpensesRecord(revenueExpensesRecordTwo);
|
||||
longs.add(revenueExpensesRecordTwo.getRevenueExpensesRecordId());
|
||||
}
|
||||
VerificationPo verificationPo = new VerificationPo();
|
||||
// verificationPo.setWaybillId(loanManage.getWaybillId());
|
||||
verificationPo.setFirstSubject(SubjectConstants.FIRST_SUBJECT_ONE.getCode());
|
||||
verificationPo.setSecondSubject(SubjectConstants.SECOND_SUBJECT_ONE_FIVE.getCode());
|
||||
List<VerificationPo> verificationPos = verificationDomainService.selectVerificationList(verificationPo);
|
||||
if(verificationPos != null && verificationPos.size() > 0){
|
||||
VerificationPo verificationPo1 = verificationPos.get(0);
|
||||
Verification verification = new Verification();
|
||||
verification.setVerificationId(verificationPo1.getVerificationId());
|
||||
verification.setVerificationStatus(6);
|
||||
String verificationPoContent = JSON.toJSONString(verificationPo1);
|
||||
mapRedis.put("verificationPoContent",verificationPoContent);
|
||||
verificationDomainService.updateVerification(verification);
|
||||
//生成扣付的收支流水
|
||||
RevenueExpensesRecord revenueExpensesRecordTwo = new RevenueExpensesRecord();
|
||||
// revenueExpensesRecordTwo.setBranchId(verificationPo1.getBranchId());
|
||||
//生成配载单号
|
||||
int random = (int) (Math.random()*9000+1000);
|
||||
String innerNumberTwo = format + random + verificationPo1.getVerificationId();
|
||||
revenueExpensesRecord.setInnerNumber(innerNumberTwo);
|
||||
revenueExpensesRecord.setRevenueExpensesType(1);
|
||||
revenueExpensesRecord.setMoney(verificationPo1.getVerificationMoney());
|
||||
revenueExpensesRecord.setFirstSubject(verificationPo1.getFirstSubject());
|
||||
revenueExpensesRecord.setSecondSubject(verificationPo1.getSecondSubject());
|
||||
revenueExpensesRecord.setFirstSubjectName(verificationPo1.getFirstSubjectName());
|
||||
revenueExpensesRecord.setSecondSubjectName(verificationPo1.getSecondSubjectName());
|
||||
revenueExpensesRecord.setPayChannel(verificationPo1.getPayChannel());
|
||||
revenueExpensesRecord.setPayChannelName(verificationPo1.getPayChannelName());
|
||||
revenueExpensesRecord.setEntryValue(1);
|
||||
revenueExpensesRecord.setDayToDayStatus(1);
|
||||
// revenueExpensesRecord.setWaybillId(verificationPo1.getWaybillId());
|
||||
// revenueExpensesRecord.setWaybillNumber(verificationPo1.getWaybillNumber());
|
||||
// revenueExpensesRecord.setWaybillSource(verificationPo1.getWaybillSource());
|
||||
// revenueExpensesRecord.setWaybillSourceName(verificationPo1.getWaybillSourceName());
|
||||
// revenueExpensesRecord.setSettleAccountsStatus(1);
|
||||
revenueExpensesRecord.setBankNumber(verificationPo1.getBankNumber());
|
||||
revenueExpensesRecord.setCreateTime(new Date());
|
||||
revenueExpensesRecord.setCreateBy(userId);
|
||||
revenueExpensesRecord.setCreateByName(userName);
|
||||
revenueExpensesRecordDomainService.insertRevenueExpensesRecord(revenueExpensesRecord);
|
||||
longs.add(revenueExpensesRecord.getRevenueExpensesRecordId());
|
||||
}
|
||||
}
|
||||
else if(loanManageDto.getGrantStatus() != null && loanManageDto.getGrantStatus() == 1){
|
||||
loanManagePo.setCommissionChargesStatus(4);
|
||||
//取消放款
|
||||
RevenueExpensesRecord revenueExpensesRecord = new RevenueExpensesRecord();
|
||||
// revenueExpensesRecord.setBranchId(loanManage.getBranchId());
|
||||
//生成配载单号
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour + loanManage.getLoanManageId();
|
||||
revenueExpensesRecord.setInnerNumber(innerNumber);
|
||||
revenueExpensesRecord.setRevenueExpensesType(1);
|
||||
revenueExpensesRecord.setMoney(loanManage.getLoanMoney());
|
||||
revenueExpensesRecord.setFirstSubject(SubjectConstants.FIRST_SUBJECT_TWO.getCode());
|
||||
revenueExpensesRecord.setFirstSubjectName(SubjectConstants.FIRST_SUBJECT_TWO.getName());
|
||||
revenueExpensesRecord.setSecondSubject(SubjectConstants.SECOND_SUBJECT_TWO_THREE.getCode());
|
||||
revenueExpensesRecord.setSecondSubjectName(SubjectConstants.SECOND_SUBJECT_TWO_THREE.getName());
|
||||
revenueExpensesRecord.setPayChannel(loanManage.getPayChannel());
|
||||
revenueExpensesRecord.setPayChannelName(loanManage.getPayChannelName());
|
||||
revenueExpensesRecord.setRemark("冲正");
|
||||
revenueExpensesRecord.setEntryValue(1);
|
||||
revenueExpensesRecord.setDayToDayStatus(1);
|
||||
// revenueExpensesRecord.setWaybillId(loanManage.getWaybillId());
|
||||
// revenueExpensesRecord.setWaybillNumber(loanManage.getWaybillNumber());
|
||||
// revenueExpensesRecord.setWaybillSource(loanManage.getWaybillSource());
|
||||
// revenueExpensesRecord.setWaybillSourceName(loanManage.getWaybillSourceName());
|
||||
// revenueExpensesRecord.setSettleAccountsStatus(1);
|
||||
revenueExpensesRecord.setBankNumber(loanManage.getBankNumber());
|
||||
revenueExpensesRecord.setCreateTime(new Date());
|
||||
revenueExpensesRecord.setCreateBy(userId);
|
||||
revenueExpensesRecord.setCreateByName(userName);
|
||||
revenueExpensesRecordDomainService.insertRevenueExpensesRecord(revenueExpensesRecord);
|
||||
longs.add(revenueExpensesRecord.getRevenueExpensesRecordId());
|
||||
if(loanManage != null && loanManage.getCommissionCharges() != null && loanManage.getCommissionCharges().compareTo(BigDecimal.ZERO) != 0){
|
||||
//取消放款 - 生成手续费冲正流水
|
||||
RevenueExpensesRecord revenueExpensesRecordTwo = new RevenueExpensesRecord();
|
||||
// revenueExpensesRecordTwo.setBranchId(loanManage.getBranchId());
|
||||
revenueExpensesRecordTwo.setInnerNumber(innerNumber);
|
||||
revenueExpensesRecordTwo.setRevenueExpensesType(2);
|
||||
revenueExpensesRecordTwo.setMoney(loanManage.getCommissionCharges());
|
||||
revenueExpensesRecordTwo.setFirstSubject(SubjectConstants.FIRST_SUBJECT_TWO.getCode());
|
||||
revenueExpensesRecordTwo.setFirstSubjectName(SubjectConstants.FIRST_SUBJECT_TWO.getName());
|
||||
revenueExpensesRecordTwo.setSecondSubject(SubjectConstants.SECOND_SUBJECT_TWO_ONE.getCode());
|
||||
revenueExpensesRecordTwo.setSecondSubjectName(SubjectConstants.SECOND_SUBJECT_TWO_ONE.getName());
|
||||
revenueExpensesRecordTwo.setPayChannel(loanManage.getPayChannel());
|
||||
revenueExpensesRecordTwo.setPayChannelName(loanManage.getPayChannelName());
|
||||
revenueExpensesRecordTwo.setRemark("冲正");
|
||||
revenueExpensesRecordTwo.setEntryValue(1);
|
||||
revenueExpensesRecordTwo.setDayToDayStatus(1);
|
||||
// revenueExpensesRecordTwo.setWaybillId(loanManage.getWaybillId());
|
||||
// revenueExpensesRecordTwo.setWaybillNumber(loanManage.getWaybillNumber());
|
||||
// revenueExpensesRecordTwo.setWaybillSource(loanManage.getWaybillSource());
|
||||
// revenueExpensesRecordTwo.setWaybillSourceName(loanManage.getWaybillSourceName());
|
||||
// revenueExpensesRecordTwo.setSettleAccountsStatus(1);
|
||||
revenueExpensesRecordTwo.setBankNumber(loanManage.getBankNumber());
|
||||
revenueExpensesRecordTwo.setCreateTime(new Date());
|
||||
revenueExpensesRecordTwo.setCreateBy(userId);
|
||||
revenueExpensesRecordTwo.setCreateByName(userName);
|
||||
revenueExpensesRecordDomainService.insertRevenueExpensesRecord(revenueExpensesRecordTwo);
|
||||
longs.add(revenueExpensesRecordTwo.getRevenueExpensesRecordId());
|
||||
}
|
||||
if (loanManage != null && loanManage.getWithholdPayment() != null && loanManage.getWithholdPayment().compareTo(BigDecimal.ZERO) != 0){
|
||||
//取消放款 - 生成扣付冲正流水
|
||||
//判断是否核销 未核销状态不生成冲正流水
|
||||
LoanManageDo query = new LoanManageDo();
|
||||
query.setLoanType(1);
|
||||
query.setWaybillId(loanManage.getWaybillId());
|
||||
LoanManagePo loanManageInfo = loanManageDomainService.selectLoanManageInfo(query);
|
||||
if (loanManageInfo!= null && loanManageInfo.getCollectionStatus() == 3){
|
||||
RevenueExpensesRecord revenueExpensesRecordTwo = new RevenueExpensesRecord();
|
||||
// revenueExpensesRecordTwo.setBranchId(loanManage.getBranchId());
|
||||
revenueExpensesRecordTwo.setInnerNumber(innerNumber);
|
||||
revenueExpensesRecordTwo.setRevenueExpensesType(2);
|
||||
revenueExpensesRecordTwo.setMoney(loanManage.getWithholdPayment());
|
||||
revenueExpensesRecordTwo.setFirstSubject(SubjectConstants.FIRST_SUBJECT_ONE.getCode());
|
||||
revenueExpensesRecordTwo.setFirstSubjectName(SubjectConstants.FIRST_SUBJECT_ONE.getName());
|
||||
revenueExpensesRecordTwo.setSecondSubject(SubjectConstants.SECOND_SUBJECT_ONE_FIVE.getCode());
|
||||
revenueExpensesRecordTwo.setSecondSubjectName(SubjectConstants.SECOND_SUBJECT_ONE_FIVE.getName());
|
||||
revenueExpensesRecordTwo.setPayChannel(loanManage.getPayChannel());
|
||||
revenueExpensesRecordTwo.setPayChannelName(loanManage.getPayChannelName());
|
||||
revenueExpensesRecordTwo.setRemark("冲正");
|
||||
revenueExpensesRecordTwo.setEntryValue(1);
|
||||
revenueExpensesRecordTwo.setDayToDayStatus(1);
|
||||
// revenueExpensesRecordTwo.setWaybillId(loanManage.getWaybillId());
|
||||
// revenueExpensesRecordTwo.setWaybillNumber(loanManage.getWaybillNumber());
|
||||
// revenueExpensesRecordTwo.setWaybillSource(loanManage.getWaybillSource());
|
||||
// revenueExpensesRecordTwo.setWaybillSourceName(loanManage.getWaybillSourceName());
|
||||
// revenueExpensesRecordTwo.setSettleAccountsStatus(1);
|
||||
revenueExpensesRecordTwo.setBankNumber(loanManage.getBankNumber());
|
||||
revenueExpensesRecordTwo.setCreateTime(new Date());
|
||||
revenueExpensesRecordTwo.setCreateBy(userId);
|
||||
revenueExpensesRecordTwo.setCreateByName(userName);
|
||||
revenueExpensesRecordDomainService.insertRevenueExpensesRecord(revenueExpensesRecordTwo);
|
||||
longs.add(revenueExpensesRecordTwo.getRevenueExpensesRecordId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//挂失
|
||||
if(loanManageDto.getReportLossStatus() != null && loanManageDto.getReportLossStatus() == 3){
|
||||
loanManagePo.setReportLossId(userId);
|
||||
loanManagePo.setReportLossName(userName);
|
||||
loanManagePo.setReportLossTime(new Date());
|
||||
}
|
||||
//修改收入核销为代收还款/手续费科目的数据为已核销状态
|
||||
if(loanManageDto.getCollectionStatus() != null && loanManageDto.getCollectionStatus() == 3){
|
||||
//收款渠道
|
||||
if (StringUtils.isNotEmpty(loanManagePo.getPayChannel())) {
|
||||
List<SysDictDataVo> timeTagEndVos = selectListByDictType(DictCode.pay_channel.getCode());
|
||||
if (StringUtils.isNotEmpty(loanManagePo.getPayChannel()) && timeTagEndVos != null) {
|
||||
List<SysDictDataVo> noticeMouldManagePos = timeTagEndVos.stream().filter(info -> ObjectUtil.equal(info.getDictValue(), loanManagePo.getPayChannel())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(noticeMouldManagePos)) {
|
||||
loanManagePo.setPayChannelName(noticeMouldManagePos.get(0).getDictLabel());
|
||||
} else {
|
||||
throw new ServiceException("请先维护支付通道数据字典");
|
||||
}
|
||||
}
|
||||
}
|
||||
// loanManagePo.setCollectionTime(new Date());
|
||||
loanManagePo.setCancelAfterVerificationId(userId);
|
||||
loanManagePo.setCancelAfterVerificationName(userName);
|
||||
loanManagePo.setCancelAfterVerificationTime(new Date());
|
||||
//货款收回核销后生成收支流水记录
|
||||
//生成收入货款收回的流水
|
||||
RevenueExpensesRecord revenueExpensesRecord = new RevenueExpensesRecord();
|
||||
// revenueExpensesRecord.setBranchId(loanManage.getBranchId());
|
||||
//生成配载单号
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour + loanManage.getLoanManageId();
|
||||
revenueExpensesRecord.setInnerNumber(innerNumber);
|
||||
revenueExpensesRecord.setRevenueExpensesType(1);
|
||||
revenueExpensesRecord.setMoney(loanManage.getLoanMoney());
|
||||
revenueExpensesRecord.setFirstSubject(SubjectConstants.FIRST_SUBJECT_TWO.getCode());
|
||||
revenueExpensesRecord.setFirstSubjectName(SubjectConstants.FIRST_SUBJECT_TWO.getName());
|
||||
revenueExpensesRecord.setSecondSubject(SubjectConstants.SECOND_SUBJECT_TWO_TWO.getCode());
|
||||
revenueExpensesRecord.setSecondSubjectName(SubjectConstants.SECOND_SUBJECT_TWO_TWO.getName());
|
||||
revenueExpensesRecord.setPayChannel(loanManage.getPayChannel());
|
||||
revenueExpensesRecord.setPayChannelName(loanManage.getPayChannelName());
|
||||
revenueExpensesRecord.setEntryValue(1);
|
||||
revenueExpensesRecord.setDayToDayStatus(1);
|
||||
// revenueExpensesRecord.setWaybillId(loanManage.getWaybillId());
|
||||
// revenueExpensesRecord.setWaybillNumber(loanManage.getWaybillNumber());
|
||||
// revenueExpensesRecord.setWaybillSource(loanManage.getWaybillSource());
|
||||
// revenueExpensesRecord.setWaybillSourceName(loanManage.getWaybillSourceName());
|
||||
// revenueExpensesRecord.setSettleAccountsStatus(1);
|
||||
revenueExpensesRecord.setBankNumber(loanManage.getBankNumber());
|
||||
revenueExpensesRecord.setCreateTime(new Date());
|
||||
revenueExpensesRecord.setCreateBy(userId);
|
||||
revenueExpensesRecord.setCreateByName(userName);
|
||||
revenueExpensesRecordDomainService.insertRevenueExpensesRecord(revenueExpensesRecord);
|
||||
longs.add(revenueExpensesRecord.getRevenueExpensesRecordId());
|
||||
}
|
||||
else if (loanManageDto.getCollectionStatus() != null && loanManageDto.getCollectionStatus() == 2){
|
||||
//收款渠道
|
||||
if (StringUtils.isNotEmpty(loanManagePo.getPayChannel())) {
|
||||
List<SysDictDataVo> timeTagEndVos = selectListByDictType(DictCode.pay_channel.getCode());
|
||||
if (StringUtils.isNotEmpty(loanManagePo.getPayChannel()) && timeTagEndVos != null) {
|
||||
List<SysDictDataVo> noticeMouldManagePos = timeTagEndVos.stream().filter(info -> ObjectUtil.equal(info.getDictValue(), loanManagePo.getPayChannel())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(noticeMouldManagePos)) {
|
||||
loanManagePo.setPayChannelName(noticeMouldManagePos.get(0).getDictLabel());
|
||||
} else {
|
||||
throw new ServiceException("请先维护支付通道数据字典");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(loanManage != null){
|
||||
//是3表示之前是核销状态现在是取消核销,是1表示之前是未收款状态现在是收款
|
||||
if(loanManage.getCollectionStatus() != null && loanManage.getCollectionStatus() == 1){
|
||||
if(StringUtils.isEmpty(loanManage.getCollectionInnerNumber())){
|
||||
loanManagePo.setCollectionId(userId);
|
||||
loanManagePo.setCollectionName(userName);
|
||||
loanManagePo.setCollectionTime(new Date());
|
||||
loanManagePo.setCollectionInnerNumber("shoukuan"+sdf.format(new Date()));
|
||||
}
|
||||
}
|
||||
if(loanManage.getCollectionStatus() != null && loanManage.getCollectionStatus() == 3){
|
||||
if(StringUtils.isEmpty(loanManage.getCollectionInnerNumber())){
|
||||
loanManagePo.setCollectionId(userId);
|
||||
loanManagePo.setCollectionName(userName);
|
||||
loanManagePo.setCollectionTime(new Date());
|
||||
loanManagePo.setCollectionInnerNumber("shoukuan"+sdf.format(new Date()));
|
||||
}
|
||||
if(loanManage != null && loanManage.getCommissionCharges() != null && loanManage.getCommissionCharges().compareTo(BigDecimal.ZERO) != 0){
|
||||
//取消收款
|
||||
RevenueExpensesRecord revenueExpensesRecord = new RevenueExpensesRecord();
|
||||
// revenueExpensesRecord.setBranchId(loanManage.getBranchId());
|
||||
//生成配载单号
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour + loanManage.getLoanManageId();
|
||||
revenueExpensesRecord.setInnerNumber(innerNumber);
|
||||
revenueExpensesRecord.setRevenueExpensesType(2);
|
||||
revenueExpensesRecord.setMoney(loanManage.getLoanMoney());
|
||||
revenueExpensesRecord.setFirstSubject(SubjectConstants.FIRST_SUBJECT_TWO.getCode());
|
||||
revenueExpensesRecord.setFirstSubjectName(SubjectConstants.FIRST_SUBJECT_TWO.getName());
|
||||
revenueExpensesRecord.setSecondSubject(SubjectConstants.SECOND_SUBJECT_TWO_TWO.getCode());
|
||||
revenueExpensesRecord.setSecondSubjectName(SubjectConstants.SECOND_SUBJECT_TWO_TWO.getName());
|
||||
revenueExpensesRecord.setPayChannel(loanManage.getPayChannel());
|
||||
revenueExpensesRecord.setPayChannelName(loanManage.getPayChannelName());
|
||||
revenueExpensesRecord.setRemark("冲正");
|
||||
revenueExpensesRecord.setEntryValue(1);
|
||||
revenueExpensesRecord.setDayToDayStatus(1);
|
||||
// revenueExpensesRecord.setWaybillId(loanManage.getWaybillId());
|
||||
// revenueExpensesRecord.setWaybillNumber(loanManage.getWaybillNumber());
|
||||
// revenueExpensesRecord.setWaybillSource(loanManage.getWaybillSource());
|
||||
// revenueExpensesRecord.setWaybillSourceName(loanManage.getWaybillSourceName());
|
||||
// revenueExpensesRecord.setSettleAccountsStatus(1);
|
||||
revenueExpensesRecord.setBankNumber(loanManage.getBankNumber());
|
||||
revenueExpensesRecord.setCreateTime(new Date());
|
||||
revenueExpensesRecord.setCreateBy(userId);
|
||||
revenueExpensesRecord.setCreateByName(userName);
|
||||
revenueExpensesRecordDomainService.insertRevenueExpensesRecord(revenueExpensesRecord);
|
||||
longs.add(revenueExpensesRecord.getRevenueExpensesRecordId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (loanManageDto.getCollectionStatus() != null && loanManageDto.getCollectionStatus() == 1){
|
||||
if(loanManage != null && loanManage.getCommissionCharges() != null && loanManage.getCommissionCharges().compareTo(BigDecimal.ZERO) != 0){
|
||||
//取消收款
|
||||
RevenueExpensesRecord revenueExpensesRecord = new RevenueExpensesRecord();
|
||||
// revenueExpensesRecord.setBranchId(loanManage.getBranchId());
|
||||
//生成配载单号
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour + loanManage.getLoanManageId();
|
||||
revenueExpensesRecord.setInnerNumber(innerNumber);
|
||||
revenueExpensesRecord.setRevenueExpensesType(2);
|
||||
revenueExpensesRecord.setMoney(loanManage.getLoanMoney());
|
||||
revenueExpensesRecord.setFirstSubject(SubjectConstants.FIRST_SUBJECT_TWO.getCode());
|
||||
revenueExpensesRecord.setFirstSubjectName(SubjectConstants.FIRST_SUBJECT_TWO.getName());
|
||||
revenueExpensesRecord.setSecondSubject(SubjectConstants.SECOND_SUBJECT_TWO_TWO.getCode());
|
||||
revenueExpensesRecord.setSecondSubjectName(SubjectConstants.SECOND_SUBJECT_TWO_TWO.getName());
|
||||
revenueExpensesRecord.setPayChannel(loanManage.getPayChannel());
|
||||
revenueExpensesRecord.setPayChannelName(loanManage.getPayChannelName());
|
||||
revenueExpensesRecord.setRemark("冲正");
|
||||
revenueExpensesRecord.setEntryValue(1);
|
||||
revenueExpensesRecord.setDayToDayStatus(1);
|
||||
// revenueExpensesRecord.setWaybillId(loanManage.getWaybillId());
|
||||
// revenueExpensesRecord.setWaybillNumber(loanManage.getWaybillNumber());
|
||||
// revenueExpensesRecord.setWaybillSource(loanManage.getWaybillSource());
|
||||
// revenueExpensesRecord.setSettleAccountsStatus(1);
|
||||
revenueExpensesRecord.setBankNumber(loanManage.getBankNumber());
|
||||
revenueExpensesRecordDomainService.insertRevenueExpensesRecord(revenueExpensesRecord);
|
||||
longs.add(revenueExpensesRecord.getRevenueExpensesRecordId());
|
||||
}
|
||||
}
|
||||
int i = loanManageDomainService.updateLoanManages(loanManagePo);
|
||||
if (i == 0) {
|
||||
throw new ServiceException("操作失败");
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 挂失
|
||||
*
|
||||
* @param loanManageDto 货款管理
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional
|
||||
public int reportLoss(LoanManageDto loanManageDto){
|
||||
LoanManagePo loanManagePo = new LoanManagePo();
|
||||
BeanUtils.copyProperties(loanManageDto, loanManagePo);
|
||||
// 获取登录人id
|
||||
Long userId = SecurityUtils.getLoginUser().getUserid();
|
||||
// 获取登录人id
|
||||
String userName = SecurityUtils.getLoginUser().getUsername();
|
||||
loanManageDomainService.deleteLoanImageByLoanId(loanManagePo.getLoanManageId());
|
||||
//修改收入核销为代收还款/手续费科目的数据为已核销状态
|
||||
if(loanManageDto.getGrantStatus() != null && loanManageDto.getGrantStatus() == 3){
|
||||
loanManagePo.setReportLossId(userId);
|
||||
loanManagePo.setReportLossName(userName);
|
||||
loanManagePo.setReportLossTime(new Date());
|
||||
Verification verification = new Verification();
|
||||
VerificationPo verificationPo = new VerificationPo();
|
||||
// verificationPo.setWaybillId(loanManagePo.getWaybillId());
|
||||
verificationPo.setFirstSubject(SubjectConstants.FIRST_SUBJECT_TWO.getCode());
|
||||
verificationPo.setSecondSubject(SubjectConstants.SECOND_SUBJECT_TWO_ONE.getCode());
|
||||
verificationPo.setFirstSubjectName(SubjectConstants.FIRST_SUBJECT_TWO.getName());
|
||||
verificationPo.setSecondSubjectName(SubjectConstants.SECOND_SUBJECT_TWO_ONE.getName());
|
||||
// verification.setWaybillId(loanManagePo.getWaybillId());
|
||||
verification.setFirstSubject(SubjectConstants.FIRST_SUBJECT_TWO.getCode());
|
||||
verification.setSecondSubject(SubjectConstants.SECOND_SUBJECT_TWO_ONE.getCode());
|
||||
verification.setFirstSubjectName(SubjectConstants.FIRST_SUBJECT_TWO.getName());
|
||||
verification.setSecondSubjectName(SubjectConstants.SECOND_SUBJECT_TWO_ONE.getName());
|
||||
verification.setVerificationStatus(6);
|
||||
verificationDomainService.updateVerificationByWaybillId(verification);
|
||||
List<VerificationPo> verificationPos = verificationDomainService.selectVerificationList(verificationPo);
|
||||
if(verificationPos != null && verificationPos.size() > 0){
|
||||
RevenueExpensesRecord revenueExpensesRecord = new RevenueExpensesRecord();
|
||||
// revenueExpensesRecord.setBranchId(verificationPos.get(0).getBranchId());
|
||||
//生成配载单号
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour + verificationPos.get(0).getVerificationId();
|
||||
revenueExpensesRecord.setInnerNumber(innerNumber);
|
||||
revenueExpensesRecord.setRevenueExpensesType(1);
|
||||
revenueExpensesRecord.setMoney(verificationPos.get(0).getVerificationMoney());
|
||||
revenueExpensesRecord.setFirstSubject(verificationPos.get(0).getFirstSubject());
|
||||
revenueExpensesRecord.setSecondSubject(verificationPos.get(0).getSecondSubject());
|
||||
revenueExpensesRecord.setPayChannel(verificationPos.get(0).getPayChannel());
|
||||
revenueExpensesRecord.setPayChannelName(verificationPos.get(0).getPayChannelName());
|
||||
revenueExpensesRecord.setEntryValue(1);
|
||||
revenueExpensesRecord.setDayToDayStatus(1);
|
||||
// revenueExpensesRecord.setWaybillId(verificationPos.get(0).getWaybillId());
|
||||
// revenueExpensesRecord.setWaybillNumber(verificationPos.get(0).getWaybillNumber());
|
||||
// revenueExpensesRecord.setWaybillSource(verificationPos.get(0).getWaybillSource());
|
||||
// revenueExpensesRecord.setWaybillSourceName(verificationPos.get(0).getWaybillSourceName());
|
||||
// revenueExpensesRecord.setSettleAccountsStatus(1);
|
||||
revenueExpensesRecord.setBankNumber(verificationPos.get(0).getBankNumber());
|
||||
revenueExpensesRecord.setCreateTime(new Date());
|
||||
revenueExpensesRecord.setCreateBy(userId);
|
||||
revenueExpensesRecord.setCreateByName(userName);
|
||||
revenueExpensesRecordDomainService.insertRevenueExpensesRecord(revenueExpensesRecord);
|
||||
}
|
||||
}
|
||||
|
||||
return loanManageDomainService.updateLoanManages(loanManagePo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除货款管理
|
||||
*
|
||||
* @param loanManageId 货款管理主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteLoanManageByLoanManageId(Long loanManageId){
|
||||
return loanManageDomainService.deleteLoanManageByLoanManageId(loanManageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除货款管理
|
||||
*
|
||||
* @param loanManageIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteLoanManageByLoanManageIds(Long[] loanManageIds){
|
||||
return loanManageDomainService.deleteLoanManageByLoanManageIds(loanManageIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 结果
|
||||
*/
|
||||
public List<SysDictDataVo> selectListByDictType(String dictType){
|
||||
List<SysDictDataVo> noticeTypeList = new ArrayList<>();
|
||||
//查询数据字典通知类型中的配置
|
||||
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(dictType);
|
||||
if("200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
noticeTypeList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
|
||||
}
|
||||
return noticeTypeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询货款收回状态列表
|
||||
*
|
||||
* @return 回单集合
|
||||
*/
|
||||
public List<Map<String,String>> selectLoanOneStatusNum(){
|
||||
// //获取登录人信息
|
||||
// LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
// //当前组织id
|
||||
// Long organizationId = new Long("2");
|
||||
// if(loginUser != null){
|
||||
// if(loginUser.getUserPo() != null && loginUser.getUserPo().getOrganizationId() != null){
|
||||
// organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// }
|
||||
// }
|
||||
// //查询当前组织的网点
|
||||
// BranchPo branchPo = new BranchPo();
|
||||
// AjaxResult info = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
||||
// if("200".equals(String.valueOf(info.get("code")))){
|
||||
// branchPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), BranchPo.class);
|
||||
// }
|
||||
return loanManageDomainService.selectLoanOneStatusNum(new LoanManageDo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询货款发放状态列表
|
||||
*
|
||||
* @return 回单集合
|
||||
*/
|
||||
public List<Map<String,String>> selectLoanTwoStatusNum(){
|
||||
// //获取登录人信息
|
||||
// LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
// //当前组织id
|
||||
// Long organizationId = new Long("2");
|
||||
// if(loginUser != null){
|
||||
// if(loginUser.getUserPo() != null && loginUser.getUserPo().getOrganizationId() != null){
|
||||
// organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// }
|
||||
// }
|
||||
// //查询当前组织的网点
|
||||
// BranchPo branchPo = new BranchPo();
|
||||
// AjaxResult info = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
||||
// if("200".equals(String.valueOf(info.get("code")))){
|
||||
// branchPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), BranchPo.class);
|
||||
// }
|
||||
return loanManageDomainService.selectLoanTwoStatusNum(new LoanManageDo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询货款发放状态列表
|
||||
*
|
||||
* @return 回单集合
|
||||
*/
|
||||
public List<Map<String,String>> selectLoanThreeStatusNum(){
|
||||
// //获取登录人信息
|
||||
// LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
// //当前组织id
|
||||
// Long organizationId = new Long("2");
|
||||
// if(loginUser != null){
|
||||
// if(loginUser.getUserPo() != null && loginUser.getUserPo().getOrganizationId() != null){
|
||||
// organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// }
|
||||
// }
|
||||
// //查询当前组织的网点
|
||||
// BranchPo branchPo = new BranchPo();
|
||||
// AjaxResult info = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
||||
// if("200".equals(String.valueOf(info.get("code")))){
|
||||
// branchPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), BranchPo.class);
|
||||
// }
|
||||
return loanManageDomainService.selectLoanThreeStatusNum(new LoanManageDo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据运单号逻辑删除
|
||||
*/
|
||||
public boolean tombstoneByWaybillNumber(String waybillNumber) {
|
||||
return loanManageDomainService.tombstoneByWaybillNumber(waybillNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据运单号逻辑删除
|
||||
*/
|
||||
public boolean tombstoneByWaybillNumbers(List<String> waybillNumber) {
|
||||
return loanManageDomainService.tombstoneByWaybillNumbers(waybillNumber);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 代收款统计
|
||||
*/
|
||||
public List<CollectionStatisticsPO> collectionStatistics(ReportDTO reportDTO) {
|
||||
//获取当前登录人,获取当前登录人的租户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
|
||||
List<CollectionStatisticsPO> collectionStatisticsPOS = loanManageDomainService.collectionStatistics(reportDTO);
|
||||
//处理网点名称
|
||||
AjaxResult ajaxResult = specialLogisticsServiceFeign.getBranchInfoByTopOrganizationId(topOrganizationId);
|
||||
if ("200".equals(String.valueOf(ajaxResult.get("code")))) {
|
||||
List<Branch> branchList = JSONUtil.toList(JSONObject.toJSONString(ajaxResult.get("data")), Branch.class);
|
||||
if (CollUtil.isNotEmpty(branchList)) {
|
||||
Map<Long, String> branchMap = branchList.stream().collect(Collectors.toMap(Branch::getBranchId, Branch::getBranchName));
|
||||
for (CollectionStatisticsPO collectionStatisticsPO : collectionStatisticsPOS) {
|
||||
collectionStatisticsPO.setBranchName(branchMap.get(collectionStatisticsPO.getBranchId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return collectionStatisticsPOS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 网点放款统计
|
||||
*/
|
||||
public List<LoanStatisticsPO> loanStatistics(ReportDTO reportDTO) {
|
||||
//获取当前登录人,获取当前登录人的租户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
|
||||
List<LoanStatisticsPO> loanStatisticsPOS = loanManageDomainService.loanStatistics(reportDTO);
|
||||
//处理网点名称
|
||||
AjaxResult ajaxResult = specialLogisticsServiceFeign.getBranchInfoByTopOrganizationId(topOrganizationId);
|
||||
if ("200".equals(String.valueOf(ajaxResult.get("code")))) {
|
||||
List<Branch> branchList = JSONUtil.toList(JSONObject.toJSONString(ajaxResult.get("data")), Branch.class);
|
||||
if (CollUtil.isNotEmpty(branchList)) {
|
||||
Map<Long, String> branchMap = branchList.stream().collect(Collectors.toMap(Branch::getBranchId, Branch::getBranchName));
|
||||
for (LoanStatisticsPO loanStatisticsPO : loanStatisticsPOS) {
|
||||
loanStatisticsPO.setBranchName(branchMap.get(loanStatisticsPO.getBranchId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return loanStatisticsPOS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 未回款统计
|
||||
*/
|
||||
public List<CollectionStatisticsPO> unrepairedStatistics(ReportDTO reportDTO) {
|
||||
//获取当前登录人,获取当前登录人的租户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
|
||||
List<CollectionStatisticsPO> unrepairedStatistics = loanManageDomainService.unrepairedStatistics(reportDTO);
|
||||
//处理网点名称
|
||||
AjaxResult ajaxResult = specialLogisticsServiceFeign.getBranchInfoByTopOrganizationId(topOrganizationId);
|
||||
if ("200".equals(String.valueOf(ajaxResult.get("code")))) {
|
||||
List<Branch> branchList = JSONUtil.toList(JSONObject.toJSONString(ajaxResult.get("data")), Branch.class);
|
||||
if (CollUtil.isNotEmpty(branchList)) {
|
||||
Map<Long, String> branchMap = branchList.stream().collect(Collectors.toMap(Branch::getBranchId, Branch::getBranchName));
|
||||
for (CollectionStatisticsPO collectionStatisticsPO : unrepairedStatistics) {
|
||||
collectionStatisticsPO.setBranchName(branchMap.get(collectionStatisticsPO.getBranchId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return unrepairedStatistics;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 代收款统计详情列表
|
||||
*/
|
||||
public List<LoanManagePo> collectionStatisticsInfoList(ReportDTO reportDTO) {
|
||||
if (ObjectUtil.isNull(reportDTO.getBranchId())) {
|
||||
throw new ServiceException("网点ID不能为空");
|
||||
}
|
||||
return loanManageDomainService.collectionStatisticsInfoList(reportDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 网点放款统计详情列表
|
||||
*/
|
||||
public List<LoanManagePo> loanStatisticsInfoList(ReportDTO reportDTO) {
|
||||
return loanManageDomainService.loanStatisticsInfoList(reportDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 未回款统计详情统计
|
||||
*/
|
||||
public List<LoanManagePo> unrepairedStatisticsInfoList(ReportDTO reportDTO) {
|
||||
return loanManageDomainService.unrepairedStatisticsInfoList(reportDTO);
|
||||
}
|
||||
}
|
||||
+641
@@ -0,0 +1,641 @@
|
||||
package com.linke.finance.application.service.revenueExpensesRecord;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.linke.finance.application.server.businessDocument.BusinessDocumentApplicationService;
|
||||
import com.linke.finance.domain.businessDocumentDetali.entity.BusinessDocumentDetali;
|
||||
import com.linke.finance.domain.report.repository.po.BranchProfitStatisticsPO;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.entity.RevenueExpensesRecord;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.repository.po.RevenueExpensesRecordPo;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.repository.todo.RevenueExpensesRecordDO;
|
||||
import com.linke.finance.domain.revenueExpensesRecord.service.RevenueExpensesRecordDomainService;
|
||||
import com.linke.finance.domain.verification.service.VerificationDomainService;
|
||||
import com.linke.finance.infrastructure.feign.SpecialLogisticsServiceFeign;
|
||||
import com.linke.finance.infrastructure.feign.SystemServiceFeign;
|
||||
import com.linke.finance.infrastructure.feign.UserServiceFeign;
|
||||
import com.linke.finance.infrastructure.util.annotation.DataPermissions;
|
||||
import com.linke.finance.infrastructure.vo.SysDictDataVo;
|
||||
import com.linke.finance.interfaces.dto.RevenueExpensesRecordAddDto;
|
||||
import com.linke.finance.interfaces.dto.RevenueExpensesRecordDto;
|
||||
import com.mhd.common.core.domain.dto.wlhy.RepaymentTransmitDTO;
|
||||
import com.mhd.common.core.domain.dto.wlhy.RevenueExpensesRecordDTO;
|
||||
import com.mhd.common.core.domain.dto.wlhy.UpdatePaymentStatusDTO;
|
||||
import com.mhd.common.core.domain.entity.Branch;
|
||||
import com.mhd.common.core.domain.entity.R;
|
||||
import com.mhd.common.core.domain.po.*;
|
||||
import com.mhd.common.core.enums.*;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
|
||||
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
|
||||
import com.mhd.common.core.utils.AESUtil;
|
||||
import com.mhd.common.core.utils.StringUtils;
|
||||
import com.mhd.common.core.utils.bean.BeanUtils;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.common.security.utils.password.PasswordUtil;
|
||||
import com.mhd.system.api.WlhyServiceFeign;
|
||||
import com.mhd.system.api.domain.SecondSubjectPO;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import io.seata.spring.annotation.GlobalTransactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 收入支出记录 应用服务层
|
||||
*
|
||||
* 本层可以综合应用各种业务间的组合
|
||||
*
|
||||
* 2023-03-18
|
||||
*
|
||||
* @author 王子豪
|
||||
*/
|
||||
@Service
|
||||
public class RevenueExpensesRecordApplicationService
|
||||
{
|
||||
@Autowired
|
||||
private RevenueExpensesRecordDomainService revenueExpensesRecordDomainService;
|
||||
@Autowired
|
||||
private VerificationDomainService verificationDomainService;
|
||||
@Autowired
|
||||
private SpecialLogisticsServiceFeign specialLogisticsServiceFeign;
|
||||
@Autowired
|
||||
private SystemServiceFeign systemServiceFeign;
|
||||
@Autowired
|
||||
private UserServiceFeign userServiceFeign;
|
||||
@Autowired
|
||||
private WlhyServiceFeign wlhyServiceFeign;
|
||||
@Autowired
|
||||
private BusinessDocumentApplicationService businessDocumentApplicationService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询收入支出记录
|
||||
*
|
||||
* @param revenueExpensesRecordId 收入支出记录主键
|
||||
* @return 收入支出记录
|
||||
*/
|
||||
public RevenueExpensesRecordPo selectRevenueExpensesRecordByRevenueExpensesRecordId(Long revenueExpensesRecordId){
|
||||
return revenueExpensesRecordDomainService.selectRevenueExpensesRecordByRevenueExpensesRecordId(revenueExpensesRecordId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询收入支出记录列表
|
||||
*
|
||||
* @param revenueExpensesRecordPo 收入支出记录
|
||||
* @return 收入支出记录集合
|
||||
*/
|
||||
// @DataPermissions(cacheName = "branch")
|
||||
public List<RevenueExpensesRecordPo> selectRevenueExpensesRecordList(RevenueExpensesRecordPo revenueExpensesRecordPo){
|
||||
List<RevenueExpensesRecordPo> list = new ArrayList<>();
|
||||
//获取登录人信息
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
OrganizationPo organizationPo = loginUser.getOrganizationPo();
|
||||
List<Long> organizationIdList = new ArrayList<>();
|
||||
if (organizationPo == null){
|
||||
organizationIdList.add(userPo.getOrganizationId());
|
||||
}else {
|
||||
List<Long> organizationIdList1 = organizationPo.getOrganizationIdList();
|
||||
if (organizationIdList1 != null && organizationIdList1.size() > 0){
|
||||
organizationIdList.addAll(organizationIdList1);
|
||||
}else {
|
||||
organizationIdList.add(organizationPo.getOrganizationId());
|
||||
}
|
||||
}
|
||||
if (organizationIdList != null && organizationIdList.size() > 0){
|
||||
organizationIdList.add(userPo.getOrganizationId());
|
||||
}
|
||||
revenueExpensesRecordPo.setOrganizationIdList(organizationIdList);
|
||||
|
||||
// if (revenueExpensesRecordPo.getBranchId() != null || CollUtil.isNotEmpty(revenueExpensesRecordPo.getBranchIdList())) {
|
||||
list = revenueExpensesRecordDomainService.selectRevenueExpensesRecordList(revenueExpensesRecordPo);
|
||||
// }
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增收入支出记录
|
||||
*
|
||||
* @param revenueExpensesRecord 收入支出记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertRevenueExpensesRecord(RevenueExpensesRecord revenueExpensesRecord){
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new DigitalLogisticsException(UserError.TIMEOUT);
|
||||
}
|
||||
|
||||
//支付通道
|
||||
if(StringUtils.isNotEmpty(revenueExpensesRecord.getPayChannel())){
|
||||
List<SysDictDataVo> timeTagEndVos = selectListByDictType(DictCode.pay_channel.getCode());
|
||||
if(StringUtils.isNotEmpty(revenueExpensesRecord.getPayChannel()) && timeTagEndVos != null){
|
||||
List<SysDictDataVo> noticeMouldManagePos = timeTagEndVos.stream().filter(info -> ObjectUtil.equal(info.getDictValue(),revenueExpensesRecord.getPayChannel())).collect(Collectors.toList());
|
||||
if(noticeMouldManagePos.size() > 0){
|
||||
revenueExpensesRecord.setPayChannelName(noticeMouldManagePos.get(0).getDictLabel());
|
||||
}else {
|
||||
throw new ServiceException("请先维护支付通道数据字典");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (revenueExpensesRecord.getEntryValue() == null){
|
||||
revenueExpensesRecord.setEntryValue(2);
|
||||
}
|
||||
return revenueExpensesRecordDomainService.insertRevenueExpensesRecord(revenueExpensesRecord);
|
||||
}
|
||||
private boolean checkPaypassword(String payPassword) {
|
||||
//解密支付密码
|
||||
payPassword = AESUtil.decrypt(payPassword);
|
||||
//获取当前登录人
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
UserPo userPo = loginUser.getUserPo();
|
||||
//临时方案,用户修改密码后,用token获取用户信息,数据不一致,需要重新获取用户信息
|
||||
AjaxResult ajaxResult = userServiceFeign.getInfo(userPo.getUserId());
|
||||
if("200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
userPo = JSONUtil.toBean(JSONObject.toJSONString(ajaxResult.get("data")), UserPo.class);
|
||||
}else {
|
||||
throw new ServiceException("用户信息获取失败");
|
||||
}
|
||||
//校验用户支付密码是否正确
|
||||
if (!PasswordUtil.matchesPassword(userPo.getUserAccount(), payPassword, userPo.getUserSalt(), userPo.getUserPayPassword())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应付账单支付--批量挂账
|
||||
* @param revenueExpensesRecordAddDto
|
||||
* @return
|
||||
*/
|
||||
@GlobalTransactional(rollbackFor = Exception.class)
|
||||
public boolean batchOnAccount(RevenueExpensesRecordAddDto revenueExpensesRecordAddDto){
|
||||
try{
|
||||
List<Long> verificationIds = revenueExpensesRecordAddDto.getVerificationIds();
|
||||
if(verificationIds.size()==0){
|
||||
throw new ServiceException("未获取到账单信息!");
|
||||
}
|
||||
List<VerificationPo> list = verificationDomainService.selectVerificationListByIds(verificationIds);
|
||||
for (VerificationPo verification:list){
|
||||
verification.setVerificationStatus(3);//挂账
|
||||
}
|
||||
//更新应付账单支付状态为已挂账
|
||||
boolean updateFlag = verificationDomainService.updateVerificationList(list);
|
||||
if(!updateFlag){
|
||||
throw new ServiceException("更新应付账单支付状态失败!");
|
||||
}
|
||||
//更新应付单据的支付状态为已挂账
|
||||
|
||||
//生成挂账流水
|
||||
|
||||
}catch (Exception e){
|
||||
throw new ServiceException("操作异常");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 应付账单支付--批量生成收支流水
|
||||
* @param revenueExpensesRecordAddDto
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
// @GlobalTransactional(rollbackFor = Exception.class)
|
||||
public boolean batchAdd(RevenueExpensesRecordAddDto revenueExpensesRecordAddDto){
|
||||
//获取登录人
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (ObjectUtil.isNull(loginUser)) {
|
||||
throw new ServiceException("用户登录超时!");
|
||||
}
|
||||
String operationType = revenueExpensesRecordAddDto.getOperationType();//操作类型:支付还是挂账
|
||||
/* if(!checkPaypassword(revenueExpensesRecordAddDto.getPayPassword())){
|
||||
throw new ServiceException("支付密码错误");
|
||||
}*/
|
||||
if("pay".equals(operationType)&&StringUtils.isEmpty(revenueExpensesRecordAddDto.getPayChannel())){
|
||||
throw new ServiceException("支付通道不能为空");
|
||||
}
|
||||
try{
|
||||
String payChannelName = "";
|
||||
if("pay".equals(operationType)&&StringUtils.isNotEmpty(revenueExpensesRecordAddDto.getPayChannel())){
|
||||
List<SysDictDataVo> timeTagEndVos = selectListByDictType(DictCode.pay_channel.getCode());
|
||||
if(StringUtils.isNotEmpty(revenueExpensesRecordAddDto.getPayChannel()) && timeTagEndVos != null){
|
||||
List<SysDictDataVo> noticeMouldManagePos = timeTagEndVos.stream().filter(info -> ObjectUtil.equal(info.getDictValue(),revenueExpensesRecordAddDto.getPayChannel())).collect(Collectors.toList());
|
||||
if(noticeMouldManagePos != null && noticeMouldManagePos.size() > 0){
|
||||
payChannelName = noticeMouldManagePos.get(0).getDictLabel();
|
||||
}else {
|
||||
throw new ServiceException("请先维护支付通道数据字典");
|
||||
}
|
||||
}
|
||||
}
|
||||
// if(revenueExpensesRecordAddDto.getBusinessType()==null){
|
||||
// throw new ServiceException("未获取到业务来源类型!");
|
||||
// }
|
||||
Date now = new Date();
|
||||
List<RevenueExpensesRecord> saveList = new ArrayList<>();
|
||||
// if(revenueExpensesRecordAddDto.getBusinessType()==1){//应付账单
|
||||
List<Long> verificationIds = revenueExpensesRecordAddDto.getVerificationIds();
|
||||
List<VerificationPo> list = verificationDomainService.selectVerificationListByIds(verificationIds);
|
||||
int verificationStatus =2;//应付账单状态--已支付
|
||||
int revenueExpensesTypeDeduct=1;//借款抵扣的收支流水表的收入支出状态
|
||||
String kingdee = "应付减少";
|
||||
String kingdeeDeduct ="冲减借款";
|
||||
if("pay".equals(operationType)){
|
||||
boolean allPositive = list.stream() .allMatch(record -> record.getVerificationMoney() != null && record.getVerificationMoney().compareTo(BigDecimal.ZERO) > 0);
|
||||
if (!allPositive) {
|
||||
throw new ServiceException("收支流水金额必须大于0!");
|
||||
}
|
||||
for (VerificationPo verification:list) {
|
||||
if (verification.getVerificationStatus()==2) {
|
||||
throw new ServiceException(verification.getInnerNumber()+"账单已支付!");
|
||||
}
|
||||
}
|
||||
}else if("account".equals(operationType)){
|
||||
for (VerificationPo verification:list) {
|
||||
if (verification.getVerificationStatus()==3) {
|
||||
throw new ServiceException(verification.getInnerNumber()+"账单已挂账,请重新加载数据!");
|
||||
}
|
||||
}
|
||||
verificationStatus =3;//应付账单状态--已挂账
|
||||
revenueExpensesTypeDeduct = 3;//借款抵扣的收支流水表的收入支出状态--已挂账
|
||||
kingdee = "应付挂帐";
|
||||
kingdeeDeduct ="借款挂帐";
|
||||
}
|
||||
|
||||
for (VerificationPo verification:list) {
|
||||
if(SubjectCodeEnum.first_zycl_clhs.getCode().equals(verification.getFirstSubject())
|
||||
&&SubjectCodeEnum.second_zycl_xjhj.getCode().equals(verification.getSecondSubject())&&"现金借款".equals(verification.getPayType())){
|
||||
//车辆核算+现金合计+现金借款 ==》1.生成还款记录(借款金额中减去对应金额)2.生成一条还款的收入流水,3.不生成流水:支出流水包含在现金合计中
|
||||
//1.调用tms生成还款记录与处理金额
|
||||
RevenueExpensesRecordDTO recordDto = new RevenueExpensesRecordDTO();
|
||||
recordDto.setMoney(verification.getVerificationMoney());
|
||||
recordDto.setSecondSubject(verification.getSecondSubject());
|
||||
recordDto.setSecondSubjectName(verification.getSecondSubjectName());
|
||||
recordDto.setLoanType(1);
|
||||
recordDto.setDriverId(verification.getPayId());
|
||||
recordDto.setDriverName(verification.getPayName());
|
||||
recordDto.setTransportationWorkNumber(verification.getBusinessDocumentNumber());
|
||||
recordDto.setUserId(loginUser.getUserid());
|
||||
recordDto.setUserName(loginUser.getUsername());
|
||||
R<Boolean> handleDriverLoanInfo = wlhyServiceFeign.handleDriverLoanInfo(recordDto);
|
||||
if (R.FAIL == handleDriverLoanInfo.getCode()) {
|
||||
throw new ServiceException(handleDriverLoanInfo.getMsg());
|
||||
}
|
||||
//2.
|
||||
RevenueExpensesRecord record = makeRecord(verification,revenueExpensesRecordAddDto,payChannelName,loginUser,kingdee);
|
||||
record.setSecondSubject(SubjectCodeEnum.second_zycl_xjjk.getCode());
|
||||
record.setSecondSubjectName(SubjectCodeEnum.second_zycl_xjjk.getItem());
|
||||
record.setRevenueExpensesType(revenueExpensesTypeDeduct);//收支类型,支付时-收入,挂账时-挂账
|
||||
record.setKingdee(kingdeeDeduct);//冲减借款
|
||||
saveList.add(record);
|
||||
|
||||
verification.setVerificationStatus(verificationStatus);
|
||||
verification.setVerificationTime(now);
|
||||
}else if(SubjectCodeEnum.first_zycl_clhs.getCode().equals(verification.getFirstSubject())
|
||||
&&SubjectCodeEnum.second_zycl_yk.getCode().equals(verification.getSecondSubject())&&"油卡借款".equals(verification.getPayType())){
|
||||
//车辆核算+油卡+油卡借款==》1.生成还款记录(借款金额中减去对应金额)2.生成一条还款的收入流水,3.生成油卡支出流水记录
|
||||
//1.调用tms生成还款记录与处理金额
|
||||
RevenueExpensesRecordDTO recordDto = new RevenueExpensesRecordDTO();
|
||||
recordDto.setMoney(verification.getVerificationMoney());
|
||||
recordDto.setSecondSubject(verification.getSecondSubject());
|
||||
recordDto.setSecondSubjectName(verification.getSecondSubjectName());
|
||||
recordDto.setLoanType(2);
|
||||
recordDto.setDriverId(verification.getPayId());
|
||||
recordDto.setDriverName(verification.getPayName());
|
||||
recordDto.setTransportationWorkNumber(verification.getBusinessDocumentNumber());
|
||||
recordDto.setUserId(loginUser.getUserid());
|
||||
recordDto.setUserName(loginUser.getUsername());
|
||||
R<Boolean> handleDriverLoanInfo = wlhyServiceFeign.handleDriverLoanInfo(recordDto);
|
||||
if (R.FAIL == handleDriverLoanInfo.getCode()) {
|
||||
throw new ServiceException(handleDriverLoanInfo.getMsg());
|
||||
}
|
||||
//2.
|
||||
RevenueExpensesRecord record = makeRecord(verification,revenueExpensesRecordAddDto,payChannelName,loginUser,kingdee);
|
||||
record.setSecondSubject(SubjectCodeEnum.second_zycl_ykjk.getCode());
|
||||
record.setSecondSubjectName(SubjectCodeEnum.second_zycl_ykjk.getItem());
|
||||
record.setRevenueExpensesType(revenueExpensesTypeDeduct);//收支类型,支付时-收入,挂账时-挂账
|
||||
record.setKingdee(kingdeeDeduct);//冲减借款
|
||||
saveList.add(record);
|
||||
//3.
|
||||
RevenueExpensesRecord record2 = makeRecord(verification,revenueExpensesRecordAddDto,payChannelName,loginUser,kingdee);
|
||||
record2.setSecondSubject(SubjectCodeEnum.second_zycl_ykjk.getCode());
|
||||
record2.setSecondSubjectName(SubjectCodeEnum.second_zycl_ykjk.getItem());
|
||||
saveList.add(record2);
|
||||
verification.setVerificationStatus(verificationStatus);
|
||||
verification.setVerificationTime(now);
|
||||
}else if(SubjectCodeEnum.first_zycl_clhs.getCode().equals(verification.getFirstSubject())
|
||||
&&SubjectCodeEnum.second_zycl_xjhj.getCode().equals(verification.getSecondSubject())&&"现金".equals(verification.getPayType())){
|
||||
//现金==》查询费用明细生成多个流水
|
||||
R<List<SecondSubjectPO>> secondSubjectList = wlhyServiceFeign.getZyclXjhjSecondSubjectList(verification.getBusinessDocumentId());
|
||||
if (secondSubjectList.getCode() == R.SUCCESS&&secondSubjectList.getData().size()>0){
|
||||
List<SecondSubjectPO> detailList = secondSubjectList.getData();
|
||||
for (SecondSubjectPO subjectDetail:detailList) {
|
||||
RevenueExpensesRecord record = makeRecord(verification,revenueExpensesRecordAddDto,payChannelName,loginUser,kingdee);
|
||||
record.setSecondSubject(subjectDetail.getSecondSubject());
|
||||
record.setSecondSubjectName(subjectDetail.getSecondSubjectName());
|
||||
record.setMoney(subjectDetail.getAmount());
|
||||
record.setPayType(subjectDetail.getPayType());
|
||||
saveList.add(record);
|
||||
}
|
||||
verification.setVerificationStatus(verificationStatus);
|
||||
verification.setVerificationTime(now);
|
||||
}else{
|
||||
throw new ServiceException("查询现金合计流水明细失败!");
|
||||
}
|
||||
}else{
|
||||
//处理其他常规费用
|
||||
RevenueExpensesRecord record = makeRecord(verification,revenueExpensesRecordAddDto,payChannelName,loginUser,kingdee);
|
||||
saveList.add(record);
|
||||
|
||||
verification.setVerificationStatus(verificationStatus);
|
||||
verification.setVerificationTime(now);
|
||||
}
|
||||
|
||||
}
|
||||
//更新应付账单支付状态为已支付
|
||||
boolean updateFlag = verificationDomainService.updateVerificationList(list);
|
||||
if(!updateFlag){
|
||||
throw new ServiceException("更新应付账单支付状态失败!");
|
||||
}
|
||||
if("pay".equals(operationType)){
|
||||
//支付时:更新应付单据支付状态(挂账时暂不考虑处理这些逻辑)
|
||||
List<VerificationPo> distinctVerificationList = list.stream()
|
||||
.collect(Collectors.toMap(
|
||||
VerificationPo::getBusinessDocumentId,
|
||||
po -> po,
|
||||
(existing, replacement) -> {
|
||||
// 合并逻辑:累加 BigDecimal 类型的 amount
|
||||
existing.setVerificationMoney(
|
||||
existing.getVerificationMoney().add(replacement.getVerificationMoney())
|
||||
);
|
||||
return existing;
|
||||
}
|
||||
))
|
||||
.values()
|
||||
.stream()
|
||||
.collect(Collectors.toList());
|
||||
for (VerificationPo verificationPo:distinctVerificationList) {
|
||||
// String businessDocumentId = verificationPo.getBusinessDocumentId();
|
||||
Long businessDocumentDetaliId = verificationPo.getBusinessDocumentDetaliId();
|
||||
BusinessDocumentDetali detailBean = businessDocumentApplicationService.selectById(businessDocumentDetaliId);
|
||||
BigDecimal thisPaymentAmount = verificationPo.getVerificationMoney()==null ? BigDecimal.ZERO : verificationPo.getVerificationMoney();//本次支付金额
|
||||
BigDecimal amountPaid = thisPaymentAmount.add(detailBean.getAmountPaid()==null ? BigDecimal.ZERO : detailBean.getAmountPaid());//已付金额
|
||||
int paymentStatus = 2;
|
||||
Integer payStatus = PayStatusEnum.PAYMENT.getKey();
|
||||
if(amountPaid.compareTo(detailBean.getAmount())<0){
|
||||
paymentStatus = 3;//部分付款
|
||||
payStatus = PayStatusEnum.PART_PAYMEBT.getKey();
|
||||
}
|
||||
int updateNum = businessDocumentApplicationService.updatePaymentStatusAndAmountByBusinessDocumentDetailId(paymentStatus,thisPaymentAmount,businessDocumentDetaliId);
|
||||
if(updateNum<=0){
|
||||
throw new ServiceException("更新应付单据支付状态失败!");
|
||||
}
|
||||
verificationPo.setPaymentStatus(payStatus);
|
||||
}
|
||||
//更新运输单(运单)、借款单、订单等支付状态为已支付;;;有可能是部分付款,待处理
|
||||
List<UpdatePaymentStatusDTO> updateList = new ArrayList<>();
|
||||
for (VerificationPo po:distinctVerificationList) {
|
||||
UpdatePaymentStatusDTO updatePaymentStatusDTO = new UpdatePaymentStatusDTO();
|
||||
BeanUtils.copyProperties(po,updatePaymentStatusDTO);
|
||||
updatePaymentStatusDTO.setPaymentUserId(loginUser.getUserid());
|
||||
updatePaymentStatusDTO.setPaymentUserName(loginUser.getUsername());
|
||||
updatePaymentStatusDTO.setVoucherImages(revenueExpensesRecordAddDto.getVoucherImages());
|
||||
updateList.add(updatePaymentStatusDTO);
|
||||
}
|
||||
R<Boolean> updatePaymentStatusResult = wlhyServiceFeign.updatePaymentStatusByBusinessDocumentId(updateList);
|
||||
if (R.FAIL == updatePaymentStatusResult.getCode()) {
|
||||
throw new ServiceException(updatePaymentStatusResult.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
// }
|
||||
if(saveList.size()>0){
|
||||
return revenueExpensesRecordDomainService.batchAddRevenueExpensesRecord(saveList);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}catch (Exception ex){
|
||||
throw new ServiceException(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
private RevenueExpensesRecord makeRecord(VerificationPo verification,RevenueExpensesRecordAddDto revenueExpensesRecordAddDto,String payChannelName,LoginUser loginUser,String kingdee){
|
||||
Long organizationId = loginUser.getOrganizationPo().getOrganizationId();
|
||||
Long topOrganizationId = loginUser.getOrganizationPo().getParentOrganizationId();
|
||||
Long userId = loginUser.getUserid();
|
||||
String userName = loginUser.getUsername();
|
||||
Date now = new Date();
|
||||
|
||||
RevenueExpensesRecord record = new RevenueExpensesRecord();
|
||||
BeanUtils.copyProperties(verification,record);
|
||||
record.setBusinessTypeItem(BussinessEnum.findByKey(verification.getBusinessType()));
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour;
|
||||
record.setBusinessDocumentId(verification.getVerificationId());
|
||||
record.setBusinessDocumentNumber(verification.getInnerNumber());
|
||||
record.setInnerNumber(innerNumber);
|
||||
record.setMoney(verification.getVerificationMoney());
|
||||
record.setPayChannel(revenueExpensesRecordAddDto.getPayChannel());
|
||||
record.setPayChannelName(payChannelName);
|
||||
record.setBankNumber(revenueExpensesRecordAddDto.getBankNumber());
|
||||
record.setBankAccount(revenueExpensesRecordAddDto.getBankAccount());
|
||||
record.setVoucherImages(revenueExpensesRecordAddDto.getVoucherImages());
|
||||
record.setRevenueExpensesType(revenueExpensesRecordAddDto.getRevenueExpensesType());
|
||||
record.setRemark(revenueExpensesRecordAddDto.getRemark());
|
||||
record.setDayToDayStatus(1);//流水状态:1.正常2.作废
|
||||
record.setEntryValue(1);//系统入账
|
||||
record.setKingdee(kingdee);
|
||||
record.setOrganizationId(organizationId);
|
||||
record.setTopOrganizationId(topOrganizationId);
|
||||
record.setCreateTime(now);
|
||||
record.setCreateBy(userId);
|
||||
record.setCreateByName(userName);
|
||||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 结果
|
||||
*/
|
||||
public List<SysDictDataVo> selectListByDictType(String dictType){
|
||||
List<SysDictDataVo> noticeTypeList = new ArrayList<>();
|
||||
//查询数据字典通知类型中的配置
|
||||
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(dictType);
|
||||
if("200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
noticeTypeList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
|
||||
}
|
||||
return noticeTypeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改收入支出记录
|
||||
*
|
||||
* @param revenueExpensesRecord 收入支出记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRevenueExpensesRecord(RevenueExpensesRecord revenueExpensesRecord){
|
||||
return revenueExpensesRecordDomainService.updateRevenueExpensesRecord(revenueExpensesRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ids批量修改收入支出记录
|
||||
*
|
||||
* @param revenueExpensesRecordDto 收入支出记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateRevenueExpensesRecords(RevenueExpensesRecordDto revenueExpensesRecordDto){
|
||||
RevenueExpensesRecordPo revenueExpensesRecordPo = new RevenueExpensesRecordPo();
|
||||
BeanUtils.copyProperties(revenueExpensesRecordDto, revenueExpensesRecordPo);
|
||||
//判断所有记录,只有手动添加的才可进行作废
|
||||
RevenueExpensesRecordPo revenueExpensesRecordPo1 = new RevenueExpensesRecordPo();
|
||||
revenueExpensesRecordPo1.setRevenueExpensesRecordIds(revenueExpensesRecordDto.getRevenueExpensesRecordIds());
|
||||
List<RevenueExpensesRecordPo> list = revenueExpensesRecordDomainService.selectRevenueExpensesRecordList(revenueExpensesRecordPo1);
|
||||
for (RevenueExpensesRecordPo expensesRecordPo : list) {
|
||||
if (ObjectUtil.notEqual(2,expensesRecordPo.getEntryValue())){
|
||||
throw new ServiceException("只有在收支流水页面手动添加的流水才可以作废!");
|
||||
}
|
||||
}
|
||||
return revenueExpensesRecordDomainService.updateRevenueExpensesRecords(revenueExpensesRecordPo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除收入支出记录
|
||||
*
|
||||
* @param revenueExpensesRecordId 收入支出记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRevenueExpensesRecordByRevenueExpensesRecordId(Long revenueExpensesRecordId){
|
||||
return revenueExpensesRecordDomainService.deleteRevenueExpensesRecordByRevenueExpensesRecordId(revenueExpensesRecordId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除收入支出记录
|
||||
*
|
||||
* @param revenueExpensesRecordIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRevenueExpensesRecordByRevenueExpensesRecordIds(Long[] revenueExpensesRecordIds){
|
||||
return revenueExpensesRecordDomainService.deleteRevenueExpensesRecordByRevenueExpensesRecordIds(revenueExpensesRecordIds);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 网点利润
|
||||
* @author ZhouGY
|
||||
* @date 2023/12/15 11:37
|
||||
* @param revenueExpensesRecordDO
|
||||
* @return List<BranchProfitStatisticsPO>
|
||||
*/
|
||||
@DataPermissions(cacheName = "branch")
|
||||
public List<BranchProfitStatisticsPO> branchProfitStatistics(RevenueExpensesRecordDO revenueExpensesRecordDO){
|
||||
UserPo userPo = SecurityUtils.getLoginUser().getUserPo();
|
||||
AjaxResult ajaxResult = specialLogisticsServiceFeign.getBranchInfoByTopOrganizationId(userPo.getTopOrganizationId());
|
||||
if (!"200".equals(String.valueOf(ajaxResult.get("code")))){
|
||||
throw new ServiceException("根据一级组织获取网点信息失败");
|
||||
}
|
||||
List<Branch> branchList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), Branch.class);
|
||||
Map<Long, String> branchInfoMap = branchList.stream().collect(Collectors.toMap(Branch::getBranchId, Branch::getBranchName, (key1, key2) -> key2));
|
||||
List<BranchProfitStatisticsPO> branchProfitStatisticsPOList = revenueExpensesRecordDomainService.branchProfitStatistics(revenueExpensesRecordDO);
|
||||
for (BranchProfitStatisticsPO branchProfitStatisticsPO : branchProfitStatisticsPOList){
|
||||
branchProfitStatisticsPO.setBranchName(branchInfoMap.get(branchProfitStatisticsPO.getBranchId()));
|
||||
}
|
||||
return branchProfitStatisticsPOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动还款&作废还款时新增流水记录
|
||||
* @param repaymentTransmitDTOList
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
public boolean pushRepaymentInfo(List<RepaymentTransmitDTO> repaymentTransmitDTOList){
|
||||
try{
|
||||
Date now = new Date();
|
||||
//生成收入流水
|
||||
List<RevenueExpensesRecord> recordList = new ArrayList<>();
|
||||
for (RepaymentTransmitDTO bean:repaymentTransmitDTOList) {
|
||||
if(bean.getOperationType()==null || bean.getLoanType()==null){
|
||||
throw new ServiceException("未获取到操作类型或还款类型!");
|
||||
}
|
||||
RevenueExpensesRecord record = new RevenueExpensesRecord();
|
||||
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
|
||||
int randomFour = (int) (Math.random()*9000+1000);
|
||||
String format = sd.format(new Date());
|
||||
String innerNumber = format + randomFour;
|
||||
record.setInnerNumber(innerNumber);
|
||||
record.setMoney(bean.getMoney());
|
||||
record.setFirstSubject(SubjectCodeEnum.first_zycl_cljk.getCode());
|
||||
record.setFirstSubjectName(SubjectCodeEnum.first_zycl_cljk.getItem());
|
||||
if(bean.getLoanType()==1){//现金还款
|
||||
record.setSecondSubject(SubjectCodeEnum.second_zycl_xjhk.getCode());
|
||||
record.setSecondSubjectName(SubjectCodeEnum.second_zycl_xjhk.getItem());
|
||||
record.setPayType(PayTypeEnum.CASH.getValue());
|
||||
if("repayment".equals(bean.getOperationType())){//还款
|
||||
record.setAccountingReasons("现金手动还款");
|
||||
}else if("delete".equals(bean.getOperationType())){//还款作废
|
||||
record.setAccountingReasons("现金还款作废");
|
||||
}
|
||||
}else if(bean.getLoanType()==2){//油卡还款
|
||||
record.setSecondSubject(SubjectCodeEnum.second_zycl_ykhk.getCode());
|
||||
record.setSecondSubjectName(SubjectCodeEnum.second_zycl_ykhk.getItem());
|
||||
record.setPayType(PayTypeEnum.OIL_CARD.getValue());
|
||||
if("repayment".equals(bean.getOperationType())){//还款
|
||||
record.setAccountingReasons("油卡手动还款");
|
||||
}else if("delete".equals(bean.getOperationType())){//还款作废
|
||||
record.setAccountingReasons("油卡还款作废");
|
||||
}
|
||||
}
|
||||
if("repayment".equals(bean.getOperationType())){//还款
|
||||
record.setKingdee(KingdeeEnum.kingdee_cjjk.getItem());
|
||||
}else if("delete".equals(bean.getOperationType())){//还款作废
|
||||
record.setKingdee(KingdeeEnum.kingdee_cjjkhc.getItem());
|
||||
}
|
||||
record.setRevenueExpensesType(bean.getRevenueExpensesType());
|
||||
record.setExpenseItem(ExpenseItemEnum.ZYCL.getItem());
|
||||
record.setPayee(ExpenseItemEnum.ZYCL.getItem());//付款对象
|
||||
record.setPayId(bean.getDriverId());
|
||||
record.setPayName(bean.getDriverName());
|
||||
record.setDepartmentId("");
|
||||
record.setDepartmentName("");
|
||||
record.setBusinessDocumentId(Long.parseLong(bean.getBusinessDocumentId()));
|
||||
record.setBusinessDocumentNumber(bean.getBusinessDocumentNumber());
|
||||
record.setBusinessTypeItem(BussinessEnum.REPAYMENT_BILL.getValue());
|
||||
record.setVoucherImages("");
|
||||
record.setPayChannel("");
|
||||
record.setPayChannelName("");
|
||||
record.setBankNumber("");
|
||||
record.setBankAccount("");
|
||||
record.setRemark("");
|
||||
record.setDayToDayStatus(1);//流水状态:1.正常2.作废
|
||||
record.setEntryValue(1);//系统入账
|
||||
record.setOrganizationId(bean.getOrganizationId());
|
||||
record.setTopOrganizationId(bean.getTopOrganizationId());
|
||||
record.setCreateTime(now);
|
||||
record.setCreateBy(bean.getUserId());
|
||||
record.setCreateByName(bean.getUserName());
|
||||
recordList.add(record);
|
||||
}
|
||||
boolean saveFlag = revenueExpensesRecordDomainService.batchAddRevenueExpensesRecord(recordList);
|
||||
if(!saveFlag){
|
||||
throw new ServiceException("批量保存流水记录失败!");
|
||||
}
|
||||
return true;
|
||||
|
||||
}catch (Exception ex){
|
||||
throw new ServiceException("批量保存流水记录异常!");
|
||||
}
|
||||
}
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
package com.linke.finance.application.service.serviceBill;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.linke.finance.domain.serviceBill.repository.po.ServiceBillPO;
|
||||
import com.linke.finance.domain.serviceBill.repository.todo.ServiceBillDO;
|
||||
import com.linke.finance.domain.serviceBill.service.ServiceBillDomainService;
|
||||
import com.linke.finance.infrastructure.feign.SpecialLogisticsServiceFeign;
|
||||
import com.mhd.common.core.domain.po.BranchPo;
|
||||
import com.mhd.common.core.exception.ServiceException;
|
||||
import com.mhd.common.core.web.domain.AjaxResult;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
/**
|
||||
* 服务费账单ApplicationService
|
||||
*
|
||||
* @author gen
|
||||
* @date 2023-11-06
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ServiceBillApplicationService {
|
||||
@Autowired
|
||||
private ServiceBillDomainService serviceBillDomainService;
|
||||
@Autowired
|
||||
private SpecialLogisticsServiceFeign specialLogisticsServiceFeign;
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询服务费账单列表
|
||||
*/
|
||||
|
||||
public List<ServiceBillPO> queryList(ServiceBillDO serviceBillDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
serviceBillDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
//查询当前组织的网点
|
||||
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// AjaxResult info = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
||||
// if(!"200".equals(String.valueOf(info.get("code")))){
|
||||
// throw new ServiceException("获取当前登录用户网点失败,请联系管理员");
|
||||
// }
|
||||
// BranchPo branchPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), BranchPo.class);
|
||||
// serviceBillDO.setBranchId(branchPo.getBranchId());
|
||||
}
|
||||
return serviceBillDomainService.queryList(serviceBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 收入记录、支出记录数
|
||||
* @author ZhouGY
|
||||
* @date 2023/11/6 16:35
|
||||
* @param serviceBillDO 服务费实体
|
||||
* @return ServiceBillPO
|
||||
*/
|
||||
public ServiceBillPO countTabTotal(ServiceBillDO serviceBillDO) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null){
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (topOrganizationId != null && topOrganizationId != 1){
|
||||
serviceBillDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
|
||||
}
|
||||
//查询当前组织的网点
|
||||
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
// AjaxResult info = specialLogisticsServiceFeign.getBranchByOrganizationId(organizationId);
|
||||
// if(!"200".equals(String.valueOf(info.get("code")))){
|
||||
// throw new ServiceException("获取当前登录用户网点失败,请联系管理员");
|
||||
// }
|
||||
// BranchPo branchPo = JSONObject.parseObject(JSONObject.toJSONString(info.get("data")), BranchPo.class);
|
||||
// serviceBillDO.setBranchInId(branchPo.getBranchId());
|
||||
// serviceBillDO.setBranchOutId(branchPo.getBranchId());
|
||||
}
|
||||
return serviceBillDomainService.countTabTotal(serviceBillDO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增服务费账单
|
||||
*/
|
||||
public Boolean insert(ServiceBillDO serviceBillDO) {
|
||||
|
||||
return serviceBillDomainService.insert(serviceBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改服务费账单
|
||||
*/
|
||||
public Boolean update(ServiceBillDO serviceBillDO) {
|
||||
return serviceBillDomainService.update(serviceBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改服务费账单状态
|
||||
*/
|
||||
public int updateStatus(ServiceBillDO serviceBillDO) {
|
||||
return serviceBillDomainService.updateStatus(serviceBillDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除服务费账单
|
||||
*/
|
||||
public boolean delete(Long[] serviceBillIds) {
|
||||
return serviceBillDomainService.delete(serviceBillIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务费账单详细信息
|
||||
*/
|
||||
public ServiceBillPO getInfo(Long serviceBillId)
|
||||
{
|
||||
return serviceBillDomainService.getInfo(serviceBillId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 确认服务费
|
||||
* @author ZhouGY
|
||||
* @date 2023/11/24 8:43
|
||||
* @param serviceBillId
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean confirmServiceBill(Long serviceBillId){
|
||||
return serviceBillDomainService.confirmServiceBill(serviceBillId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+2460
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user