微信后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
10 KiB

package com.ynxbd.common.bean.pay;
import com.ynxbd.common.result.ResultEnum;
import com.ynxbd.common.result.ServiceException;
import com.ynxbd.common.service.RegService;
import com.ynxbd.common.service.params.RequestParams;
import com.ynxbd.wx.wxfactory.AesWxHelper;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import java.math.BigDecimal;
/**
* @Author wsq
* @Date 2020/11/27 10:02
* @Copyright @ 2020 云南新八达科技有限公司 All rights reserved.
*/
@Slf4j
@Setter
@Getter
@ToString(callSuper = true)
@NoArgsConstructor
public class Register extends Order {
private Long id;
private String deptCode;
private String subDeptCode;
private String deptName;
private String doctCode;
private String doctName;
private String address;
private String payDate;
private String payTime;
private String payDeviceId;
private BigDecimal regFee;
private BigDecimal clinicFee;
private String clinicCode;
private String clinicName;
private String refundDate;
// 时段id
private String tid;
// 时段名
private String tName;
// 挂号类型(1:预约挂号,2:今日挂号,3:分时段预约挂号,4:分时段今日挂号)
private String regType;
// 挂号日期|医生排班日期
private String regDate;
// 号别名
private String regName;
// 号别编码
private String regCode;
// 分时段----------------------
// 序号
private String queueNum;
// 号源id
private String sourceId;
private String begTime;
private String endTime;
// 【今日挂号】是否就诊[0:未就诊,1:已就诊,-1:已退号]
private Integer isTreat;
// 【预约挂号】是否取号[0:未取号,1:已取号,-1:取消预约]
private Integer isTake;
// 非分时段挂号------------------------
private String isCheckIn;
// 总号源数
private Integer sourceCount;
// 剩余号源数
private Integer remainCount;
// 0:没有号源不允许挂号;1:有号源可以挂号
private Integer allowReg;
// 是否被占用
private Integer isUsed;
// 院区
private String hospitalArea;
// 挂号订单来源平台
private String orderFromOwner;
// 判断是否为分时段挂号
private Boolean isSplitTime;
// 就医助手标记
private String medToolMark;
// 预问诊报告标记[1:报告已生成]
private Integer preConsultState;
// 预问诊跳转链接
private String url;
public boolean hasIsTake(int val) {
return isTake != null && isTake == val;
}
public boolean hasIsTreat(int val) {
return isTreat != null && isTreat == val;
}
// [普通挂号]有剩余号源(>0为有号)
public boolean hasRemainCount() {
return this.remainCount != null && this.remainCount > 0;
}
// [普通挂号]为无限号(0为无限号)
public boolean hasSourceCount() {
return this.remainCount != null && this.remainCount == 0;
}
/**
* * // * @param regFee 金额
* * // * @param clinicFee 金额
* * // * @param payMoney 金额
* * // * @param tel 电话
* * // * @param openid openid
* * // * @param idCardNo 身份证号码
* * // * @param patientId 患者id
* * // * @param deptCode 科室编码
* * // * @param deptName 科室名称
* * // * @param doctCode 医生编码
* * // * @param doctName 医生名
* * // * @param address 地址
* * // * @param hospitalArea 院区
* * // * @param tid 时段名
* * // * @param tName 时段名
* * // * @param begTime 开始时间(分时段)
* * // * @param endTime 开始时间(分时段)
* * // * @param regCode 挂号编码
* * // * @param regDate 挂号日期
* * // * @param sourceId 号源id(分时段)
* * // * @param queueNum 序列号(分时段)
* * // * @param clinicCode 编码
*
* @param params 请求参数
* @param isDesc
*/
public Register getRegParams(RequestParams params, boolean isDesc) throws ServiceException {
String openid = params.getString("openid");
String payOpenId = params.getString("payOpenId"); // 下单的openId
String patientName = params.getString("patientName");
String patientId = AesWxHelper.decode(params.getString("enPatientId"));
if (ObjectUtils.isEmpty(patientId)) {
patientId = params.getString("patientId");
}
String cardNo = AesWxHelper.decode(params.getString("enCardNo"));
if (ObjectUtils.isEmpty(cardNo)) {
cardNo = params.getString("idCardNo");
}
if (ObjectUtils.isEmpty(cardNo)) {
cardNo = params.getString("cardNo");
}
String tel = AesWxHelper.decode(params.getString("enTel"));
if (ObjectUtils.isEmpty(tel)) {
tel = params.getString("tel");
}
BigDecimal payMoney = params.getBigDecimal("payMoney");
BigDecimal totalFee = params.getBigDecimal("totalFee");
String enPayMoney = params.getString("enPayMoney");
String deptCode = params.getString("deptCode");
String subDeptCode = params.getString("subDeptCode");
String doctCode = params.getString("doctCode");
String regCode = params.getString("regCode");
String regDate = params.getString("regDate");
String tid = params.getString("tid");
System.out.println("[挂号]证件号码:" + (ObjectUtils.isEmpty(cardNo) ? "" : cardNo)); // 此处打印不存日志
if (openid == null || patientId == null || cardNo == null || deptCode == null || doctCode == null || regDate == null || tid == null) {
log.info("[挂号]参数缺失 openid={}, patientId={}, deptCode={}, doctCode={}, regCode={}, regDate={}, tid={}",
openid, patientId, deptCode, doctCode, regCode, regDate, tid);
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
if (payMoney == null || totalFee == null) {
log.info("[挂号]参数缺失 payMoney");
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
Boolean isSplitTime = params.getBoolean("isSplitTime");
if (isSplitTime == null) {
log.info("[挂号]挂号类型参数缺失isSplitTime");
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
log.info("[挂号类型]{}", (isSplitTime ? "分时段挂号" : "普通挂号"));
this.isSplitTime = isSplitTime;
if (isSplitTime) { // 分时段
String tName = params.getString("tName");
String queueNum = params.getString("queueNum");
String sourceId = params.getString("sourceId");
String begTime = params.getString("begTime");
String endTime = params.getString("endTime");
if (tName == null || queueNum == null || sourceId == null || begTime == null || endTime == null) {
log.info("[挂号]参数缺失 tName={}, queueNum={}, sourceId={}, begTime={}, endTime={}", tName, queueNum, sourceId, begTime, endTime);
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
this.tName = tName;
this.begTime = begTime;
this.endTime = endTime;
this.sourceId = sourceId;
this.queueNum = queueNum;
} else {
String clinicCode = params.getString("clinicCode");
if (clinicCode == null) {
log.info("[普通挂号]参数缺失clinicCode");
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
this.clinicCode = clinicCode;
}
if (isDesc) {
BigDecimal regFee = params.getBigDecimal("regFee");
BigDecimal clinicFee = params.getBigDecimal("clinicFee");
if (regFee == null || clinicFee == null) {
log.info("[挂号]参数缺失 regFee={}, clinicFee={}", regFee, clinicFee);
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
String address = params.getString("address");
String deptName = params.getString("deptName");
String doctName = params.getString("doctName");
String hospitalArea = params.getString("hospitalArea");
if (deptName == null || doctName == null) {
log.info("[挂号]参数缺失 patientId={}, deptName={}, hospitalArea={}", patientId, deptName, hospitalArea);
throw new ServiceException(ResultEnum.PARAM_IS_DEFECT);
}
this.regFee = regFee;
this.clinicFee = clinicFee;
this.address = address;
this.hospitalArea = hospitalArea;
this.deptName = deptName;
this.doctName = doctName;
this.regType = RegService.setRegType(regDate, isSplitTime);
}
this.deptCode = deptCode;
this.subDeptCode = subDeptCode;
this.doctCode = doctCode;
this.regCode = regCode;
this.regDate = regDate;
this.tid = tid;
// 金额
this.setPayMoney(payMoney);
this.setTotalFee(totalFee);
this.setEnPayMoney(enPayMoney);
// 个人信息
this.setOpenid(openid);
this.setPayOpenId(payOpenId);
this.setPatientId(patientId);
this.setPatientName(patientName);
this.setIdCardNo(cardNo);
this.setTel(tel);
return this;
}
}