|
@@ -14,10 +14,7 @@ import cn.hnthyy.thmz.entity.his.zd.ZdChargeItem;
|
|
|
import cn.hnthyy.thmz.entity.his.zd.ZdUnitCode;
|
|
|
import cn.hnthyy.thmz.entity.his.zy.ZyZdAuditItem;
|
|
|
import cn.hnthyy.thmz.entity.thmz.*;
|
|
|
-import cn.hnthyy.thmz.enums.ConfirmFlagEnum;
|
|
|
-import cn.hnthyy.thmz.enums.GenderEnum;
|
|
|
-import cn.hnthyy.thmz.enums.PayMarkEnum;
|
|
|
-import cn.hnthyy.thmz.enums.YesNoEnum;
|
|
|
+import cn.hnthyy.thmz.enums.*;
|
|
|
import cn.hnthyy.thmz.pageDto.MzChargeDetailPageDto;
|
|
|
import cn.hnthyy.thmz.service.his.mz.*;
|
|
|
import cn.hnthyy.thmz.service.his.yp.YpZdDictService;
|
|
@@ -81,6 +78,8 @@ public class MzChargeDetailController {
|
|
|
private YpZdDictService ypZdDictService;
|
|
|
@Autowired
|
|
|
private YpZdDrugKindService ypZdDrugKindService;
|
|
|
+ @Autowired
|
|
|
+ private MzDepositFileService mzDepositFileService;
|
|
|
|
|
|
/**
|
|
|
* 查询费用列表
|
|
@@ -1783,87 +1782,181 @@ public class MzChargeDetailController {
|
|
|
*/
|
|
|
@UserLoginToken
|
|
|
@RequestMapping(value = "/getChargeDetailForGuideCard", method = {RequestMethod.GET})
|
|
|
- public Map<String, Object> getChargeDetailForGuideCard(@RequestParam("patientId") String patientId, @RequestParam("times") Integer times) {
|
|
|
+ public Map<String, Object> getChargeDetailForGuideCard(@RequestParam("patientId") String patientId, @RequestParam("times") Integer times, HttpServletRequest httpServletRequest) {
|
|
|
+ Map<String, Object> results = null;
|
|
|
+ try {
|
|
|
+ results = getChargeDetailFee(patientId, times, 1, null, httpServletRequest);
|
|
|
+ BigDecimal selfAmount = (BigDecimal) results.get("selfAmount");
|
|
|
+ String payQrcode = haiCiAdapterService.genMzPayQrcode(selfAmount.multiply(BigDecimal.valueOf(100)).intValue(), patientId, patientId + "_" + times + "_1");
|
|
|
+ if (payQrcode != null) {
|
|
|
+ results.put("payQrcode", payQrcode);
|
|
|
+ }
|
|
|
+ return results;
|
|
|
+ } catch (Exception e) {
|
|
|
+ if (results == null) {
|
|
|
+ results = new HashMap<>();
|
|
|
+ }
|
|
|
+ e.printStackTrace();
|
|
|
+ results.put("code", -1);
|
|
|
+ results.put("message", "门诊缴费指引单查询失败,请联系管理员");
|
|
|
+ log.error("系统异常,错误信息{}", e);
|
|
|
+ return results;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询门诊订单金额与支付明细
|
|
|
+ *
|
|
|
+ * @param patientId 门诊病人id
|
|
|
+ * @param times 就诊次数
|
|
|
+ * @param receiptNo 缴费次数
|
|
|
+ * @param clnicId 订单id
|
|
|
+ * @param httpServletRequest
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @UserLoginToken
|
|
|
+ @RequestMapping(value = "/getChargeDetailFee", method = {RequestMethod.GET})
|
|
|
+ public Map<String, Object> getChargeDetailFee(@RequestParam("patientId") String patientId, @RequestParam("times") Integer times, @RequestParam("receiptNo") Integer receiptNo, @RequestParam("clnicId") Long clnicId, HttpServletRequest httpServletRequest) {
|
|
|
Map<String, Object> results = new HashMap<>();
|
|
|
- if (times == null) {
|
|
|
+ if (clnicId == null && times == null) {
|
|
|
results.put("code", -1);
|
|
|
results.put("message", "就诊次数为空");
|
|
|
return results;
|
|
|
}
|
|
|
- if (StringUtils.isBlank(patientId)) {
|
|
|
+ if (clnicId == null && StringUtils.isBlank(patientId)) {
|
|
|
results.put("code", -1);
|
|
|
results.put("message", "患者门诊ID不能为空");
|
|
|
return results;
|
|
|
}
|
|
|
try {
|
|
|
- MzChargeDetail mzChargeDetail = new MzChargeDetail(patientId, times);
|
|
|
- mzChargeDetail.setBillItemCode("100");
|
|
|
- List<MzChargeDetail> mzChargeDetailList = mzChargeDetailService.getTempMzChargeDetailListForUnPaid(mzChargeDetail);
|
|
|
- if (mzChargeDetailList == null || mzChargeDetailList.size() == 0) {
|
|
|
- results.put("code", -2);
|
|
|
- results.put("message", "未查询到门诊缴费指引单记录");
|
|
|
- return results;
|
|
|
- }
|
|
|
- mzChargeDetailList = mzChargeDetailService.getMzChargeDetails(mzChargeDetailList);
|
|
|
- List<Map<String, Object>> returnList = new ArrayList<>();
|
|
|
- Map<String, ZdUnitCode> unitCodeMap = new HashMap<>();
|
|
|
- Map<String, Map<String, Object>> tempMap = new HashMap<>();
|
|
|
- List<BillItem> mzBillItems = mzBillItemService.queryMzBillItem();
|
|
|
- Map<String, String> mzBillItemMap = null;
|
|
|
- if (mzBillItems != null) {
|
|
|
- mzBillItemMap = mzBillItems.stream().collect(Collectors.toMap(BillItem::getCode, BillItem::getName));
|
|
|
+ String payMark = PayMarkEnum.NO_CHARGE.code;
|
|
|
+ if (clnicId != null) {
|
|
|
+ Clinic clinic = clinicService.queryById(clnicId);
|
|
|
+ if (clinic == null) {
|
|
|
+ results.put("code", -1);
|
|
|
+ results.put("message", "患者就诊记录不存在");
|
|
|
+ return results;
|
|
|
+ }
|
|
|
+ patientId=clinic.getPatientId();
|
|
|
+ times=clinic.getTimes();
|
|
|
+ receiptNo=clinic.getReceiptNo();
|
|
|
+ if (ClinicStatusEnum.HAD_CLINIC.code.equals(clinic.getClinicStatus())) {
|
|
|
+ payMark = PayMarkEnum.NO_CHARGE.code;
|
|
|
+ } else if (ClinicStatusEnum.CHARGED.code.equals(clinic.getClinicStatus())) {
|
|
|
+ payMark = PayMarkEnum.CHARGED.code;
|
|
|
+ } else {
|
|
|
+ results.put("code", -1);
|
|
|
+ results.put("message", "次状态的处方无需查看缴费明细");
|
|
|
+ return results;
|
|
|
+ }
|
|
|
}
|
|
|
- BigDecimal totalAmount = BigDecimal.ZERO;
|
|
|
- for (MzChargeDetail mz : mzChargeDetailList) {
|
|
|
- if (Arrays.asList(Constants.TC, Constants.SSWRF).contains(mz.getBillItemCode())) {
|
|
|
- continue;
|
|
|
+ if (PayMarkEnum.NO_CHARGE.code.equals(payMark)) {
|
|
|
+ MzChargeDetail mzChargeDetail = new MzChargeDetail(patientId, times);
|
|
|
+ mzChargeDetail.setBillItemCode("100");
|
|
|
+ List<MzChargeDetail> mzChargeDetailList = mzChargeDetailService.getTempMzChargeDetailListForUnPaid(mzChargeDetail);
|
|
|
+ if (mzChargeDetailList == null || mzChargeDetailList.size() == 0) {
|
|
|
+ results.put("code", -2);
|
|
|
+ results.put("message", "未查询到门诊处方记录");
|
|
|
+ return results;
|
|
|
}
|
|
|
- Map<String, Object> map = tempMap.get(mz.getBillItemCode());
|
|
|
- if (map == null) {
|
|
|
- map = new HashMap<>();
|
|
|
- tempMap.put(mz.getBillItemCode(), map);
|
|
|
- returnList.add(map);
|
|
|
- if (mzBillItemMap != null) {
|
|
|
- map.put("itemType", mzBillItemMap.get(mz.getBillItemCode()));
|
|
|
+ mzChargeDetailList = mzChargeDetailService.getMzChargeDetails(mzChargeDetailList);
|
|
|
+ List<Map<String, Object>> returnList = new ArrayList<>();
|
|
|
+ Map<String, ZdUnitCode> unitCodeMap = new HashMap<>();
|
|
|
+ Map<String, Map<String, Object>> tempMap = new HashMap<>();
|
|
|
+ List<BillItem> mzBillItems = mzBillItemService.queryMzBillItem();
|
|
|
+ Map<String, String> mzBillItemMap = null;
|
|
|
+ if (mzBillItems != null) {
|
|
|
+ mzBillItemMap = mzBillItems.stream().collect(Collectors.toMap(BillItem::getCode, BillItem::getName));
|
|
|
+ }
|
|
|
+ BigDecimal totalAmount = BigDecimal.ZERO;
|
|
|
+ for (MzChargeDetail mz : mzChargeDetailList) {
|
|
|
+ if (Arrays.asList(Constants.TC, Constants.SSWRF).contains(mz.getBillItemCode())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, Object> map = tempMap.get(mz.getBillItemCode());
|
|
|
+ if (map == null) {
|
|
|
+ map = new HashMap<>();
|
|
|
+ tempMap.put(mz.getBillItemCode(), map);
|
|
|
+ returnList.add(map);
|
|
|
+ if (mzBillItemMap != null) {
|
|
|
+ map.put("itemType", mzBillItemMap.get(mz.getBillItemCode()));
|
|
|
+ }
|
|
|
+ ZdUnitCode unitCode = unitCodeMap.get(mz.getExecDept());
|
|
|
+ if (unitCode == null && StringUtils.isNotBlank(mz.getExecDept())) {
|
|
|
+ unitCode = zdUnitCodeService.queryByCode(mz.getExecDept());
|
|
|
+ unitCodeMap.put(mz.getExecDept(), unitCode);
|
|
|
+ }
|
|
|
+ map.put("execDeptName", unitCode == null ? "" : unitCode.getName());
|
|
|
+ map.put("execDeptAddress", (unitCode == null || unitCode.getOfficePos() == null) ? "" : unitCode.getOfficePos());
|
|
|
}
|
|
|
- ZdUnitCode unitCode = unitCodeMap.get(mz.getExecDept());
|
|
|
- if (unitCode == null && StringUtils.isNotBlank(mz.getExecDept())) {
|
|
|
- unitCode = zdUnitCodeService.queryByCode(mz.getExecDept());
|
|
|
- unitCodeMap.put(mz.getExecDept(), unitCode);
|
|
|
+ BigDecimal unitPrice = mz.getUnitPrice().setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ if (BigDecimal.ZERO.equals(unitPrice)) {
|
|
|
+ unitPrice = BigDecimal.valueOf(0.01D);
|
|
|
}
|
|
|
- map.put("execDeptName", unitCode == null ? "" : unitCode.getName());
|
|
|
- map.put("execDeptAddress", (unitCode == null || unitCode.getOfficePos() == null) ? "" : unitCode.getOfficePos());
|
|
|
+ //unitPrice = unitPrice.multiply(BigDecimal.valueOf(100));
|
|
|
+ BigDecimal quantity = mz.getQuantity() == null ? BigDecimal.ONE : BigDecimal.valueOf(mz.getQuantity());
|
|
|
+ BigDecimal drugWin = mz.getDrugWin() == null ? BigDecimal.ONE : BigDecimal.valueOf(mz.getDrugWin());
|
|
|
+ BigDecimal amount = (BigDecimal) map.get("itemTotalFee");
|
|
|
+ if (amount == null) {
|
|
|
+ amount = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ BigDecimal tempAmount = unitPrice.multiply(quantity).multiply(drugWin);
|
|
|
+ totalAmount = totalAmount.add(tempAmount);
|
|
|
+ map.put("itemTotalFee", amount.add(tempAmount));
|
|
|
}
|
|
|
- BigDecimal unitPrice = mz.getUnitPrice().setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- if (BigDecimal.ZERO.equals(unitPrice)) {
|
|
|
- unitPrice = BigDecimal.valueOf(0.01D);
|
|
|
+ totalAmount = totalAmount.setScale(1, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal selfAmount = totalAmount;
|
|
|
+ User tokenUser = TokenUtil.getUser(httpServletRequest);
|
|
|
+ PayInfo payInfo = tsmzService.uploadFees(tokenUser.getUserIdCode(), patientId, times, receiptNo);
|
|
|
+ if (payInfo != null && payInfo.getCode() == 0) {
|
|
|
+ //个人医保账户支付
|
|
|
+ results.put("acctPay", payInfo.getAcctPay());
|
|
|
+ //医保统筹报销
|
|
|
+ results.put("fundPay", payInfo.getFundPay());
|
|
|
+ selfAmount = totalAmount.subtract(payInfo.getAcctPay()).subtract(payInfo.getFundPay());
|
|
|
}
|
|
|
- //unitPrice = unitPrice.multiply(BigDecimal.valueOf(100));
|
|
|
- BigDecimal quantity = mz.getQuantity() == null ? BigDecimal.ONE : BigDecimal.valueOf(mz.getQuantity());
|
|
|
- BigDecimal drugWin = mz.getDrugWin() == null ? BigDecimal.ONE : BigDecimal.valueOf(mz.getDrugWin());
|
|
|
- BigDecimal amount = (BigDecimal) map.get("itemTotalFee");
|
|
|
- if (amount == null) {
|
|
|
- amount = BigDecimal.ZERO;
|
|
|
+ results.put("code", 0);
|
|
|
+ results.put("message", "查询门诊订单金额与支付明细成功");
|
|
|
+ results.put("totalAmount", totalAmount);
|
|
|
+ results.put("selfAmount", selfAmount);
|
|
|
+ results.put("data", returnList);
|
|
|
+ return results;
|
|
|
+ }
|
|
|
+ MzDepositFile mzDepositFile = new MzDepositFile(patientId, times);
|
|
|
+ mzDepositFile.setReceiptNo(receiptNo);
|
|
|
+ List<MzDepositFile> mzDepositFileList = mzDepositFileService.queryMzDepositFile(mzDepositFile);
|
|
|
+ BigDecimal totalAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal selfAmount = BigDecimal.ZERO;
|
|
|
+ BigDecimal acctPay = BigDecimal.ZERO;
|
|
|
+ BigDecimal fundPay = BigDecimal.ZERO;
|
|
|
+ if (mzDepositFileList != null && mzDepositFileList.size() > 0) {
|
|
|
+ for (MzDepositFile mf : mzDepositFileList) {
|
|
|
+ if (mf.getAmount() != null) {
|
|
|
+ totalAmount = totalAmount.add(mf.getAmount());
|
|
|
+ }
|
|
|
+ if (Constants.YBJZ.equals(mf.getChequeType())) {
|
|
|
+ fundPay = fundPay.add(mf.getAmount());
|
|
|
+ } else if (Constants.SSHIYBK.equals(mf.getChequeType()) || Constants.SHENYBK.equals(mf.getChequeType())) {
|
|
|
+ acctPay = acctPay.add(mf.getAmount());
|
|
|
+ } else {
|
|
|
+ selfAmount = selfAmount.add(mf.getAmount());
|
|
|
+ }
|
|
|
}
|
|
|
- BigDecimal tempAmount = unitPrice.multiply(quantity).multiply(drugWin);
|
|
|
- totalAmount = totalAmount.add(tempAmount);
|
|
|
- map.put("itemTotalFee", amount.add(tempAmount));
|
|
|
}
|
|
|
- totalAmount = totalAmount.setScale(1, BigDecimal.ROUND_HALF_UP);
|
|
|
- String payQrcode = haiCiAdapterService.genMzPayQrcode(totalAmount.multiply(BigDecimal.valueOf(100)).intValue(), patientId, patientId + "_" + times + "_1");
|
|
|
results.put("code", 0);
|
|
|
- results.put("message", "门诊缴费指引单查询成功");
|
|
|
+ results.put("message", "查询门诊订单金额与支付明细成功");
|
|
|
results.put("totalAmount", totalAmount);
|
|
|
- results.put("data", returnList);
|
|
|
- if (payQrcode != null) {
|
|
|
- results.put("payQrcode", payQrcode);
|
|
|
- }
|
|
|
+ results.put("selfAmount", selfAmount);
|
|
|
+ results.put("fundPay", fundPay);
|
|
|
+ results.put("acctPay", acctPay);
|
|
|
return results;
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
results.put("code", -1);
|
|
|
- results.put("message", "门诊缴费指引单查询失败,请联系管理员");
|
|
|
- log.error("系统异常,错误信息{}", e);
|
|
|
+ results.put("message", "查询门诊订单金额与支付明细失败,请联系管理员");
|
|
|
+ log.error("查询门诊订单金额与支付明细时系统异常,错误信息{}", e);
|
|
|
return results;
|
|
|
}
|
|
|
}
|
|
@@ -2112,11 +2205,11 @@ public class MzChargeDetailController {
|
|
|
resultMap.put("message", "职工门诊统筹试算失败,读卡类型为空");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- if (StringUtils.isBlank(mzPrescriptionVo.getReadCardResult())) {
|
|
|
- resultMap.put("code", -1);
|
|
|
- resultMap.put("message", "职工门诊统筹试算失败,读卡返回为空");
|
|
|
- return resultMap;
|
|
|
- }
|
|
|
+// if (StringUtils.isBlank(mzPrescriptionVo.getReadCardResult())) {
|
|
|
+// resultMap.put("code", -1);
|
|
|
+// resultMap.put("message", "职工门诊统筹试算失败,读卡返回为空");
|
|
|
+// return resultMap;
|
|
|
+// }
|
|
|
User tokenUser = TokenUtil.getUser(httpServletRequest);
|
|
|
if (tokenUser == null) {
|
|
|
resultMap.put("code", -1);
|