|
@@ -1,8 +1,10 @@
|
|
|
package cn.hnthyy.thmz.controller.zy;
|
|
|
|
|
|
+import cn.hnthyy.thmz.Utils.HttpUtil;
|
|
|
import cn.hnthyy.thmz.Utils.NumberToCN;
|
|
|
import cn.hnthyy.thmz.Utils.TokenUtil;
|
|
|
import cn.hnthyy.thmz.comment.UserLoginToken;
|
|
|
+import cn.hnthyy.thmz.common.Constants;
|
|
|
import cn.hnthyy.thmz.entity.MzException;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.Employee;
|
|
|
import cn.hnthyy.thmz.entity.his.mz.MzPatientMi;
|
|
@@ -11,6 +13,8 @@ import cn.hnthyy.thmz.entity.his.zy.ZyActpatient;
|
|
|
import cn.hnthyy.thmz.entity.his.zy.ZyDepositFile;
|
|
|
import cn.hnthyy.thmz.entity.his.zy.ZyLedgerFile;
|
|
|
import cn.hnthyy.thmz.entity.thmz.User;
|
|
|
+import cn.hnthyy.thmz.entity.thmz.Windows;
|
|
|
+import cn.hnthyy.thmz.enums.YesNoEnum;
|
|
|
import cn.hnthyy.thmz.enums.ZyDepositFileStatusEnum;
|
|
|
import cn.hnthyy.thmz.service.his.mz.EmployeeService;
|
|
|
import cn.hnthyy.thmz.service.his.mz.MzPatientMiService;
|
|
@@ -19,13 +23,17 @@ import cn.hnthyy.thmz.service.his.zd.ZdUnitCodeService;
|
|
|
import cn.hnthyy.thmz.service.his.zy.ZyActpatientService;
|
|
|
import cn.hnthyy.thmz.service.his.zy.ZyDepositFileService;
|
|
|
import cn.hnthyy.thmz.service.his.zy.ZyLedgerFileService;
|
|
|
+import cn.hnthyy.thmz.service.thmz.TransactionService;
|
|
|
+import cn.hnthyy.thmz.service.thmz.WindowsService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -48,6 +56,11 @@ public class ZyDepositFileController {
|
|
|
private ZdUnitCodeService zdUnitCodeService;
|
|
|
@Autowired
|
|
|
private MzPatientMiService mzPatientMiService;
|
|
|
+ @Autowired
|
|
|
+ private WindowsService windowsService;
|
|
|
+ @Autowired
|
|
|
+ private TransactionService transactionService;
|
|
|
+
|
|
|
/**
|
|
|
* 根据住院号和次数查询缴费记录
|
|
|
*
|
|
@@ -79,14 +92,14 @@ public class ZyDepositFileController {
|
|
|
resultMap.put("message", "根据住院号和次数查询缴费记录成功");
|
|
|
List<ZyDepositFile> zyDepositFiles = zyDepositFileService.queryZyDepositFileBYInpatientNoAndTimes(zyDepositFile);
|
|
|
//总支付金额
|
|
|
- BigDecimal totalPay=BigDecimal.ZERO;
|
|
|
+ BigDecimal totalPay = BigDecimal.ZERO;
|
|
|
//总退费金额
|
|
|
- BigDecimal totalRefund=BigDecimal.ZERO;
|
|
|
- if(zyDepositFiles!=null && zyDepositFiles.size()>0){
|
|
|
- List<ZdChequeType> zdChequeTypes=zdChequeTypeService.queryAllZdChequeType();
|
|
|
- Map<String,String> zdChequeTypeMap=zdChequeTypes.stream().collect(Collectors.toMap(ZdChequeType::getCode,ZdChequeType::getName));
|
|
|
- ZyLedgerFile lastZyLedgerFile=zyLedgerFileService.queryLastLedgerSn(zyDepositFile.getInpatientNo(),zyDepositFile.getAdmissTimes().intValue());
|
|
|
- for (ZyDepositFile zdf:zyDepositFiles){
|
|
|
+ BigDecimal totalRefund = BigDecimal.ZERO;
|
|
|
+ if (zyDepositFiles != null && zyDepositFiles.size() > 0) {
|
|
|
+ List<ZdChequeType> zdChequeTypes = zdChequeTypeService.queryAllZdChequeType();
|
|
|
+ Map<String, String> zdChequeTypeMap = zdChequeTypes.stream().collect(Collectors.toMap(ZdChequeType::getCode, ZdChequeType::getName));
|
|
|
+ ZyLedgerFile lastZyLedgerFile = zyLedgerFileService.queryLastLedgerSn(zyDepositFile.getInpatientNo(), zyDepositFile.getAdmissTimes().intValue());
|
|
|
+ for (ZyDepositFile zdf : zyDepositFiles) {
|
|
|
zdf.setStatusName(ZyDepositFileStatusEnum.geteZyDepositFileStatusByCode(zdf.getStatus()).name);
|
|
|
//设置账页的结算状态到支付信息,做退费控制
|
|
|
zdf.setSettleType(lastZyLedgerFile.getSettleType());
|
|
@@ -95,10 +108,10 @@ public class ZyDepositFileController {
|
|
|
if (opEmployee != null) {
|
|
|
zdf.setOpIdName(opEmployee.getEmployeeName());
|
|
|
}
|
|
|
- if(ZyDepositFileStatusEnum.PREPAY.code.equals(zdf.getStatus())){
|
|
|
- totalPay= totalPay.add(zdf.getDepoAmount());
|
|
|
- }else if(ZyDepositFileStatusEnum.STRAIGHT_BACK.code.equals(zdf.getStatus())){
|
|
|
- totalRefund=totalRefund.add(zdf.getDepoAmount());
|
|
|
+ if (ZyDepositFileStatusEnum.PREPAY.code.equals(zdf.getStatus())) {
|
|
|
+ totalPay = totalPay.add(zdf.getDepoAmount());
|
|
|
+ } else if (ZyDepositFileStatusEnum.STRAIGHT_BACK.code.equals(zdf.getStatus())) {
|
|
|
+ totalRefund = totalRefund.add(zdf.getDepoAmount());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -116,8 +129,6 @@ public class ZyDepositFileController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 保存住院收费或者退费
|
|
|
*
|
|
@@ -139,15 +150,21 @@ public class ZyDepositFileController {
|
|
|
resultMap.put("message", "事务类型不能为空");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- if (StringUtils.isBlank(zyDepositFile.getDepoType())) {
|
|
|
- resultMap.put("code", -1);
|
|
|
- resultMap.put("message", "支付方式不能为空");
|
|
|
- return resultMap;
|
|
|
- }
|
|
|
+// if (StringUtils.isBlank(zyDepositFile.getDepoType())) {
|
|
|
+// resultMap.put("code", -1);
|
|
|
+// resultMap.put("message", "支付方式不能为空");
|
|
|
+// return resultMap;
|
|
|
+// }
|
|
|
User tokenUser = TokenUtil.getUser(httpServletRequest);
|
|
|
zyDepositFile.setOpIdCode(tokenUser.getUserIdCode());
|
|
|
+ if (StringUtils.isBlank(zyDepositFile.getReceiptNo())) {
|
|
|
+ zyDepositFile.setReceiptNo(null);
|
|
|
+ }
|
|
|
+ boolean isPos = false;
|
|
|
+ Windows windowsDb = null;
|
|
|
+ ZyDepositFile dbZyDepositFile = null;
|
|
|
//缴费
|
|
|
- if(ZyDepositFileStatusEnum.PREPAY.code.equals(zyDepositFile.getStatus())){
|
|
|
+ if (ZyDepositFileStatusEnum.PREPAY.code.equals(zyDepositFile.getStatus())) {
|
|
|
if (StringUtils.isBlank(zyDepositFile.getInpatientNo())) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "病人住院号不能为空");
|
|
@@ -159,43 +176,67 @@ public class ZyDepositFileController {
|
|
|
resultMap.put("message", "缴费金额不能为空");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- }else if(ZyDepositFileStatusEnum.STRAIGHT_BACK.code.equals(zyDepositFile.getStatus())){
|
|
|
- ZyDepositFile dbZyDepositFile=zyDepositFileService.queryZyDepositFileByReceiptNo(zyDepositFile.getReceiptNo());
|
|
|
- if(dbZyDepositFile==null){
|
|
|
+ } else if (ZyDepositFileStatusEnum.STRAIGHT_BACK.code.equals(zyDepositFile.getStatus())) {
|
|
|
+ String ipAddress = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
+ windowsDb = windowsService.queryLastWindowsIpAddress(ipAddress);
|
|
|
+ if (windowsDb == null) {
|
|
|
resultMap.put("code", -1);
|
|
|
- resultMap.put("message", "当前退费的收据号不存在。");
|
|
|
+ resultMap.put("message", "您暂未配置只能POS机的【路由识别码】,请配置完后重试!");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- if(!dbZyDepositFile.getDepoType().equals(zyDepositFile.getDepoType())){
|
|
|
+ dbZyDepositFile = zyDepositFileService.queryZyDepositFileByReceiptNo(zyDepositFile.getReceiptNo());
|
|
|
+ if (dbZyDepositFile == null) {
|
|
|
resultMap.put("code", -1);
|
|
|
- resultMap.put("message", "当前退费的退费方式与原收据的付款方式不一致。");
|
|
|
+ resultMap.put("message", "当前退费的收据号不存在。");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- BigDecimal depoAmount=zyDepositFileService.querySumDepoAmountByReceiptNo(zyDepositFile.getReceiptNo());
|
|
|
- if(BigDecimal.ZERO.compareTo(depoAmount)==0){
|
|
|
+ zyDepositFile.setInpatientNo(dbZyDepositFile.getInpatientNo());
|
|
|
+ isPos = YesNoEnum.YES.code.equals(zyDepositFile.getRefundType()) && Arrays.asList(Constants.BYJZ, Constants.YLK, Constants.JHZF).contains(dbZyDepositFile.getDepoType());
|
|
|
+// if(!dbZyDepositFile.getDepoType().equals(zyDepositFile.getDepoType())){
|
|
|
+// resultMap.put("code", -1);
|
|
|
+// resultMap.put("message", "当前退费的退费方式与原收据的付款方式不一致。");
|
|
|
+// return resultMap;
|
|
|
+// }
|
|
|
+ BigDecimal depoAmount = zyDepositFileService.querySumDepoAmountByReceiptNo(zyDepositFile.getReceiptNo());
|
|
|
+ if (BigDecimal.ZERO.compareTo(depoAmount) == 0) {
|
|
|
zyDepositFileService.modifyReportFlag(zyDepositFile.getReceiptNo());
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "当前操作的费用已经退过费,请勿重复操作。");
|
|
|
return resultMap;
|
|
|
}
|
|
|
//退费
|
|
|
- zyDepositFile.setDepoAmount(BigDecimal.ZERO.subtract(dbZyDepositFile.getDepoAmount()));
|
|
|
- zyDepositFile.setInpatientNo(dbZyDepositFile.getInpatientNo());
|
|
|
- zyDepositFile.setAdmissTimes(dbZyDepositFile.getAdmissTimes());
|
|
|
- zyDepositFile.setLedgerSn(dbZyDepositFile.getLedgerSn());
|
|
|
- zyDepositFile.setPrinted(dbZyDepositFile.getPrinted());
|
|
|
+// zyDepositFile.setDepoAmount(BigDecimal.ZERO.subtract(dbZyDepositFile.getDepoAmount()));
|
|
|
+// zyDepositFile.setInpatientNo(dbZyDepositFile.getInpatientNo());
|
|
|
+// zyDepositFile.setAdmissTimes(dbZyDepositFile.getAdmissTimes());
|
|
|
+// zyDepositFile.setLedgerSn(dbZyDepositFile.getLedgerSn());
|
|
|
+// zyDepositFile.setPrinted(dbZyDepositFile.getPrinted());
|
|
|
}
|
|
|
zyDepositFileService.saveZyDepositFile(zyDepositFile);
|
|
|
+ if (isPos && StringUtils.isNotBlank(windowsDb.getMisPosRouterCode())) {
|
|
|
+ String lsOrderNo = dbZyDepositFile.getPsordnum() + "_" + dbZyDepositFile.getDepoAmount().toString();
|
|
|
+ JSONObject jsonObject = transactionService.refund(windowsDb.getMisPosRouterCode(), BigDecimal.ZERO.subtract(zyDepositFile.getDepoAmount()), lsOrderNo, null, dbZyDepositFile.getDepoType(), dbZyDepositFile.getParChannel(), dbZyDepositFile.getPsordnum(), dbZyDepositFile.getTransDate(), dbZyDepositFile.getAgtordnum());
|
|
|
+ if (jsonObject == null) {
|
|
|
+ resultMap.put("code", -2);
|
|
|
+ resultMap.put("message", "住院预交金已退,但是患者智能POS退款失败,请去财务工具查询并退款!");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ String resCode = (String) jsonObject.get("resCode");
|
|
|
+ if (!"00".equals(resCode)) {
|
|
|
+ resultMap.put("code", -2);
|
|
|
+ resultMap.put("message", "住院预交金已退,但是患者智能POS退款失败,错误信息为:" + jsonObject.get("resMsg") + "请去财务工具查询并退款!");
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
resultMap.put("code", 0);
|
|
|
resultMap.put("message", "操作成功");
|
|
|
resultMap.put("receiptNo", zyDepositFile.getReceiptNo());
|
|
|
resultMap.put("zyDepositFile", zyDepositFileService.queryZyDepositFileByReceiptNo(zyDepositFile.getReceiptNo()));
|
|
|
return resultMap;
|
|
|
- }catch (MzException e){
|
|
|
+ } catch (MzException e) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", e.getMessage());
|
|
|
return resultMap;
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "保存住院收费或者退费记录出错,请联系管理员");
|
|
@@ -205,8 +246,6 @@ public class ZyDepositFileController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 根据流水号查询住院缴费单
|
|
|
*
|
|
@@ -214,7 +253,7 @@ public class ZyDepositFileController {
|
|
|
*/
|
|
|
@UserLoginToken
|
|
|
@RequestMapping(value = "/getZyDepositFileByReceiptNo", method = {RequestMethod.GET})
|
|
|
- public Map<String, Object> getZyDepositFileByReceiptNo(@RequestParam("receiptNo") String receiptNo,@RequestParam("inpatientNo") String inpatientNo) {
|
|
|
+ public Map<String, Object> getZyDepositFileByReceiptNo(@RequestParam("receiptNo") String receiptNo, @RequestParam("inpatientNo") String inpatientNo) {
|
|
|
log.info("根据流水号查询住院缴费单");
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
try {
|
|
@@ -228,34 +267,34 @@ public class ZyDepositFileController {
|
|
|
resultMap.put("message", "住院号不能为空");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- ZyDepositFile zyDepositFile=zyDepositFileService.queryZyDepositFileByReceiptNo(receiptNo);
|
|
|
- if(zyDepositFile==null){
|
|
|
+ ZyDepositFile zyDepositFile = zyDepositFileService.queryZyDepositFileByReceiptNo(receiptNo);
|
|
|
+ if (zyDepositFile == null) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "流水号对应的缴费记录不存在");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- ZyActpatient zyActpatient=zyActpatientService.queryByInpatientNo("zy_actpatient",inpatientNo,zyDepositFile.getAdmissTimes().intValue());
|
|
|
- if(zyActpatient==null){
|
|
|
+ ZyActpatient zyActpatient = zyActpatientService.queryByInpatientNo("zy_actpatient", inpatientNo, zyDepositFile.getAdmissTimes().intValue());
|
|
|
+ if (zyActpatient == null) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "住院号对应的住院记录不存在");
|
|
|
return resultMap;
|
|
|
}
|
|
|
zyActpatient.setAdmissDept(zdUnitCodeService.queryDeptNameByIdInCache(zyActpatient.getAdmissDept()));
|
|
|
- MzPatientMi mzPatientMi=mzPatientMiService.queryByPatientId(zyActpatient.getMzNo());
|
|
|
- if(mzPatientMi==null){
|
|
|
+ MzPatientMi mzPatientMi = mzPatientMiService.queryByPatientId(zyActpatient.getMzNo());
|
|
|
+ if (mzPatientMi == null) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "门诊病人不存在");
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
- ZdChequeType zdChequeType=zdChequeTypeService.queryChequeTypeByCode(zyDepositFile.getDepoType());
|
|
|
- if(zdChequeType==null){
|
|
|
+ ZdChequeType zdChequeType = zdChequeTypeService.queryChequeTypeByCode(zyDepositFile.getDepoType());
|
|
|
+ if (zdChequeType == null) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "支付方式不存在");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- Employee employee=employeeService.queryByUserCode(zyDepositFile.getOpIdCode());
|
|
|
- if(employee==null){
|
|
|
+ Employee employee = employeeService.queryByUserCode(zyDepositFile.getOpIdCode());
|
|
|
+ if (employee == null) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "操作员不存在");
|
|
|
return resultMap;
|
|
@@ -279,10 +318,6 @@ public class ZyDepositFileController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 打印住院缴费单
|
|
|
*
|
|
@@ -320,7 +355,7 @@ public class ZyDepositFileController {
|
|
|
*/
|
|
|
@UserLoginToken
|
|
|
@RequestMapping(value = "/cancelCashi", method = {RequestMethod.GET})
|
|
|
- public Map<String, Object> cancelCashi(@RequestParam("inpatientNo") String inpatientNo,@RequestParam("admissTimes") Integer admissTimes, HttpServletRequest httpServletRequest) {
|
|
|
+ public Map<String, Object> cancelCashi(@RequestParam("inpatientNo") String inpatientNo, @RequestParam("admissTimes") Integer admissTimes, HttpServletRequest httpServletRequest) {
|
|
|
log.info("根据流水号查询住院缴费单");
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
try {
|
|
@@ -329,13 +364,13 @@ public class ZyDepositFileController {
|
|
|
resultMap.put("message", "住院号不能为空");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- if (admissTimes==null) {
|
|
|
+ if (admissTimes == null) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "住院次数不能为空");
|
|
|
return resultMap;
|
|
|
}
|
|
|
User tokenUser = TokenUtil.getUser(httpServletRequest);
|
|
|
- zyDepositFileService.cancelCashi(tokenUser.getUserIdCode(),inpatientNo,admissTimes);
|
|
|
+ zyDepositFileService.cancelCashi(tokenUser.getUserIdCode(), inpatientNo, admissTimes);
|
|
|
resultMap.put("code", 0);
|
|
|
resultMap.put("message", "费用冲消成功");
|
|
|
return resultMap;
|
|
@@ -354,7 +389,6 @@ public class ZyDepositFileController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 住院费用出纳处理
|
|
|
*
|
|
@@ -366,13 +400,13 @@ public class ZyDepositFileController {
|
|
|
log.info("根据流水号查询住院缴费单");
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
try {
|
|
|
- if (zyDepositFiles==null || zyDepositFiles.size()==0) {
|
|
|
+ if (zyDepositFiles == null || zyDepositFiles.size() == 0) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "费用支付渠道不能为空");
|
|
|
return resultMap;
|
|
|
}
|
|
|
User tokenUser = TokenUtil.getUser(httpServletRequest);
|
|
|
- zyDepositFileService.teller(tokenUser.getUserIdCode(),zyDepositFiles);
|
|
|
+ zyDepositFileService.teller(tokenUser.getUserIdCode(), zyDepositFiles);
|
|
|
resultMap.put("code", 0);
|
|
|
resultMap.put("message", "出纳处理成功");
|
|
|
return resultMap;
|