付款模块
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.web.payment.appservice;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.financial.domain.PaymentRecDetail;
|
||||
import com.openhis.financial.domain.PaymentReconciliation;
|
||||
import com.openhis.web.outpatientmanage.dto.OutpatientSkinTestRecordDto;
|
||||
import com.openhis.web.payment.dto.PaymentDetailDto;
|
||||
import com.openhis.web.payment.dto.PaymentDto;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 付款应用层Service
|
||||
*
|
||||
* @author SunJQ
|
||||
* @date 2025-03-29
|
||||
*/
|
||||
public interface IPaymentRecService {
|
||||
/**
|
||||
* 付款
|
||||
* @param paymentDto
|
||||
* @return
|
||||
*/
|
||||
R<?> savePayment(PaymentDto paymentDto);
|
||||
/**
|
||||
* 取消付款
|
||||
* @param paymentDto
|
||||
* @return
|
||||
*/
|
||||
R<?> cancelPayment(PaymentDto paymentDto);
|
||||
|
||||
/**
|
||||
* 支付列表
|
||||
* @param searchKey
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
IPage<PaymentDto> getPage(String searchKey, Integer pageNo, Integer pageSize, HttpServletRequest request);
|
||||
|
||||
List<PaymentDetailDto> getDetail(PaymentDto paymentDto);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.web.payment.appservice.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.utils.AgeCalculatorUtil;
|
||||
import com.core.common.utils.AssignSeqUtil;
|
||||
import com.core.common.utils.DateUtils;
|
||||
import com.core.common.utils.MessageUtils;
|
||||
import com.core.common.utils.bean.BeanUtils;
|
||||
import com.openhis.common.constant.CommonConstants;
|
||||
import com.openhis.common.constant.PromptMsgConstant;
|
||||
import com.openhis.common.enums.*;
|
||||
import com.openhis.common.utils.EnumUtils;
|
||||
import com.openhis.common.utils.HisQueryUtils;
|
||||
import com.openhis.financial.domain.Contract;
|
||||
import com.openhis.financial.domain.PaymentRecDetail;
|
||||
import com.openhis.financial.domain.PaymentReconciliation;
|
||||
import com.openhis.financial.service.IContractService;
|
||||
import com.openhis.financial.service.IPaymentRecDetailService;
|
||||
import com.openhis.financial.service.IPaymentReconciliationService;
|
||||
import com.openhis.web.outpatientmanage.dto.OutpatientInfusionPatientDto;
|
||||
import com.openhis.web.payment.appservice.IPaymentRecService;
|
||||
import com.openhis.web.payment.dto.PaymentDetailDto;
|
||||
import com.openhis.web.payment.dto.PaymentDto;
|
||||
import com.openhis.web.payment.mapper.PaymentMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 付款应用层Service
|
||||
*
|
||||
* @author SunJQ
|
||||
* @date 2025-03-29
|
||||
*/
|
||||
@Component
|
||||
public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
@Resource
|
||||
IPaymentReconciliationService paymentReconciliationService;
|
||||
@Resource
|
||||
IPaymentRecDetailService paymentRecDetailService;
|
||||
@Resource
|
||||
IContractService contractService;
|
||||
@Resource
|
||||
AssignSeqUtil assignSeqUtil;
|
||||
@Resource
|
||||
PaymentMapper paymentMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public R<?> savePayment(PaymentDto paymentDto) {
|
||||
Contract contract = contractService.getOne(new LambdaQueryWrapper<Contract>().eq(Contract::getBusNo, paymentDto.getContractNo()));
|
||||
if (contract == null) {
|
||||
//todo:sjq 返回提示信息
|
||||
R.fail();
|
||||
}
|
||||
Category categoryEnum = Category.getByValue(contract.getCategoryEnum());
|
||||
//todo:sjq 医保支付与普通门诊支付多2207操作
|
||||
switch (categoryEnum) {
|
||||
case SELF:
|
||||
case PUBLIC:
|
||||
return normalCharge(paymentDto);
|
||||
case PROVINCIAL_INSURANCE:
|
||||
case MUNICIPAL_INSURANCE:
|
||||
return insuranceCharge(paymentDto);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 医保支付
|
||||
* @param paymentDto
|
||||
* @return
|
||||
*/
|
||||
private R<?> insuranceCharge(PaymentDto paymentDto) {
|
||||
normalCharge(paymentDto);
|
||||
//todo:sjq 调用2207
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自费支付
|
||||
* @param paymentDto
|
||||
* @return
|
||||
*/
|
||||
private R<?> normalCharge(PaymentDto paymentDto) {
|
||||
//获取参数
|
||||
List<PaymentDetailDto> paymentDetails = paymentDto.getPaymentDetails();
|
||||
PaymentReconciliation paymentReconciliation = new PaymentReconciliation();
|
||||
BigDecimal sum = BigDecimal.ZERO;
|
||||
//数额校验
|
||||
ArrayList<PaymentRecDetail> paymentRecDetails = new ArrayList<>();
|
||||
for (PaymentDetailDto paymentDetail : paymentDetails) {
|
||||
PaymentRecDetail paymentRecDetail = new PaymentRecDetail();
|
||||
BeanUtils.copyProperties(paymentDetail,paymentRecDetail);
|
||||
paymentRecDetail.setPredecessorId(paymentReconciliation.getId());
|
||||
paymentRecDetail.setAccountId(paymentDetail.getAccountId()==null?0:paymentDetail.getAccountId());
|
||||
paymentRecDetail.setResultEnum(PaymentResult.PAID.getValue());
|
||||
paymentRecDetails.add(paymentRecDetail);
|
||||
sum = sum.add(paymentRecDetail.getAmount());
|
||||
}
|
||||
if(sum.compareTo(paymentReconciliation.getTenderedAmount()) != 0){
|
||||
//todo:sjq 返回文字提示:实收金额合计不等于应收金额
|
||||
return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00010, null));
|
||||
}
|
||||
|
||||
BeanUtils.copyProperties(paymentDto, paymentReconciliation);
|
||||
paymentReconciliation.setStatusEnum(PaymentStatus.SUCCESS.getValue())
|
||||
.setPaymentNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.PAYMENT_NO.getPrefix(), 20))
|
||||
.setPaymentEnum(PaymentType.PAY.getValue());
|
||||
|
||||
//保存付款
|
||||
paymentReconciliationService.save(paymentReconciliation);
|
||||
|
||||
//保存付款详情
|
||||
paymentRecDetailService.saveBatch(paymentRecDetails);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> cancelPayment(PaymentDto paymentDto) {
|
||||
//todo:sjq 退费方法
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<PaymentDto> getPage(String searchKey, Integer pageNo, Integer pageSize, HttpServletRequest request) {
|
||||
// 构建查询条件
|
||||
QueryWrapper<PaymentDto> queryWrapper =
|
||||
HisQueryUtils.buildQueryWrapper(new PaymentDto(), searchKey,
|
||||
new HashSet<>(Arrays.asList(CommonConstants.FieldName.encouterId,
|
||||
CommonConstants.FieldName.contractNo, CommonConstants.FieldName.paymentNo)),
|
||||
request);
|
||||
|
||||
IPage<PaymentDto> paymentDtoIPage =
|
||||
paymentMapper.getPage(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
|
||||
//todo:sjq 1.是否联表查询患者名字,收款员姓名等信息 2.赋值
|
||||
// paymentDtoIPage.getRecords().forEach(e -> {
|
||||
// // 性别
|
||||
// e.setKindEnum_enumText(EnumUtils.getInfoByValue(PaymentKind.class, e.getKindEnum()));
|
||||
// // 计算年龄
|
||||
// e.setAgeString(AgeCalculatorUtil.getAge(DateUtils.parseDate(e.getBirthDate())));
|
||||
// });
|
||||
|
||||
return paymentDtoIPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaymentDetailDto> getDetail(PaymentDto paymentDto) {
|
||||
return paymentMapper.getPaymentDetailList(paymentDto.getId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.web.payment.controller;
|
||||
|
||||
import com.core.common.core.domain.R;
|
||||
import com.core.common.utils.MessageUtils;
|
||||
import com.openhis.common.constant.PromptMsgConstant;
|
||||
import com.openhis.web.payment.appservice.IPaymentRecService;
|
||||
import com.openhis.web.payment.dto.PaymentDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 付款管理
|
||||
*
|
||||
* @author SunJQ
|
||||
* @date 2025-03-29
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/payment/payment")
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class PaymentReconciliationController {
|
||||
|
||||
@Autowired
|
||||
private IPaymentRecService paymentReconciliationService;
|
||||
|
||||
/**
|
||||
* 付款
|
||||
*
|
||||
* @param paymentDto 付款实体
|
||||
*/
|
||||
@PostMapping("/charge")
|
||||
public R<?> savePayment(@Validated @RequestBody PaymentDto paymentDto) {
|
||||
return paymentReconciliationService.savePayment(paymentDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消付款
|
||||
*
|
||||
* @param paymentDto 付款实体
|
||||
*/
|
||||
@PostMapping("/uncharge")
|
||||
public R<?> cancelPayment(@RequestBody PaymentDto paymentDto) {
|
||||
return paymentReconciliationService.cancelPayment(paymentDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付列表
|
||||
* @param searchKey
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/page")
|
||||
public R<?> paymentPage(@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
|
||||
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request){
|
||||
return R
|
||||
.ok(paymentReconciliationService.getPage(searchKey, pageNo, pageSize, request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付详情
|
||||
* @param paymentDto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/detail")
|
||||
public R<?> paymentDetail(@RequestBody PaymentDto paymentDto){
|
||||
return R.ok(paymentReconciliationService.getDetail(paymentDto));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.web.payment.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 支付详情
|
||||
*
|
||||
* @author SunJQ
|
||||
* @date 2025-03-29
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PaymentDetailDto {
|
||||
|
||||
/** 付款类型 */
|
||||
private Integer targetEnum;
|
||||
|
||||
/** 账户 */
|
||||
private Long accountId;
|
||||
|
||||
/** 账户类型 */
|
||||
private Integer accountEnum;
|
||||
|
||||
/** 支付类型 */
|
||||
private Integer payEnum;
|
||||
|
||||
/** 支付类型等级 */
|
||||
private Integer payLevelEnum;
|
||||
|
||||
/** 金额 */
|
||||
private BigDecimal amount;
|
||||
|
||||
/** 找零 */
|
||||
private BigDecimal returnAmount;
|
||||
|
||||
/** 交款 */
|
||||
private BigDecimal chargeAmount;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.web.payment.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 付款入参
|
||||
*
|
||||
* @author SunJQ
|
||||
* @date 2025-03-29
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PaymentDto {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/** 发起支付的工作流程类别 */
|
||||
@NotNull
|
||||
private Integer kindEnum;
|
||||
private String kindEnum_enumText;
|
||||
|
||||
/** 付款类别 */
|
||||
@NotNull
|
||||
private Integer paymentEnum;
|
||||
private String paymentEnum_enumText;
|
||||
|
||||
/** 收款员 */
|
||||
private Long entererId;
|
||||
|
||||
/** 支付的患者ID */
|
||||
@NotNull
|
||||
private Long patientId;
|
||||
|
||||
/** 应收金额 */
|
||||
@NotNull
|
||||
private BigDecimal tenderedAmount;
|
||||
|
||||
/** 找零金额 */
|
||||
@NotNull
|
||||
private BigDecimal returnedAmount;
|
||||
|
||||
/** 付款总额 */
|
||||
@NotNull
|
||||
private BigDecimal displayAmount;
|
||||
|
||||
/** 合同编码 */
|
||||
@NotNull
|
||||
private String contractNo;
|
||||
|
||||
/** 就诊ID */
|
||||
@NotBlank
|
||||
private Long encounterId;
|
||||
|
||||
/** 收费项 */
|
||||
@NotBlank
|
||||
private String chargeItemIds;
|
||||
|
||||
/** 支付详细 */
|
||||
@NotEmpty
|
||||
private List<PaymentDetailDto> paymentDetails;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright ©2023 CJB-CNIT Team. All rights reserved
|
||||
*/
|
||||
package com.openhis.web.payment.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.openhis.web.payment.dto.PaymentDetailDto;
|
||||
import com.openhis.web.payment.dto.PaymentDto;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 付款Dao
|
||||
*
|
||||
* @author SunJQ
|
||||
* @date 2025-03-29
|
||||
*/
|
||||
public interface PaymentMapper {
|
||||
/**
|
||||
* 付款列表
|
||||
* @param page
|
||||
* @param queryWrapper
|
||||
* @return
|
||||
*/
|
||||
IPage<PaymentDto> getPage(Page<Object> page, QueryWrapper<PaymentDto> queryWrapper);
|
||||
|
||||
/**
|
||||
* 付款详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<PaymentDetailDto> getPaymentDetailList(@Param("id") Long id);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.openhis.web.cliniccharge.mapper.ChargeItemBizMapper">
|
||||
|
||||
<select id="getChargeItemPage" resultType="com.openhis.web.cliniccharge.dto.ChargeItemPageDto">
|
||||
SELECT
|
||||
id
|
||||
,status_enum
|
||||
,patient_id
|
||||
,encounter_id
|
||||
,quantity_value
|
||||
,quantity_unit
|
||||
,unit_price
|
||||
,total_price
|
||||
,service_table
|
||||
,service_id
|
||||
FROM adm_charge_item
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.openhis.web.payment.mapper.PaymentMapper">
|
||||
|
||||
<select id="getPage" resultType="com.openhis.web.payment.dto.PaymentDto">
|
||||
SELECT T1.id,
|
||||
T1.status_enum,
|
||||
T1.relation_id,
|
||||
T1.payment_no,
|
||||
T1.payment_enum,
|
||||
T1.payment_reconciliation_id,
|
||||
T1.kind_enum,
|
||||
T1.enterer_id,
|
||||
T1.issuer_enum,
|
||||
T1.patient_id,
|
||||
T1.practitioner_id,
|
||||
T1.outcome_enum,
|
||||
T1.location_id,
|
||||
T1.expiration_date,
|
||||
T1.tendered_amount,
|
||||
T1.returned_amount,
|
||||
T1.display_amount,
|
||||
T1.print_count,
|
||||
T1.contract_no,
|
||||
T1.charge_item_ids,
|
||||
T1.encouter_id,
|
||||
T1.yb_clear_flag,
|
||||
T1.account_id,
|
||||
T1.tenant_id,
|
||||
T1.delete_flag,
|
||||
T1.create_by,
|
||||
T1.create_time,
|
||||
T1.update_by,
|
||||
T1.update_time
|
||||
FROM (SELECT t.relation_id,
|
||||
t.status_enum,
|
||||
t.payment_no,
|
||||
t.payment_enum,
|
||||
t.payment_reconciliation_id,
|
||||
t.kind_enum,
|
||||
t.enterer_id,
|
||||
t.issuer_enum,
|
||||
t.patient_id,
|
||||
t.practitioner_id,
|
||||
t.outcome_enum,
|
||||
t.location_id,
|
||||
t.expiration_date,
|
||||
t.tendered_amount,
|
||||
t.returned_amount,
|
||||
t.display_amount,
|
||||
t.print_count,
|
||||
t.contract_no,
|
||||
t.charge_item_ids,
|
||||
t.encouter_id,
|
||||
t.yb_clear_flag,
|
||||
t.account_id,
|
||||
t.tenant_id,
|
||||
t.delete_flag,
|
||||
t.create_by,
|
||||
t.create_time,
|
||||
t.update_by,
|
||||
t.update_time
|
||||
FROM fin_payment_reconciliation t
|
||||
WHERE 1 = 1
|
||||
ORDER BY create_time) as T1
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
<select id="getPaymentDetailList" resultType="com.openhis.web.payment.dto.PaymentDetailDto">
|
||||
SELECT
|
||||
id,
|
||||
predecessor_id,
|
||||
target_enum,
|
||||
account_id,
|
||||
account_enum,
|
||||
pay_enum,
|
||||
pay_level_enum,
|
||||
amount,
|
||||
return_amount,
|
||||
charge_amount,
|
||||
pay_trans_no,
|
||||
pay_trans_text,
|
||||
pay_trans_date,
|
||||
before_balance,
|
||||
after_balance,
|
||||
result_enum,
|
||||
tenant_id,
|
||||
delete_flag,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time
|
||||
FROM fin_payment_rec_detail WHERE
|
||||
predecessor_id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user