first commit

This commit is contained in:
陈现府
2025-11-20 10:45:16 +08:00
commit 8355431361
2643 changed files with 291314 additions and 0 deletions
@@ -0,0 +1,22 @@
package com.linke.finance;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
//@SpringBootApplication
@SpringBootApplication(scanBasePackages = {"com.mhd", "com.linke"},
exclude = DataSourceAutoConfiguration.class)
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"com.mhd","com.linke","com.linke.finance.infrastructure.feign"})
@MapperScan("com.linke.finance.domain.**.mapper")
public class FinanceApplication {
public static void main(String[] args) {
SpringApplication.run(FinanceApplication.class, args);
}
}
@@ -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);
}
}
@@ -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());
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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);
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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 {
}
}
}
}
@@ -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);
}
}
@@ -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("收账网点组织账号未找到");
}
}
}
@@ -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);
}
}
@@ -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;
}
}
@@ -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("存在申请中的发票信息,请处理后再试;");
}
}
}
@@ -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);
}
}
@@ -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("批量保存流水记录异常!");
}
}
}
@@ -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);
}
}
@@ -0,0 +1,97 @@
package com.linke.finance.domain.accountManage.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 银行卡管理对象 account_bank_card
*
* @author mhd
* @date 2023-03-21
*/
@Data
public class AccountBankCard extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 银行卡管理表id */
@ApiModelProperty(name = "银行卡管理表id")
@TableId(type = IdType.AUTO)
private Long accountBankCardId;
/** 账户类型(1-对私账户,2-对公账户) */
@ApiModelProperty(name = "账户类型(1-对私账户,2-对公账户)")
private Integer accountBankType;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 用户账号 */
@ApiModelProperty(name = "用户账号")
private String userAccount;
/** 用户姓名 */
@ApiModelProperty(name = "用户姓名")
private String userName;
/** 用户手机号 */
@ApiModelProperty(name = "用户手机号")
private String userPhone;
/** 银行卡号 */
@ApiModelProperty(name = "银行卡号")
private String bankCardNumber;
/** 开户银行code */
@ApiModelProperty(name = "开户银行code")
private String bankNameCode;
/** 开户银行名称 */
@ApiModelProperty(name = "开户银行名称")
private String bankName;
@ApiModelProperty(name = "开户银行图标地址")
private String bankImg;
/** 银行卡预留电话 */
@ApiModelProperty(name = "银行卡预留电话")
private String bankBindingPhone;
/** 银行卡预留姓名 */
@ApiModelProperty(name = "银行卡预留姓名")
private String bankBindingName;
/** 用户身份证号 */
@ApiModelProperty(name = "用户身份证号")
private String bankBindingIdNum;
/** 持卡人地址 */
@ApiModelProperty(name = "持卡人地址")
private String bankUserAddress;
@ApiModelProperty(name = "开户行支行名称")
private String bankBranchName;
@ApiModelProperty(name = "联行号")
private String bankNo;
@ApiModelProperty(name = "银行卡正面图片地址")
private String bankImgUrl;
@ApiModelProperty(name = "默认地址状态(1-是,2-否)")
private Integer defaultStatus;
@ApiModelProperty(name = "车牌号")
private String vehicleLicensePlateNumber;
@ApiModelProperty(name = "组织id")
private Long organizationId;
@ApiModelProperty(name = "公司名称")
private String companyName;
}
@@ -0,0 +1,94 @@
package com.linke.finance.domain.accountManage.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 用户钱包账户对象 account_cash_wallet
*
* @author mhd
* @date 2023-03-18
*/
@Data
public class AccountCashWallet extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 用户钱包账户id */
@ApiModelProperty(name = "用户钱包账户id")
@TableId(type = IdType.AUTO)
private Long accountCashWalletId;
/** 钱包id */
@ApiModelProperty(name = "钱包id")
private Long accountWalletId;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 姓名 */
@ApiModelProperty(name = "姓名")
private String userName;
/** 账号 */
@ApiModelProperty(name = "账号")
private String userAccount;
/** 身份证号 */
@ApiModelProperty(name = "身份证号")
private String userIdcardNumber;
/** 手机号 */
@ApiModelProperty(name = "手机号")
private String userPhone;
/** 公司名称 */
@ApiModelProperty(name = "公司名称")
private String enterpriseName;
/** 组织id */
@ApiModelProperty(name = "组织id")
private Long organizationId;
@ApiModelProperty(name = "一级组织表ID")
private Long topOrganizationId;
/** 组织名称 */
@ApiModelProperty(name = "组织名称")
private String organizationName;
/** 钱包余额 */
@ApiModelProperty(name = "钱包余额")
private BigDecimal walletBalance;
/** 可用金额 */
@ApiModelProperty(name = "可用金额")
private BigDecimal walletAvailableBalance;
/** 冻结金额 */
@ApiModelProperty(name = "冻结金额")
private BigDecimal walletFreezeBalance;
/** 账户状态(1-正常,2-锁定) */
@ApiModelProperty(name = "账户状态(1-正常,2-锁定)")
private Integer accountWalletStatus;
@ApiModelProperty(name = "账户类型(1-个人,2-组织)")
private Integer accountType;
@ApiModelProperty(name = "授信额度")
private BigDecimal creditLimit;
@ApiModelProperty(name = "总授信额度")
private BigDecimal totalLimit;
@ApiModelProperty(name = "支付宝账户")
private String alipayAccount;
@ApiModelProperty(name = "支付宝账户名称")
private String alipayAccountName;
}
@@ -0,0 +1,171 @@
package com.linke.finance.domain.accountManage.entity;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
/**
* 账户消费记录对象 account_expend_records
*
* @author mhd
* @date 2023-03-18
*/
@Data
public class AccountExpendRecords extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 消费记录表id */
@ApiModelProperty(name = "消费记录表id")
@TableId(type = IdType.AUTO)
private Long accountExpendRecordsId;
/** 内部流水号 */
@ApiModelProperty(name = "内部流水号")
private String accountSerialNumber;
/** 一级账户code */
@ApiModelProperty(name = "一级账户code")
private String accountFirstCode;
/** 一级账户value */
@ApiModelProperty(name = "一级账户value")
private String accountFirstValue;
/** 二级账户code */
@ApiModelProperty(name = "二级账户code")
private String accountSecondCode;
/** 二级账户value */
@ApiModelProperty(name = "二级账户value")
private String accountSecondValue;
/** 一级科目code */
@ApiModelProperty(name = "一级科目code")
private String subjectFirstCode;
/** 一级科目value */
@ApiModelProperty(name = "一级科目value")
private String subjectFirstValue;
/** 二级科目code */
@ApiModelProperty(name = "二级科目code")
private String subjectSecondCode;
/** 二级科目value */
@ApiModelProperty(name = "二级科目value")
private String subjectSecondValue;
/** 收支类型(1-收入,2-支出) */
@ApiModelProperty(name = "收支类型")
private Integer accountExpenseType;
/** 经办人 */
@ApiModelProperty(name = "经办人")
private String accountExpendOperator;
/** 关联运单/订单号 */
@ApiModelProperty(name = "关联运单/订单号")
private String waybillNumber;
/** 银企直联流水号 */
@ApiModelProperty(name = "银企直联流水号")
private String bankSerialNumber;
/** 订单来源code */
@ApiModelProperty(name = "订单来源code")
private String orderSourceCode;
/** 订单来源value */
@ApiModelProperty(name = "订单来源value")
private String orderSourceValue;
/** 消费备注 */
@ApiModelProperty(name = "消费备注")
private String accountRecordsRemark;
/** 上笔余额 */
@ApiModelProperty(name = "上笔余额")
private BigDecimal accountLastBalance;
/** 交易金额 */
@ApiModelProperty(name = "交易金额")
private BigDecimal transactionAmount;
/** 账户余额 */
@ApiModelProperty(name = "账户余额")
private BigDecimal accountBalance;
/** 交易时间 */
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "交易时间")
private Date transactionTime;
/** 用户名 */
@ApiModelProperty(name = "用户名")
private String userName;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 公司名称 */
@ApiModelProperty(name = "公司名称")
private String enterpriseName;
/** 用户账号 */
@ApiModelProperty(name = "用户账号")
private String userAccount;
/** 入账类型(1-系统入账,2-手工入账) */
@ApiModelProperty(name = "入账类型")
private Integer accountEnterType;
/** 流水状态(1-正常,2-作废) */
@ApiModelProperty(name = "流水状态")
private Integer capitalFlowStatus;
/** 用户钱包账户id */
@ApiModelProperty(name = "用户钱包账户id")
private Long accountCashWalletId;
/** 钱包id */
@ApiModelProperty(name = "钱包id")
private Long accountWalletId;
@ApiModelProperty(name = "银行卡管理表id")
private Long accountBankCardId;
@ApiModelProperty(name = "银行卡预留姓名")
private String bankBindingName;
@ApiModelProperty(name = "开户银行code")
private String bankNameCode;
@ApiModelProperty(name = "开户银行名称")
private String bankName;
@ApiModelProperty(name = "银行卡号")
private String bankCardNumber;
@ApiModelProperty(name = "组织id")
private Long organizationId;
@ApiModelProperty(name = "支付凭证")
private String paymentVoucher;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "获取凭证时间")
private Date voucherTime;
}
@@ -0,0 +1,125 @@
package com.linke.finance.domain.accountManage.entity;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 会员转账充值对象 account_transfer_recharge
*
* @author mhd
* @date 2023-03-23
*/
@Data
public class AccountTransferRecharge extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 会员转账充值表id */
@ApiModelProperty(name = "会员转账充值表id")
@TableId(type = IdType.AUTO)
private Long accountTransferRechargeId;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 用户账号 */
@ApiModelProperty(name = "用户账号")
private String userAccount;
/** 用户姓名 */
@ApiModelProperty(name = "用户姓名")
private String userName;
/** 用户手机号 */
@ApiModelProperty(name = "用户手机号")
private String userPhone;
/** 充值状态(1-待处理,2-已同意,3-已拒绝) */
@ApiModelProperty(name = "充值状态")
private Integer accountTransferStatus;
/** 一级账户code */
@ApiModelProperty(name = "一级账户code")
private String accountFirstCode;
/** 一级账户value */
@ApiModelProperty(name = "一级账户value")
private String accountFirstValue;
/** 二级账户code */
@ApiModelProperty(name = "二级账户code")
private String accountSecondCode;
/** 二级账户value */
@ApiModelProperty(name = "二级账户value")
private String accountSecondValue;
/** 交易流水 */
@ApiModelProperty(name = "交易流水")
private String accountTransferNumber;
/** 交易金额 */
@ApiModelProperty(name = "交易金额")
private BigDecimal accountTransferAmount;
/** 账户余额 */
@ApiModelProperty(name = "账户余额")
private BigDecimal accountBalance;
/** 交易方式code */
@ApiModelProperty(name = "交易方式code")
private String transferTypeCode;
/** 交易方式value */
@ApiModelProperty(name = "交易方式value")
private String transferTypeValue;
/** 交易时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "交易时间")
private Date accountTransferTime;
/** 收支类型(1-收入,2-支出) */
@ApiModelProperty(name = "收支类型(1-收入,2-支出)")
private Integer accountTransferType;
/** 经办人 */
@ApiModelProperty(name = "经办人")
private String accountTransferOperator;
/** 交易凭证图片地址 */
@ApiModelProperty(name = "交易凭证图片地址")
private String accountTransferVoucherUrl;
/** 备注 */
@ApiModelProperty(name = "备注")
private String accountTransferRemark;
/** 审核人id */
@ApiModelProperty(name = "审核人id")
private Long transferReviewerId;
/** 审核人 */
@ApiModelProperty(name = "审核人")
private String accountTransferReviewer;
/** 审核时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(name = "审核时间")
private Date transferReviewerTime;
/** 驳回理由 */
@ApiModelProperty(name = "驳回理由")
private String accountTransferReject;
@ApiModelProperty(name = "组织id")
private Long organizationId;
}
@@ -0,0 +1,33 @@
package com.linke.finance.domain.accountManage.repository.facade;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linke.finance.domain.accountManage.entity.AccountBankCard;
import com.linke.finance.domain.accountManage.repository.po.AccountBankCardPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountBankCardDo;
/**
* 银行卡管理Service接口
*
* @author mhd
* @date 2023-03-21
*/
public interface AccountBankCardInterface extends IService<AccountBankCard>
{
/**
* 查询银行卡管理
*
* @param accountBankCardId 银行卡管理主键
* @return 银行卡管理
*/
public AccountBankCardPo selectAccountBankCardByAccountBankCardId(Long accountBankCardId);
/**
* 查询银行卡管理列表
*
* @param accountBankCardDo 银行卡管理
* @return 银行卡管理集合
*/
public List<AccountBankCardPo> selectAccountBankCardList(AccountBankCardDo accountBankCardDo);
}
@@ -0,0 +1,56 @@
package com.linke.finance.domain.accountManage.repository.facade;
import java.math.BigDecimal;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linke.finance.domain.accountManage.entity.AccountCashWallet;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletAppPo;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountCashWalletDo;
/**
* 用户钱包账户Service接口
*
* @author mhd
* @date 2023-03-18
*/
public interface AccountCashWalletInterface extends IService<AccountCashWallet>
{
/**
* 查询用户钱包账户
*
* @param accountCashWalletId 用户钱包账户主键
* @return 用户钱包账户
*/
public AccountCashWalletPo selectAccountCashWalletByAccountCashWalletId(Long accountCashWalletId);
/**
* 查询用户钱包账户列表
*
* @param accountCashWalletDo 用户钱包账户
* @return 用户钱包账户集合
*/
public List<AccountCashWalletPo> selectAccountCashWalletList(AccountCashWalletDo accountCashWalletDo);
/**
* 根据用户id查询用户钱包信息
* @param userId
* @return
*/
AccountCashWalletAppPo selectUserWalletInfo(Long userId);
int updateAccountCashWallet(BigDecimal payAmount,Long userId);
void updateCreditLimit(AccountCashWallet accountCashWallet);
void updateTotalLimit(AccountCashWallet accountCashWallet);
AccountCashWallet getLimitByUserId(Long userId);
int updateAccountCashWalletAdd(BigDecimal payAmount, Long userId);
int updateFreezeCashWalletSub(BigDecimal payAmount, Long userId);
int updateFreezeCashWalletAdd(BigDecimal payAmount, Long userId);
}
@@ -0,0 +1,55 @@
package com.linke.finance.domain.accountManage.repository.facade;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linke.finance.domain.accountManage.entity.AccountExpendRecords;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletPo;
import com.linke.finance.domain.accountManage.repository.po.AccountExpendRecordsAppPo;
import com.linke.finance.domain.accountManage.repository.po.AccountExpendRecordsPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountExpendRecordsDo;
/**
* 账户消费记录Service接口
*
* @author mhd
* @date 2023-03-18
*/
public interface AccountExpendRecordsInterface extends IService<AccountExpendRecords>
{
/**
* 查询账户消费记录
*
* @param accountExpendRecordsId 账户消费记录主键
* @return 账户消费记录
*/
public AccountExpendRecordsPo selectAccountExpendRecordsByAccountExpendRecordsId(Long accountExpendRecordsId);
/**
* 查询账户消费记录列表
*
* @param accountExpendRecordsDo 账户消费记录
* @return 账户消费记录集合
*/
public List<AccountExpendRecordsPo> selectAccountExpendRecordsList(AccountExpendRecordsDo accountExpendRecordsDo);
/**
* APP收支明细列表查询
* @param accountExpendRecordsDo
* @return
*/
List<AccountExpendRecordsAppPo> selectAccountExpendRecordsAppList(AccountExpendRecordsDo accountExpendRecordsDo);
/**
* 根据用户id查询钱包信息
* @param userId
* @return
*/
AccountCashWalletPo getWalletByUserId(Long userId);
/**
* 根据用户id查询钱包信息
* @param userId
* @return
*/
String queryAccountExpendRecordsByUserId(Long userId);
}
@@ -0,0 +1,33 @@
package com.linke.finance.domain.accountManage.repository.facade;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linke.finance.domain.accountManage.entity.AccountTransferRecharge;
import com.linke.finance.domain.accountManage.repository.po.AccountTransferRechargePo;
import com.linke.finance.domain.accountManage.repository.todo.AccountTransferRechargeDo;
/**
* 会员转账充值Service接口
*
* @author mhd
* @date 2023-03-23
*/
public interface AccountTransferRechargeInterface extends IService<AccountTransferRecharge>
{
/**
* 查询会员转账充值
*
* @param accountTransferRechargeId 会员转账充值主键
* @return 会员转账充值
*/
public AccountTransferRechargePo selectAccountTransferRechargeById(Long accountTransferRechargeId);
/**
* 查询会员转账充值列表
*
* @param accountTransferRechargeDo 会员转账充值
* @return 会员转账充值集合
*/
public List<AccountTransferRechargePo> selectAccountTransferRechargeList(AccountTransferRechargeDo accountTransferRechargeDo);
}
@@ -0,0 +1,34 @@
package com.linke.finance.domain.accountManage.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.finance.domain.accountManage.entity.AccountBankCard;
import com.linke.finance.domain.accountManage.repository.po.AccountBankCardPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountBankCardDo;
import org.apache.ibatis.annotations.Param;
/**
* 银行卡管理Mapper接口
*
* @author mhd
* @date 2023-03-21
*/
public interface AccountBankCardMapper extends BaseMapper<AccountBankCard>
{
/**
* 查询银行卡管理
*
* @param accountBankCardId 银行卡管理主键
* @return 银行卡管理
*/
public AccountBankCardPo selectAccountBankCardByAccountBankCardId(@Param("accountBankCardId") Long accountBankCardId);
/**
* 查询银行卡管理列表
*
* @param accountBankCardDo 银行卡管理
* @return 银行卡管理集合
*/
public List<AccountBankCardPo> selectAccountBankCardList(@Param("accountBankCardDo") AccountBankCardDo accountBankCardDo);
}
@@ -0,0 +1,92 @@
package com.linke.finance.domain.accountManage.repository.mapper;
import java.math.BigDecimal;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.finance.domain.accountManage.entity.AccountCashWallet;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletAppPo;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountCashWalletDo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
/**
* 用户钱包账户Mapper接口
*
* @author mhd
* @date 2023-03-18
*/
public interface AccountCashWalletMapper extends BaseMapper<AccountCashWallet>
{
/**
* 查询用户钱包账户
*
* @param accountCashWalletId 用户钱包账户主键
* @return 用户钱包账户
*/
public AccountCashWalletPo selectAccountCashWalletByAccountCashWalletId(Long accountCashWalletId);
/**
* 查询用户钱包账户列表
*
* @param accountCashWalletDo 用户钱包账户
* @return 用户钱包账户集合
*/
public List<AccountCashWalletPo> selectAccountCashWalletList(@Param("accountCashWalletDo") AccountCashWalletDo accountCashWalletDo);
/**
* 根据用户id查询现金钱包信息
* @param userId
* @return
*/
AccountCashWalletAppPo selectUserWalletInfo(@Param("userId") Long userId);
/**
* 更新钱包余额(减)
* @param payAmount 金额
* @param userId 用户id
* @return
*/
@Update("UPDATE account_cash_wallet SET wallet_balance = wallet_balance - #{payAmount},wallet_available_balance = wallet_available_balance - #{payAmount} WHERE user_id = #{userId} AND del_flag = 1 AND account_wallet_status = 1")
int updateAccountCashWallet(@Param("payAmount") BigDecimal payAmount,@Param("userId") Long userId);
/**
* 使用/回充使用额度
* @param accountCashWallet
*/
@Select("UPDATE account_cash_wallet SET credit_limit = credit_limit - #{creditLimit} WHERE user_id = #{userId}")
void updateCreditLimit(AccountCashWallet accountCashWallet);
/**
* 修改总金额
* @param accountCashWallet
*/
@Select("UPDATE account_cash_wallet SET total_limit = #{totalLimit} WHERE user_id = #{userId}")
void updateTotalLimit(AccountCashWallet accountCashWallet);
/**
* 更新钱包余额(加)
* @param payAmount
* @param userId
* @return
*/
@Update("UPDATE account_cash_wallet SET wallet_balance = wallet_balance + #{payAmount},wallet_available_balance = wallet_available_balance + #{payAmount} WHERE user_id = #{userId} AND del_flag = 1 AND account_wallet_status = 1")
int updateAccountCashWalletAdd(@Param("payAmount") BigDecimal payAmount, @Param("userId") Long userId);
/**
* 更新钱包余额(冻结金额减)
*/
@Update("UPDATE account_cash_wallet SET wallet_balance = wallet_balance - #{payAmount},wallet_freeze_balance = wallet_freeze_balance - #{payAmount} WHERE user_id = #{userId} AND del_flag = 1 AND account_wallet_status = 1")
int updateFreezeCashWalletSub(@Param("payAmount") BigDecimal payAmount, @Param("userId") Long userId);
/**
* 更新钱包余额(冻结金额加)
*/
@Update("UPDATE account_cash_wallet SET wallet_balance = wallet_balance + #{payAmount},wallet_freeze_balance = wallet_freeze_balance + #{payAmount} WHERE user_id = #{userId} AND del_flag = 1 AND account_wallet_status = 1")
int updateFreezeCashWalletAdd(@Param("payAmount")BigDecimal payAmount,@Param("userId") Long userId);
}
@@ -0,0 +1,53 @@
package com.linke.finance.domain.accountManage.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.finance.domain.accountManage.entity.AccountExpendRecords;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletPo;
import com.linke.finance.domain.accountManage.repository.po.AccountExpendRecordsAppPo;
import com.linke.finance.domain.accountManage.repository.po.AccountExpendRecordsPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountExpendRecordsDo;
import org.apache.ibatis.annotations.Param;
/**
* 账户消费记录Mapper接口
*
* @author mhd
* @date 2023-03-18
*/
public interface AccountExpendRecordsMapper extends BaseMapper<AccountExpendRecords>
{
/**
* 查询账户消费记录
*
* @param accountExpendRecordsId 账户消费记录主键
* @return 账户消费记录
*/
public AccountExpendRecordsPo selectAccountExpendRecordsByAccountExpendRecordsId(@Param("accountExpendRecordsId") Long accountExpendRecordsId);
/**
* 查询账户消费记录列表
*
* @param accountExpendRecordsDo 账户消费记录
* @return 账户消费记录集合
*/
public List<AccountExpendRecordsPo> selectAccountExpendRecordsList(@Param("accountExpendRecordsDo") AccountExpendRecordsDo accountExpendRecordsDo);
/**
* APP收支明细分页列表查询
* @param accountExpendRecordsDo
* @return
*/
List<AccountExpendRecordsAppPo> selectAccountExpendRecordsAppList(@Param("accountExpendRecordsDo") AccountExpendRecordsDo accountExpendRecordsDo);
/**
* 根据用户id查询钱包信息
*/
AccountCashWalletPo getWalletByUserId(@Param("userId") Long userId);
/**
* 根据用户id查询钱包信息
*/
String queryAccountExpendRecordsByUserId(@Param("userId") Long userId);
}
@@ -0,0 +1,35 @@
package com.linke.finance.domain.accountManage.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.finance.domain.accountManage.entity.AccountTransferRecharge;
import com.linke.finance.domain.accountManage.repository.po.AccountTransferRechargePo;
import com.linke.finance.domain.accountManage.repository.todo.AccountTransferRechargeDo;
import org.apache.ibatis.annotations.Param;
/**
* 会员转账充值Mapper接口
*
* @author mhd
* @date 2023-03-23
*/
public interface AccountTransferRechargeMapper extends BaseMapper<AccountTransferRecharge>
{
/**
* 查询会员转账充值
*
* @param accountTransferRechargeId 会员转账充值主键
* @return 会员转账充值
*/
public AccountTransferRechargePo selectAccountTransferRechargeById(@Param("accountTransferRechargeId") Long accountTransferRechargeId);
/**
* 查询会员转账充值列表
*
* @param accountTransferRechargeDo 会员转账充值
* @return 会员转账充值集合
*/
public List<AccountTransferRechargePo> selectAccountTransferRechargeList(@Param("accountTransferRechargeDo") AccountTransferRechargeDo accountTransferRechargeDo);
}
@@ -0,0 +1,50 @@
package com.linke.finance.domain.accountManage.repository.persistence;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.finance.domain.accountManage.entity.AccountBankCard;
import com.linke.finance.domain.accountManage.repository.facade.AccountBankCardInterface;
import com.linke.finance.domain.accountManage.repository.mapper.AccountBankCardMapper;
import com.linke.finance.domain.accountManage.repository.po.AccountBankCardPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountBankCardDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 银行卡管理Service业务层处理
*
* @author mhd
* @date 2023-03-21
*/
@Service
public class AccountBankCardImpl extends ServiceImpl<AccountBankCardMapper, AccountBankCard> implements AccountBankCardInterface
{
@Autowired
private AccountBankCardMapper accountBankCardMapper;
/**
* 查询银行卡管理
*
* @param accountBankCardId 银行卡管理主键
* @return 银行卡管理
*/
@Override
public AccountBankCardPo selectAccountBankCardByAccountBankCardId(Long accountBankCardId)
{
AccountBankCardPo accountBankCardPo = accountBankCardMapper.selectAccountBankCardByAccountBankCardId(accountBankCardId);
return accountBankCardPo;
}
/**
* 查询银行卡管理列表
*
* @param accountBankCardDo 银行卡管理
* @return 银行卡管理
*/
@Override
public List<AccountBankCardPo> selectAccountBankCardList(AccountBankCardDo accountBankCardDo)
{
return accountBankCardMapper.selectAccountBankCardList(accountBankCardDo);
}
}
@@ -0,0 +1,120 @@
package com.linke.finance.domain.accountManage.repository.persistence;
import java.math.BigDecimal;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.finance.domain.accountManage.entity.AccountCashWallet;
import com.linke.finance.domain.accountManage.repository.facade.AccountCashWalletInterface;
import com.linke.finance.domain.accountManage.repository.mapper.AccountCashWalletMapper;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletAppPo;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountCashWalletDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 用户钱包账户Service业务层处理
*
* @author mhd
* @date 2023-03-18
*/
@Service
public class AccountCashWalletImpl extends ServiceImpl<AccountCashWalletMapper,AccountCashWallet> implements AccountCashWalletInterface
{
@Autowired
private AccountCashWalletMapper accountCashWalletMapper;
/**
* 查询用户钱包账户
*
* @param accountCashWalletId 用户钱包账户主键
* @return 用户钱包账户
*/
@Override
public AccountCashWalletPo selectAccountCashWalletByAccountCashWalletId(Long accountCashWalletId)
{
return accountCashWalletMapper.selectAccountCashWalletByAccountCashWalletId(accountCashWalletId);
}
/**
* 查询用户钱包账户列表
*
* @param accountCashWalletDo 用户钱包账户
* @return 用户钱包账户
*/
@Override
public List<AccountCashWalletPo> selectAccountCashWalletList(AccountCashWalletDo accountCashWalletDo)
{
return accountCashWalletMapper.selectAccountCashWalletList(accountCashWalletDo);
}
/**
* 根据用户id查询用户钱包信息
* @param userId
* @return
*/
@Override
public AccountCashWalletAppPo selectUserWalletInfo(Long userId) {
return accountCashWalletMapper.selectUserWalletInfo(userId);
}
/**
* 更新钱包余额(减)
* @param payAmount 金额
* @param userId 用户id
* @return
*/
@Override
public int updateAccountCashWallet(BigDecimal payAmount, Long userId) {
return accountCashWalletMapper.updateAccountCashWallet(payAmount,userId);
}
@Override
public void updateCreditLimit(AccountCashWallet accountCashWallet) {
accountCashWalletMapper.updateCreditLimit(accountCashWallet);
}
@Override
public void updateTotalLimit(AccountCashWallet accountCashWallet) {
accountCashWalletMapper.updateTotalLimit(accountCashWallet);
}
@Override
public AccountCashWallet getLimitByUserId(Long userId) {
return accountCashWalletMapper.selectOne(new LambdaQueryWrapper<AccountCashWallet>()
.eq(AccountCashWallet::getUserId, userId)
.eq(AccountCashWallet::getDelFlag, 1)
.last("limit 1"));
}
/**
* 更新钱包余额(加)
* @param payAmount 金额
* @param userId 用户id
* @return
*/
@Override
public int updateAccountCashWalletAdd(BigDecimal payAmount, Long userId) {
return accountCashWalletMapper.updateAccountCashWalletAdd(payAmount,userId);
}
/**
* 更新钱包余额(冻结金额减)
*/
@Override
public int updateFreezeCashWalletSub(BigDecimal payAmount, Long userId) {
return accountCashWalletMapper.updateFreezeCashWalletSub(payAmount,userId);
}
/**
* 更新钱包余额(冻结金额加)
*/
@Override
public int updateFreezeCashWalletAdd(BigDecimal payAmount, Long userId) {
return accountCashWalletMapper.updateFreezeCashWalletAdd(payAmount,userId);
}
}
@@ -0,0 +1,77 @@
package com.linke.finance.domain.accountManage.repository.persistence;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.finance.domain.accountManage.entity.AccountExpendRecords;
import com.linke.finance.domain.accountManage.repository.facade.AccountExpendRecordsInterface;
import com.linke.finance.domain.accountManage.repository.mapper.AccountExpendRecordsMapper;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletPo;
import com.linke.finance.domain.accountManage.repository.po.AccountExpendRecordsAppPo;
import com.linke.finance.domain.accountManage.repository.po.AccountExpendRecordsPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountExpendRecordsDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 账户消费记录Service业务层处理
*
* @author mhd
* @date 2023-03-18
*/
@Service
public class AccountExpendRecordsImpl extends ServiceImpl<AccountExpendRecordsMapper, AccountExpendRecords> implements AccountExpendRecordsInterface
{
@Autowired
private AccountExpendRecordsMapper accountExpendRecordsMapper;
/**
* 查询账户消费记录
*
* @param accountExpendRecordsId 账户消费记录主键
* @return 账户消费记录
*/
@Override
public AccountExpendRecordsPo selectAccountExpendRecordsByAccountExpendRecordsId(Long accountExpendRecordsId)
{
return accountExpendRecordsMapper.selectAccountExpendRecordsByAccountExpendRecordsId(accountExpendRecordsId);
}
/**
* 查询账户消费记录列表
*
* @param accountExpendRecordsDo 账户消费记录
* @return 账户消费记录
*/
@Override
public List<AccountExpendRecordsPo> selectAccountExpendRecordsList(AccountExpendRecordsDo accountExpendRecordsDo)
{
return accountExpendRecordsMapper.selectAccountExpendRecordsList(accountExpendRecordsDo);
}
/**
* APP收支明细分页列表查询
* @param accountExpendRecordsDo
* @return
*/
@Override
public List<AccountExpendRecordsAppPo> selectAccountExpendRecordsAppList(AccountExpendRecordsDo accountExpendRecordsDo) {
return accountExpendRecordsMapper.selectAccountExpendRecordsAppList(accountExpendRecordsDo);
}
/**
* 根据用户id查询钱包信息
* @param userId
* @return
*/
@Override
public AccountCashWalletPo getWalletByUserId(Long userId) {
return accountExpendRecordsMapper.getWalletByUserId(userId);
}
@Override
public String queryAccountExpendRecordsByUserId(Long userId) {
return accountExpendRecordsMapper.queryAccountExpendRecordsByUserId(userId);
}
}
@@ -0,0 +1,49 @@
package com.linke.finance.domain.accountManage.repository.persistence;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.finance.domain.accountManage.entity.AccountTransferRecharge;
import com.linke.finance.domain.accountManage.repository.facade.AccountTransferRechargeInterface;
import com.linke.finance.domain.accountManage.repository.mapper.AccountTransferRechargeMapper;
import com.linke.finance.domain.accountManage.repository.po.AccountTransferRechargePo;
import com.linke.finance.domain.accountManage.repository.todo.AccountTransferRechargeDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 会员转账充值Service业务层处理
*
* @author mhd
* @date 2023-03-23
*/
@Service
public class AccountTransferRechargeImpl extends ServiceImpl<AccountTransferRechargeMapper, AccountTransferRecharge> implements AccountTransferRechargeInterface
{
@Autowired
private AccountTransferRechargeMapper accountTransferRechargeMapper;
/**
* 查询会员转账充值
*
* @param accountTransferRechargeId 会员转账充值主键
* @return 会员转账充值
*/
@Override
public AccountTransferRechargePo selectAccountTransferRechargeById(Long accountTransferRechargeId)
{
return accountTransferRechargeMapper.selectAccountTransferRechargeById(accountTransferRechargeId);
}
/**
* 查询会员转账充值列表
*
* @param accountTransferRechargeDo 会员转账充值
* @return 会员转账充值
*/
@Override
public List<AccountTransferRechargePo> selectAccountTransferRechargeList(AccountTransferRechargeDo accountTransferRechargeDo)
{
return accountTransferRechargeMapper.selectAccountTransferRechargeList(accountTransferRechargeDo);
}
}
@@ -0,0 +1,94 @@
package com.linke.finance.domain.accountManage.repository.po;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 银行卡管理对象 account_bank_card
*
* @author mhd
* @date 2023-03-21
*/
@Data
public class AccountBankCardPo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 银行卡管理表id */
@ApiModelProperty(name = "银行卡管理表id")
private Long accountBankCardId;
/** 账户类型(1-对私账户,2-对公账户) */
@ApiModelProperty(name = "账户类型(1-对私账户,2-对公账户)")
private Integer accountBankType;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 用户账号 */
@ApiModelProperty(name = "用户账号")
private String userAccount ="";
/** 用户姓名 */
@ApiModelProperty(name = "用户姓名")
private String userName ="";
/** 用户手机号 */
@ApiModelProperty(name = "用户手机号")
private String userPhone ="";
/** 银行卡号 */
@ApiModelProperty(name = "银行卡号")
private String bankCardNumber ="";
/** 开户银行code */
@ApiModelProperty(name = "开户银行code")
private String bankNameCode ="";
/** 开户银行名称 */
@ApiModelProperty(name = "开户银行名称")
private String bankName ="";
@ApiModelProperty(name = "开户银行图标地址")
private String bankImg ="";
/** 银行卡预留电话 */
@ApiModelProperty(name = "银行卡预留电话")
private String bankBindingPhone ="";
/** 银行卡预留姓名 */
@ApiModelProperty(name = "银行卡预留姓名")
private String bankBindingName ="";
/** 用户身份证号 */
@ApiModelProperty(name = "用户身份证号")
private String bankBindingIdNum ="";
/** 持卡人地址 */
@ApiModelProperty(name = "持卡人地址")
private String bankUserAddress ="";
@ApiModelProperty(name = "开户行支行名称")
private String bankBranchName ="";
@ApiModelProperty(name = "联行号")
private String bankNo ="";
@ApiModelProperty(name = "银行卡正面图片地址")
private String bankImgUrl ="";
@ApiModelProperty(name = "默认地址状态(1-是,2-否)")
private Integer defaultStatus;
@ApiModelProperty(name = "车牌号")
private String vehicleLicensePlateNumber ="";
@ApiModelProperty(name = "组织id")
private Long organizationId;
@ApiModelProperty(name = "公司名称")
private String companyName;
}
@@ -0,0 +1,94 @@
package com.linke.finance.domain.accountManage.repository.po;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 用户钱包账户对象 account_cash_wallet
*
* @author mhd
* @date 2023-03-18
*/
@Data
public class AccountCashWalletAppPo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 用户钱包账户id */
@ApiModelProperty(name = "用户钱包账户id")
private Long accountCashWalletId = 0L;
/** 钱包id */
@ApiModelProperty(name = "钱包id")
private Long accountWalletId = 0L;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId = 0L;
/** 姓名 */
@ApiModelProperty(name = "姓名")
private String userName = "";
/** 账号 */
@ApiModelProperty(name = "账号")
private String userAccount = "";
/** 身份证号 */
@ApiModelProperty(name = "身份证号")
private String userIdcardNumber = "";
/** 手机号 */
@ApiModelProperty(name = "手机号")
private String userPhone = "";
/** 公司名称 */
@ApiModelProperty(name = "公司名称")
private String enterpriseName = "";
/** 组织id */
@ApiModelProperty(name = "组织id")
private Long organizationId = 0L;
@ApiModelProperty(name = "一级组织表ID")
private Long topOrganizationId = 0L;
@ApiModelProperty(name = "一级组织表Name")
private String topOrganizationName = "";
/** 组织名称 */
@ApiModelProperty(name = "组织名称")
private String organizationName = "";
/** 钱包余额 */
@ApiModelProperty(name = "钱包余额")
private BigDecimal walletBalance = BigDecimal.ZERO;
/** 可用金额 */
@ApiModelProperty(name = "可用金额")
private BigDecimal walletAvailableBalance = BigDecimal.ZERO;
/** 冻结金额 */
@ApiModelProperty(name = "冻结金额")
private BigDecimal walletFreezeBalance = BigDecimal.ZERO;
/** 账户状态(1-正常,2-锁定) */
@ApiModelProperty(name = "账户状态(1-正常,2-锁定)")
private Integer accountWalletStatus = 0;
@ApiModelProperty(name = "账户类型(1-个人,2-组织)")
private Integer accountType;
@ApiModelProperty(name = "授信额度")
private BigDecimal creditLimit;
@ApiModelProperty(name = "总授信额度")
private BigDecimal totalLimit;
@ApiModelProperty(name = "支付宝账户")
private String alipayAccount;
@ApiModelProperty(name = "支付宝账户名称")
private String alipayAccountName;
}
@@ -0,0 +1,93 @@
package com.linke.finance.domain.accountManage.repository.po;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 用户钱包账户对象 account_cash_wallet
*
* @author mhd
* @date 2023-03-18
*/
@Data
public class AccountCashWalletPo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 用户钱包账户id */
@ApiModelProperty(name = "用户钱包账户id")
private Long accountCashWalletId;
/** 钱包id */
@ApiModelProperty(name = "钱包id")
private Long accountWalletId;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 姓名 */
@ApiModelProperty(name = "姓名")
private String userName;
/** 账号 */
@ApiModelProperty(name = "账号")
private String userAccount;
/** 身份证号 */
@ApiModelProperty(name = "身份证号")
private String userIdcardNumber;
/** 手机号 */
@ApiModelProperty(name = "手机号")
private String userPhone;
/** 公司名称 */
@ApiModelProperty(name = "公司名称")
private String enterpriseName;
/** 组织id */
@ApiModelProperty(name = "组织id")
private Long organizationId;
@ApiModelProperty(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty(name = "一级组织表Name")
private String topOrganizationName;
/** 组织名称 */
@ApiModelProperty(name = "组织名称")
private String organizationName;
/** 钱包余额 */
@ApiModelProperty(name = "钱包余额")
private BigDecimal walletBalance;
/** 可用金额 */
@ApiModelProperty(name = "可用金额")
private BigDecimal walletAvailableBalance;
/** 冻结金额 */
@ApiModelProperty(name = "冻结金额")
private BigDecimal walletFreezeBalance;
/** 账户状态(1-正常,2-锁定) */
@ApiModelProperty(name = "账户状态(1-正常,2-锁定)")
private Integer accountWalletStatus;
@ApiModelProperty(name = "账户类型(1-个人,2-组织)")
private Integer accountType;
@ApiModelProperty(name = "授信额度")
private BigDecimal creditLimit;
@ApiModelProperty(name = "总授信额度")
private BigDecimal totalLimit;
@ApiModelProperty(name = "支付宝账户")
private String alipayAccount;
@ApiModelProperty(name = "支付宝账户名称")
private String alipayAccountName;
}
@@ -0,0 +1,97 @@
package com.linke.finance.domain.accountManage.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* APP收支明细详情
*
* @author mhd
* @date 2023-03-18
*/
@Data
public class AccountExpendRecordsAppDetailPo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 消费记录表id */
@ApiModelProperty(name = "消费记录表id")
private Long accountExpendRecordsId;
/** 内部流水号 */
@ApiModelProperty(name = "内部流水号")
private String accountSerialNumber;
/** 一级账户value */
@ApiModelProperty(name = "一级账户value")
private String accountFirstValue;
/** 二级账户value */
@ApiModelProperty(name = "二级账户value")
private String accountSecondValue;
/** 一级科目value */
@ApiModelProperty(name = "一级科目value")
private String subjectFirstValue;
/** 二级科目value */
@ApiModelProperty(name = "二级科目value")
private String subjectSecondValue;
/** 收支类型(1-收入,2-支出) */
@ApiModelProperty(name = "收支类型")
private Integer accountExpenseType;
/** 关联运单/订单号 */
@ApiModelProperty(name = "关联运单/订单号")
private String waybillNumber;
/** 消费备注 */
@ApiModelProperty(name = "消费备注")
private String accountRecordsRemark;
/** 交易金额 */
@ApiModelProperty(name = "交易金额")
private BigDecimal transactionAmount;
/** 交易时间 */
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "交易时间")
private Date transactionTime;
/** 用户名 */
@ApiModelProperty(name = "用户名")
private String userName;
/** 流水状态(1-正常,2-作废) */
@ApiModelProperty(name = "流水状态")
private Integer capitalFlowStatus;
@ApiModelProperty(name = "支付状态")
private String payStatus;
@ApiModelProperty(name = "支付方式")
private String payType;
/** 订单来源code */
@ApiModelProperty(name = "订单来源code")
private String orderSourceCode = "";
/** 关联运单id */
@ApiModelProperty(name = "关联运单id")
private String waybillId = "";
/** 跳转页面 */
@ApiModelProperty(name = "跳转页面:1-网货运单详情,2-零担运单详情,3-零担调度单详情")
private Integer jumpPage = 0;
}
@@ -0,0 +1,77 @@
package com.linke.finance.domain.accountManage.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* APP收支明细列表
*
* @author mhd
* @date 2023-03-18
*/
@Data
public class AccountExpendRecordsAppPo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 消费记录表id */
@ApiModelProperty(name = "消费记录表id")
private Long accountExpendRecordsId;
/** 一级账户value */
@ApiModelProperty(name = "一级账户value")
private String accountFirstValue;
/** 二级账户value */
@ApiModelProperty(name = "二级账户value")
private String accountSecondValue;
/** 一级科目value */
@ApiModelProperty(name = "一级科目value")
private String subjectFirstValue;
/** 二级科目value */
@ApiModelProperty(name = "二级科目value")
private String subjectSecondValue;
/** 收支类型(1-收入,2-支出) */
@ApiModelProperty(name = "收支类型")
private Integer accountExpenseType;
/** 交易金额 */
@ApiModelProperty(name = "交易金额")
private BigDecimal transactionAmount;
/** 账户余额 */
@ApiModelProperty(name = "账户余额")
private BigDecimal accountBalance;
/** 交易时间 */
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "交易时间")
private Date transactionTime;
/** 用户名 */
@ApiModelProperty(name = "用户名")
private String userName;
/** 公司名称 */
@ApiModelProperty(name = "公司名称")
private String enterpriseName;
/** 用户账号 */
@ApiModelProperty(name = "用户账号")
private String userAccount;
/** 消费备注 */
@ApiModelProperty(name = "消费备注")
private String accountRecordsRemark;
}
@@ -0,0 +1,168 @@
package com.linke.finance.domain.accountManage.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 账户消费记录对象 account_expend_records
*
* @author mhd
* @date 2023-03-18
*/
@Data
public class AccountExpendRecordsPo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 消费记录表id */
@ApiModelProperty(name = "消费记录表id")
private Long accountExpendRecordsId;
/** 内部流水号 */
@ApiModelProperty(name = "内部流水号")
private String accountSerialNumber;
/** 一级账户code */
@ApiModelProperty(name = "一级账户code")
private String accountFirstCode;
/** 一级账户value */
@ApiModelProperty(name = "一级账户value")
private String accountFirstValue;
/** 二级账户code */
@ApiModelProperty(name = "二级账户code")
private String accountSecondCode;
/** 二级账户value */
@ApiModelProperty(name = "二级账户value")
private String accountSecondValue;
/** 一级科目code */
@ApiModelProperty(name = "一级科目code")
private String subjectFirstCode;
/** 一级科目value */
@ApiModelProperty(name = "一级科目value")
private String subjectFirstValue;
/** 二级科目code */
@ApiModelProperty(name = "二级科目code")
private String subjectSecondCode;
/** 二级科目value */
@ApiModelProperty(name = "二级科目value")
private String subjectSecondValue;
/** 收支类型(1-收入,2-支出) */
@ApiModelProperty(name = "收支类型")
private Integer accountExpenseType;
/** 经办人 */
@ApiModelProperty(name = "经办人")
private String accountExpendOperator;
/** 关联运单/订单号 */
@ApiModelProperty(name = "关联运单/订单号")
private String waybillNumber;
/** 银企直联流水号 */
@ApiModelProperty(name = "银企直联流水号")
private String bankSerialNumber;
/** 订单来源code */
@ApiModelProperty(name = "订单来源code")
private String orderSourceCode;
/** 订单来源value */
@ApiModelProperty(name = "订单来源value")
private String orderSourceValue;
/** 消费备注 */
@ApiModelProperty(name = "消费备注")
private String accountRecordsRemark;
/** 上笔余额 */
@ApiModelProperty(name = "上笔余额")
private BigDecimal accountLastBalance;
/** 交易金额 */
@ApiModelProperty(name = "交易金额")
private BigDecimal transactionAmount;
/** 账户余额 */
@ApiModelProperty(name = "账户余额")
private BigDecimal accountBalance;
/** 交易时间 */
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "交易时间")
private Date transactionTime;
/** 用户名 */
@ApiModelProperty(name = "用户名")
private String userName;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 公司名称 */
@ApiModelProperty(name = "公司名称")
private String enterpriseName;
/** 用户账号 */
@ApiModelProperty(name = "用户账号")
private String userAccount;
/** 入账类型(1-系统入账,2-手工入账) */
@ApiModelProperty(name = "入账类型")
private Integer accountEnterType;
/** 流水状态(1-正常,2-作废) */
@ApiModelProperty(name = "流水状态")
private Integer capitalFlowStatus;
/** 用户钱包账户id */
@ApiModelProperty(name = "用户钱包账户id")
private Long accountCashWalletId;
/** 钱包id */
@ApiModelProperty(name = "钱包id")
private Long accountWalletId;
@ApiModelProperty(name = "银行卡管理表id")
private Long accountBankCardId;
@ApiModelProperty(name = "银行卡预留姓名")
private String bankBindingName;
@ApiModelProperty(name = "开户银行code")
private String bankNameCode;
@ApiModelProperty(name = "开户银行名称")
private String bankName;
@ApiModelProperty(name = "银行卡号")
private String bankCardNumber;
@ApiModelProperty(name = "组织id")
private Long organizationId;
@ApiModelProperty(name = "支付凭证")
private String paymentVoucher;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "获取凭证时间")
private Date voucherTime;
}
@@ -0,0 +1,124 @@
package com.linke.finance.domain.accountManage.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
/**
* 会员转账充值对象 account_transfer_recharge
*
* @author mhd
* @date 2023-03-23
*/
@Data
public class AccountTransferRechargePo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 会员转账充值表id */
@ApiModelProperty(name = "会员转账充值表id")
private Long accountTransferRechargeId;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 用户账号 */
@ApiModelProperty(name = "用户账号")
private String userAccount;
/** 用户姓名 */
@ApiModelProperty(name = "用户姓名")
private String userName;
/** 用户手机号 */
@ApiModelProperty(name = "用户手机号")
private String userPhone;
/** 充值状态(1-待处理,2-已同意,3-已拒绝) */
@ApiModelProperty(name = "充值状态")
private Integer accountTransferStatus;
/** 一级账户code */
@ApiModelProperty(name = "一级账户code")
private String accountFirstCode;
/** 一级账户value */
@ApiModelProperty(name = "一级账户value")
private String accountFirstValue;
/** 二级账户code */
@ApiModelProperty(name = "二级账户code")
private String accountSecondCode;
/** 二级账户value */
@ApiModelProperty(name = "二级账户value")
private String accountSecondValue;
/** 交易流水 */
@ApiModelProperty(name = "交易流水")
private String accountTransferNumber;
/** 交易金额 */
@ApiModelProperty(name = "交易金额")
private BigDecimal accountTransferAmount;
/** 账户余额 */
@ApiModelProperty(name = "账户余额")
private BigDecimal accountBalance;
/** 交易方式code */
@ApiModelProperty(name = "交易方式code")
private String transferTypeCode;
/** 交易方式value */
@ApiModelProperty(name = "交易方式value")
private String transferTypeValue;
/** 交易时间 */
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "交易时间")
private String accountTransferTime;
/** 收支类型(1-收入,2-支出) */
@ApiModelProperty(name = "收支类型(1-收入,2-支出)")
private Integer accountTransferType;
/** 经办人 */
@ApiModelProperty(name = "经办人")
private String accountTransferOperator;
/** 交易凭证图片地址 */
@ApiModelProperty(name = "交易凭证图片地址")
private String accountTransferVoucherUrl;
/** 备注 */
@ApiModelProperty(name = "备注")
private String accountTransferRemark;
/** 审核人id */
@ApiModelProperty(name = "审核人id")
private Long transferReviewerId;
/** 审核人 */
@ApiModelProperty(name = "审核人")
private String accountTransferReviewer;
/** 审核时间 */
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "审核时间")
private String transferReviewerTime;
/** 驳回理由 */
@ApiModelProperty(name = "驳回理由")
private String accountTransferReject;
@ApiModelProperty(name = "组织id")
private Long organizationId;
}
@@ -0,0 +1,122 @@
package com.linke.finance.domain.accountManage.repository.todo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
* 银行卡管理对象 account_bank_card
*
* @author mhd
* @date 2023-03-21
*/
@Data
public class AccountBankCardDo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 银行卡管理表id */
@ApiModelProperty(name = "银行卡管理表id")
private Long accountBankCardId;
@ApiModelProperty(name = "银行卡管理表ids")
private Long[] accountBankCardIds;
/** 账户类型(1-对私账户,2-对公账户) */
@ApiModelProperty(name = "账户类型(1-对私账户,2-对公账户)")
private Integer accountBankType;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 用户账号 */
@ApiModelProperty(name = "用户账号")
private String userAccount;
/** 用户姓名 */
@ApiModelProperty(name = "用户姓名")
private String userName;
/** 用户手机号 */
@ApiModelProperty(name = "用户手机号")
private String userPhone;
/** 银行卡号 */
@ApiModelProperty(name = "银行卡号")
private String bankCardNumber;
/** 开户银行code */
@ApiModelProperty(name = "开户银行code")
private String bankNameCode;
/** 开户银行名称 */
@ApiModelProperty(name = "开户银行名称")
private String bankName;
@ApiModelProperty(name = "开户银行图标地址")
private String bankImg;
/** 银行卡预留电话 */
@ApiModelProperty(name = "银行卡预留电话")
private String bankBindingPhone;
/** 银行卡预留姓名 */
@ApiModelProperty(name = "银行卡预留姓名")
private String bankBindingName;
/** 用户身份证号 */
@ApiModelProperty(name = "用户身份证号")
private String bankBindingIdNum;
/** 持卡人地址 */
@ApiModelProperty(name = "持卡人地址")
private String bankUserAddress;
@ApiModelProperty(name = "开户行支行名称")
private String bankBranchName;
@ApiModelProperty(name = "联行号")
private String bankNo;
@ApiModelProperty(name = "银行卡正面图片地址")
private String bankImgUrl;
@ApiModelProperty(name = "默认地址状态(1-是,2-否)")
private Integer defaultStatus;
@ApiModelProperty(name = "车牌号")
private String vehicleLicensePlateNumber;
@ApiModelProperty(name = "用户信息")
private String userInfo;
@ApiModelProperty(name = "银行卡信息")
private String cardInfo;
@ApiModelProperty(name = "开户信息")
private String accountInfo;
@ApiModelProperty(name = "组织id")
private Long organizationId;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "公司名称")
private String companyName;
@ApiModelProperty(value = "创建结束日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date createEndTime;
@ApiModelProperty(value = "创建开始日期")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date createStartTime;
}
@@ -0,0 +1,42 @@
package com.linke.finance.domain.accountManage.repository.todo;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 网点支付实体
*
* @author mhd
* @date 2023-03-18
*/
@Data
public class AccountBranchPayDo
{
private static final long serialVersionUID = 1L;
@ApiModelProperty(name = "支付用户id")
private Long payUserId;
@ApiModelProperty(name = "接收用户id")
private Long receiveUserId;
@ApiModelProperty(name = "支付金额")
private BigDecimal payBalance;
@ApiModelProperty(name = "支付密码")
private String payPassword;
@ApiModelProperty(name = "收款渠道code")
private String payWay;
@ApiModelProperty(name = "平台类型:1-支付人,2-接收人")
private Integer plateType;
@ApiModelProperty(name = "核销流水号")
private String innerNumber;
}
@@ -0,0 +1,128 @@
package com.linke.finance.domain.accountManage.repository.todo;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* 用户钱包账户对象 account_cash_wallet
*
* @author mhd
* @date 2023-03-18
*/
@Data
public class AccountCashWalletDo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 用户钱包账户id */
@ApiModelProperty(name = "用户钱包账户id")
private Long accountCashWalletId;
@ApiModelProperty(name = "用户钱包账户ids")
private Long[] accountCashWalletIds;
/** 钱包id */
@ApiModelProperty(name = "钱包id")
private Long accountWalletId;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 姓名 */
@ApiModelProperty(name = "姓名")
private String userName;
/** 账号 */
@ApiModelProperty(name = "账号")
private String userAccount;
/** 身份证号 */
@ApiModelProperty(name = "身份证号")
private String userIdcardNumber;
/** 手机号 */
@ApiModelProperty(name = "手机号")
private String userPhone;
/** 公司名称 */
@ApiModelProperty(name = "公司名称")
private String enterpriseName;
/** 组织id */
@ApiModelProperty(name = "组织id")
private Long organizationId;
@ApiModelProperty(name = "一级组织表ID")
private Long topOrganizationId;
/** 组织名称 */
@ApiModelProperty(name = "组织名称")
private String organizationName;
/** 钱包余额 */
@ApiModelProperty(name = "钱包余额")
private BigDecimal walletBalance;
/** 可用金额 */
@ApiModelProperty(name = "可用金额")
private BigDecimal walletAvailableBalance;
/** 冻结金额 */
@ApiModelProperty(name = "冻结金额")
private BigDecimal walletFreezeBalance;
/** 账户状态(1-正常,2-锁定) */
@ApiModelProperty(name = "账户状态(1-正常,2-锁定)")
private Integer accountWalletStatus;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "变动日期查询条件开始日期")
private String updateTimeStart;
@ApiModelProperty(name = "变动日期查询条件结束日期")
private String updateTimeEnd;
@ApiModelProperty(name = "钱包余额开始")
private BigDecimal walletBalanceBegin;
@ApiModelProperty(name = "钱包余额结束")
private BigDecimal walletBalanceEnd;
@ApiModelProperty(name = "可用金额开始")
private BigDecimal walletAvailableBalanceBegin;
@ApiModelProperty(name = "可用金额结束")
private BigDecimal walletAvailableBalanceEnd;
@ApiModelProperty(name = "冻结金额开始")
private BigDecimal walletFreezeBalanceBegin;
@ApiModelProperty(name = "冻结金额结束")
private BigDecimal walletFreezeBalanceEnd;
@ApiModelProperty(name = "操作类型(1-充值,2-回收,3-退回,4-冻结,5-解冻)")
private Integer operationType;
@ApiModelProperty(name = "支付密码")
private String payPassword;
@ApiModelProperty(name = "消费备注")
private String accountRecordsRemark;
@ApiModelProperty(name = "菜单表ID")
public Long permissionMenuId;
@ApiModelProperty(name = "账户类型(1-个人,2-组织)")
private Integer accountType;
@ApiModelProperty(name = "授信额度")
private BigDecimal creditLimit;
@ApiModelProperty(name = "总授信额度")
private BigDecimal totalLimit;
@ApiModelProperty(name = "支付宝账户")
private String alipayAccount;
@ApiModelProperty(name = "支付宝账户名称")
private String alipayAccountName;
}
@@ -0,0 +1,187 @@
package com.linke.finance.domain.accountManage.repository.todo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 账户消费记录对象 account_expend_records
*
* @author mhd
* @date 2023-03-18
*/
@Data
public class AccountExpendRecordsDo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 消费记录表id */
@ApiModelProperty(name = "消费记录表id")
private Long accountExpendRecordsId;
@ApiModelProperty(name = "消费记录表ids")
private Long[] accountExpendRecordsIds;
/** 内部流水号 */
@ApiModelProperty(name = "内部流水号")
private String accountSerialNumber;
/** 一级账户code */
@ApiModelProperty(name = "一级账户code")
private String accountFirstCode;
/** 一级账户value */
@ApiModelProperty(name = "一级账户value")
private String accountFirstValue;
/** 二级账户code */
@ApiModelProperty(name = "二级账户code")
private String accountSecondCode;
/** 二级账户value */
@ApiModelProperty(name = "二级账户value")
private String accountSecondValue;
/** 一级科目code */
@ApiModelProperty(name = "一级科目code")
private String subjectFirstCode;
/** 一级科目value */
@ApiModelProperty(name = "一级科目value")
private String subjectFirstValue;
/** 二级科目code */
@ApiModelProperty(name = "二级科目code")
private String subjectSecondCode;
/** 二级科目value */
@ApiModelProperty(name = "二级科目value")
private String subjectSecondValue;
/** 收支类型(1-收入,2-支出) */
@ApiModelProperty(name = "收支类型")
private Integer accountExpenseType;
/** 经办人 */
@ApiModelProperty(name = "经办人")
private String accountExpendOperator;
/** 关联运单/订单号 */
@ApiModelProperty(name = "关联运单/订单号")
private String waybillNumber;
/** 银企直联流水号 */
@ApiModelProperty(name = "银企直联流水号")
private String bankSerialNumber;
/** 订单来源code */
@ApiModelProperty(name = "订单来源code")
private String orderSourceCode;
/** 订单来源value */
@ApiModelProperty(name = "订单来源value")
private String orderSourceValue;
/** 消费备注 */
@ApiModelProperty(name = "消费备注")
private String accountRecordsRemark;
/** 上笔余额 */
@ApiModelProperty(name = "上笔余额")
private BigDecimal accountLastBalance;
/** 交易金额 */
@ApiModelProperty(name = "交易金额")
private BigDecimal transactionAmount;
/** 账户余额 */
@ApiModelProperty(name = "账户余额")
private BigDecimal accountBalance;
/** 交易时间 */
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "交易时间")
private Date transactionTime;
/** 用户名 */
@ApiModelProperty(name = "用户名")
private String userName;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 公司名称 */
@ApiModelProperty(name = "公司名称")
private String enterpriseName;
/** 用户账号 */
@ApiModelProperty(name = "用户账号")
private String userAccount;
/** 入账类型(1-系统入账,2-手工入账) */
@ApiModelProperty(name = "入账类型")
private Integer accountEnterType;
/** 流水状态(1-正常,2-作废) */
@ApiModelProperty(name = "流水状态")
private Integer capitalFlowStatus;
/** 用户钱包账户id */
@ApiModelProperty(name = "用户钱包账户id")
private Long accountCashWalletId;
/** 钱包id */
@ApiModelProperty(name = "钱包id")
private Long accountWalletId;
@ApiModelProperty(name = "交易日期查询条件开始日期")
private String transactionTimeStart;
@ApiModelProperty(name = "交易日期查询条件结束日期")
private String transactionTimeEnd;
@ApiModelProperty(name = "用户信息(用户名/账号/公司名称)")
private String accountUserInfo;
@ApiModelProperty(name = "交易金额开始")
private BigDecimal transactionAmountBegin;
@ApiModelProperty(name = "交易金额结束")
private BigDecimal transactionAmountEnd;
@ApiModelProperty(name = "银行卡管理表id")
private Long accountBankCardId;
@ApiModelProperty(name = "银行卡预留姓名")
private String bankBindingName;
@ApiModelProperty(name = "开户银行code")
private String bankNameCode;
@ApiModelProperty(name = "开户银行名称")
private String bankName;
@ApiModelProperty(name = "银行卡号")
private String bankCardNumber;
@ApiModelProperty(name = "组织id")
private Long organizationId;
private List<Long> organizationIdList;
@ApiModelProperty(name = "APP收支明细查询条件(1-今天,2-本周,3-本月,4-最近半年,5-自定义)")
private Integer queryDateFlag;
@ApiModelProperty(name = "支付凭证")
private String paymentVoucher;
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "获取凭证时间")
private Date voucherTime;
}
@@ -0,0 +1,157 @@
package com.linke.finance.domain.accountManage.repository.todo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 会员转账充值对象 account_transfer_recharge
*
* @author mhd
* @date 2023-03-23
*/
@Data
public class AccountTransferRechargeDo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 会员转账充值表id */
@ApiModelProperty(name = "会员转账充值表id")
private Long accountTransferRechargeId;
@ApiModelProperty(name = "会员转账充值表ids")
private Long[] accountTransferRechargeIds;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 用户账号 */
@ApiModelProperty(name = "用户账号")
private String userAccount;
/** 用户姓名 */
@ApiModelProperty(name = "用户姓名")
private String userName;
/** 用户手机号 */
@ApiModelProperty(name = "用户手机号")
private String userPhone;
/** 充值状态(1-待处理,2-已同意,3-已拒绝) */
@ApiModelProperty(name = "充值状态")
private Integer accountTransferStatus;
/** 一级账户code */
@ApiModelProperty(name = "一级账户code")
private String accountFirstCode;
/** 一级账户value */
@ApiModelProperty(name = "一级账户value")
private String accountFirstValue;
/** 二级账户code */
@ApiModelProperty(name = "二级账户code")
private String accountSecondCode;
/** 二级账户value */
@ApiModelProperty(name = "二级账户value")
private String accountSecondValue;
/** 交易流水 */
@ApiModelProperty(name = "交易流水")
private String accountTransferNumber;
/** 交易金额 */
@ApiModelProperty(name = "交易金额")
private BigDecimal accountTransferAmount;
/** 账户余额 */
@ApiModelProperty(name = "账户余额")
private BigDecimal accountBalance;
/** 交易方式code */
@ApiModelProperty(name = "交易方式code")
private String transferTypeCode;
/** 交易方式value */
@ApiModelProperty(name = "交易方式value")
private String transferTypeValue;
/** 交易时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "交易时间")
private Date accountTransferTime;
/** 收支类型(1-收入,2-支出) */
@ApiModelProperty(name = "收支类型(1-收入,2-支出)")
private Integer accountTransferType;
/** 经办人 */
@ApiModelProperty(name = "经办人")
private String accountTransferOperator;
/** 交易凭证图片地址 */
@ApiModelProperty(name = "交易凭证图片地址")
private String accountTransferVoucherUrl;
/** 备注 */
@ApiModelProperty(name = "备注")
private String accountTransferRemark;
/** 审核人id */
@ApiModelProperty(name = "审核人id")
private Long transferReviewerId;
/** 审核人 */
@ApiModelProperty(name = "审核人")
private String accountTransferReviewer;
/** 审核时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(name = "审核时间")
private Date transferReviewerTime;
/** 驳回理由 */
@ApiModelProperty(name = "驳回理由")
private String accountTransferReject;
@ApiModelProperty(name = "用户信息")
private String userInfo;
@ApiModelProperty(name = "交易时间查询条件开始日期")
private String accountTransferTimeStart;
@ApiModelProperty(name = "交易时间查询条件结束日期")
private String accountTransferTimeEnd;
@ApiModelProperty(name = "交易金额开始")
private BigDecimal accountTransferAmountBegin;
@ApiModelProperty(name = "交易金额结束")
private BigDecimal accountTransferAmountEnd;
@ApiModelProperty(name = "提交时间查询条件开始日期")
private String createTimeStart;
@ApiModelProperty(name = "提交时间查询条件结束日期")
private String createTimeEnd;
@ApiModelProperty(name = "审核时间查询条件开始日期")
private String transferReviewerTimeStart;
@ApiModelProperty(name = "审核时间查询条件结束日期")
private String transferReviewerTimeEnd;
@ApiModelProperty(name = "操作类型(1-同意,2-拒绝)")
private Integer operateType;
@ApiModelProperty(name = "支付密码")
private String payPassword;
@ApiModelProperty(name = "组织id")
private Long organizationId;
@ApiModelProperty(name = "支付方式(1-微信,2-对公转账)")
private Integer paymentMethod;
}
@@ -0,0 +1,167 @@
package com.linke.finance.domain.accountManage.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.linke.finance.domain.accountManage.entity.AccountBankCard;
import com.linke.finance.domain.accountManage.repository.facade.AccountBankCardInterface;
import com.linke.finance.domain.accountManage.repository.po.AccountBankCardPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountBankCardDo;
import com.linke.finance.interfaces.dto.AccountBankCardDto;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.security.utils.SecurityUtils;
import org.checkerframework.checker.units.qual.A;
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.util.*;
/**
* 银行卡管理Service业务层处理
*
* @author mhd
* @date 2023-03-21
*/
@Service
public class AccountBankCardDomainService {
@Autowired
private AccountBankCardInterface accountBankCardInterface;
@Resource
private AccountWlhyDomainService accountWlhyDomainService;
/**
* 查询银行卡管理
*
* @param accountBankCardId 银行卡管理主键
* @return 银行卡管理
*/
public AccountBankCardPo selectAccountBankCardByAccountBankCardId(Long accountBankCardId)
{
return accountBankCardInterface.selectAccountBankCardByAccountBankCardId(accountBankCardId);
}
/**
* 查询银行卡管理列表
*
* @param accountBankCardDo 银行卡管理
* @return 银行卡管理
*/
public List<AccountBankCardPo> selectAccountBankCardList(AccountBankCardDo accountBankCardDo)
{
return accountBankCardInterface.selectAccountBankCardList(accountBankCardDo);
}
/**
* 新增银行卡信息
* @param accountBankCard
* @return
*/
public boolean insertAccountBankCard(AccountBankCard accountBankCard) {
return accountBankCardInterface.save(accountBankCard);
}
/**
* 编辑银行卡信息
* @param accountBankCard
* @return
*/
public boolean updateAccountBankCard(AccountBankCard accountBankCard) {
return accountBankCardInterface.updateById(accountBankCard);
}
/**
* 根据银行卡id查询详情
* @param accountBankCardId
* @return
*/
public AccountBankCardPo getAccountBankCard(Long accountBankCardId) {
return accountBankCardInterface.selectAccountBankCardByAccountBankCardId(accountBankCardId);
}
/**
* 根据id删除银行卡信息
* @param accountBankCardDo
* @return
*/
@Transactional(rollbackFor = Exception.class)
public boolean deleteAccountBankCardById(AccountBankCardDo accountBankCardDo) {
if(accountBankCardDo.getAccountBankCardIds()==null || accountBankCardDo.getAccountBankCardIds().length==0){
throw new ServiceException("操作银行卡信息id不能为空");
}
String userName = SecurityUtils.getLoginUser().getUsername();
Long userId = SecurityUtils.getLoginUser().getUserid();
Date now = new Date();
Set<AccountBankCard> accountBankCardList = new HashSet<>();
for (Long accountBankCardId : accountBankCardDo.getAccountBankCardIds()) {
AccountBankCard accountBankCard = new AccountBankCard();
accountBankCard.setAccountBankCardId(accountBankCardId);
accountBankCard.setUpdateBy(userId);
accountBankCard.setUpdateByName(userName);
accountBankCard.setUpdateTime(now);
accountBankCard.setDelFlag(2);
accountBankCardList.add(accountBankCard);
}
boolean flag = accountBankCardInterface.updateBatchById(accountBankCardList);
//同步删除网货银行卡
accountWlhyDomainService.deleteBankCardByIds(accountBankCardDo.getAccountBankCardIds());
return flag;
}
/**
* 设置银行卡为非默认银行卡
* @param userId
*/
public boolean setDefaultStatus(Long userId) {
return accountBankCardInterface.update(new UpdateWrapper<AccountBankCard>().lambda()
.set(AccountBankCard::getDefaultStatus,2).set(AccountBankCard::getUpdateBy,SecurityUtils.getUserId())
.set(AccountBankCard::getUpdateTime,new Date()).set(AccountBankCard::getUpdateByName,SecurityUtils.getUsername())
.eq(AccountBankCard::getUserId,userId).eq(AccountBankCard::getDelFlag,1));
}
/**
* 设置当前银行卡信息为默认
* @param accountBankCardDto
* @return
*/
public boolean changeDefaultStatus(AccountBankCardDto accountBankCardDto) {
/*
如果是租户管理员操作银行卡默认,则需要先查询出当前银行卡信息,查询出银行卡信息对应的用户,然后对该用户进行操作
*/
if(accountBankCardDto.getAccountBankCardId()==null){
throw new ServiceException("银行卡id不能为空");
}
AccountBankCardPo accountBankCardPo = accountBankCardInterface.selectAccountBankCardByAccountBankCardId(accountBankCardDto.getAccountBankCardId());
if(null == accountBankCardPo){
throw new ServiceException("银行卡信息未找到");
}
boolean istrue = setDefaultStatus(accountBankCardPo.getUserId());
if(!istrue){
throw new ServiceException("操作其他银行卡信息失败");
}
boolean flag = accountBankCardInterface.update(new UpdateWrapper<AccountBankCard>().lambda().set(AccountBankCard::getDefaultStatus,1)
.eq(AccountBankCard::getAccountBankCardId,accountBankCardDto.getAccountBankCardId()).eq(AccountBankCard::getDelFlag,1));
//调用同步网货银行卡信息
AccountBankCard accountBankCard = new AccountBankCard();
BeanUtils.copyProperties(accountBankCardPo,accountBankCard);
accountWlhyDomainService.syncBankCardInfo(accountBankCard);
return flag;
}
public AccountBankCard getAccountBankCardByNum(String bankCardNumber,Long userId) {
LambdaQueryWrapper<AccountBankCard> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AccountBankCard::getBankCardNumber,bankCardNumber);
queryWrapper.eq(AccountBankCard::getUserId,userId);
queryWrapper.eq(AccountBankCard::getDelFlag,1);
return accountBankCardInterface.getOne(queryWrapper);
}
public List<AccountBankCard> getAccountBankCardByUser(Long userId) {
LambdaQueryWrapper<AccountBankCard> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AccountBankCard::getUserId,userId);
queryWrapper.eq(AccountBankCard::getDelFlag,1);
return accountBankCardInterface.list(queryWrapper);
}
}
@@ -0,0 +1,200 @@
package com.linke.finance.domain.accountManage.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.linke.finance.domain.accountManage.entity.AccountCashWallet;
import com.linke.finance.domain.accountManage.repository.facade.AccountCashWalletInterface;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletAppPo;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountCashWalletDo;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.security.utils.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* 用户钱包账户Service业务层处理
*
* @author mhd
* @date 2023-03-18
*/
@Service
public class AccountCashWalletDomainService
{
@Autowired
private AccountCashWalletInterface accountCashWalletInterface;
/**
* 查询用户钱包账户
*
* @param accountCashWalletId 用户钱包账户主键
* @return 用户钱包账户
*/
public AccountCashWalletPo selectAccountCashWalletByAccountCashWalletId(Long accountCashWalletId)
{
//TODO 根据一级组织id 返回组织姓名
return accountCashWalletInterface.selectAccountCashWalletByAccountCashWalletId(accountCashWalletId);
}
/**
* 查询用户钱包账户列表
*
* @param accountCashWalletDo 用户钱包账户
* @return 用户钱包账户
*/
public List<AccountCashWalletPo> selectAccountCashWalletList(AccountCashWalletDo accountCashWalletDo)
{
return accountCashWalletInterface.selectAccountCashWalletList(accountCashWalletDo);
}
/**
* 会员钱包开户
* @param accountCashWallet
* @return
*/
public boolean insertAccountCashWallet(AccountCashWallet accountCashWallet) {
return accountCashWalletInterface.save(accountCashWallet);
}
/**
* 查询用户账户信息 返回实体类
* @param accountCashWalletId
* @return
*/
public AccountCashWallet selectByAccountCashWalletId(Long accountCashWalletId) {
return accountCashWalletInterface.getBaseMapper().selectOne(new QueryWrapper<AccountCashWallet>().lambda()
.eq(AccountCashWallet::getAccountCashWalletId,accountCashWalletId).eq(AccountCashWallet::getDelFlag,1));
}
/**
* 更新账户余额
* @param accountCashWalletList
* @return
*/
public boolean updateAccountCashWallets(List<AccountCashWallet> accountCashWalletList) {
return accountCashWalletInterface.updateBatchById(accountCashWalletList);
}
/**
* 锁定、解锁操作 可批量
* @param accountCashWalletDo
* @return
*/
public boolean changeLock(AccountCashWalletDo accountCashWalletDo) {
if(accountCashWalletDo.getAccountCashWalletIds() == null || accountCashWalletDo.getAccountCashWalletIds().length==0){
throw new ServiceException("操作用户账号id不能为空");
}
if(accountCashWalletDo.getAccountWalletStatus()==null || (accountCashWalletDo.getAccountWalletStatus()!=1 && accountCashWalletDo.getAccountWalletStatus()!=2)){
throw new ServiceException("账户状态类型错误");
}
Set<AccountCashWallet> accountCashWalletList = new HashSet<>();
for (Long accountCashWalletId : accountCashWalletDo.getAccountCashWalletIds()) {
AccountCashWallet accountCashWallet = new AccountCashWallet();
accountCashWallet.setAccountCashWalletId(accountCashWalletId);
accountCashWallet.setUpdateBy(SecurityUtils.getUserId());
accountCashWallet.setUpdateByName(SecurityUtils.getUsername());
accountCashWallet.setUpdateTime(new Date());
accountCashWallet.setAccountWalletStatus(accountCashWalletDo.getAccountWalletStatus());
accountCashWalletList.add(accountCashWallet);
}
return accountCashWalletInterface.updateBatchById(accountCashWalletList);
}
/**
* 根据用户id查询用户钱包
* @param userId
* @return
*/
public AccountCashWallet selectByUserId(Long userId) {
return accountCashWalletInterface.getBaseMapper().selectOne(new QueryWrapper<AccountCashWallet>().lambda()
.eq(AccountCashWallet::getUserId,userId).eq(AccountCashWallet::getDelFlag,1));
}
public boolean updateAccountCashWalletById(AccountCashWallet accountCashWallet) {
return accountCashWalletInterface.updateById(accountCashWallet);
}
/**
* 根据用户id查询用户钱包信息
* @param userId
* @return
*/
public AccountCashWalletAppPo selectUserWalletInfo(Long userId) {
return accountCashWalletInterface.selectUserWalletInfo(userId);
}
/**
* 更新钱包余额(可用金额减)
* @param payAmount
* @return
*/
public int updateAccountCashWalletSub(BigDecimal payAmount,Long userId) {
return accountCashWalletInterface.updateAccountCashWallet(payAmount,userId);
}
/**
* 更新钱包余额(可用金额加)
* @param payAmount
* @param userId
* @return
*/
public int updateAccountCashWalletAdd(BigDecimal payAmount,Long userId) {
return accountCashWalletInterface.updateAccountCashWalletAdd(payAmount,userId);
}
/**
* 更新钱包余额(冻结金额减)
* @param payAmount
* @return
*/
public int updateFreezeCashWalletSub(BigDecimal payAmount,Long userId) {
return accountCashWalletInterface.updateFreezeCashWalletSub(payAmount,userId);
}
/**
* 更新钱包余额(冻结金额加)
* @param payAmount
* @param userId
* @return
*/
public int updateFreezeCashWalletAdd(BigDecimal payAmount,Long userId) {
return accountCashWalletInterface.updateFreezeCashWalletAdd(payAmount,userId);
}
/**
* 更新授信额度
*/
public void updateCreditLimit(AccountCashWallet accountCashWallet){
accountCashWalletInterface.updateCreditLimit(accountCashWallet);
}
public void updateTotalLimit(AccountCashWallet accountCashWallet) {
accountCashWalletInterface.updateTotalLimit(accountCashWallet);
}
public AccountCashWalletPo getLimitByUserId(Long userId) {
AccountCashWalletPo accountCashWalletPo = new AccountCashWalletPo();
AccountCashWallet accountCashWallet = accountCashWalletInterface.getLimitByUserId(userId);
if (accountCashWallet != null){
BeanUtils.copyProperties(accountCashWallet, accountCashWalletPo);
}else {
accountCashWalletPo.setCreditLimit(BigDecimal.valueOf(0.00));
accountCashWalletPo.setTotalLimit(BigDecimal.valueOf(0.00));
}
return accountCashWalletPo;
}
public boolean deleteCashWalletById(Long id) {
AccountCashWallet accountCashWallet = new AccountCashWallet();
accountCashWallet.setDelFlag(2);
accountCashWallet.setAccountCashWalletId(id);
return accountCashWalletInterface.updateById(accountCashWallet);
}
}
@@ -0,0 +1,180 @@
package com.linke.finance.domain.accountManage.service;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.linke.finance.domain.accountManage.entity.AccountExpendRecords;
import com.linke.finance.domain.accountManage.repository.facade.AccountExpendRecordsInterface;
import com.linke.finance.domain.accountManage.repository.po.AccountCashWalletPo;
import com.linke.finance.domain.accountManage.repository.po.AccountExpendRecordsAppDetailPo;
import com.linke.finance.domain.accountManage.repository.po.AccountExpendRecordsAppPo;
import com.linke.finance.domain.accountManage.repository.po.AccountExpendRecordsPo;
import com.linke.finance.domain.accountManage.repository.todo.AccountExpendRecordsDo;
import com.linke.finance.interfaces.dto.AccountExpendRecordsDto;
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.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 账户消费记录Service业务层处理
*
* @author mhd
* @date 2023-03-18
*/
@Service
public class AccountExpendRecordsDomainService{
@Autowired
private AccountExpendRecordsInterface accountExpendRecordsInterface;
/**
* 查询账户消费记录
*
* @param accountExpendRecordsId 账户消费记录主键
* @return 账户消费记录
*/
public AccountExpendRecordsPo selectAccountExpendRecordsByAccountExpendRecordsId(Long accountExpendRecordsId)
{
return accountExpendRecordsInterface.selectAccountExpendRecordsByAccountExpendRecordsId(accountExpendRecordsId);
}
/**
* 查询账户消费记录列表
*
* @param accountExpendRecordsDo 账户消费记录
* @return 账户消费记录
*/
public List<AccountExpendRecordsPo> selectAccountExpendRecordsList(AccountExpendRecordsDo accountExpendRecordsDo)
{
return accountExpendRecordsInterface.selectAccountExpendRecordsList(accountExpendRecordsDo);
}
/**
* 批量消费记录保存
* @param accountExpendRecordsList
*/
public boolean insertAccountExpendRecordsBatch(List<AccountExpendRecords> accountExpendRecordsList) {
return accountExpendRecordsInterface.saveBatch(accountExpendRecordsList);
}
/**
* 作废/恢复 可批量
* @param accountExpendRecordsDo
* @return
*/
public boolean changeFlowStatus(AccountExpendRecordsDo accountExpendRecordsDo) {
if(accountExpendRecordsDo.getAccountExpendRecordsIds()==null || accountExpendRecordsDo.getAccountExpendRecordsIds().length==0){
throw new ServiceException("操作消费记录id不能为空");
}
if(accountExpendRecordsDo.getCapitalFlowStatus()==null || (accountExpendRecordsDo.getCapitalFlowStatus() !=1 && accountExpendRecordsDo.getCapitalFlowStatus() !=2)){
throw new ServiceException("流水状态类型错误");
}
Set<AccountExpendRecords> accountExpendRecordList = new HashSet<>();
for (Long accountCashWalletId : accountExpendRecordsDo.getAccountExpendRecordsIds()) {
AccountExpendRecords accountExpendRecords = new AccountExpendRecords();
accountExpendRecords.setAccountExpendRecordsId(accountCashWalletId);
accountExpendRecords.setUpdateBy(SecurityUtils.getUserId());
accountExpendRecords.setUpdateByName(SecurityUtils.getUsername());
accountExpendRecords.setUpdateTime(new Date());
accountExpendRecords.setCapitalFlowStatus(accountExpendRecordsDo.getCapitalFlowStatus());
accountExpendRecordList.add(accountExpendRecords);
}
return accountExpendRecordsInterface.updateBatchById(accountExpendRecordList);
}
/**
* 根据id删除对应消费记录
* @param accountExpendRecordsDo
* @return
*/
public boolean deleteAccountExpendRecordsById(AccountExpendRecordsDo accountExpendRecordsDo) {
if(accountExpendRecordsDo.getAccountExpendRecordsIds()==null || accountExpendRecordsDo.getAccountExpendRecordsIds().length==0){
throw new ServiceException("操作消费记录id不能为空");
}
Set<AccountExpendRecords> accountExpendRecordList = new HashSet<>();
for (Long accountCashWalletId : accountExpendRecordsDo.getAccountExpendRecordsIds()) {
AccountExpendRecords accountExpendRecords = new AccountExpendRecords();
accountExpendRecords.setAccountExpendRecordsId(accountCashWalletId);
accountExpendRecords.setUpdateBy(SecurityUtils.getUserId());
accountExpendRecords.setUpdateByName(SecurityUtils.getUsername());
accountExpendRecords.setUpdateTime(new Date());
accountExpendRecords.setDelFlag(2);
accountExpendRecordList.add(accountExpendRecords);
}
return accountExpendRecordsInterface.updateBatchById(accountExpendRecordList);
}
public String queryAccountExpendRecordsByUserId(Long userId) {
return accountExpendRecordsInterface.queryAccountExpendRecordsByUserId(userId);
}
/**
* 新增消费记录
* @param accountExpendRecords
* @return
*/
public boolean insertAccountExpendRecords(AccountExpendRecords accountExpendRecords) {
return accountExpendRecordsInterface.save(accountExpendRecords);
}
/**
* APP查询收支明细列表
* @param accountExpendRecordsDo
* @return
*/
public List<AccountExpendRecordsAppPo> selectAccountExpendRecordsAppList(AccountExpendRecordsDo accountExpendRecordsDo) {
return accountExpendRecordsInterface.selectAccountExpendRecordsAppList(accountExpendRecordsDo);
}
/**
* APP 获取账单详情
* @param accountExpendRecordsDto
* @return
*/
public AccountExpendRecordsAppDetailPo getAppAccountExpendRecordsById(AccountExpendRecordsDto accountExpendRecordsDto) {
AccountExpendRecordsAppDetailPo accountExpendRecordsAppDetailPo = new AccountExpendRecordsAppDetailPo();
AccountExpendRecords accountExpendRecords = accountExpendRecordsInterface.getById(accountExpendRecordsDto.getAccountExpendRecordsId());
BeanUtils.copyProperties(accountExpendRecords,accountExpendRecordsAppDetailPo);
accountExpendRecordsAppDetailPo.setPayStatus("支付成功");
accountExpendRecordsAppDetailPo.setPayType(DictCode.PC_WALLET_PAY.getInfo());
return accountExpendRecordsAppDetailPo;
}
/**
* 根据用户id查询钱包信息
* @param userId
* @return
*/
public AccountCashWalletPo getWalletByUserId(Long userId) {
return accountExpendRecordsInterface.getWalletByUserId(userId);
}
public boolean batchAddAccountExpendRecords(List<AccountExpendRecords> accountExpendRecordsList) {
return accountExpendRecordsInterface.saveBatch(accountExpendRecordsList);
}
/**
* 根据流水号,批量修改记录状态为正常
* @param accountExpendRecordsList
* @return
*/
public boolean batchUpdateAccountRecordsByNum(List<String> accountExpendRecordsList) {
LambdaUpdateWrapper<AccountExpendRecords> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(AccountExpendRecords::getCapitalFlowStatus,1);
updateWrapper.eq(AccountExpendRecords::getDelFlag,1);
updateWrapper.in(AccountExpendRecords::getAccountSerialNumber,accountExpendRecordsList);
return accountExpendRecordsInterface.update(updateWrapper);
}
}
@@ -0,0 +1,134 @@
package com.linke.finance.domain.accountManage.service;
import com.linke.finance.domain.accountManage.entity.AccountTransferRecharge;
import com.linke.finance.domain.accountManage.repository.facade.AccountTransferRechargeInterface;
import com.linke.finance.domain.accountManage.repository.po.AccountTransferRechargePo;
import com.linke.finance.domain.accountManage.repository.todo.AccountTransferRechargeDo;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* 会员转账充值Service业务层处理
*
* @author mhd
* @date 2023-03-23
*/
@Service
public class AccountTransferRechargeDomainService
{
@Autowired
private AccountTransferRechargeInterface accountTransferRechargeInterface;
/**
* 查询会员转账充值
*
* @param accountTransferRechargeId 会员转账充值主键
* @return 会员转账充值
*/
public AccountTransferRechargePo selectAccountTransferRechargeById(Long accountTransferRechargeId)
{
return accountTransferRechargeInterface.selectAccountTransferRechargeById(accountTransferRechargeId);
}
/**
* 查询会员转账充值列表
*
* @param accountTransferRechargeDo 会员转账充值
* @return 会员转账充值
*/
public List<AccountTransferRechargePo> selectAccountTransferRechargeList(AccountTransferRechargeDo accountTransferRechargeDo)
{
return accountTransferRechargeInterface.selectAccountTransferRechargeList(accountTransferRechargeDo);
}
/**
* 新增会员充值转账
* @param accountTransferRecharge
* @return
*/
public boolean insertAccountTransferRecharge(AccountTransferRecharge accountTransferRecharge) {
return accountTransferRechargeInterface.save(accountTransferRecharge);
}
/**
* 根据id删除
* @param accountTransferRechargeDo
* @return
*/
public boolean deleteAccountTransferRecharge(AccountTransferRechargeDo accountTransferRechargeDo) {
if(accountTransferRechargeDo.getAccountTransferRechargeIds()==null || accountTransferRechargeDo.getAccountTransferRechargeIds().length==0){
throw new ServiceException("删除id不能为空");
}
Set<AccountTransferRecharge> accountTransferRecharges = new HashSet<>();
Long userId = SecurityUtils.getLoginUser().getUserid();
String userName = SecurityUtils.getLoginUser().getUsername();
Date now = new Date();
for (Long accountTransferRechargeId : accountTransferRechargeDo.getAccountTransferRechargeIds()) {
AccountTransferRecharge accountTransferRecharge = new AccountTransferRecharge();
accountTransferRecharge.setAccountTransferRechargeId(accountTransferRechargeId);
accountTransferRecharge.setUpdateTime(now);
accountTransferRecharge.setUpdateBy(userId);
accountTransferRecharge.setUpdateByName(userName);
accountTransferRecharge.setDelFlag(2);
accountTransferRecharges.add(accountTransferRecharge);
}
return accountTransferRechargeInterface.updateBatchById(accountTransferRecharges);
}
/**
* 拒绝用户充值转账记录
* @param accountTransferRechargeDo
* @return
*/
public boolean refuseAccountTransferRecharge(AccountTransferRechargeDo accountTransferRechargeDo) {
if(accountTransferRechargeDo.getAccountTransferRechargeIds()==null || accountTransferRechargeDo.getAccountTransferRechargeIds().length==0){
return false;
}
Set<AccountTransferRecharge> accountTransferRecharges = new HashSet<>();
Long userId = SecurityUtils.getLoginUser().getUserid();
String userName = SecurityUtils.getLoginUser().getUsername();
Date now = new Date();
for (Long accountTransferRechargeId : accountTransferRechargeDo.getAccountTransferRechargeIds()) {
AccountTransferRecharge accountTransferRecharge = new AccountTransferRecharge();
accountTransferRecharge.setAccountTransferRechargeId(accountTransferRechargeId);
accountTransferRecharge.setUpdateTime(now);
accountTransferRecharge.setUpdateBy(userId);
accountTransferRecharge.setUpdateByName(userName);
accountTransferRecharge.setAccountTransferStatus(3);
accountTransferRecharge.setAccountTransferReviewer(userName);
accountTransferRecharge.setTransferReviewerId(userId);
accountTransferRecharge.setAccountTransferReject(accountTransferRechargeDo.getAccountTransferReject());
accountTransferRecharge.setTransferReviewerTime(now);
accountTransferRecharges.add(accountTransferRecharge);
}
return accountTransferRechargeInterface.updateBatchById(accountTransferRecharges);
}
/**
* 同意用户充值转账记录
* @param accountTransferRechargeId
* @return
*/
public boolean agreeAccountTransferRecharge(Long accountTransferRechargeId) {
Long userId = SecurityUtils.getLoginUser().getUserid();
String userName = SecurityUtils.getLoginUser().getUsername();
Date now = new Date();
AccountTransferRecharge accountTransferRecharge = new AccountTransferRecharge();
accountTransferRecharge.setAccountTransferRechargeId(accountTransferRechargeId);
accountTransferRecharge.setUpdateTime(now);
accountTransferRecharge.setUpdateBy(userId);
accountTransferRecharge.setUpdateByName(userName);
accountTransferRecharge.setAccountTransferStatus(2);
accountTransferRecharge.setAccountTransferReviewer(userName);
accountTransferRecharge.setTransferReviewerId(userId);
accountTransferRecharge.setTransferReviewerTime(now);
return accountTransferRechargeInterface.updateById(accountTransferRecharge);
}
}
@@ -0,0 +1,131 @@
package com.linke.finance.domain.accountManage.service;
import cn.hutool.core.util.ObjectUtil;
import com.linke.finance.domain.accountManage.entity.AccountBankCard;
import com.mhd.common.core.constant.CacheConstants;
import com.mhd.common.core.domain.dto.wlhy.TmsBankCardDTO;
import com.mhd.common.core.domain.entity.OrgProductConfig;
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.redis.service.RedisService;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.WlhyServiceFeign;
import com.mhd.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class AccountWlhyDomainService {
@Resource
private RedisService redisService;
@Resource
private WlhyServiceFeign wlhyServiceFeign;
/**
* 校验是否配置网货产品
* @return true-开启,false-关闭
*/
private boolean checkSwitch() {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
String key = CacheConstants.ORG_PRODUCT_KEY + loginUser.getUserPo().getTopOrganizationId();
OrgProductConfig orgProductConfig = redisService.getCacheObject(key);
if(null == orgProductConfig) {
return false;
}
//配置网货
return orgProductConfig.getWlhyFlag() == 1;
}
/**
* 同步银行卡信息
* @param accountBankCard
*/
public boolean syncBankCardInfo(AccountBankCard accountBankCard) {
if(null == accountBankCard){
throw new ServiceException("同步数据不能为空");
}
//检查是否开启网货
boolean flag = checkSwitch();
if(!flag){
//如果未配置网货产品,返回跳过
return true;
}
TmsBankCardDTO tmsBankCardDTO = bankCardConvert(accountBankCard);
AjaxResult ajaxResult = wlhyServiceFeign.szwlSyncBankCard(tmsBankCardDTO);
if(null != ajaxResult && "200".equals(String.valueOf(ajaxResult.get("code")))){
return true;
}else if(null != ajaxResult && !"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("同步网货信息失败:" + ajaxResult.get("msg"));
}else {
throw new ServiceException("同步网货信息失败");
}
}
/**
* 银行卡实体转换
* @param accountBankCard
* @return
*/
private TmsBankCardDTO bankCardConvert(AccountBankCard accountBankCard) {
TmsBankCardDTO tmsBankCardDTO = new TmsBankCardDTO();
tmsBankCardDTO.setBankId(accountBankCard.getBankNameCode());
tmsBankCardDTO.setBankName(accountBankCard.getBankName());
tmsBankCardDTO.setSzwlBankCardId(accountBankCard.getAccountBankCardId());
tmsBankCardDTO.setBankCardUserName(accountBankCard.getUserName());
tmsBankCardDTO.setBankCardUserPhone(accountBankCard.getUserPhone());
tmsBankCardDTO.setAccountOwnerName(accountBankCard.getUserName());
tmsBankCardDTO.setBankCardNumber(accountBankCard.getBankCardNumber());
tmsBankCardDTO.setBindingPhone(accountBankCard.getBankBindingPhone());
tmsBankCardDTO.setBankCardUserId(String.valueOf(accountBankCard.getUserId()));
if(accountBankCard.getDefaultStatus()==1){
tmsBankCardDTO.setIsDefault(1);
}else {
tmsBankCardDTO.setIsDefault(0);
}
if(accountBankCard.getDelFlag()==1){
tmsBankCardDTO.setIsDelete(0);
}else {
tmsBankCardDTO.setIsDelete(1);
}
tmsBankCardDTO.setAddress(accountBankCard.getBankUserAddress());
tmsBankCardDTO.setFromWhere(0);
tmsBankCardDTO.setIsMine(1);
return tmsBankCardDTO;
}
public boolean deleteBankCardByIds(Long[] accountBankCardIds) {
if(null == accountBankCardIds || accountBankCardIds.length==0){
throw new ServiceException("同步数据不能为空");
}
//检查是否开启网货
boolean flag = checkSwitch();
if(!flag){
//如果未配置网货产品,返回跳过
return true;
}
TmsBankCardDTO tmsBankCardDTO = new TmsBankCardDTO();
tmsBankCardDTO.setAccountBankCardIds(accountBankCardIds);
AjaxResult ajaxResult = wlhyServiceFeign.szwlDeleteBankCard(tmsBankCardDTO);
if(null != ajaxResult && "200".equals(String.valueOf(ajaxResult.get("code")))){
return true;
}else if(null != ajaxResult && !"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("同步网货信息失败:" + ajaxResult.get("msg"));
}else {
throw new ServiceException("同步网货信息失败");
}
}
}
@@ -0,0 +1,64 @@
package com.linke.finance.domain.address.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 【请填写功能名称】对象 receiving_address_manage
*
* @author mhd
* @date 2023-03-14
*/
@Data
public class ReceivingAddressManage extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 收件地址信息id */
@ApiModelProperty(name = "收件地址信息id")
@TableId(type = IdType.AUTO)
private Long receivingAddressId;
/** 收件人姓名 */
@ApiModelProperty(name = "收件人姓名")
private String receivingName;
/** 所在地区编码 */
@ApiModelProperty(name = "所在地区编码")
private Long countyCode;
/** 所在地区 */
@ApiModelProperty(name = "所在地区")
private String countyName;
/** 街道地址 */
@ApiModelProperty(name = "街道地址")
private String address;
/** 邮政编码 */
@ApiModelProperty(name = "邮政编码")
private String postalCode;
/** 手机号 */
@ApiModelProperty(name = "手机号")
private String phone;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 默认地址状态(1-是,2-否) */
@ApiModelProperty(name = "默认地址状态")
private Integer defaultStatus;
@ApiModelProperty(name = "组织表ID")
private Long organizationId;
@ApiModelProperty(name = "一级组织表ID")
private Long topOrganizationId;
}
@@ -0,0 +1,50 @@
package com.linke.finance.domain.address.repository.facade;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
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;
/**
* 【请填写功能名称】Service接口
*
* @author mhd
* @date 2023-03-14
*/
public interface ReceivingAddressManageInterface extends IService<ReceivingAddressManage>
{
/**
* 查询【请填写功能名称】
*
* @param receivingAddressId 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
public ReceivingAddressManagePo selectByReceivingAddressId(Long receivingAddressId);
/**
* 查询【请填写功能名称】列表
*
* @param receivingAddressManageDo 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public List<ReceivingAddressManagePo> selectReceivingAddressManageList(ReceivingAddressManageDo receivingAddressManageDo);
/**
* 新增【请填写功能名称】
*
* @param receivingAddressManage 【请填写功能名称】
* @return 结果
*/
public int insertReceivingAddressManage(ReceivingAddressManage receivingAddressManage);
/**
* 修改【请填写功能名称】
*
* @param receivingAddressManage 【请填写功能名称】
* @return 结果
*/
public int updateReceivingAddressManage(ReceivingAddressManage receivingAddressManage);
}
@@ -0,0 +1,50 @@
package com.linke.finance.domain.address.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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 org.apache.ibatis.annotations.Param;
/**
* 【请填写功能名称】Mapper接口
*
* @author mhd
* @date 2023-03-14
*/
public interface ReceivingAddressManageMapper extends BaseMapper<ReceivingAddressManage>
{
/**
* 查询【请填写功能名称】
*
* @param receivingAddressId 【请填写功能名称】主键
* @return 【请填写功能名称】
*/
public ReceivingAddressManagePo selectByReceivingAddressId(@Param("receivingAddressId") Long receivingAddressId);
/**
* 查询【请填写功能名称】列表
*
* @param receivingAddressManageDo 【请填写功能名称】
* @return 【请填写功能名称】集合
*/
public List<ReceivingAddressManagePo> selectReceivingAddressManageList(ReceivingAddressManageDo receivingAddressManageDo);
/**
* 删除【请填写功能名称】
*
* @param receivingAddressId 【请填写功能名称】主键
* @return 结果
*/
public int deleteByReceivingAddressId(@Param("receivingAddressId") Long receivingAddressId);
/**
* 批量删除【请填写功能名称】
*
* @param receivingAddressIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteByReceivingAddressIds(@Param("receivingAddressIds") Long[] receivingAddressIds);
}
@@ -0,0 +1,74 @@
package com.linke.finance.domain.address.repository.persistence;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.finance.domain.address.entity.ReceivingAddressManage;
import com.linke.finance.domain.address.repository.facade.ReceivingAddressManageInterface;
import com.linke.finance.domain.address.repository.mapper.ReceivingAddressManageMapper;
import com.linke.finance.domain.address.repository.po.ReceivingAddressManagePo;
import com.linke.finance.domain.address.repository.todo.ReceivingAddressManageDo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 请填写功能名称Service业务层处理
*
* @author mhd
* @date 2023-03-14
*/
@Service
public class ReceivingAddressManageImpl extends ServiceImpl<ReceivingAddressManageMapper, ReceivingAddressManage> implements ReceivingAddressManageInterface
{
@Autowired
private ReceivingAddressManageMapper receivingAddressManageMapper;
/**
* 查询请填写功能名称
*
* @param receivingAddressId 请填写功能名称主键
* @return 请填写功能名称
*/
@Override
public ReceivingAddressManagePo selectByReceivingAddressId(Long receivingAddressId)
{
return receivingAddressManageMapper.selectByReceivingAddressId(receivingAddressId);
}
/**
* 查询请填写功能名称列表
*
* @param receivingAddressManageDo 请填写功能名称
* @return 请填写功能名称
*/
@Override
public List<ReceivingAddressManagePo> selectReceivingAddressManageList(ReceivingAddressManageDo receivingAddressManageDo)
{
return receivingAddressManageMapper.selectReceivingAddressManageList(receivingAddressManageDo);
}
/**
* 新增请填写功能名称
*
* @param receivingAddressManage 请填写功能名称
* @return 结果
*/
@Override
public int insertReceivingAddressManage(ReceivingAddressManage receivingAddressManage)
{
return receivingAddressManageMapper.insert(receivingAddressManage);
}
/**
* 修改请填写功能名称
*
* @param receivingAddressManage 请填写功能名称
* @return 结果
*/
@Override
public int updateReceivingAddressManage(ReceivingAddressManage receivingAddressManage)
{
return receivingAddressManageMapper.updateById(receivingAddressManage);
}
}
@@ -0,0 +1,61 @@
package com.linke.finance.domain.address.repository.po;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 请填写功能名称对象 receiving_address_manage
*
* @author mhd
* @date 2023-03-14
*/
@Data
public class ReceivingAddressManagePo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 收件地址信息id */
@ApiModelProperty(name = "收件地址信息id")
private Long receivingAddressId;
/** 收件人姓名 */
@ApiModelProperty(name = "收件人姓名")
private String receivingName;
/** 所在地区编码 */
@ApiModelProperty(name = "所在地区编码")
private Long countyCode;
/** 所在地区 */
@ApiModelProperty(name = "所在地区")
private String countyName;
/** 街道地址 */
@ApiModelProperty(name = "街道地址")
private String address;
/** 邮政编码 */
@ApiModelProperty(name = "邮政编码")
private String postalCode;
/** 手机号 */
@ApiModelProperty(name = "手机号")
private String phone;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 默认地址状态(1-是,2-否) */
@ApiModelProperty(name = "默认地址状态")
private Integer defaultStatus;
@ApiModelProperty(name = "组织表ID")
private Long organizationId;
@ApiModelProperty(name = "一级组织表ID")
private Long topOrganizationId;
}
@@ -0,0 +1,66 @@
package com.linke.finance.domain.address.repository.todo;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 请填写功能名称对象 receiving_address_manage
*
* @author mhd
* @date 2023-03-14
*/
@Data
public class ReceivingAddressManageDo extends BaseVOEntity
{
private static final long serialVersionUID = 1L;
/** 收件地址信息id */
@ApiModelProperty(name = "收件地址信息id")
private Long receivingAddressId;
/** 收件人姓名 */
@ApiModelProperty(name = "收件人姓名")
private String receivingName;
/** 所在地区编码 */
@ApiModelProperty(name = "所在地区编码")
private Long countyCode;
/** 所在地区 */
@ApiModelProperty(name = "所在地区")
private String countyName;
/** 街道地址 */
@ApiModelProperty(name = "街道地址")
private String address;
/** 邮政编码 */
@ApiModelProperty(name = "邮政编码")
private String postalCode;
/** 手机号 */
@ApiModelProperty(name = "手机号")
private String phone;
/** 用户id */
@ApiModelProperty(name = "用户id")
private Long userId;
/** 默认地址状态(1-是,2-否) */
@ApiModelProperty(name = "默认地址状态")
private Integer defaultStatus;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "组织表ID")
private Long organizationId;
@ApiModelProperty(name = "一级组织表ID")
private Long topOrganizationId;
}
@@ -0,0 +1,165 @@
package com.linke.finance.domain.address.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.finance.domain.address.entity.ReceivingAddressManage;
import com.linke.finance.domain.address.repository.facade.ReceivingAddressManageInterface;
import com.linke.finance.domain.address.repository.mapper.ReceivingAddressManageMapper;
import com.linke.finance.domain.address.repository.po.ReceivingAddressManagePo;
import com.linke.finance.domain.address.repository.todo.ReceivingAddressManageDo;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* 请填写功能名称Service业务层处理
*
* @author mhd
* @date 2023-03-14
*/
@Service
public class ReceivingAddressManageDomainService extends ServiceImpl<ReceivingAddressManageMapper, ReceivingAddressManage> implements ReceivingAddressManageInterface
{
@Autowired
private ReceivingAddressManageInterface receivingAddressManageInterface;
/**
* 查询请填写功能名称
*
* @param receivingAddressId 请填写功能名称主键
* @return 请填写功能名称
*/
public ReceivingAddressManagePo selectByReceivingAddressId(Long receivingAddressId)
{
return receivingAddressManageInterface.selectByReceivingAddressId(receivingAddressId);
}
/**
* 查询请填写功能名称列表
*
* @param receivingAddressManageDo 请填写功能名称
* @return 请填写功能名称
*/
public List<ReceivingAddressManagePo> selectReceivingAddressManageList(ReceivingAddressManageDo receivingAddressManageDo)
{
return receivingAddressManageInterface.selectReceivingAddressManageList(receivingAddressManageDo);
}
/**
* 新增请填写功能名称
*
* @param receivingAddressManage 请填写功能名称
* @return 结果
*/
@Transactional(rollbackFor = Exception.class)
public int insertReceivingAddressManage(ReceivingAddressManage receivingAddressManage)
{
receivingAddressManage.setCreateBy(SecurityUtils.getUserId());
receivingAddressManage.setCreateByName(SecurityUtils.getUsername());
receivingAddressManage.setCreateTime(new Date());
if(receivingAddressManage.getDefaultStatus()==1){
//查询当前用户默认收件地址
ReceivingAddressManage receivingAddressManageOld = receivingAddressManageInterface.getBaseMapper().selectOne(
new QueryWrapper<ReceivingAddressManage>().lambda().eq(ReceivingAddressManage::getCreateBy,SecurityUtils.getUserId()).eq(ReceivingAddressManage::getDefaultStatus,1).eq(ReceivingAddressManage::getDelFlag,1));
if(null != receivingAddressManageOld){
receivingAddressManageInterface.update(new ReceivingAddressManage(),
new UpdateWrapper<ReceivingAddressManage>().lambda().eq(ReceivingAddressManage::getReceivingAddressId,receivingAddressManageOld.getReceivingAddressId())
.set(ReceivingAddressManage::getDefaultStatus,2).set(ReceivingAddressManage::getUpdateBy,SecurityUtils.getUserId())
.set(ReceivingAddressManage::getUpdateTime,new Date()).set(ReceivingAddressManage::getUpdateByName,SecurityUtils.getUsername()));
}
}
return receivingAddressManageInterface.insertReceivingAddressManage(receivingAddressManage);
}
/**
* 修改请填写功能名称
*
* @param receivingAddressManage 请填写功能名称
* @return 结果
*/
@Transactional(rollbackFor = Exception.class)
public int updateReceivingAddressManage(ReceivingAddressManage receivingAddressManage)
{
receivingAddressManage.setUpdateBy(SecurityUtils.getUserId());
receivingAddressManage.setUpdateByName(SecurityUtils.getUsername());
receivingAddressManage.setUpdateTime(new Date());
//如果修改后的为默认收件地址
if(receivingAddressManage.getDefaultStatus()==1){
//查询当前用户默认收件地址
ReceivingAddressManage receivingAddressManageOld = receivingAddressManageInterface.getBaseMapper().selectOne(
new QueryWrapper<ReceivingAddressManage>().lambda().eq(ReceivingAddressManage::getCreateBy,SecurityUtils.getUserId()).eq(ReceivingAddressManage::getDefaultStatus,1).eq(ReceivingAddressManage::getDelFlag,1));
if(null != receivingAddressManageOld){
receivingAddressManageInterface.update(new ReceivingAddressManage(),
new UpdateWrapper<ReceivingAddressManage>().lambda().eq(ReceivingAddressManage::getReceivingAddressId,receivingAddressManageOld.getReceivingAddressId())
.set(ReceivingAddressManage::getDefaultStatus,2).set(ReceivingAddressManage::getUpdateBy,SecurityUtils.getUserId())
.set(ReceivingAddressManage::getUpdateTime,new Date()).set(ReceivingAddressManage::getUpdateByName,SecurityUtils.getUsername()));
}
}
return receivingAddressManageInterface.updateReceivingAddressManage(receivingAddressManage);
}
public boolean deleteByIds(Long[] receivingAddressIds) {
Set<ReceivingAddressManage> receivingAddressManages = new HashSet<>();
String userName = SecurityUtils.getLoginUser().getUsername();
Long userId = SecurityUtils.getLoginUser().getUserid();
Date now = new Date();
for (Long receivingAddressId : receivingAddressIds) {
ReceivingAddressManage receivingAddressManage = new ReceivingAddressManage();
receivingAddressManage.setReceivingAddressId(receivingAddressId);
receivingAddressManage.setUpdateBy(userId);
receivingAddressManage.setUpdateTime(now);
receivingAddressManage.setUpdateByName(userName);
receivingAddressManage.setDelFlag(2);
receivingAddressManages.add(receivingAddressManage);
}
return receivingAddressManageInterface.updateBatchById(receivingAddressManages);
}
/**
* 标记默认收货地址
* @param receivingAddressManageDo
* @return
*/
@Transactional(rollbackFor = Exception.class)
public boolean markDefault(ReceivingAddressManageDo receivingAddressManageDo) {
/**
* 根据当前登录用户查询改用户下的默认收件地址然后取消默认给传来的收件地址设为默认
*/
if(receivingAddressManageDo.getReceivingAddressId() ==null){
throw new ServiceException("收件地址id不能为空");
}
Long userId = SecurityUtils.getLoginUser().getUserid();
//查询当前用户默认收件地址
ReceivingAddressManage receivingAddressManage = receivingAddressManageInterface.getBaseMapper().selectOne(
new QueryWrapper<ReceivingAddressManage>().lambda().eq(ReceivingAddressManage::getCreateBy,userId).eq(ReceivingAddressManage::getDefaultStatus,1).eq(ReceivingAddressManage::getDelFlag,1));
if(null != receivingAddressManage){
receivingAddressManageInterface.update(new ReceivingAddressManage(),
new UpdateWrapper<ReceivingAddressManage>().lambda().eq(ReceivingAddressManage::getReceivingAddressId,receivingAddressManage.getReceivingAddressId())
.set(ReceivingAddressManage::getDefaultStatus,2).set(ReceivingAddressManage::getUpdateBy,SecurityUtils.getUserId())
.set(ReceivingAddressManage::getUpdateTime,new Date()).set(ReceivingAddressManage::getUpdateByName,SecurityUtils.getUsername()));
}
//将传来的收件地址设为默认
return receivingAddressManageInterface.update(new ReceivingAddressManage(),
new UpdateWrapper<ReceivingAddressManage>().lambda().eq(ReceivingAddressManage::getReceivingAddressId,receivingAddressManageDo.getReceivingAddressId())
.set(ReceivingAddressManage::getDefaultStatus,1).set(ReceivingAddressManage::getUpdateBy,SecurityUtils.getUserId())
.set(ReceivingAddressManage::getUpdateTime,new Date()).set(ReceivingAddressManage::getUpdateByName,SecurityUtils.getUsername()));
}
/**
* 查询当前登录用户默认收件地址
* @return
*/
public ReceivingAddressManage selectReceivingAddressMine() {
Long userId = SecurityUtils.getLoginUser().getUserid();
return receivingAddressManageInterface.getBaseMapper().selectOne(new QueryWrapper<ReceivingAddressManage>()
.lambda().eq(ReceivingAddressManage::getDelFlag,1).eq(ReceivingAddressManage::getDefaultStatus,1).eq(ReceivingAddressManage::getCreateBy,userId));
}
}
@@ -0,0 +1,83 @@
package com.linke.finance.domain.approvalDocument.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 审批单据对象 approval_document
*
* @author gen
* @date 2025-07-16
*/
@Data
public class ApprovalDocument extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键id")
@TableId(type = IdType.AUTO)
private Long id;
@ApiModelProperty("审批单号")
@Excel(name = "审批单号")
private String approvalOrderNumber;
@ApiModelProperty("钉钉审批单号")
@Excel(name = "钉钉审批单号")
private String approvalNumber;
@ApiModelProperty("审批类型")
@Excel(name = "审批类型")
private String approvalType;
@ApiModelProperty("审批标题")
@Excel(name = "审批标题")
private String approvalTitle;
@ApiModelProperty("审批状态 0-未审批 1-审批中 2-审批通过 3-审批拒绝 4-已撤销")
@Excel(name = "审批状态 0-未审批 1-审批中 2-审批通过 3-审批拒绝 4-已撤销")
private Long approvalStatus;
@ApiModelProperty("完成时间")
private String finishTime;
@ApiModelProperty("$column.columnComment")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String approvalOpinion;
@ApiModelProperty("审批单来源")
@Excel(name = "审批单来源")
private String approvalFormSource;
@ApiModelProperty("组织ID")
@Excel(name = "组织ID")
private Long organizationId;
@ApiModelProperty("一级组织ID")
@Excel(name = "一级组织ID")
private Long topOrganizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("单据数量")
@Excel(name = "单据数量")
private Integer documentsNumber;
@ApiModelProperty("当前审批人id")
@Excel(name = "当前审批人id")
private String currentApprover;
@ApiModelProperty("当前审批人名称")
@Excel(name = "当前审批人名称")
private String currentApproverName;
}
@@ -0,0 +1,55 @@
package com.linke.finance.domain.approvalDocument.repository.facade;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
import com.baomidou.mybatisplus.extension.service.IService;
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.interfaces.vo.ApprovalStatsVO;
import java.util.List;
/**
* 审批单据Service接口
*
* @author gen
* @date 2025-07-16
*/
public interface IApprovalDocumentService extends IService<ApprovalDocument>
{
/**
* 分页查询审批单据列表
*/
public List<ApprovalDocumentPO> queryList(ApprovalDocumentDO approvalDocumentDO);
/**
* 新增审批单据
*/
public Boolean insert(ApprovalDocumentDO approvalDocumentDO);
/**
* 修改审批单据
*/
public Boolean update(ApprovalDocumentDO approvalDocumentDO);
/**
* 批量删除审批单据
*/
public Boolean delete(Long[] ids);
/**
* 查询审批单据
*/
public ApprovalDocumentPO getInfo(Long id);
public ApprovalDocument getByProcessInstanceId(String processInstanceId);
public WorkflowProcessInstancesByIdDO workflowProcessInstancesById(Long businessDocumentDetaliId);
public void workflowProcessInstancesMore(String ids);
public ApprovalStatsVO getApprovalStatistics(Long orgId);
}
@@ -0,0 +1,37 @@
package com.linke.finance.domain.approvalDocument.repository.mapper;
import com.linke.finance.interfaces.vo.ApprovalStatsVO;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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 org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* 审批单据Mapper接口
*
* @author gen
* @date 2025-07-16
*/
public interface ApprovalDocumentMapper extends BaseMapper<ApprovalDocument>
{
/**
* 查询审批单据列表
*/
public List<ApprovalDocumentPO> queryList(ApprovalDocumentDO approvalDocumentDO);
/**
* 统计审批单据总数及各状态数量
* @return 统计结果封装对象
*/
ApprovalStatsVO countByStatus(@Param("orgId") Long orgId);
@Select("select * from approval_document where del_flag=1 and approval_order_number=#{processInstanceId}")
ApprovalDocument getByProcessInstanceId(@Param("processInstanceId") String processInstanceId);
}
@@ -0,0 +1,697 @@
package com.linke.finance.domain.approvalDocument.repository.persistence;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSONObject;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dingtalk.api.response.OapiV2UserGetResponse;
import com.linke.finance.domain.approvalDocument.entity.ApprovalDocument;
import com.linke.finance.domain.approvalDocument.repository.facade.IApprovalDocumentService;
import com.linke.finance.domain.approvalDocument.repository.mapper.ApprovalDocumentMapper;
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.OperationRecordsDO;
import com.linke.finance.domain.approvalDocument.repository.todo.TasksDO;
import com.linke.finance.domain.approvalDocument.repository.todo.WorkflowProcessInstancesByIdDO;
import com.linke.finance.domain.businessDocumentDetali.entity.BusinessDocumentDetali;
import com.linke.finance.domain.businessDocumentDetali.repository.mapper.BusinessDocumentDetaliMapper;
import com.linke.finance.domain.businessDocumentDetali.service.BusinessDocumentDetaliDomainService;
import com.linke.finance.domain.reconciliation.entity.Reconciliation;
import com.linke.finance.domain.reconciliation.repository.mapper.ReconciliationMapper;
import com.linke.finance.domain.verification.service.VerificationDomainService;
import com.linke.finance.interfaces.vo.ApprovalStatsVO;
import com.mhd.common.core.domain.dto.BusinessDocumentDTO;
import com.mhd.common.core.domain.dto.BusinessDocumentDetaliDTO;
import com.mhd.common.core.domain.dto.wlhy.EditPaymentStatusDTO;
import com.mhd.common.core.domain.entity.R;
import com.mhd.common.core.domain.entity.Verification;
import com.mhd.common.core.enums.ApproveStatusEnum;
import com.mhd.common.core.enums.SubjectCodeEnum;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.feign.ThirdPartyServiceFeign;
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.UserServiceFeign;
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.apache.commons.lang.StringUtils;
import org.redisson.api.RLock;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* 审批单据Service业务层处理
*
* @author gen
* @date 2025-07-16
*/
@Service
public class ApprovalDocumentImpl extends ServiceImpl<ApprovalDocumentMapper, ApprovalDocument> implements IApprovalDocumentService {
@Autowired
private ApprovalDocumentMapper approvalDocumentMapper;
@Autowired
private ThirdPartyServiceFeign thirdPartyServiceFeign;
@Autowired
private BusinessDocumentDetaliMapper businessDocumentDetaliMapper;
@Autowired
private ReconciliationMapper reconciliationMapper;
@Autowired
private UserServiceFeign userServiceFeign;
@Autowired
private WlhyServiceFeign wlhyServiceFeign;
@Autowired
private BusinessDocumentDetaliDomainService businessDocumentDetaliDomainService;
@Autowired
private VerificationDomainService verificationDomainService;
@Autowired
private RedisLock redisLock;
/**
* 查询审批单据列表
*/
@Override
public List<ApprovalDocumentPO> queryList(ApprovalDocumentDO approvalDocumentDO)
{
return approvalDocumentMapper.queryList(approvalDocumentDO);
}
/**
* 新增审批单据
*/
@Override
public Boolean insert(ApprovalDocumentDO approvalDocumentDO) {
ApprovalDocument approvalDocument = new ApprovalDocument();
BeanUtils.copyProperties(approvalDocumentDO,approvalDocument);
return this.save(approvalDocument);
}
/**
* 修改审批单据
*/
@Override
public Boolean update(ApprovalDocumentDO approvalDocumentDO) {
ApprovalDocument approvalDocument = new ApprovalDocument();
BeanUtils.copyProperties(approvalDocumentDO,approvalDocument);
return this.updateById(approvalDocument);
}
/**
* 批量删除审批单据
*/
@Override
public Boolean delete(Long[] ids ) {
List<ApprovalDocument> list = new ArrayList<>();
for (Long id : ids) {
ApprovalDocument approvalDocument = new ApprovalDocument();
approvalDocument.setId(id);
approvalDocument.setDelFlag(2);
list.add(approvalDocument);
}
return this.updateBatchById(list);
}
/**
* 修改审批单据
*/
@Override
public ApprovalDocumentPO getInfo(Long id) {
ApprovalDocument approvalDocument = this.getById(id);
ApprovalDocumentPO approvalDocumentPO = new ApprovalDocumentPO();
BeanUtils.copyProperties(approvalDocument,approvalDocumentPO);
return approvalDocumentPO;
}
@Override
public ApprovalDocument getByProcessInstanceId(String processInstanceId) {
return approvalDocumentMapper.getByProcessInstanceId(processInstanceId);
}
@Override
@GlobalTransactional(rollbackFor = Exception.class)
public WorkflowProcessInstancesByIdDO workflowProcessInstancesById(Long businessDocumentDetaliId) {
LoginUser loginUser= SecurityUtils.getLoginUser();
ApprovalDocument approvalDocument=approvalDocumentMapper.selectById(businessDocumentDetaliId);
log.error(new Date()+"钉钉订阅消息通知:businessDocumentDetaliId====="+businessDocumentDetaliId);
if(ObjectUtil.isNotNull(approvalDocument)){
if(StringUtils.isNotBlank(approvalDocument.getApprovalOrderNumber())){
AjaxResult ajaxResult1=thirdPartyServiceFeign.processInstancesById(approvalDocument.getApprovalOrderNumber());
if("200".equals(String.valueOf(ajaxResult1.get("code")))){
Map<String,Object> map = com.alibaba.fastjson2.JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult1.get("data")), Map.class);
GetProcessInstanceResponse startProcessInstanceResponse = com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.toJSONString(map), GetProcessInstanceResponse.class);
WorkflowProcessInstancesByIdDO workflowProcessInstancesByIdDO=new WorkflowProcessInstancesByIdDO();
if(ObjectUtil.isNull(startProcessInstanceResponse)){
throw new ServiceException("获取单个审批实例详情失败");
}else{
if(approvalDocument.getApprovalFormSource().equals("应付单据")){
List<BusinessDocumentDetali> businessDocumentDetaliList=businessDocumentDetaliMapper.selectList(new QueryWrapper<BusinessDocumentDetali>()
.lambda().eq(BusinessDocumentDetali::getInstanceId,approvalDocument.getApprovalOrderNumber())
.eq(BusinessDocumentDetali::getDelFlag,1));
for (BusinessDocumentDetali businessDocumentDetali1:businessDocumentDetaliList){
if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("RUNNING")){
businessDocumentDetali1.setApprovalStatus(2);
businessDocumentDetali1.setAuditStatus(1);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("TERMINATED")){
businessDocumentDetali1.setApprovalStatus(3);
businessDocumentDetali1.setAuditStatus(4);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("COMPLETED")){
businessDocumentDetali1.setApprovalStatus(4);
// if(startProcessInstanceResponse.getBody().getResult().getResult().equals("agree")){
// businessDocumentDetali1.setAuditStatus(2);
// }else if(startProcessInstanceResponse.getBody().getResult().getResult().equals("refuse")){
// businessDocumentDetali1.setAuditStatus(3);
// }
}
// businessDocumentDetali1.setApprovalResult(startProcessInstanceResponse.getBody().getResult().getResult());
// businessDocumentDetaliMapper.updateById(businessDocumentDetali1);
}
//lyh 2025-09-15应付单据逻辑修改不是简单的修改状态业务单据来源相关状态都需要改
if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("COMPLETED")||startProcessInstanceResponse.getBody().getResult().getStatus().equals("TERMINATED")){
Integer auditStatus = -1;
if(startProcessInstanceResponse.getBody().getResult().getResult().equals("agree")){
auditStatus = 2;
}else if(startProcessInstanceResponse.getBody().getResult().getResult().equals("refuse")){
auditStatus = 3;
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("TERMINATED")){
auditStatus = 4;
}
if(auditStatus>0){
RedisLockTypeEnum redisLockTypeEnum = RedisLockTypeEnum.FINANCE;
String key = redisLockTypeEnum.getUniqueKey(String.valueOf(approvalDocument.getApprovalNumber()));
RLock lock = null;
try {
lock = redisLock.getRLock(key);
//尝试获取锁 不等待 持有锁5分钟
if(!lock.tryLock(-1,5, TimeUnit.MINUTES)){
lock = null;
log.error(approvalDocument.getApprovalNumber()+"审批单结束,业务逻辑处理中");
}else{
log.error(approvalDocument.getApprovalNumber()+"审批单加锁成功");
boolean resultAudit= yfdjAudit(businessDocumentDetaliList,auditStatus,"",loginUser);
if(!resultAudit){
throw new ServiceException("审批结束:同步业务数据失败");
}
}
} catch (Exception e){
log.error(approvalDocument.getApprovalNumber()+"审批单结束时,业务逻辑处理异常!");
throw new ServiceException("审批结束:同步业务数据异常");
} finally {
if (lock != null && lock.isHeldByCurrentThread()){
lock.unlock();
log.error(approvalDocument.getApprovalNumber()+"审批单释放了锁!");
}
}
}
}
}else if(approvalDocument.getApprovalFormSource().equals("应收单据")){
List<Reconciliation> reconciliationList=reconciliationMapper.selectList(new QueryWrapper<Reconciliation>()
.lambda().eq(Reconciliation::getInstanceId,approvalDocument.getApprovalOrderNumber())
.eq(Reconciliation::getDelFlag,1));
for (Reconciliation reconciliation:reconciliationList){
if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("RUNNING")){
reconciliation.setApprovalStatus(2);
reconciliation.setAuditStatus(1);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("TERMINATED")){
reconciliation.setApprovalStatus(3);
reconciliation.setAuditStatus(4);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("COMPLETED")){
reconciliation.setApprovalStatus(4);
if(startProcessInstanceResponse.getBody().getResult().getResult().equals("agree")){
reconciliation.setAuditStatus(2);
}else if(startProcessInstanceResponse.getBody().getResult().getResult().equals("refuse")){
reconciliation.setAuditStatus(3);
}
}
reconciliation.setApprovalResult(startProcessInstanceResponse.getBody().getResult().getResult());
reconciliationMapper.updateById(reconciliation);
}
}
if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("RUNNING")){
approvalDocument.setApprovalStatus(1L);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("TERMINATED")){
approvalDocument.setApprovalStatus(4L);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("COMPLETED")){
if(startProcessInstanceResponse.getBody().getResult().getResult().equals("agree")){
approvalDocument.setApprovalStatus(2L);
}else if(startProcessInstanceResponse.getBody().getResult().getResult().equals("refuse")){
approvalDocument.setApprovalStatus(3L);
}
}
approvalDocument.setApprovalTitle(startProcessInstanceResponse.getBody().getResult().getTitle());
approvalDocument.setApprovalNumber(startProcessInstanceResponse.getBody().getResult().getBusinessId());
if(StringUtils.isNotBlank(startProcessInstanceResponse.getBody().getResult().getFinishTime())){
String finishTime=startProcessInstanceResponse.getBody().getResult().getFinishTime().replace("T"," ").replace("Z",":00");;
approvalDocument.setFinishTime(finishTime);
}
if(ObjectUtil.isNotNull(loginUser)){
approvalDocument.setUpdateBy(loginUser.getUserid());
approvalDocument.setUpdateByName(loginUser.getUsername());
}
approvalDocument.setUpdateTime(new Date());
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks> tasks=startProcessInstanceResponse.getBody().getResult().getTasks();
if(ObjectUtil.isNotNull(tasks)&&tasks.size()>0){
String userId=tasks.get(tasks.size()-1).getUserId();
approvalDocument.setCurrentApprover(userId);
AjaxResult ajaxResult2=thirdPartyServiceFeign.userGet(userId);
if("200".equals(String.valueOf(ajaxResult2.get("code")))){
Map<String,Object> map1 = com.alibaba.fastjson2.JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult2.get("data")), Map.class);
OapiV2UserGetResponse oapiV2UserGetResponse = com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.toJSONString(map1), OapiV2UserGetResponse.class);
if(ObjectUtil.isNull(startProcessInstanceResponse)){
throw new ServiceException("获取单个审批实例详情失败");
}else{
approvalDocument.setCurrentApproverName(oapiV2UserGetResponse.getResult().getName());
}
}
}
approvalDocumentMapper.updateById(approvalDocument);
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult getProcessInstanceResponseBodyResult=startProcessInstanceResponse.getBody().getResult();
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultOperationRecords> operationRecordsList=getProcessInstanceResponseBodyResult.getOperationRecords();
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks> tasksList=getProcessInstanceResponseBodyResult.getTasks();
BeanUtils.copyProperties(getProcessInstanceResponseBodyResult,workflowProcessInstancesByIdDO);
AjaxResult ajaxResult4=thirdPartyServiceFeign.userGet(getProcessInstanceResponseBodyResult.getOriginatorUserId());
if("200".equals(String.valueOf(ajaxResult4.get("code")))){
Map<String,Object> map2 = com.alibaba.fastjson2.JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult4.get("data")), Map.class);
OapiV2UserGetResponse oapiV2UserGetResponse = com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.toJSONString(map2), OapiV2UserGetResponse.class);
if(ObjectUtil.isNull(startProcessInstanceResponse)){
}else{
workflowProcessInstancesByIdDO.setOriginatorUserName(oapiV2UserGetResponse.getResult().getName());
}
}
String createTime2=getProcessInstanceResponseBodyResult.getCreateTime().replace("T"," ").replace("Z",":00");;
workflowProcessInstancesByIdDO.setCreateTime(createTime2);
if(StringUtils.isNotBlank(getProcessInstanceResponseBodyResult.getFinishTime())){
String finishTime1=getProcessInstanceResponseBodyResult.getFinishTime().replace("T"," ").replace("Z",":00");;
workflowProcessInstancesByIdDO.setFinishTime(finishTime1);
}
List<OperationRecordsDO> operationRecordsDOList=new ArrayList<OperationRecordsDO>();
List<TasksDO> tasksDOList=new ArrayList<TasksDO>();
if(ObjectUtil.isNotNull(operationRecordsList)&&operationRecordsList.size()>0){
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultOperationRecords getProcessInstanceResponseBodyResultOperationRecords:operationRecordsList){
OperationRecordsDO operationRecordsDO=new OperationRecordsDO();
BeanUtils.copyProperties(getProcessInstanceResponseBodyResultOperationRecords,operationRecordsDO);
String date=getProcessInstanceResponseBodyResultOperationRecords.getDate().replace("T"," ").replace("Z",":00");;
operationRecordsDO.setDate(date);
AjaxResult ajaxResult3=thirdPartyServiceFeign.userGet(getProcessInstanceResponseBodyResultOperationRecords.getUserId());
if("200".equals(String.valueOf(ajaxResult3.get("code")))){
Map<String,Object> map2 = com.alibaba.fastjson2.JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult3.get("data")), Map.class);
OapiV2UserGetResponse oapiV2UserGetResponse = com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.toJSONString(map2), OapiV2UserGetResponse.class);
if(ObjectUtil.isNull(startProcessInstanceResponse)){
}else{
operationRecordsDO.setUserName(oapiV2UserGetResponse.getResult().getName());
}
}
operationRecordsDOList.add(operationRecordsDO);
}
}
if(ObjectUtil.isNotNull(tasksList)&&tasksList.size()>0){
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks getProcessInstanceResponseBodyResultTasks:tasksList){
TasksDO tasksDO=new TasksDO();
BeanUtils.copyProperties(getProcessInstanceResponseBodyResultTasks,tasksDO);
String createTime=getProcessInstanceResponseBodyResultTasks.getCreateTime().replace("T"," ").replace("Z",":00");;
tasksDO.setCreateTime(createTime);
if(StringUtils.isNotBlank(getProcessInstanceResponseBodyResultTasks.getFinishTime())){
String finishTime1=getProcessInstanceResponseBodyResultTasks.getFinishTime().replace("T"," ").replace("Z",":00");;
tasksDO.setFinishTime(finishTime1);
}
AjaxResult ajaxResult3=thirdPartyServiceFeign.userGet(getProcessInstanceResponseBodyResultTasks.getUserId());
if("200".equals(String.valueOf(ajaxResult3.get("code")))){
Map<String,Object> map2 = com.alibaba.fastjson2.JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult3.get("data")), Map.class);
OapiV2UserGetResponse oapiV2UserGetResponse = com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.toJSONString(map2), OapiV2UserGetResponse.class);
if(ObjectUtil.isNull(startProcessInstanceResponse)){
}else{
tasksDO.setUserName(oapiV2UserGetResponse.getResult().getName());
}
}
tasksDOList.add(tasksDO);
}
}
workflowProcessInstancesByIdDO.setOperationRecords(operationRecordsDOList);
workflowProcessInstancesByIdDO.setTasks(tasksDOList);
}
return workflowProcessInstancesByIdDO;
}
}
}
return null;
}
/**
* 审核结果出现后业务数据同步更新
* @return
*/
private boolean yfdjAudit(List<BusinessDocumentDetali> detailList,Integer auditStatus,String auditRemark,LoginUser loginUser){
Date now = new Date();
List<Verification> verificationList = new ArrayList<>();
List<BusinessDocumentDetali> businessDocumentDetaliUpdateList = new ArrayList<>();
List<BusinessDocumentDetaliDTO> businessDocumentDetailDtoList = new ArrayList<>();
//将已经
for (BusinessDocumentDetali detail:detailList) {
log.error(detail.getBusinessDocumentDetaliNumber()+"应付单据号查询的审核状态为==="+detail.getAuditStatus()+",本次审核状态为:"+auditStatus);
/* if(detail.getAuditStatus()==2||detail.getAuditStatus()==3||detail.getAuditStatus()==4){
continue;
}*/
log.error("应付单据号:"+detail.getBusinessDocumentDetaliNumber()+",审核通过或拒绝");
//只有同意的才生成应付账单
if(auditStatus== ApproveStatusEnum.AGREE.getKey()){
if(SubjectCodeEnum.first_zycl_clhs.getCode().equals(detail.getFirstSubject())){//车辆核算的单独处理
//查询要自有车辆费用明细
R<List<SecondSubjectPO>> secondSubjectList = wlhyServiceFeign.getZyclClhsSecondSubjectList(detail.getBusinessCocumentId());
if (secondSubjectList.getCode() == R.SUCCESS&&secondSubjectList.getData().size()>0){
for (SecondSubjectPO secondSubjectPO:secondSubjectList.getData()) {
Verification verification = packVerication(detail);
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
int randomFour = (int) (Math.random() * 9000 + 1000);
String format = sd.format(now);
String innerNumber = "YF" + format + randomFour;//应付单据号
verification.setSecondSubject(secondSubjectPO.getSecondSubject());
verification.setSecondSubjectName(secondSubjectPO.getSecondSubjectName());
verification.setVerificationMoney(secondSubjectPO.getAmount());
verification.setInnerNumber(innerNumber);
verification.setAuditRemark(auditRemark);
verification.setBillRemarks(detail.getRemark());
verification.setPaymentMethod(detail.getPaymentMethod());
verification.setFuelCardNumber(detail.getFuelCardNumber());
if(ObjectUtil.isNotNull(loginUser)){
verification.setCreateBy(loginUser.getUserid());
verification.setCreateByName(loginUser.getUsername());
}
verification.setPayType(secondSubjectPO.getPayType());
//司机工资收款人单独处理
if(com.mhd.common.core.utils.StringUtils.isNotBlank(secondSubjectPO.getPayName())){
verification.setPayId("");//传递的收款人姓名没有对应id
verification.setPayName(secondSubjectPO.getPayName());
}
verificationList.add(verification);
}
}else{
throw new ServiceException("查询车辆核算二级科目异常!");
}
}else{
Verification verification = packVerication(detail);
SimpleDateFormat sd = new SimpleDateFormat("yyMMddHHmm");
int randomFour = (int) (Math.random() * 9000 + 1000);
String format = sd.format(now);
String innerNumber = "YF" + format + randomFour;//应付单据号
verification.setInnerNumber(innerNumber);
verification.setAuditRemark(auditRemark);
log.error("用户登录信息loginUser==="+loginUser);
if(ObjectUtil.isNotNull(loginUser)){
log.error("用户登录信息loginUser.userName==="+loginUser.getUsername());
verification.setCreateBy(loginUser.getUserid());
verification.setCreateByName(loginUser.getUsername());
}
verification.setPayType(detail.getSecondSubjectName());//付款方式油卡借款/现金借款=>与二级科目保持一致
verificationList.add(verification);
}
}
detail.setAuditStatus(auditStatus);//审批结果
detail.setAuditRemark(auditRemark);
detail.setPaymentStatus(1);//未支付
detail.setAuditType(2);//人工审批
if(ObjectUtil.isNotNull(loginUser)){
detail.setUpdateBy(loginUser.getUserid());
detail.setUpdateByName(loginUser.getUsername());
}
detail.setUpdateTime(now);
businessDocumentDetaliUpdateList.add(detail);
BusinessDocumentDetaliDTO detailDto = new BusinessDocumentDetaliDTO();
BeanUtils.copyProperties(detail,detailDto);
detailDto.setAuditRemark(auditRemark);
businessDocumentDetailDtoList.add(detailDto);
//车辆维修单同步工时费申请状态
if(auditStatus==2||auditStatus==3||auditStatus==4){
if(detail.getFirstSubject().equals("zycl_clwx")){
EditPaymentStatusDTO editPaymentStatusDTO=new EditPaymentStatusDTO();
editPaymentStatusDTO.setId(detail.getBusinessCocumentId());
if(auditStatus==2){
editPaymentStatusDTO.setPaymentStatus(3);
}else if(auditStatus==3||auditStatus==4){
editPaymentStatusDTO.setPaymentStatus(2);
}else if(auditStatus==4){
editPaymentStatusDTO.setPaymentStatus(5);
}
AjaxResult ajaxResult = wlhyServiceFeign.editPaymentStatus(editPaymentStatusDTO);
if (null != ajaxResult && !"200".equals(String.valueOf(ajaxResult.get("code")))) {
log.error("同步车辆维修工时费支付状态信息失败:" + ajaxResult.get("msg"));
throw new ServiceException("同步车辆维修工时费支付状态信息失败:" + ajaxResult.get("msg"));
}
}
}
}
//更新详情数据
if (!businessDocumentDetaliUpdateList.isEmpty()){
boolean saveFlag = businessDocumentDetaliDomainService.updateBatch(businessDocumentDetaliUpdateList);
if(!saveFlag){
throw new ServiceException("更新应付单据审核信息失败!");
}
}
//应付账单
if (!verificationList.isEmpty()){
boolean saveFlag = verificationDomainService.batchAddVerification(verificationList);
if(!saveFlag){
throw new ServiceException("保存应付账单失败!");
}
}
//推送数据到tms:审核通过修改单据状态为待付款审核拒绝修改状态为已拒绝并处理相关逻辑
if(businessDocumentDetailDtoList.size()>0){
AjaxResult ajaxResult = wlhyServiceFeign.syncBusinessDocumentInfo(businessDocumentDetailDtoList);
if (null != ajaxResult && !"200".equals(String.valueOf(ajaxResult.get("code")))) {
log.error("同步TMS业务单据信息失败:" + ajaxResult.get("msg"));
throw new ServiceException("同步TMS业务单据信息失败:" + ajaxResult.get("msg"));
}
}
return true;
}
public Verification packVerication(BusinessDocumentDetali businessDocumentDetaliDTO){
Date date = new Date();
Verification verification = new Verification();
verification.setOrganizationId(businessDocumentDetaliDTO.getOrganizationId());
verification.setTopOrganizationId(businessDocumentDetaliDTO.getTopOrganizationId());
verification.setVerificationStatus(1);//未支付
verification.setBusinessDocumentDetaliId(businessDocumentDetaliDTO.getBusinessDocumentDetaliId());
verification.setBusinessDocumentDetaliNumber(businessDocumentDetaliDTO.getBusinessDocumentDetaliNumber());
verification.setBusinessDocumentId(businessDocumentDetaliDTO.getBusinessCocumentId());
verification.setBusinessDocumentNumber(businessDocumentDetaliDTO.getWaybillNumber());
verification.setBusinessType(businessDocumentDetaliDTO.getBusinessType());
verification.setEnterAccountTime(date);
verification.setExpenseItem(businessDocumentDetaliDTO.getExpenseItem());
verification.setFirstSubject(businessDocumentDetaliDTO.getFirstSubject());
verification.setFirstSubjectName(businessDocumentDetaliDTO.getFirstSubjectName());
verification.setSecondSubject(businessDocumentDetaliDTO.getSecondSubject());
verification.setSecondSubjectName(businessDocumentDetaliDTO.getSecondSubjectName());
verification.setVerificationMoney(businessDocumentDetaliDTO.getAmount());
verification.setAuditRemark(businessDocumentDetaliDTO.getAuditRemark());
verification.setPayee(businessDocumentDetaliDTO.getPayee());
verification.setPayId(businessDocumentDetaliDTO.getPayId());
verification.setPayName(businessDocumentDetaliDTO.getPayName());
verification.setLicenseNumber(businessDocumentDetaliDTO.getLicenseNumber());
verification.setDepartmentId(businessDocumentDetaliDTO.getDepartmentId());
verification.setDepartmentName(businessDocumentDetaliDTO.getDepartmentName());
verification.setAccountHolderBank("");
verification.setCreateTime(date);
verification.setBillRemarks(businessDocumentDetaliDTO.getRemark());
verification.setPaymentMethod(businessDocumentDetaliDTO.getPaymentMethod());
verification.setFuelCardNumber(businessDocumentDetaliDTO.getFuelCardNumber());
return verification;
}
@Override
public void workflowProcessInstancesMore(String ids) {
String [] idList=ids.split(",");
LoginUser loginUser= SecurityUtils.getLoginUser();
for (String id:idList) {
ApprovalDocument approvalDocument=approvalDocumentMapper.selectById(id);
if(ObjectUtil.isNotNull(approvalDocument)){
if(StringUtils.isNotBlank(approvalDocument.getApprovalOrderNumber())){
AjaxResult ajaxResult1=thirdPartyServiceFeign.processInstancesById(approvalDocument.getApprovalOrderNumber());
if(ObjectUtil.isNotNull(ajaxResult1)&&"200".equals(String.valueOf(ajaxResult1.get("code")))){
if(null==ajaxResult1.get("data")){
throw new ServiceException("更新状态失败");
}
Map<String,Object> map = com.alibaba.fastjson2.JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult1.get("data")), Map.class);
GetProcessInstanceResponse startProcessInstanceResponse = com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.toJSONString(map), GetProcessInstanceResponse.class);
WorkflowProcessInstancesByIdDO workflowProcessInstancesByIdDO=new WorkflowProcessInstancesByIdDO();
if(ObjectUtil.isNull(startProcessInstanceResponse)){
throw new ServiceException("获取单个审批实例详情失败");
}else{
if(approvalDocument.getApprovalFormSource().equals("应付单据")){
List<BusinessDocumentDetali> businessDocumentDetaliList=businessDocumentDetaliMapper.selectList(new QueryWrapper<BusinessDocumentDetali>()
.lambda().eq(BusinessDocumentDetali::getInstanceId,approvalDocument.getApprovalOrderNumber())
.eq(BusinessDocumentDetali::getDelFlag,1));
for (BusinessDocumentDetali businessDocumentDetali1:businessDocumentDetaliList){
if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("RUNNING")){
businessDocumentDetali1.setApprovalStatus(2);
businessDocumentDetali1.setAuditStatus(1);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("TERMINATED")){
businessDocumentDetali1.setApprovalStatus(3);
businessDocumentDetali1.setAuditStatus(4);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("COMPLETED")){
businessDocumentDetali1.setApprovalStatus(4);
if(startProcessInstanceResponse.getBody().getResult().getResult().equals("agree")){
businessDocumentDetali1.setAuditStatus(2);
}else if(startProcessInstanceResponse.getBody().getResult().getResult().equals("refuse")){
businessDocumentDetali1.setAuditStatus(3);
}
}
businessDocumentDetali1.setApprovalResult(startProcessInstanceResponse.getBody().getResult().getResult());
businessDocumentDetaliMapper.updateById(businessDocumentDetali1);
}
}else if(approvalDocument.getApprovalFormSource().equals("应收单据")){
List<Reconciliation> reconciliationList=reconciliationMapper.selectList(new QueryWrapper<Reconciliation>()
.lambda().eq(Reconciliation::getInstanceId,approvalDocument.getApprovalOrderNumber())
.eq(Reconciliation::getDelFlag,1));
for (Reconciliation reconciliation:reconciliationList){
if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("RUNNING")){
reconciliation.setApprovalStatus(2);
reconciliation.setAuditStatus(1);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("TERMINATED")){
reconciliation.setApprovalStatus(3);
reconciliation.setAuditStatus(4);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("COMPLETED")){
reconciliation.setApprovalStatus(4);
if(startProcessInstanceResponse.getBody().getResult().getResult().equals("agree")){
reconciliation.setAuditStatus(2);
}else if(startProcessInstanceResponse.getBody().getResult().getResult().equals("refuse")){
reconciliation.setAuditStatus(3);
}
}
reconciliation.setApprovalResult(startProcessInstanceResponse.getBody().getResult().getResult());
reconciliationMapper.updateById(reconciliation);
}
}
if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("RUNNING")){
approvalDocument.setApprovalStatus(1L);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("TERMINATED")){
approvalDocument.setApprovalStatus(4L);
}else if(startProcessInstanceResponse.getBody().getResult().getStatus().equals("COMPLETED")){
if(startProcessInstanceResponse.getBody().getResult().getResult().equals("agree")){
approvalDocument.setApprovalStatus(2L);
}else if(startProcessInstanceResponse.getBody().getResult().getResult().equals("refuse")){
approvalDocument.setApprovalStatus(3L);
}
}
approvalDocument.setApprovalTitle(startProcessInstanceResponse.getBody().getResult().getTitle());
approvalDocument.setApprovalNumber(startProcessInstanceResponse.getBody().getResult().getBusinessId());
if(StringUtils.isNotBlank(startProcessInstanceResponse.getBody().getResult().getFinishTime())){
String finishTime=startProcessInstanceResponse.getBody().getResult().getFinishTime().replace("T"," ").replace("Z",":00");;
approvalDocument.setFinishTime(finishTime);
}
approvalDocument.setUpdateBy(loginUser.getUserid());
approvalDocument.setUpdateByName(loginUser.getUsername());
approvalDocument.setUpdateTime(new Date());
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks> tasks=startProcessInstanceResponse.getBody().getResult().getTasks();
if(ObjectUtil.isNotNull(tasks)&&tasks.size()>0){
String userId=tasks.get(tasks.size()-1).getUserId();
approvalDocument.setCurrentApprover(userId);
AjaxResult ajaxResult2=thirdPartyServiceFeign.userGet(userId);
if("200".equals(String.valueOf(ajaxResult2.get("code")))){
Map<String,Object> map1 = com.alibaba.fastjson2.JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult2.get("data")), Map.class);
OapiV2UserGetResponse oapiV2UserGetResponse = com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.toJSONString(map1), OapiV2UserGetResponse.class);
if(ObjectUtil.isNull(startProcessInstanceResponse)){
throw new ServiceException("获取单个审批实例详情失败");
}else{
approvalDocument.setCurrentApproverName(oapiV2UserGetResponse.getResult().getName());
}
}
approvalDocumentMapper.updateById(approvalDocument);
}
GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResult getProcessInstanceResponseBodyResult=startProcessInstanceResponse.getBody().getResult();
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultOperationRecords> operationRecordsList=getProcessInstanceResponseBodyResult.getOperationRecords();
List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks> tasksList=getProcessInstanceResponseBodyResult.getTasks();
BeanUtils.copyProperties(getProcessInstanceResponseBodyResult,workflowProcessInstancesByIdDO);
AjaxResult ajaxResult4=thirdPartyServiceFeign.userGet(getProcessInstanceResponseBodyResult.getOriginatorUserId());
if("200".equals(String.valueOf(ajaxResult4.get("code")))){
Map<String,Object> map2 = com.alibaba.fastjson2.JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult4.get("data")), Map.class);
OapiV2UserGetResponse oapiV2UserGetResponse = com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.toJSONString(map2), OapiV2UserGetResponse.class);
if(ObjectUtil.isNull(startProcessInstanceResponse)){
}else{
workflowProcessInstancesByIdDO.setOriginatorUserName(oapiV2UserGetResponse.getResult().getName());
}
}
String createTime2=getProcessInstanceResponseBodyResult.getCreateTime().replace("T"," ").replace("Z",":00");;
workflowProcessInstancesByIdDO.setCreateTime(createTime2);
if(StringUtils.isNotBlank(getProcessInstanceResponseBodyResult.getFinishTime())){
String finishTime1=getProcessInstanceResponseBodyResult.getFinishTime().replace("T"," ").replace("Z",":00");;
workflowProcessInstancesByIdDO.setFinishTime(finishTime1);
}
List<OperationRecordsDO> operationRecordsDOList=new ArrayList<OperationRecordsDO>();
List<TasksDO> tasksDOList=new ArrayList<TasksDO>();
if(ObjectUtil.isNotNull(operationRecordsList)&&operationRecordsList.size()>0){
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultOperationRecords getProcessInstanceResponseBodyResultOperationRecords:operationRecordsList){
OperationRecordsDO operationRecordsDO=new OperationRecordsDO();
BeanUtils.copyProperties(getProcessInstanceResponseBodyResultOperationRecords,operationRecordsDO);
String date=getProcessInstanceResponseBodyResultOperationRecords.getDate().replace("T"," ").replace("Z",":00");;
operationRecordsDO.setDate(date);
AjaxResult ajaxResult3=thirdPartyServiceFeign.userGet(getProcessInstanceResponseBodyResultOperationRecords.getUserId());
if("200".equals(String.valueOf(ajaxResult3.get("code")))){
Map<String,Object> map2 = com.alibaba.fastjson2.JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult3.get("data")), Map.class);
OapiV2UserGetResponse oapiV2UserGetResponse = com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.toJSONString(map2), OapiV2UserGetResponse.class);
if(ObjectUtil.isNull(startProcessInstanceResponse)){
}else{
operationRecordsDO.setUserName(oapiV2UserGetResponse.getResult().getName());
}
}
operationRecordsDOList.add(operationRecordsDO);
}
}
if(ObjectUtil.isNotNull(tasksList)&&tasksList.size()>0){
for (GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultTasks getProcessInstanceResponseBodyResultTasks:tasksList){
TasksDO tasksDO=new TasksDO();
BeanUtils.copyProperties(getProcessInstanceResponseBodyResultTasks,tasksDO);
String createTime=getProcessInstanceResponseBodyResultTasks.getCreateTime().replace("T"," ").replace("Z",":00");;
tasksDO.setCreateTime(createTime);
if(StringUtils.isNotBlank(getProcessInstanceResponseBodyResultTasks.getFinishTime())){
String finishTime1=getProcessInstanceResponseBodyResultTasks.getFinishTime().replace("T"," ").replace("Z",":00");;
tasksDO.setFinishTime(finishTime1);
}
AjaxResult ajaxResult3=thirdPartyServiceFeign.userGet(getProcessInstanceResponseBodyResultTasks.getUserId());
if("200".equals(String.valueOf(ajaxResult3.get("code")))){
Map<String,Object> map2 = com.alibaba.fastjson2.JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult3.get("data")), Map.class);
OapiV2UserGetResponse oapiV2UserGetResponse = com.alibaba.fastjson2.JSONObject.parseObject(JSONObject.toJSONString(map2), OapiV2UserGetResponse.class);
if(ObjectUtil.isNull(startProcessInstanceResponse)){
}else{
tasksDO.setUserName(oapiV2UserGetResponse.getResult().getName());
}
}
tasksDOList.add(tasksDO);
}
}
workflowProcessInstancesByIdDO.setOperationRecords(operationRecordsDOList);
workflowProcessInstancesByIdDO.setTasks(tasksDOList);
}
}
}
}
}
}
@Override
public ApprovalStatsVO getApprovalStatistics(Long orgId) {
return approvalDocumentMapper.countByStatus(orgId);
}
}
@@ -0,0 +1,96 @@
package com.linke.finance.domain.approvalDocument.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 审批单据对象 approval_document
*
* @author gen
* @date 2025-07-16
*/
@Data
@ApiModel(value = "审批单据对象", description = "审批单据响应对象")
public class ApprovalDocumentPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键id")
private Long id;
@ApiModelProperty("审批单号")
@Excel(name = "审批单号")
private String approvalOrderNumber;
@ApiModelProperty("审批类型")
@Excel(name = "审批类型")
private String approvalType;
@ApiModelProperty("审批标题")
@Excel(name = "审批标题")
private String approvalTitle;
@ApiModelProperty("审批状态 0-未审批 1-审批中 2-审批通过 3-审批拒绝 4-已撤销 5-全部")
@Excel(name = "审批状态 0-未审批 1-审批中 2-审批通过 3-审批拒绝 4-已撤销 5-全部")
private Long approvalStatus;
@ApiModelProperty("完成时间")
private String finishTime;
@ApiModelProperty("$column.columnComment")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String approvalOpinion;
@ApiModelProperty("审批单来源")
@Excel(name = "审批单来源")
private String approvalFormSource;
@ApiModelProperty("组织ID")
@Excel(name = "组织ID")
private Long organizationId;
@ApiModelProperty("一级组织ID")
@Excel(name = "一级组织ID")
private Long topOrganizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("全部数量")
@Excel(name = "全部数量")
private Integer allNumber;
@ApiModelProperty("审批中数量")
@Excel(name = "审批中数量")
private Integer underApprovalNumber;
@ApiModelProperty("通过数量")
@Excel(name = "通过数量")
private Integer passNumber;
@ApiModelProperty("撤销数量")
@Excel(name = "撤销数量")
private Integer revocationsNumber;
@ApiModelProperty("单据数量")
@Excel(name = "单据数量")
private Integer documentsNumber;
@ApiModelProperty("当前审批人id")
@Excel(name = "当前审批人id")
private String currentApprover;
@ApiModelProperty("当前审批人名称")
@Excel(name = "当前审批人名称")
private String currentApproverName;
@ApiModelProperty("钉钉审批单号")
@Excel(name = "钉钉审批单号")
private String approvalNumber;
}
@@ -0,0 +1,76 @@
package com.linke.finance.domain.approvalDocument.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* 审批单据对象 approval_document
*
* @author gen
* @date 2025-07-16
*/
@Data
public class ApprovalDocumentDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键id")
private Long id;
@ApiModelProperty("审批单号")
@Excel(name = "审批单号")
private String approvalOrderNumber;
@ApiModelProperty("审批类型")
@Excel(name = "审批类型")
private String approvalType;
@ApiModelProperty("审批标题")
@Excel(name = "审批标题")
private String approvalTitle;
@ApiModelProperty("审批状态 0-未审批 1-审批中 2-审批通过 3-审批拒绝 4-已撤销")
@Excel(name = "审批状态 0-未审批 1-审批中 2-审批通过 3-审批拒绝 4-已撤销")
private Long approvalStatus;
@ApiModelProperty("完成时间")
private String finishTime;
@ApiModelProperty("$column.columnComment")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private String approvalOpinion;
@ApiModelProperty("审批单来源")
@Excel(name = "审批单来源")
private String approvalFormSource;
@ApiModelProperty("组织ID")
@Excel(name = "组织ID")
private Long organizationId;
@ApiModelProperty("一级组织ID")
@Excel(name = "一级组织ID")
private Long topOrganizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty("钉钉审批单号")
@Excel(name = "钉钉审批单号")
private String approvalNumber;
}
@@ -0,0 +1,25 @@
package com.linke.finance.domain.approvalDocument.repository.todo;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ApprovalDocumentSumDO {
@ApiModelProperty("全部数量")
@Excel(name = "全部数量")
private Integer allNumber;
@ApiModelProperty("审批中数量")
@Excel(name = "审批中数量")
private Integer underApprovalNumber;
@ApiModelProperty("通过数量")
@Excel(name = "通过数量")
private Integer passNumber;
@ApiModelProperty("撤销数量")
@Excel(name = "撤销数量")
private Integer revocationsNumber;
}
@@ -0,0 +1,112 @@
package com.linke.finance.domain.approvalDocument.repository.todo;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody;
import com.aliyun.tea.NameInMap;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class OperationRecordsDO {
/**
* 操作人userId
*/
@ApiModelProperty("操作人userId")
public String userId;
/**
* 操作人userName
*/
@ApiModelProperty("操作人userName")
public String userName;
/**
* 操作时间
*/
@ApiModelProperty("操作时间")
public String date;
/**
* 操作类型
*
* EXECUTE_TASK_NORMAL正常执行任务
*
* EXECUTE_TASK_AGENT代理人执行任务
*
* APPEND_TASK_BEFORE前加签任务
*
* APPEND_TASK_AFTER后加签任务
*
* REDIRECT_TASK转交任务
*
* START_PROCESS_INSTANCE发起流程实例
*
* TERMINATE_PROCESS_INSTANCE终止(撤销)流程实例
*
* FINISH_PROCESS_INSTANCE结束流程实例
*
* ADD_REMARK添加评论
*
* REDIRECT_PROCESS审批退回
*
* PROCESS_CC抄送
*/
@ApiModelProperty("操作类型")
public String type;
/**
* 操作结果
*
* AGREE同意
*
* REFUSE拒绝
*
* NONE未处理
*/
@ApiModelProperty("操作结果")
public String result;
/**
* 评论内容
*/
@ApiModelProperty("评论内容")
public String remark;
/**
* 评论附件列表
*/
@ApiModelProperty("评论附件列表")
public java.util.List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultOperationRecordsAttachments> attachments;
/**
* 任务节点ID
*/
@ApiModelProperty("任务节点ID")
public String activityId;
/**
* 任务节点名称
*/
@ApiModelProperty("任务节点名称")
public String showName;
/**
* 抄送人userIds列表
*/
@ApiModelProperty("抄送人userIds列表")
public java.util.List<String> ccUserIds;
/**
* 单个图片链接
*/
@ApiModelProperty("单个图片链接")
public java.util.List<String> images;
}
@@ -0,0 +1,101 @@
package com.linke.finance.domain.approvalDocument.repository.todo;
import com.aliyun.tea.NameInMap;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class TasksDO {
/**
* 任务ID
*/
@ApiModelProperty("任务ID")
public Long taskId;
/**
* 任务处理人
*/
@ApiModelProperty("任务处理人")
public String userId;
/**
* 任务处理人名称
*/
@ApiModelProperty("任务处理人名称")
public String userName;
/**
* 任务状态
*
* NEW未启动
*
* RUNNING处理中
*
* PAUSED暂停
*
* CANCELED取消
*
* COMPLETED完成
*
* TERMINATED终止
*/
@ApiModelProperty("任务状态")
public String status;
/**
* 结果
*
* AGREE同意
*
* REFUSE拒绝
*
* REDIRECTED转交
*/
@ApiModelProperty("结果")
public String result;
/**
* 开始时间
*/
@ApiModelProperty("开始时间")
public String createTime;
/**
* 结束时间
*/
@ApiModelProperty("结束时间")
public String finishTime;
/**
* 移动端任务URL
*/
@ApiModelProperty("移动端任务URL")
public String mobileUrl;
/**
* PC端任务URL
*/
@ApiModelProperty("PC端任务URL")
public String pcUrl;
/**
* 任务节点ID
*/
@ApiModelProperty("任务节点ID")
public String activityId;
/**
* 实例ID
*/
@ApiModelProperty("实例ID")
public String processInstanceId;
}
@@ -0,0 +1,139 @@
package com.linke.finance.domain.approvalDocument.repository.todo;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponseBody;
import com.aliyun.tea.NameInMap;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class WorkflowProcessInstancesByIdDO {
/**
* 审批实例标题
*/
@ApiModelProperty("审批实例标题")
public String title;
/**
* 结束时间
*/
@ApiModelProperty("结束时间")
public String finishTime;
/**
* 发起人的userId
*/
@ApiModelProperty("发起人的userId")
public String originatorUserId;
/**
* 发起人的userId
*/
@ApiModelProperty("发起人的名称")
public String originatorUserName;
/**
* 发起人的部门-1表示根部门
*/
@ApiModelProperty("发起人的部门,-1表示根部门")
public String originatorDeptId;
/**
* 发起人的部门名称>
*/
@ApiModelProperty("发起人的部门名称")
public String originatorDeptName;
/**
* 审批状态
*
* RUNNING审批中
* TERMINATED已撤销
* COMPLETED审批完成
*/
@ApiModelProperty("审批状态")
public String status;
/**
* 审批人userId
*/
@ApiModelProperty("审批人userId")
public java.util.List<String> approverUserIds;
/**
* 抄送人userId
*/
@ApiModelProperty("抄送人userId")
public java.util.List<String> ccUserIds;
/**
* 审批结果
*
* agree同意
*
* refuse拒绝
*/
@ApiModelProperty("审批结果")
public String result;
/**
* 审批实例业务编号
*/
@ApiModelProperty("审批实例业务编号")
public String businessId;
/**
* 操作记录列表
*/
@ApiModelProperty("操作记录列表")
public java.util.List<OperationRecordsDO> operationRecords;
/**
* 任务列表
*/
@ApiModelProperty("任务列表")
public java.util.List<TasksDO> tasks;
/**
* 审批实例业务动作
*
* MODIFY表示该审批实例是基于原来的实例修改而来
* REVOKE表示该审批实例是由原来的实例撤销后重新发起的
* NONE表示正常发起
*/
@ApiModelProperty("审批实例业务动作")
public String bizAction;
/**
* 审批附属实例
*/
@ApiModelProperty("审批实例业务动作")
public java.util.List<String> attachedProcessInstanceIds;
/**
* 主流程实例标识
*/
@ApiModelProperty("主流程实例标识")
public String mainProcessInstanceId;
/**
* 表单组件详情列表
*/
@ApiModelProperty("表单组件详情列表")
public java.util.List<GetProcessInstanceResponseBody.GetProcessInstanceResponseBodyResultFormComponentValues> formComponentValues;
/**
* 用户自定义业务参数透出
*/
@ApiModelProperty("用户自定义业务参数透出")
public String bizData;
/**
* 创建时间
*/
@ApiModelProperty("创建时间")
public String createTime;
}
@@ -0,0 +1,91 @@
package com.linke.finance.domain.approvalDocument.service;
import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
import com.linke.finance.domain.approvalDocument.entity.ApprovalDocument;
import com.linke.finance.domain.approvalDocument.repository.facade.IApprovalDocumentService;
import com.linke.finance.domain.approvalDocument.repository.po.ApprovalDocumentPO;
import com.linke.finance.domain.approvalDocument.repository.todo.ApprovalDocumentDO;
import com.linke.finance.interfaces.vo.ApprovalStatsVO;
import com.linke.finance.domain.approvalDocument.repository.todo.WorkflowProcessInstancesByIdDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 审批单据
*
* @author gen
* @date 2025-07-16
*/
@Service
@Slf4j
public class ApprovalDocumentDomainService {
@Autowired
private IApprovalDocumentService approvalDocumentService;
/**
* 分页查询审批单据列表
*/
public List<ApprovalDocumentPO> queryList(ApprovalDocumentDO approvalDocumentDO) {
return approvalDocumentService.queryList(approvalDocumentDO);
}
public ApprovalStatsVO getApprovalStatistics(Long orgId){
return approvalDocumentService.getApprovalStatistics(orgId);
}
/**
* 新增审批单据
*/
public Boolean insert(ApprovalDocumentDO approvalDocumentDO) {
return approvalDocumentService.insert(approvalDocumentDO);
}
/**
* 修改审批单据
*/
public Boolean update(ApprovalDocumentDO approvalDocumentDO) {
return approvalDocumentService.update(approvalDocumentDO);
}
/**
* 批量删除审批单据
*/
public Boolean delete(Long[] ids) {
return approvalDocumentService.delete(ids);
}
/**
* 获取审批单据详细信息
*/
public ApprovalDocumentPO getInfo(Long id)
{
return approvalDocumentService.getInfo(id);
}
/**
* 根据钉钉审批id获取审批单据详细信息
*/
public ApprovalDocument getByProcessInstanceId(String processInstanceId)
{
return approvalDocumentService.getByProcessInstanceId(processInstanceId);
}
/**
* 获取单个审批实例详情
*/
public WorkflowProcessInstancesByIdDO workflowProcessInstancesById(Long businessDocumentDetaliId)
{
return approvalDocumentService.workflowProcessInstancesById(businessDocumentDetaliId);
}
public void workflowProcessInstancesMore(String ids)
{
approvalDocumentService.workflowProcessInstancesMore(ids);
}
}
@@ -0,0 +1,62 @@
package com.linke.finance.domain.approvalDocumentDetail.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 审批单据明细对象 approval_document_detail
*
* @author gen
* @date 2025-07-16
*/
@Data
public class ApprovalDocumentDetail extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("$column.columnComment")
@TableId(type = IdType.AUTO)
private Long id;
@ApiModelProperty("审批单id")
@Excel(name = "审批单id")
private Long approvalDocumentId;
@ApiModelProperty("业务单据号")
@Excel(name = "业务单据号")
private String waybillNumber;
@ApiModelProperty("金额")
@Excel(name = "金额")
private BigDecimal amount;
@ApiModelProperty("收款人姓名")
@Excel(name = "收款人姓名")
private String payName;
@ApiModelProperty("车牌号")
@Excel(name = "车牌号")
private String licenseNumber;
@ApiModelProperty("组织ID")
@Excel(name = "组织ID")
private Long organizationId;
@ApiModelProperty("一级组织ID")
@Excel(name = "一级组织ID")
private Long topOrganizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
}
@@ -0,0 +1,44 @@
package com.linke.finance.domain.approvalDocumentDetail.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linke.finance.domain.approvalDocumentDetail.entity.ApprovalDocumentDetail;
import com.linke.finance.domain.approvalDocumentDetail.repository.po.ApprovalDocumentDetailPO;
import com.linke.finance.domain.approvalDocumentDetail.repository.todo.ApprovalDocumentDetailDO;
import java.util.List;
/**
* 审批单据明细Service接口
*
* @author gen
* @date 2025-07-16
*/
public interface IApprovalDocumentDetailService extends IService<ApprovalDocumentDetail>
{
/**
* 分页查询审批单据明细列表
*/
public List<ApprovalDocumentDetailPO> queryList(ApprovalDocumentDetailDO approvalDocumentDetailDO);
/**
* 新增审批单据明细
*/
public Boolean insert(ApprovalDocumentDetailDO approvalDocumentDetailDO);
/**
* 修改审批单据明细
*/
public Boolean update(ApprovalDocumentDetailDO approvalDocumentDetailDO);
/**
* 批量删除审批单据明细
*/
public Boolean delete(Long[] ids);
/**
* 查询审批单据明细
*/
public ApprovalDocumentDetailPO getInfo(Long id);
}
@@ -0,0 +1,23 @@
package com.linke.finance.domain.approvalDocumentDetail.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.finance.domain.approvalDocumentDetail.entity.ApprovalDocumentDetail;
import com.linke.finance.domain.approvalDocumentDetail.repository.po.ApprovalDocumentDetailPO;
import com.linke.finance.domain.approvalDocumentDetail.repository.todo.ApprovalDocumentDetailDO;
import org.apache.ibatis.annotations.Param;
/**
* 审批单据明细Mapper接口
*
* @author gen
* @date 2025-07-16
*/
public interface ApprovalDocumentDetailMapper extends BaseMapper<ApprovalDocumentDetail>
{
/**
* 查询审批单据明细列表
*/
public List<ApprovalDocumentDetailPO> queryList(ApprovalDocumentDetailDO approvalDocumentDetailDO);
}
@@ -0,0 +1,82 @@
package com.linke.finance.domain.approvalDocumentDetail.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.finance.domain.approvalDocumentDetail.entity.ApprovalDocumentDetail;
import com.linke.finance.domain.approvalDocumentDetail.repository.facade.IApprovalDocumentDetailService;
import com.linke.finance.domain.approvalDocumentDetail.repository.mapper.ApprovalDocumentDetailMapper;
import com.linke.finance.domain.approvalDocumentDetail.repository.po.ApprovalDocumentDetailPO;
import com.linke.finance.domain.approvalDocumentDetail.repository.todo.ApprovalDocumentDetailDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 审批单据明细Service业务层处理
*
* @author gen
* @date 2025-07-16
*/
@Service
public class ApprovalDocumentDetailImpl extends ServiceImpl<ApprovalDocumentDetailMapper, ApprovalDocumentDetail> implements IApprovalDocumentDetailService {
@Autowired
private ApprovalDocumentDetailMapper approvalDocumentDetailMapper;
/**
* 查询审批单据明细列表
*/
@Override
public List<ApprovalDocumentDetailPO> queryList(ApprovalDocumentDetailDO approvalDocumentDetailDO)
{
return approvalDocumentDetailMapper.queryList(approvalDocumentDetailDO);
}
/**
* 新增审批单据明细
*/
@Override
public Boolean insert(ApprovalDocumentDetailDO approvalDocumentDetailDO) {
ApprovalDocumentDetail approvalDocumentDetail = new ApprovalDocumentDetail();
BeanUtils.copyProperties(approvalDocumentDetailDO,approvalDocumentDetail);
return this.save(approvalDocumentDetail);
}
/**
* 修改审批单据明细
*/
@Override
public Boolean update(ApprovalDocumentDetailDO approvalDocumentDetailDO) {
ApprovalDocumentDetail approvalDocumentDetail = new ApprovalDocumentDetail();
BeanUtils.copyProperties(approvalDocumentDetailDO,approvalDocumentDetail);
return this.updateById(approvalDocumentDetail);
}
/**
* 批量删除审批单据明细
*/
@Override
public Boolean delete(Long[] ids ) {
List<ApprovalDocumentDetail> list = new ArrayList<>();
for (Long id : ids) {
ApprovalDocumentDetail approvalDocumentDetail = new ApprovalDocumentDetail();
approvalDocumentDetail.setId(id);
approvalDocumentDetail.setDelFlag(2);
list.add(approvalDocumentDetail);
}
return this.updateBatchById(list);
}
/**
* 修改审批单据明细
*/
@Override
public ApprovalDocumentDetailPO getInfo(Long id) {
ApprovalDocumentDetail approvalDocumentDetail = this.getById(id);
ApprovalDocumentDetailPO approvalDocumentDetailPO = new ApprovalDocumentDetailPO();
BeanUtils.copyProperties(approvalDocumentDetail,approvalDocumentDetailPO);
return approvalDocumentDetailPO;
}
}
@@ -0,0 +1,62 @@
package com.linke.finance.domain.approvalDocumentDetail.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 审批单据明细对象 approval_document_detail
*
* @author gen
* @date 2025-07-16
*/
@Data
@ApiModel(value = "审批单据明细对象", description = "审批单据明细响应对象")
public class ApprovalDocumentDetailPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("$column.columnComment")
private Long id;
@ApiModelProperty("审批单id")
@Excel(name = "审批单id")
private Long approvalDocumentId;
@ApiModelProperty("业务单据号")
@Excel(name = "业务单据号")
private String waybillNumber;
@ApiModelProperty("金额")
@Excel(name = "金额")
private BigDecimal amount;
@ApiModelProperty("收款人姓名")
@Excel(name = "收款人姓名")
private String payName;
@ApiModelProperty("车牌号")
@Excel(name = "车牌号")
private String licenseNumber;
@ApiModelProperty("组织ID")
@Excel(name = "组织ID")
private Long organizationId;
@ApiModelProperty("一级组织ID")
@Excel(name = "一级组织ID")
private Long topOrganizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
}
@@ -0,0 +1,65 @@
package com.linke.finance.domain.approvalDocumentDetail.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* 审批单据明细对象 approval_document_detail
*
* @author gen
* @date 2025-07-16
*/
@Data
public class ApprovalDocumentDetailDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("$column.columnComment")
private Long id;
@ApiModelProperty("审批单id")
@Excel(name = "审批单id")
private Long approvalDocumentId;
@ApiModelProperty("业务单据号")
@Excel(name = "业务单据号")
private String waybillNumber;
@ApiModelProperty("金额")
@Excel(name = "金额")
private BigDecimal amount;
@ApiModelProperty("收款人姓名")
@Excel(name = "收款人姓名")
private String payName;
@ApiModelProperty("车牌号")
@Excel(name = "车牌号")
private String licenseNumber;
@ApiModelProperty("组织ID")
@Excel(name = "组织ID")
private Long organizationId;
@ApiModelProperty("一级组织ID")
@Excel(name = "一级组织ID")
private Long topOrganizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
}
@@ -0,0 +1,65 @@
package com.linke.finance.domain.approvalDocumentDetail.service;
import com.linke.finance.domain.approvalDocumentDetail.repository.facade.IApprovalDocumentDetailService;
import com.linke.finance.domain.approvalDocumentDetail.repository.po.ApprovalDocumentDetailPO;
import com.linke.finance.domain.approvalDocumentDetail.repository.todo.ApprovalDocumentDetailDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 审批单据明细
*
* @author gen
* @date 2025-07-16
*/
@Service
@Slf4j
public class ApprovalDocumentDetailDomainService {
@Autowired
private IApprovalDocumentDetailService approvalDocumentDetailService;
/**
* 分页查询审批单据明细列表
*/
public List<ApprovalDocumentDetailPO> queryList(ApprovalDocumentDetailDO approvalDocumentDetailDO) {
return approvalDocumentDetailService.queryList(approvalDocumentDetailDO);
}
/**
* 新增审批单据明细
*/
public Boolean insert(ApprovalDocumentDetailDO approvalDocumentDetailDO) {
return approvalDocumentDetailService.insert(approvalDocumentDetailDO);
}
/**
* 修改审批单据明细
*/
public Boolean update(ApprovalDocumentDetailDO approvalDocumentDetailDO) {
return approvalDocumentDetailService.update(approvalDocumentDetailDO);
}
/**
* 批量删除审批单据明细
*/
public Boolean delete(Long[] ids) {
return approvalDocumentDetailService.delete(ids);
}
/**
* 获取审批单据明细详细信息
*/
public ApprovalDocumentDetailPO getInfo(Long id)
{
return approvalDocumentDetailService.getInfo(id);
}
}
@@ -0,0 +1,61 @@
package com.linke.finance.domain.auditConfiguration.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 审核配置对象 audit_configuration
*
* @author gen
* @date 2024-02-28
*/
@Data
public class AuditConfiguration extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("审核配置id")
@TableId(type = IdType.AUTO)
private Long auditConfigurationId;
@ApiModelProperty("组织表id")
@Excel(name = "组织表id")
private Long organizationId;
@ApiModelProperty("一级组织表id")
@Excel(name = "一级组织表id")
private Long topOrganizationId;
@ApiModelProperty("角色表id")
@Excel(name = "角色表id")
private Long roleId;
@ApiModelProperty("角色编码")
@Excel(name = "角色编码")
private String roleCode;
@ApiModelProperty("角色名称")
@Excel(name = "角色名称")
private String roleName;
@ApiModelProperty("排序")
@Excel(name = "排序")
private Integer sort;
@ApiModelProperty("是否开启:1-开启,2-关闭")
private Integer isEnabled;
@ApiModelProperty("审核类型:1-回单审核,2-支付审核,3-结算审核")
@Excel(name = "审核类型:1-回单审核,2-支付审核,3-结算审核")
private Integer auditType;
}
@@ -0,0 +1,45 @@
package com.linke.finance.domain.auditConfiguration.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
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 java.util.List;
/**
* 审核配置Service接口
*
* @author gen
* @date 2024-02-28
*/
public interface IAuditConfigurationService extends IService<AuditConfiguration>
{
/**
* 分页查询审核配置列表
*/
public List<AuditConfigurationPO> queryList(AuditConfigurationDO auditConfigurationDO);
/**
* 新增审核配置
*/
public Boolean insert(AuditConfigurationDO auditConfigurationDO);
/**
* 修改审核配置
*/
public Boolean update(AuditConfigurationDO auditConfigurationDO);
/**
* 批量删除审核配置
*/
public Boolean delete(Long[] auditConfigurationIds);
/**
* 查询审核配置
*/
public AuditConfigurationPO getInfo(Long auditConfigurationId);
void deleteByAuditConfiguration(AuditConfigurationDO auditConfigurationDO);
}
@@ -0,0 +1,22 @@
package com.linke.finance.domain.auditConfiguration.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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;
/**
* 审核配置Mapper接口
*
* @author gen
* @date 2024-02-28
*/
public interface AuditConfigurationMapper extends BaseMapper<AuditConfiguration>
{
/**
* 查询审核配置列表
*/
public List<AuditConfigurationPO> queryList(AuditConfigurationDO auditConfigurationDO);
}
@@ -0,0 +1,89 @@
package com.linke.finance.domain.auditConfiguration.repository.persistence;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.finance.domain.auditConfiguration.entity.AuditConfiguration;
import com.linke.finance.domain.auditConfiguration.repository.facade.IAuditConfigurationService;
import com.linke.finance.domain.auditConfiguration.repository.mapper.AuditConfigurationMapper;
import com.mhd.common.core.domain.po.AuditConfigurationPO;
import com.linke.finance.domain.auditConfiguration.repository.todo.AuditConfigurationDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 审核配置Service业务层处理
*
* @author gen
* @date 2024-02-28
*/
@Service
public class AuditConfigurationImpl extends ServiceImpl<AuditConfigurationMapper, AuditConfiguration> implements IAuditConfigurationService{
@Autowired
private AuditConfigurationMapper auditConfigurationMapper;
/**
* 查询审核配置列表
*/
@Override
public List<AuditConfigurationPO> queryList(AuditConfigurationDO auditConfigurationDO)
{
return auditConfigurationMapper.queryList(auditConfigurationDO);
}
/**
* 新增审核配置
*/
@Override
public Boolean insert(AuditConfigurationDO auditConfigurationDO) {
AuditConfiguration auditConfiguration = new AuditConfiguration();
BeanUtils.copyProperties(auditConfigurationDO,auditConfiguration);
return this.save(auditConfiguration);
}
/**
* 修改审核配置
*/
@Override
public Boolean update(AuditConfigurationDO auditConfigurationDO) {
AuditConfiguration auditConfiguration = new AuditConfiguration();
BeanUtils.copyProperties(auditConfigurationDO,auditConfiguration);
return this.updateById(auditConfiguration);
}
/**
* 批量删除审核配置
*/
@Override
public Boolean delete(Long[] auditConfigurationIds ) {
List<AuditConfiguration> list = new ArrayList<>();
for (Long id : auditConfigurationIds) {
AuditConfiguration auditConfiguration = new AuditConfiguration();
auditConfiguration.setAuditConfigurationId(id);
auditConfiguration.setDelFlag(2);
list.add(auditConfiguration);
}
return this.updateBatchById(list);
}
/**
* 修改审核配置
*/
@Override
public AuditConfigurationPO getInfo(Long auditConfigurationId) {
AuditConfiguration auditConfiguration = this.getById(auditConfigurationId);
AuditConfigurationPO auditConfigurationPO = new AuditConfigurationPO();
BeanUtils.copyProperties(auditConfiguration,auditConfigurationPO);
return auditConfigurationPO;
}
@Override
public void deleteByAuditConfiguration(AuditConfigurationDO auditConfigurationDO) {
auditConfigurationMapper.delete(new LambdaQueryWrapper<AuditConfiguration>()
.eq(AuditConfiguration::getAuditType, auditConfigurationDO.getAuditType())
.eq(AuditConfiguration::getOrganizationId, auditConfigurationDO.getOrganizationId()));
}
}
@@ -0,0 +1,67 @@
package com.linke.finance.domain.auditConfiguration.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* 审核配置对象 audit_configuration
*
* @author gen
* @date 2024-02-28
*/
@Data
public class AuditConfigurationDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("审核配置id")
private Long auditConfigurationId;
@ApiModelProperty("组织表id")
@Excel(name = "组织表id")
private Long organizationId;
@ApiModelProperty("一级组织表id")
@Excel(name = "一级组织表id")
private Long topOrganizationId;
@ApiModelProperty("角色表id")
@Excel(name = "角色表id")
private Long roleId;
@ApiModelProperty("角色编码")
@Excel(name = "角色编码")
private String roleCode;
@ApiModelProperty("角色名称")
@Excel(name = "角色名称")
private String roleName;
@ApiModelProperty("排序")
@Excel(name = "排序")
private Integer sort;
@ApiModelProperty("是否开启:1-开启,2-关闭")
private Integer isEnabled;
@ApiModelProperty("审核类型:1-回单审核,2-支付审核,3-结算审核")
@Excel(name = "审核类型:1-回单审核,2-支付审核,3-结算审核")
private Integer auditType;
@ApiModelProperty("审核配置明细")
private List<AuditConfigurationDO> auditConfigurations;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
}
@@ -0,0 +1,72 @@
package com.linke.finance.domain.auditConfiguration.service;
import com.linke.finance.domain.auditConfiguration.entity.AuditConfiguration;
import com.linke.finance.domain.auditConfiguration.repository.facade.IAuditConfigurationService;
import com.mhd.common.core.domain.po.AuditConfigurationPO;
import com.linke.finance.domain.auditConfiguration.repository.todo.AuditConfigurationDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 审核配置
*
* @author gen
* @date 2024-02-28
*/
@Service
@Slf4j
public class AuditConfigurationDomainService {
@Autowired
private IAuditConfigurationService auditConfigurationService;
/**
* 分页查询审核配置列表
*/
public List<AuditConfigurationPO> queryList(AuditConfigurationDO auditConfigurationDO) {
return auditConfigurationService.queryList(auditConfigurationDO);
}
/**
* 新增审核配置
*/
public Boolean insert(AuditConfigurationDO auditConfigurationDO) {
return auditConfigurationService.insert(auditConfigurationDO);
}
/**
* 修改审核配置
*/
public Boolean update(AuditConfigurationDO auditConfigurationDO) {
return auditConfigurationService.update(auditConfigurationDO);
}
/**
* 批量删除审核配置
*/
public Boolean delete(Long[] auditConfigurationIds) {
return auditConfigurationService.delete(auditConfigurationIds);
}
/**
* 获取审核配置详细信息
*/
public AuditConfigurationPO getInfo(Long auditConfigurationId)
{
return auditConfigurationService.getInfo(auditConfigurationId);
}
public void deleteByAuditConfiguration(AuditConfigurationDO auditConfigurationDO) {
auditConfigurationService.deleteByAuditConfiguration(auditConfigurationDO);
}
public void saveBatch(List<AuditConfiguration> list) {
auditConfigurationService.saveBatch(list);
}
}
@@ -0,0 +1,135 @@
package com.linke.finance.domain.branchBill.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 网点账单对象 branch_bill
*
* @author gen
* @date 2023-11-04
*/
@Data
public class BranchBill extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("网点账单id")
@TableId(type = IdType.AUTO)
private Long branchBillId;
@ApiModelProperty("最高组织id")
@Excel(name = "最高组织id")
private Long topOrganizationId;
@ApiModelProperty("组织表id")
@Excel(name = "组织表id")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("收账网点id")
@Excel(name = "收账网点id")
private Long branchInId;
@ApiModelProperty("收账网点名称")
@Excel(name = "收账网点名称")
private String branchInName;
@ApiModelProperty("交账网点id")
@Excel(name = "交账网点id")
private Long branchOutId;
@ApiModelProperty("交账网点名称")
@Excel(name = "交账网点名称")
private String branchOutName;
@ApiModelProperty("交账记录号")
@Excel(name = "交账记录号")
private String billCode;
@ApiModelProperty("交账状态:1-未确认 2-驳回 3-确认")
@Excel(name = "交账状态:1-未确认 2-驳回 3-确认")
private Integer billStatus;
@ApiModelProperty("交账周期开始")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "交账周期开始", width = 30, dateFormat = "yyyy-MM-dd")
private Date billTimeStart;
@ApiModelProperty("交账周期结束")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "交账周期结束", width = 30, dateFormat = "yyyy-MM-dd")
private Date billTimeEnd;
@ApiModelProperty("应交金额 单位:元")
@Excel(name = "应交金额 单位:元")
private BigDecimal payableAmount;
@ApiModelProperty("上交金额 单位:元")
@Excel(name = "上交金额 单位:元")
private BigDecimal actualAmount;
@ApiModelProperty("合计收入 单位:元")
@Excel(name = "合计收入 单位:元")
private BigDecimal totalIncome;
@ApiModelProperty("合计支出 单位:元")
@Excel(name = "合计支出 单位:元")
private BigDecimal totalExpense;
@ApiModelProperty("上交笔数")
@Excel(name = "上交笔数")
private Long number;
@ApiModelProperty("上期结余 单位:元")
@Excel(name = "上期结余 单位:元")
private BigDecimal lastRemainingAmount;
@ApiModelProperty("当期结余:应交金额+上期结余-上交金额 单位:元")
@Excel(name = "当期结余:应交金额+上期结余-上交金额 单位:元")
private BigDecimal remainingAmount;
@ApiModelProperty(name = "截止时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "截止时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date deadlineTime;
@ApiModelProperty("审核时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date authTime;
@ApiModelProperty("审核网点id")
@Excel(name = "审核网点id")
private Integer authBranchId;
@ApiModelProperty("审核网点名称")
@Excel(name = "审核网点名称")
private String authBranchName;
@ApiModelProperty("审核用户id")
@Excel(name = "审核用户id")
private Integer authUserId;
@ApiModelProperty("审核用户名称")
@Excel(name = "审核用户名称")
private String authUserName;
@ApiModelProperty("上交方式(1-线下转账,2-钱包转账)")
@Excel(name = "上交方式(1-线下转账,2-钱包转账)")
private Integer payMethod;
}
@@ -0,0 +1,68 @@
package com.linke.finance.domain.branchBill.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linke.finance.domain.branchBill.entity.BranchBill;
import com.linke.finance.domain.branchBill.repository.po.BranchBillPO;
import com.linke.finance.domain.branchBill.repository.todo.BranchBillDO;
import java.util.List;
/**
* 网点账单Service接口
*
* @author gen
* @date 2023-11-04
*/
public interface IBranchBillService extends IService<BranchBill>
{
/**
* 分页查询网点账单列表
*/
public List<BranchBillPO> queryList(BranchBillDO branchBillDO);
/**
* @description 统计收账交账记录数
* @author ZhouGY
* @date 2023/11/6 16:35
* @param branchBillDO
* @return BranchBillPO
*/
public BranchBillPO countTabTotal(BranchBillDO branchBillDO);
/**
* 新增网点账单
*/
public Boolean insert(BranchBillDO branchBillDO);
/**
* 修改网点账单
*/
public Boolean update(BranchBillDO branchBillDO);
/**
* 批量删除网点账单
*/
public Boolean delete(Long[] branchBillIds);
/**
* 查询网点账单
*/
public BranchBillPO getInfo(Long branchBillId);
/**
* @description 确认收款
* @author ZhouGY
* @date 2023/11/6 17:18
* @param branchBillDO
*/
public void confirmBranchBillAmount(BranchBillDO branchBillDO);
/**
* @description 修改账单支付方式
* @author ZhouGY
* @date 2023/11/24 14:46
* @param branchBillDO
*/
public void updateBranchBillPayMethod(BranchBillDO branchBillDO);
}
@@ -0,0 +1,32 @@
package com.linke.finance.domain.branchBill.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.finance.domain.branchBill.entity.BranchBill;
import com.linke.finance.domain.branchBill.repository.po.BranchBillPO;
import com.linke.finance.domain.branchBill.repository.todo.BranchBillDO;
import org.apache.ibatis.annotations.Param;
/**
* 网点账单Mapper接口
*
* @author gen
* @date 2023-11-04
*/
public interface BranchBillMapper extends BaseMapper<BranchBill>
{
/**
* 查询网点账单列表
*/
public List<BranchBillPO> queryList(BranchBillDO branchBillDO);
/**
* @description 统计收账交账记录数
* @author ZhouGY
* @date 2023/11/6 16:35
* @param branchBillDO
* @return BranchBillPO
*/
public BranchBillPO countTabTotal(BranchBillDO branchBillDO);
}
@@ -0,0 +1,204 @@
package com.linke.finance.domain.branchBill.repository.persistence;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.finance.domain.branchBill.entity.BranchBill;
import com.linke.finance.domain.branchBill.repository.facade.IBranchBillService;
import com.linke.finance.domain.branchBill.repository.mapper.BranchBillMapper;
import com.linke.finance.domain.branchBill.repository.po.BranchBillPO;
import com.linke.finance.domain.branchBill.repository.todo.BranchBillDO;
import com.linke.finance.domain.revenueExpensesRecord.entity.RevenueExpensesRecord;
import com.linke.finance.domain.revenueExpensesRecord.repository.mapper.RevenueExpensesRecordMapper;
import com.linke.finance.domain.serviceBill.entity.ServiceBill;
import com.linke.finance.domain.serviceBill.repository.mapper.ServiceBillMapper;
import com.mhd.common.core.constant.SourceConstants;
import com.mhd.common.core.constant.SubjectConstants;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.utils.OrderSequence;
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 org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 网点账单Service业务层处理
*
* @author gen
* @date 2023-11-04
*/
@Service
@Slf4j
public class IBranchBillImpl extends ServiceImpl<BranchBillMapper, BranchBill> implements IBranchBillService {
@Autowired
private BranchBillMapper branchBillMapper;
@Autowired
private RevenueExpensesRecordMapper revenueExpensesRecordMapper;
@Autowired
private ServiceBillMapper serviceBillMapper;
/**
* 查询网点账单列表
*/
@Override
public List<BranchBillPO> queryList(BranchBillDO branchBillDO)
{
return branchBillMapper.queryList(branchBillDO);
}
/**
* @description 统计收账交账记录数
* @author ZhouGY
* @date 2023/11/6 16:35
* @param branchBillDO
* @return BranchBillPO
*/
@Override
public BranchBillPO countTabTotal(BranchBillDO branchBillDO)
{
return branchBillMapper.countTabTotal(branchBillDO);
}
/**
* 新增网点账单
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean insert(BranchBillDO branchBillDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
int count = revenueExpensesRecordMapper.update(null, new UpdateWrapper<RevenueExpensesRecord>().lambda()
// .set(RevenueExpensesRecord::getBillCode, branchBillDO.getBillCode())
// .set(RevenueExpensesRecord::getBillStatus, 2)
.set(RevenueExpensesRecord::getUpdateBy, loginUser.getUserid())
.set(RevenueExpensesRecord::getUpdateByName, loginUser.getUsername())
.set(RevenueExpensesRecord::getUpdateTime, new Date())
// .eq(RevenueExpensesRecord::getBillStatus, 1)
.eq(RevenueExpensesRecord::getDelFlag, 1)
.in(RevenueExpensesRecord::getRevenueExpensesRecordId, branchBillDO.getRevenueExpensesRecordIdList()));
if (count <= 0){
log.error("标记收支流水交账状态失败:{}", JSONUtil.toJsonStr(branchBillDO.getRevenueExpensesRecordIdList()));
throw new ServiceException("标记收支流水交账状态失败");
}
if (branchBillDO.getServiceBillIdList() != null && !branchBillDO.getServiceBillIdList().isEmpty()){
count = serviceBillMapper.update(null, new UpdateWrapper<ServiceBill>().lambda()
.set(ServiceBill::getBillCode, branchBillDO.getBillCode())
.set(ServiceBill::getBillStatus, 2)
.set(ServiceBill::getReportTime, branchBillDO.getDeadlineTime())
.set(ServiceBill::getUpdateBy, loginUser.getUserid())
.set(ServiceBill::getUpdateByName, loginUser.getUsername())
.set(ServiceBill::getUpdateTime, new Date())
.eq(ServiceBill::getBillStatus, 1)
.eq(ServiceBill::getDelFlag, 1)
.in(ServiceBill::getServiceBillId, branchBillDO.getServiceBillIdList()));
if (count <= 0){
log.error("标记服务费账单交账状态失败:{}", JSONUtil.toJsonStr(branchBillDO.getServiceBillIdList()));
throw new ServiceException("标记服务费账单交账状态失败");
}
}
BranchBill branchBill = new BranchBill();
BeanUtils.copyProperties(branchBillDO,branchBill);
branchBill.setCreateBy(loginUser.getUserid());
branchBill.setCreateTime(new Date());
branchBill.setCreateByName(loginUser.getUsername());
return save(branchBill);
}
/**
* 修改网点账单
*/
@Override
public Boolean update(BranchBillDO branchBillDO) {
BranchBill branchBill = new BranchBill();
BeanUtils.copyProperties(branchBillDO,branchBill);
return updateById(branchBill);
}
/**
* 批量删除网点账单
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean delete(Long[] branchBillIds ) {
List<BranchBill> list = new ArrayList<>();
for (Long id : branchBillIds) {
BranchBill branchBill = new BranchBill();
branchBill.setBranchBillId(id);
branchBill.setDelFlag(2);
list.add(branchBill);
}
return updateBatchById(list);
}
/**
* 修改网点账单
*/
@Override
public BranchBillPO getInfo(Long branchBillId) {
LambdaQueryWrapper<BranchBill> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BranchBill::getDelFlag,1);
queryWrapper.eq(BranchBill::getBranchBillId,branchBillId);
BranchBill branchBill = getOne(queryWrapper);
BranchBillPO branchBillPO = new BranchBillPO();
BeanUtils.copyProperties(branchBill,branchBillPO);
return branchBillPO;
}
/**
* @description 确认收款
* @author ZhouGY
* @date 2023/11/6 17:18
* @param branchBillDO
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void confirmBranchBillAmount(BranchBillDO branchBillDO){
LoginUser loginUser = SecurityUtils.getLoginUser();
int count = baseMapper.update(null, new UpdateWrapper<BranchBill>().lambda()
.set(BranchBill::getBillStatus, 3)
.set(BranchBill::getAuthBranchId, branchBillDO.getBranchInId())
.set(BranchBill::getAuthBranchName, branchBillDO.getBranchInName())
.set(BranchBill::getAuthUserId, loginUser.getUserid())
.set(BranchBill::getAuthUserName, loginUser.getUsername())
.set(BranchBill::getUpdateBy, loginUser.getUserid())
.set(BranchBill::getUpdateByName, loginUser.getUsername())
.set(BranchBill::getUpdateTime, new Date())
.eq(BranchBill::getBranchBillId, branchBillDO.getBranchBillId()));
if (count <= 0){
throw new ServiceException("确认收款失败");
}
}
/**
* @description 修改账单支付方式
* @author ZhouGY
* @date 2023/11/24 14:46
* @param branchBillDO
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void updateBranchBillPayMethod(BranchBillDO branchBillDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
int count = baseMapper.update(null, new UpdateWrapper<BranchBill>().lambda()
.set(BranchBill::getPayMethod, branchBillDO.getPayMethod())
.set(ObjUtil.isNotNull(branchBillDO.getBillStatus()), BranchBill::getBillStatus, branchBillDO.getBillStatus())
.set(BranchBill::getUpdateBy, loginUser.getUserid())
.set(BranchBill::getUpdateByName, loginUser.getUsername())
.set(BranchBill::getUpdateTime, new Date())
.eq(BranchBill::getBranchBillId, branchBillDO.getBranchBillId()));
if (count <= 0){
throw new ServiceException("确认收款失败");
}
}
}
@@ -0,0 +1,143 @@
package com.linke.finance.domain.branchBill.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* 网点账单对象 branch_bill
*
* @author gen
* @date 2023-11-04
*/
@Data
@ApiModel(value = "网点账单对象", description = "网点账单响应对象")
public class BranchBillPO extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("网点账单id")
private Long branchBillId;
@ApiModelProperty("最高组织id")
@Excel(name = "最高组织id")
private Long topOrganizationId;
@ApiModelProperty("组织表id")
@Excel(name = "组织表id")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("收账网点id")
@Excel(name = "收账网点id")
private Long branchInId;
@ApiModelProperty("收账网点名称")
@Excel(name = "收账网点名称")
private String branchInName;
@ApiModelProperty("交账网点id")
@Excel(name = "交账网点id")
private Long branchOutId;
@ApiModelProperty("交账网点名称")
@Excel(name = "交账网点名称")
private String branchOutName;
@ApiModelProperty("交账记录号")
@Excel(name = "交账记录号")
private String billCode;
@ApiModelProperty("交账状态:1-未确认 2-驳回 3-确认")
@Excel(name = "交账状态:1-未确认 2-驳回 3-确认")
private Integer billStatus;
@ApiModelProperty("交账周期开始")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "截止时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date billTimeStart;
@ApiModelProperty("交账周期结束")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "截止时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date billTimeEnd;
@ApiModelProperty("应交金额 单位:元")
@Excel(name = "应交金额 单位:元")
private BigDecimal payableAmount;
@ApiModelProperty("上交金额 单位:元")
@Excel(name = "上交金额 单位:元")
private BigDecimal actualAmount;
@ApiModelProperty("合计收入 单位:元")
@Excel(name = "合计收入 单位:元")
private BigDecimal totalIncome;
@ApiModelProperty("合计支出 单位:元")
@Excel(name = "合计支出 单位:元")
private BigDecimal totalExpense;
@ApiModelProperty("上交笔数")
@Excel(name = "上交笔数")
private Long number;
@ApiModelProperty("上期结余 单位:元")
@Excel(name = "上期结余 单位:元")
private BigDecimal lastRemainingAmount;
@ApiModelProperty("当期结余:应交金额+上期结余-上交金额 单位:元")
@Excel(name = "当期结余:应交金额+上期结余-上交金额 单位:元")
private BigDecimal remainingAmount;
@ApiModelProperty(name = "截止时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "截止时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date deadlineTime;
@ApiModelProperty("审核时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date authTime;
@ApiModelProperty("审核网点id")
@Excel(name = "审核网点id")
private Integer authBranchId;
@ApiModelProperty("审核网点名称")
@Excel(name = "审核网点名称")
private String authBranchName;
@ApiModelProperty("审核用户id")
@Excel(name = "审核用户id")
private Integer authUserId;
@ApiModelProperty("审核用户名称")
@Excel(name = "审核用户名称")
private String authUserName;
@ApiModelProperty("收账记录数")
@Excel(name = "收账记录数")
private Integer branchInNum;
@ApiModelProperty("交账记录数")
@Excel(name = "交账记录数")
private Integer branchOutNum;
@ApiModelProperty("上交方式(1-线下转账,2-钱包转账)")
@Excel(name = "上交方式(1-线下转账,2-钱包转账)")
private Integer payMethod;
}
@@ -0,0 +1,127 @@
package com.linke.finance.domain.branchBill.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author ZhouGY
* @title BranchBillPo
* @description: 客户账单上报信息统计
* @date 2023/11/4 10:15
**/
@Data
public class BranchBillStatisticsRecordPo implements Serializable
{
private static final long serialVersionUID = 1L;
@ApiModelProperty(name = "流水费用信息统计")
private Freight freight;
@ApiModelProperty(name = "缴纳费用信息统计")
private PayAmount payAmount;
@ApiModelProperty(name = "收入支出记录id集合")
private List<Long> revenueExpensesRecordIdList;
@ApiModelProperty(name = "服务费id集合")
private List<Long> serviceBillIdList;
/**
* @author ZhouGY
* @title Income
* @description: 流水费用信息统计
* @date 2023/11/4 10:15
**/
@Data
public static class Freight{
@ApiModelProperty(name = "科目")
private List<FirstSubject> firstSubject;
}
/**
* @author ZhouGY
* @title Income
* @description: 缴纳费用信息统计
* @date 2023/11/4 10:15
**/
@Data
public static class PayAmount{
@ApiModelProperty(name = "上交笔数")
private Long number;
@ApiModelProperty(name = "合计收入")
private BigDecimal totalIncome;
@ApiModelProperty(name = "合计支出")
private BigDecimal totalExpense;
@ApiModelProperty("上交金额 单位:元")
private BigDecimal actualAmount;
@ApiModelProperty(name = "应交金额:全部流水数据汇总金额,应交金额=合计收入+合计支出+服务费")
private BigDecimal payableAmount;
@ApiModelProperty(name = "上期结余:当前交账网点产生的结余情况")
private BigDecimal lastRemainingAmount;
@ApiModelProperty(name = "截止时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date deadlineTime;
}
/**
* @author ZhouGY
* @title Income
* @description: 首级科目
* @date 2023/11/4 10:15
**/
@Data
public static class FirstSubject{
@ApiModelProperty(name = "科目code")
private String subjectCode;
@ApiModelProperty(name = "科目名称")
private String subjectName;
@ApiModelProperty(name = "下级科目")
private List<Children> children;
}
/**
* @author ZhouGY
* @title Income
* @description: 下级科目
* @date 2023/11/4 10:15
**/
@Data
public static class Children{
@ApiModelProperty(name = "科目code")
private String subjectCode;
@ApiModelProperty(name = "科目名称")
private String subjectName;
@ApiModelProperty(name = "费用金额")
private BigDecimal fee;
@ApiModelProperty(name = "下级科目")
private List<Children> children;
}
}
@@ -0,0 +1,161 @@
package com.linke.finance.domain.branchBill.repository.todo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 网点账单对象 branch_bill
*
* @author gen
* @date 2023-11-04
*/
@Data
public class BranchBillDO extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("网点账单id")
private Long branchBillId;
@ApiModelProperty("最高组织id")
@Excel(name = "最高组织id")
private Long topOrganizationId;
@ApiModelProperty("组织表id")
@Excel(name = "组织表id")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("网点id")
@Excel(name = "网点id")
private Long branchId;
@ApiModelProperty("收账网点id")
@Excel(name = "收账网点id")
private Long branchInId;
@ApiModelProperty("收账网点名称")
@Excel(name = "收账网点名称")
private String branchInName;
@ApiModelProperty("交账网点id")
@Excel(name = "交账网点id")
private Long branchOutId;
@ApiModelProperty("交账网点名称")
@Excel(name = "交账网点名称")
private String branchOutName;
@ApiModelProperty("交账记录号")
@Excel(name = "交账记录号")
private String billCode;
@ApiModelProperty("交账状态:1-未确认 2-驳回 3-确认")
@Excel(name = "交账状态:1-未确认 2-驳回 3-确认")
private Integer billStatus;
@ApiModelProperty("交账周期开始")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "截止时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date billTimeStart;
@ApiModelProperty("交账周期结束")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "截止时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date billTimeEnd;
@ApiModelProperty("应交金额 单位:元")
@Excel(name = "应交金额 单位:元")
private BigDecimal payableAmount;
@ApiModelProperty("上交金额 单位:元")
@Excel(name = "上交金额 单位:元")
private BigDecimal actualAmount;
@ApiModelProperty("合计收入 单位:元")
@Excel(name = "合计收入 单位:元")
private BigDecimal totalIncome;
@ApiModelProperty("合计支出 单位:元")
@Excel(name = "合计支出 单位:元")
private BigDecimal totalExpense;
@ApiModelProperty("上交笔数")
@Excel(name = "上交笔数")
private Long number;
@ApiModelProperty("上期结余 单位:元")
@Excel(name = "上期结余 单位:元")
private BigDecimal lastRemainingAmount;
@ApiModelProperty("当期结余:应交金额+上期结余-上交金额 单位:元")
@Excel(name = "当期结余:应交金额+上期结余-上交金额 单位:元")
private BigDecimal remainingAmount;
@ApiModelProperty(name = "截止时间")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "截止时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date deadlineTime;
@ApiModelProperty("审核时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date authTime;
@ApiModelProperty("审核网点id")
@Excel(name = "审核网点id")
private Integer authBranchId;
@ApiModelProperty("审核网点名称")
@Excel(name = "审核网点名称")
private String authBranchName;
@ApiModelProperty("审核用户id")
@Excel(name = "审核用户id")
private Integer authUserId;
@ApiModelProperty("审核用户名称")
@Excel(name = "审核用户名称")
private String authUserName;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty(name = "收入支出记录id集合")
private List<Long> revenueExpensesRecordIdList;
@ApiModelProperty(name = "服务费id集合")
private List<Long> serviceBillIdList;
@ApiModelProperty(name = "记录类型:1-收账记录 2-交账记录")
private Integer type;
@ApiModelProperty(name = "交账时间查询条件开始日期")
private String createTimeStart;
@ApiModelProperty(name = "交账时间查询条件结束日期")
private String createTimeEnd;
@ApiModelProperty(name = "支付密码")
private String payPassword;
@ApiModelProperty("上交方式(1-线下转账,2-钱包转账)")
@Excel(name = "上交方式(1-线下转账,2-钱包转账)")
private Integer payMethod;
}
@@ -0,0 +1,356 @@
package com.linke.finance.domain.branchBill.service;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.linke.finance.domain.branchBill.entity.BranchBill;
import com.linke.finance.domain.branchBill.repository.facade.IBranchBillService;
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.po.BranchBillStatisticsRecordPo.*;
import com.linke.finance.domain.branchBill.repository.todo.BranchBillDO;
import com.linke.finance.domain.revenueExpensesRecord.repository.facade.RevenueExpensesRecordRepositoryInterface;
import com.linke.finance.domain.revenueExpensesRecord.repository.po.RevenueExpensesRecordPo;
import com.linke.finance.domain.serviceBill.entity.ServiceBill;
import com.linke.finance.domain.serviceBill.repository.facade.IServiceBillService;
import com.mhd.common.core.enums.DictCode;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.utils.DateUtils;
import com.mhd.common.core.utils.OrderSequence;
import com.mhd.common.redis.enums.RedisLockTypeEnum;
import com.mhd.common.redis.service.RedisLock;
import lombok.extern.slf4j.Slf4j;
import org.redisson.RedissonMultiLock;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* 网点账单
*
* @author gen
* @date 2023-11-04
*/
@Service
@Slf4j
public class BranchBillDomainService {
@Autowired
private IBranchBillService branchBillService;
@Autowired
private RevenueExpensesRecordRepositoryInterface revenueExpensesRecordRepositoryInterface;
@Autowired
private IServiceBillService serviceBillService;
/**
* 分页查询网点账单列表
*/
public List<BranchBillPO> queryList(BranchBillDO branchBillDO) {
return branchBillService.queryList(branchBillDO);
}
/**
* @description 统计收账交账记录数
* @author ZhouGY
* @date 2023/11/6 16:35
* @param branchBillDO
* @return BranchBillPO
*/
public BranchBillPO countTabTotal(BranchBillDO branchBillDO) {
return branchBillService.countTabTotal(branchBillDO);
}
/**
* 新增网点账单
*/
public Boolean insert(BranchBillDO branchBillDO) {
return branchBillService.insert(branchBillDO);
}
/**
* 修改网点账单
*/
public Boolean update(BranchBillDO branchBillDO) {
return branchBillService.update(branchBillDO);
}
/**
* 批量删除网点账单
*/
public Boolean delete(Long[] branchBillIds) {
return branchBillService.delete(branchBillIds);
}
/**
* 获取网点账单详细信息
*/
public BranchBillPO getInfo(Long branchBillId)
{
return branchBillService.getInfo(branchBillId);
}
/**
* @description 获取网点交账数据
* @author ZhouGY
* @date 2023/11/6 10:36
* @param branchBillDO
* @return BranchBillStatisticsRecordPo
*/
public BranchBillStatisticsRecordPo branchBillStatistics(BranchBillDO branchBillDO){
//查询未对账的交易流水数据
RevenueExpensesRecordPo revenueExpensesRecordPo = new RevenueExpensesRecordPo();
// revenueExpensesRecordPo.setBranchId(branchBillDO.getBranchOutId());
// revenueExpensesRecordPo.setBillStatus(1);
// revenueExpensesRecordPo.setSettleAccountsStatus(1);
revenueExpensesRecordPo.setOrderBy("first_subject_sort");
revenueExpensesRecordPo.setSortOrder("ASC");
revenueExpensesRecordPo.setDeadlineTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, branchBillDO.getDeadlineTime()));
List<RevenueExpensesRecordPo> revenueExpensesRecordPoList = revenueExpensesRecordRepositoryInterface.queryList(revenueExpensesRecordPo);
return calculateBranchBillAmount(revenueExpensesRecordPoList, branchBillDO);
}
/**
* @description 网点交账
* @author ZhouGY
* @date 2023/11/6 14:22
* @param branchBillDO
*/
public void branchPayment(BranchBillDO branchBillDO){
if (branchBillDO.getRevenueExpensesRecordIdList() == null || branchBillDO.getRevenueExpensesRecordIdList().isEmpty()){
throw new ServiceException("待交账收支流水不能为空");
}
BranchBill branchBill = branchBillService.getOne(new QueryWrapper<BranchBill>().lambda()
.eq(BranchBill::getBranchOutId, branchBillDO.getBranchOutId())
.orderByDesc(BranchBill::getDeadlineTime)
.orderByDesc(BranchBill::getBranchBillId)
.last("Limit 1"));
if (branchBill != null){
branchBillDO.setBillTimeStart(branchBill.getBillTimeEnd());
}
branchBillDO.setBillCode(OrderSequence.getOrderCode());
Date date = new Date();
branchBillDO.setBillTimeEnd(date);
RevenueExpensesRecordPo revenueExpensesRecordPo = new RevenueExpensesRecordPo();
revenueExpensesRecordPo.setRevenueExpensesRecordIdList(branchBillDO.getRevenueExpensesRecordIdList());
// revenueExpensesRecordPo.setBillStatus(1);
// revenueExpensesRecordPo.setSettleAccountsStatus(1);
revenueExpensesRecordPo.setDeadlineTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, branchBillDO.getDeadlineTime()));
List<RevenueExpensesRecordPo> revenueExpensesRecordPoList = revenueExpensesRecordRepositoryInterface.queryList(revenueExpensesRecordPo);
if (revenueExpensesRecordPoList.size() != branchBillDO.getRevenueExpensesRecordIdList().size()){
throw new ServiceException("存在已交账完成的收支流水,请重新进行网点交账!");
}
//重新计算应交金额
BranchBillStatisticsRecordPo branchBillStatisticsRecordPo = calculateBranchBillAmount(revenueExpensesRecordPoList, branchBillDO);
PayAmount payAmount = branchBillStatisticsRecordPo.getPayAmount();
branchBillDO.setPayableAmount(payAmount.getPayableAmount());
branchBillDO.setTotalIncome(payAmount.getTotalIncome());
branchBillDO.setTotalExpense(payAmount.getTotalExpense());
branchBillDO.setNumber(payAmount.getNumber());
branchBillDO.setLastRemainingAmount(payAmount.getLastRemainingAmount());
BigDecimal remainingAmount = payAmount.getPayableAmount().add(payAmount.getLastRemainingAmount()).subtract(branchBillDO.getActualAmount());
branchBillDO.setRemainingAmount(remainingAmount);
branchBillService.insert(branchBillDO);
}
/**
* @description 计算收支流水的金额
* @author ZhouGY
* @date 2023/11/6 14:02
* @param revenueExpensesRecordPoList
* @param branchBillDO
* @return BranchBillStatisticsRecordPo
*/
private BranchBillStatisticsRecordPo calculateBranchBillAmount(List<RevenueExpensesRecordPo> revenueExpensesRecordPoList, BranchBillDO branchBillDO){
/**
* 收入信息统计
*/
Map<String, List<RevenueExpensesRecordPo>> revenueExpensesRecordPoListMap = revenueExpensesRecordPoList.stream().collect(Collectors.groupingBy(RevenueExpensesRecordPo::getFirstSubject));
List<FirstSubject> firstSubjectIncomeList = new ArrayList<>();
//合计收入
BigDecimal totalIncome = BigDecimal.ZERO;
//合计支出
BigDecimal totalExpense = BigDecimal.ZERO;
//钱包支付金额
BigDecimal walletPay = BigDecimal.ZERO;
for (Map.Entry<String, List<RevenueExpensesRecordPo>> entry : revenueExpensesRecordPoListMap.entrySet()){
// 按照二级科目排序从小到大排序
List<RevenueExpensesRecordPo> revenueExpensesRecordPos = entry.getValue().stream().collect(Collectors.toList());
//一级科目
FirstSubject firstSubject = new FirstSubject();
firstSubject.setSubjectCode(revenueExpensesRecordPos.get(0).getFirstSubject());
firstSubject.setSubjectName(revenueExpensesRecordPos.get(0).getFirstSubjectName());
Map<String, Children> childrenMap = new HashMap<>();
for (RevenueExpensesRecordPo revenueExpensesRecord : revenueExpensesRecordPos) {
Children children = childrenMap.get(revenueExpensesRecord.getSecondSubject());
if (children == null) {
children = new Children();
children.setSubjectCode(revenueExpensesRecord.getSecondSubject());
children.setSubjectName(revenueExpensesRecord.getSecondSubjectName());
children.setFee(BigDecimal.ZERO);
}
BigDecimal fee = BigDecimal.ZERO;
if (revenueExpensesRecord.getRevenueExpensesType() == 1){
//合计收入
totalIncome = totalIncome.add(revenueExpensesRecord.getMoney());
fee = children.getFee().add(revenueExpensesRecord.getMoney());
}else if (revenueExpensesRecord.getRevenueExpensesType() == 2) {
//合计支出
totalExpense = totalExpense.add(revenueExpensesRecord.getMoney());
fee = children.getFee().subtract(revenueExpensesRecord.getMoney());
}
if (DictCode.PC_WALLET_PAY.getCode().equals(revenueExpensesRecord.getPayChannel())){
//钱包支付
if (revenueExpensesRecord.getRevenueExpensesType() == 1){
//钱包支付 收入
walletPay = walletPay.add(revenueExpensesRecord.getMoney());
}else if (revenueExpensesRecord.getRevenueExpensesType() == 2) {
//钱包支付 支出
walletPay = walletPay.subtract(revenueExpensesRecord.getMoney());
}
fee = children.getFee().subtract(revenueExpensesRecord.getMoney());
}
children.setFee(fee);
childrenMap.put(revenueExpensesRecord.getSecondSubject(), children);
childrenMap.put(revenueExpensesRecord.getSecondSubject(), children);
}
List<Children> childrenList = new ArrayList<>(childrenMap.values());
firstSubject.setChildren(childrenList);
firstSubjectIncomeList.add(firstSubject);
}
Freight freight = new Freight();
freight.setFirstSubject(firstSubjectIncomeList);
PayAmount payAmount = new PayAmount();
payAmount.setDeadlineTime(branchBillDO.getDeadlineTime());
payAmount.setNumber(Long.valueOf(String.valueOf(revenueExpensesRecordPoList.size())));
payAmount.setTotalIncome(totalIncome);
payAmount.setTotalExpense(totalExpense);
payAmount.setPayableAmount(totalIncome.subtract(totalExpense).subtract(walletPay));
BranchBill branchBill = branchBillService.getOne(new QueryWrapper<BranchBill>().lambda()
.eq(BranchBill::getBranchOutId, branchBillDO.getBranchOutId())
.orderByDesc(BranchBill::getDeadlineTime)
.orderByDesc(BranchBill::getBranchBillId)
.last("Limit 1"));
if (branchBill != null){
payAmount.setLastRemainingAmount(branchBill.getRemainingAmount());
}else {
payAmount.setLastRemainingAmount(BigDecimal.ZERO);
}
BranchBillStatisticsRecordPo branchBillStatisticsRecordPo = new BranchBillStatisticsRecordPo();
branchBillStatisticsRecordPo.setFreight(freight);
branchBillStatisticsRecordPo.setPayAmount(payAmount);
List<Long> revenueExpensesRecordIdList = revenueExpensesRecordPoList.stream().map(RevenueExpensesRecordPo::getRevenueExpensesRecordId).collect(Collectors.toList());
branchBillStatisticsRecordPo.setRevenueExpensesRecordIdList(revenueExpensesRecordIdList);
return branchBillStatisticsRecordPo;
}
/**
* @description 确认收款
* @author ZhouGY
* @date 2023/11/6 17:18
* @param branchBillDO
*/
public void confirmBranchBillAmount(BranchBillDO branchBillDO){
branchBillService.confirmBranchBillAmount(branchBillDO);
}
/**
* @description 获取网点交账详情
* @author ZhouGY
* @date 2023/11/6 14:22
* @param branchBillId
*/
public BranchBillStatisticsRecordPo getBranchPaymentDetail(Long branchBillId){
BranchBillPO branchBillPO = branchBillService.getInfo(branchBillId);
if (branchBillPO == null){
throw new ServiceException("网点交账信息不存在");
}
RevenueExpensesRecordPo revenueExpensesRecordPo = new RevenueExpensesRecordPo();
// revenueExpensesRecordPo.setBillCode(branchBillPO.getBillCode());
List<RevenueExpensesRecordPo> revenueExpensesRecordPoList = revenueExpensesRecordRepositoryInterface.queryList(revenueExpensesRecordPo);
/**
* 收入信息统计
*/
Map<String, List<RevenueExpensesRecordPo>> revenueExpensesRecordPoListMap = revenueExpensesRecordPoList.stream().collect(Collectors.groupingBy(RevenueExpensesRecordPo::getFirstSubject));
List<FirstSubject> firstSubjectIncomeList = new ArrayList<>();
//合计收入
BigDecimal totalIncome = BigDecimal.ZERO;
//合计支出
BigDecimal totalExpense = BigDecimal.ZERO;
for (Map.Entry<String, List<RevenueExpensesRecordPo>> entry : revenueExpensesRecordPoListMap.entrySet()){
// 按照二级科目排序从小到大排序
List<RevenueExpensesRecordPo> revenueExpensesRecordPos = entry.getValue().stream().collect(Collectors.toList());
//一级科目
FirstSubject firstSubject = new FirstSubject();
firstSubject.setSubjectCode(revenueExpensesRecordPos.get(0).getFirstSubject());
firstSubject.setSubjectName(revenueExpensesRecordPos.get(0).getFirstSubjectName());
Map<String, Children> childrenMap = new HashMap<>();
for (RevenueExpensesRecordPo revenueExpensesRecord : revenueExpensesRecordPos) {
Children children = childrenMap.get(revenueExpensesRecord.getSecondSubject());
if (children == null) {
children = new Children();
children.setSubjectCode(revenueExpensesRecord.getSecondSubject());
children.setSubjectName(revenueExpensesRecord.getSecondSubjectName());
children.setFee(BigDecimal.ZERO);
}
BigDecimal fee = BigDecimal.ZERO;
if (revenueExpensesRecord.getRevenueExpensesType() == 1){
//合计收入
totalIncome = totalIncome.add(revenueExpensesRecord.getMoney());
fee = children.getFee().add(revenueExpensesRecord.getMoney());
}else if (revenueExpensesRecord.getRevenueExpensesType() == 2) {
//合计支出
totalExpense = totalExpense.add(revenueExpensesRecord.getMoney());
fee = children.getFee().subtract(revenueExpensesRecord.getMoney());
}
children.setFee(fee);
childrenMap.put(revenueExpensesRecord.getSecondSubject(), children);
childrenMap.put(revenueExpensesRecord.getSecondSubject(), children);
}
List<Children> childrenList = new ArrayList<>(childrenMap.values());
firstSubject.setChildren(childrenList);
firstSubjectIncomeList.add(firstSubject);
}
Freight freight = new Freight();
freight.setFirstSubject(firstSubjectIncomeList);
PayAmount payAmount = new PayAmount();
payAmount.setDeadlineTime(branchBillPO.getDeadlineTime());
payAmount.setNumber(Long.valueOf(String.valueOf(revenueExpensesRecordPoList.size())));
payAmount.setTotalIncome(totalIncome);
payAmount.setTotalExpense(totalExpense);
payAmount.setPayableAmount(totalIncome.subtract(totalExpense));
payAmount.setLastRemainingAmount(branchBillPO.getRemainingAmount());
payAmount.setActualAmount(branchBillPO.getActualAmount());
BranchBillStatisticsRecordPo branchBillStatisticsRecordPo = new BranchBillStatisticsRecordPo();
branchBillStatisticsRecordPo.setFreight(freight);
branchBillStatisticsRecordPo.setPayAmount(payAmount);
return branchBillStatisticsRecordPo;
}
/**
* @description 修改账单支付方式
* @author ZhouGY
* @date 2023/11/24 14:57
* @param branchBillDO
*/
public void updateBranchBillPayMethod(BranchBillDO branchBillDO){
branchBillService.updateBranchBillPayMethod(branchBillDO);
}
}
@@ -0,0 +1,77 @@
package com.linke.finance.domain.branchBillOtherFee.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 网点账单其他费用对象 branch_bill_other_fee
*
* @author gen
* @date 2023-11-09
*/
@Data
public class BranchBillOtherFee extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("网点账单其他费用id")
@TableId(type = IdType.AUTO)
private Long branchBillOtherFeeId;
@ApiModelProperty("最高组织id")
@Excel(name = "最高组织id")
private Long topOrganizationId;
@ApiModelProperty("组织表id")
@Excel(name = "组织表id")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("网点费用账单编码")
@Excel(name = "网点费用账单编码")
private String billCode;
@ApiModelProperty("关联订单id")
@Excel(name = "关联订单id")
private Long associationOrderId;
@ApiModelProperty("关联订单编码")
@Excel(name = "关联订单编码")
private String associationOrderCode;
@ApiModelProperty("一级科目code")
@Excel(name = "一级科目code")
private String firstSubject;
@ApiModelProperty("一级科目名称")
@Excel(name = "一级科目名称")
private String firstSubjectName;
@ApiModelProperty("二级科目code")
@Excel(name = "二级科目code")
private String secondSubject;
@ApiModelProperty("二级科目名称")
@Excel(name = "二级科目名称")
private String secondSubjectName;
@ApiModelProperty("收入支出类型1.收入2.支出")
@Excel(name = "收入支出类型1.收入2.支出")
private Integer revenueExpensesType;
@ApiModelProperty("金额")
@Excel(name = "金额")
private BigDecimal money;
}
@@ -0,0 +1,43 @@
package com.linke.finance.domain.branchBillOtherFee.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linke.finance.domain.branchBillOtherFee.entity.BranchBillOtherFee;
import com.linke.finance.domain.branchBillOtherFee.repository.po.BranchBillOtherFeePO;
import com.linke.finance.domain.branchBillOtherFee.repository.todo.BranchBillOtherFeeDO;
import java.util.List;
/**
* 网点账单其他费用Service接口
*
* @author gen
* @date 2023-11-09
*/
public interface IBranchBillOtherFeeService extends IService<BranchBillOtherFee>
{
/**
* 分页查询网点账单其他费用列表
*/
public List<BranchBillOtherFeePO> queryList(BranchBillOtherFeeDO branchBillOtherFeeDO);
/**
* 新增网点账单其他费用
*/
public Boolean insert(BranchBillOtherFeeDO branchBillOtherFeeDO);
/**
* 修改网点账单其他费用
*/
public Boolean update(BranchBillOtherFeeDO branchBillOtherFeeDO);
/**
* 批量删除网点账单其他费用
*/
public Boolean delete(Long[] branchBillOtherFeeIds);
/**
* 查询网点账单其他费用
*/
public BranchBillOtherFeePO getInfo(Long branchBillOtherFeeId);
}
@@ -0,0 +1,22 @@
package com.linke.finance.domain.branchBillOtherFee.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linke.finance.domain.branchBillOtherFee.entity.BranchBillOtherFee;
import com.linke.finance.domain.branchBillOtherFee.repository.po.BranchBillOtherFeePO;
import com.linke.finance.domain.branchBillOtherFee.repository.todo.BranchBillOtherFeeDO;
import org.apache.ibatis.annotations.Param;
/**
* 网点账单其他费用Mapper接口
*
* @author gen
* @date 2023-11-09
*/
public interface BranchBillOtherFeeMapper extends BaseMapper<BranchBillOtherFee>
{
/**
* 查询网点账单其他费用列表
*/
public List<BranchBillOtherFeePO> queryList(BranchBillOtherFeeDO branchBillOtherFeeDO);
}
@@ -0,0 +1,81 @@
package com.linke.finance.domain.branchBillOtherFee.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linke.finance.domain.branchBillOtherFee.entity.BranchBillOtherFee;
import com.linke.finance.domain.branchBillOtherFee.repository.facade.IBranchBillOtherFeeService;
import com.linke.finance.domain.branchBillOtherFee.repository.mapper.BranchBillOtherFeeMapper;
import com.linke.finance.domain.branchBillOtherFee.repository.po.BranchBillOtherFeePO;
import com.linke.finance.domain.branchBillOtherFee.repository.todo.BranchBillOtherFeeDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 网点账单其他费用Service业务层处理
*
* @author gen
* @date 2023-11-09
*/
@Service
public class BranchBillOtherFeeImpl extends ServiceImpl<BranchBillOtherFeeMapper, BranchBillOtherFee> implements IBranchBillOtherFeeService{
@Autowired
private BranchBillOtherFeeMapper branchBillOtherFeeMapper;
/**
* 查询网点账单其他费用列表
*/
@Override
public List<BranchBillOtherFeePO> queryList(BranchBillOtherFeeDO branchBillOtherFeeDO)
{
return branchBillOtherFeeMapper.queryList(branchBillOtherFeeDO);
}
/**
* 新增网点账单其他费用
*/
@Override
public Boolean insert(BranchBillOtherFeeDO branchBillOtherFeeDO) {
BranchBillOtherFee branchBillOtherFee = new BranchBillOtherFee();
BeanUtils.copyProperties(branchBillOtherFeeDO,branchBillOtherFee);
return this.save(branchBillOtherFee);
}
/**
* 修改网点账单其他费用
*/
@Override
public Boolean update(BranchBillOtherFeeDO branchBillOtherFeeDO) {
BranchBillOtherFee branchBillOtherFee = new BranchBillOtherFee();
BeanUtils.copyProperties(branchBillOtherFeeDO,branchBillOtherFee);
return this.updateById(branchBillOtherFee);
}
/**
* 批量删除网点账单其他费用
*/
@Override
public Boolean delete(Long[] branchBillOtherFeeIds ) {
List<BranchBillOtherFee> list = new ArrayList<>();
for (Long id : branchBillOtherFeeIds) {
BranchBillOtherFee branchBillOtherFee = new BranchBillOtherFee();
branchBillOtherFee.setBranchBillOtherFeeId(id);
branchBillOtherFee.setDelFlag(2);
list.add(branchBillOtherFee);
}
return this.updateBatchById(list);
}
/**
* 修改网点账单其他费用
*/
@Override
public BranchBillOtherFeePO getInfo(Long branchBillOtherFeeId) {
BranchBillOtherFee branchBillOtherFee = this.getById(branchBillOtherFeeId);
BranchBillOtherFeePO branchBillOtherFeePO = new BranchBillOtherFeePO();
BeanUtils.copyProperties(branchBillOtherFee,branchBillOtherFeePO);
return branchBillOtherFeePO;
}
}
@@ -0,0 +1,77 @@
package com.linke.finance.domain.branchBillOtherFee.repository.po;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
/**
* 网点账单其他费用对象 branch_bill_other_fee
*
* @author gen
* @date 2023-11-09
*/
@Data
@ApiModel(value = "网点账单其他费用对象", description = "网点账单其他费用响应对象")
public class BranchBillOtherFeePO extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("网点账单其他费用id")
private Long branchBillOtherFeeId;
@ApiModelProperty("最高组织id")
@Excel(name = "最高组织id")
private Long topOrganizationId;
@ApiModelProperty("组织表id")
@Excel(name = "组织表id")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("网点费用账单编码")
@Excel(name = "网点费用账单编码")
private String billCode;
@ApiModelProperty("关联订单id")
@Excel(name = "关联订单id")
private Long associationOrderId;
@ApiModelProperty("关联订单编码")
@Excel(name = "关联订单编码")
private String associationOrderCode;
@ApiModelProperty("一级科目code")
@Excel(name = "一级科目code")
private String firstSubject;
@ApiModelProperty("一级科目名称")
@Excel(name = "一级科目名称")
private String firstSubjectName;
@ApiModelProperty("二级科目code")
@Excel(name = "二级科目code")
private String secondSubject;
@ApiModelProperty("二级科目名称")
@Excel(name = "二级科目名称")
private String secondSubjectName;
@ApiModelProperty("收入支出类型1.收入2.支出")
@Excel(name = "收入支出类型1.收入2.支出")
private Integer revenueExpensesType;
@ApiModelProperty("金额")
@Excel(name = "金额")
private BigDecimal money;
}
@@ -0,0 +1,79 @@
package com.linke.finance.domain.branchBillOtherFee.repository.todo;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import lombok.Data;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.List;
/**
* 网点账单其他费用对象 branch_bill_other_fee
*
* @author gen
* @date 2023-11-09
*/
@Data
public class BranchBillOtherFeeDO extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("网点账单其他费用id")
private Long branchBillOtherFeeId;
@ApiModelProperty("最高组织id")
@Excel(name = "最高组织id")
private Long topOrganizationId;
@ApiModelProperty("组织表id")
@Excel(name = "组织表id")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("网点费用账单编码")
@Excel(name = "网点费用账单编码")
private String billCode;
@ApiModelProperty("关联订单id")
@Excel(name = "关联订单id")
private Long associationOrderId;
@ApiModelProperty("关联订单编码")
@Excel(name = "关联订单编码")
private String associationOrderCode;
@ApiModelProperty("一级科目code")
@Excel(name = "一级科目code")
private String firstSubject;
@ApiModelProperty("一级科目名称")
@Excel(name = "一级科目名称")
private String firstSubjectName;
@ApiModelProperty("二级科目code")
@Excel(name = "二级科目code")
private String secondSubject;
@ApiModelProperty("二级科目名称")
@Excel(name = "二级科目名称")
private String secondSubjectName;
@ApiModelProperty("收入支出类型1.收入2.支出")
@Excel(name = "收入支出类型1.收入2.支出")
private Integer revenueExpensesType;
@ApiModelProperty("金额")
@Excel(name = "金额")
private BigDecimal money;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
}

Some files were not shown because too many files have changed in this diff Show More