|
|
@@ -10,6 +10,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUnit;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
@@ -33,6 +34,7 @@ import com.fs.course.param.SubmitCollectionAnswerParam;
|
|
|
import com.fs.course.vo.FsUserInfoCollectionUVO;
|
|
|
import com.fs.doctor.domain.DoctorMsg;
|
|
|
import com.fs.doctor.mapper.DoctorMsgMapper;
|
|
|
+import com.fs.enums.PostPayPrescStatusEnum;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
|
import com.fs.his.domain.*;
|
|
|
import com.fs.his.enums.CollectionTaskStatusEnum;
|
|
|
@@ -48,6 +50,7 @@ import com.fs.hisStore.dto.FsUserInformationCollectionOverviewDTO;
|
|
|
import com.fs.hisStore.dto.PendingSalesInfoQueryDTO;
|
|
|
import com.fs.hisStore.param.FsUserInformationCollectionListDParam;
|
|
|
import com.fs.hisStore.param.FsUserInformationCollectionParam;
|
|
|
+import com.fs.hisStore.param.bindCollectionPackageParam;
|
|
|
import com.fs.hisStore.vo.FsUserInformationCollectionListDVO;
|
|
|
import com.fs.hisStore.vo.FsUserInformationCollectionVO;
|
|
|
import com.fs.hisStore.vo.FsUserInformationCollectionOverviewVo;
|
|
|
@@ -56,7 +59,6 @@ import com.fs.huifuPay.domain.HuifuConfirmrefundResult;
|
|
|
import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentDelaytransConfirmrefundRequest;
|
|
|
import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
|
-import com.fs.qw.domain.QwExternalContact;
|
|
|
import com.fs.qw.mapper.FsUserInformationCollectionScheduleMapper;
|
|
|
import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
import com.fs.store.domain.FsDoctorConfirm;
|
|
|
@@ -195,6 +197,12 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
@Autowired
|
|
|
private QwExternalContactMapper qwExternalContactMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IPollingAssignDoctorService pollingAssignDoctorService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsUserMapper fsUserMapper;
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -230,9 +238,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Long insertFsUserInformationCollection(FsUserInformationCollectionParam param) {
|
|
|
- if (param.getFillFlag()!=null&¶m.getFillFlag()==1&&!getSalesProxyFillConfig()){
|
|
|
- throw new CustomException("当前不可代填写患者问题信息,请刷新页面后重试");
|
|
|
- }
|
|
|
+ checkSalesFillCondition(param);
|
|
|
if (param.getIsPackage() != null && param.getIsPackage() == 1) {
|
|
|
FsPackage fsPackage = packageMapper.selectFsPackageByPackageId(param.getPackageId());
|
|
|
if (fsPackage != null && !(fsPackage.getProductType() == 1 || fsPackage.getProductType() == 2 || fsPackage.getProductType() == 3)) {
|
|
|
@@ -277,9 +283,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Long updateFsUserInformationCollection(FsUserInformationCollectionParam param)
|
|
|
{
|
|
|
- if (param.getFillFlag()!=null&¶m.getFillFlag()==1&&!getSalesProxyFillConfig()){
|
|
|
- throw new CustomException("当前不可代填写患者问题信息,请刷新页面后重试");
|
|
|
- }
|
|
|
+ checkSalesFillCondition(param);
|
|
|
if (param.getId() == null || param.getId() < 1) {
|
|
|
throw new CustomException("参数错误");
|
|
|
}
|
|
|
@@ -346,10 +350,8 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
//创建简化版采集信息(没有用户id)
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Long createSimpleUserInfo(FsUserInformationCollectionParam param) {
|
|
|
- if (param.getFillFlag()!=null&¶m.getFillFlag()==1&&!getSalesProxyFillConfig()){
|
|
|
- throw new CustomException("当前不可代填写患者问题信息,请刷新页面后重试");
|
|
|
- }
|
|
|
+ public FsUserInformationCollection createSimpleUserInfo(FsUserInformationCollectionParam param) {
|
|
|
+ checkSalesFillCondition(param);
|
|
|
if (param.getIsPackage() != null && param.getIsPackage() == 1) {
|
|
|
FsPackage fsPackage = packageMapper.selectFsPackageByPackageId(param.getPackageId());
|
|
|
if (fsPackage != null && !(fsPackage.getProductType() == 1 || fsPackage.getProductType() == 2 || fsPackage.getProductType() == 3)) {
|
|
|
@@ -361,6 +363,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
FsUserInformationCollection fsUserInformationCollection = buildUserInfoCollection(param);
|
|
|
//添加个微标识
|
|
|
fsUserInformationCollection.setQwTag(1);
|
|
|
+ fsUserInformationCollection.setPersonalCollectStatus(PostPayPrescStatusEnum.INFO_COLLECTION.getCode());//个微采集表初始状态
|
|
|
try {
|
|
|
if (validateRequiredRemarks(param.getAnswers(),param.getQuestionId())){
|
|
|
//用户采集信息问题完善状态 0-未完善 1-完善
|
|
|
@@ -369,16 +372,109 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
fsUserInformationCollection.setCompleteStatus(0);
|
|
|
}
|
|
|
baseMapper.insertFsUserInformationCollection(fsUserInformationCollection);
|
|
|
- //构建采集进度对象
|
|
|
- FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule = buildUserInfoSchedule(fsUserInformationCollection);
|
|
|
- //新增用户信息采集进度
|
|
|
- scheduleMapper.insertFsUserInformationCollectionSchedule(fsUserInformationCollectionSchedule);
|
|
|
- log.info("新增用户信息采集进度数据,信息采集数据id:{}", fsUserInformationCollectionSchedule.getCollectionId());
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
logger.error("极速版-----用户信息采集进度创建失败", e);
|
|
|
throw new CustomException("信息采集进度创建失败");
|
|
|
}
|
|
|
- return fsUserInformationCollection.getId();
|
|
|
+ return fsUserInformationCollection;
|
|
|
+ }
|
|
|
+
|
|
|
+ //个微信息采集确认并生成医生待开处方
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R generateFormalPrescription(CollectionInfoConfirmParam param) {
|
|
|
+ FsUserInformationCollection collection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(param.getId());
|
|
|
+ if (collection == null) {
|
|
|
+ log.error("当前用户userId:{},信息采集表id:{}", param.getUserId(), param.getId());
|
|
|
+ return R.error("采集信息不存在");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(collection.getUserId(), param.getUserId())) {
|
|
|
+ log.error("当前用户userId:{},信息采集表userId:{}", param.getUserId(), collection.getUserId());
|
|
|
+ return R.error("用户信息不匹配,无法确认");
|
|
|
+ }
|
|
|
+
|
|
|
+ collection.setPersonalCollectStatus(PostPayPrescStatusEnum.FULLY_COLLECTED_DATA.getCode());
|
|
|
+ if (fsUserInformationCollectionMapper.updateFsUserInformationCollection(collection) > 0) {
|
|
|
+ //新增fs_prescribe处方信息
|
|
|
+ FsPrescribe fsPrescribe = transformCollectionDtoToFsPrescribe(param, collection);
|
|
|
+ fsPrescribe.setCollectionId(collection.getId());
|
|
|
+ int addPrescribeResult = fsPrescribeMapper.insertFsPrescribe(fsPrescribe);
|
|
|
+
|
|
|
+ //存入医生确认统计时间数据
|
|
|
+ Date currentTime = DateUtils.getNowDate();
|
|
|
+ FsDoctorConfirm doctorConfirm = new FsDoctorConfirm();
|
|
|
+ doctorConfirm.setCollectionId(collection.getId());
|
|
|
+ doctorConfirm.setDoctorId(collection.getDoctorId());
|
|
|
+ doctorConfirm.setStartTime(currentTime);
|
|
|
+ doctorConfirmService.insertFsDoctorConfirm(doctorConfirm);
|
|
|
+ //医生确认时间存入缓存 医生确认后删除
|
|
|
+ redisCache.setCacheObject("doctorConfirm:" + collection.getId(), doctorConfirm);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ return R.error("用户确认失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ private FsPrescribe transformCollectionDtoToFsPrescribe(CollectionInfoConfirmParam param, FsUserInformationCollection fsUserInformationCollection) {
|
|
|
+ //构建处方编号
|
|
|
+ String prescribeCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
+ FsPrescribe fsPrescribe = new FsPrescribe();
|
|
|
+ fsPrescribe.setCreateTime(DateUtils.getNowDate());
|
|
|
+ fsPrescribe.setStatus(0);//待开方
|
|
|
+ fsPrescribe.setDoctorConfirm(0);//未确认
|
|
|
+ fsPrescribe.setUsageJson(JSON.toJSONString(param.getAnswers()));
|
|
|
+ fsPrescribe.setHistoryAllergic(fsUserInformationCollection.getAllergy());
|
|
|
+
|
|
|
+ fsPrescribe.setPrescribeCode(prescribeCode);
|
|
|
+ fsPrescribe.setPatientAge(String.valueOf(fsUserInformationCollection.getAge()));
|
|
|
+ fsPrescribe.setPatientId(fsUserInformationCollection.getUserId());
|
|
|
+
|
|
|
+ fsPrescribe.setPatientName(fsUserInformationCollection.getUserName());
|
|
|
+
|
|
|
+ fsPrescribe.setPatientGender(String.valueOf(fsUserInformationCollection.getSex() == 1 ? 1 : 0));
|
|
|
+ fsPrescribe.setPatientAge(String.valueOf(fsUserInformationCollection.getAge()));
|
|
|
+ FsUser fsUser = fsUserMapper.selectFsUserById(fsUserInformationCollection.getUserId());
|
|
|
+ if (fsUser == null) {
|
|
|
+ log.error("用户信息获取异常:" + fsUserInformationCollection.getUserId());
|
|
|
+ throw new CustomException("网络异常,请稍后再试!");
|
|
|
+ }
|
|
|
+ fsPrescribe.setPatientTel(fsUser.getPhone());
|
|
|
+ //查询销售绑定医生
|
|
|
+ CompanyUser companyUser = companyUserMapper.selectCompanyUserByCompanyUserId(fsUserInformationCollection.getCompanyUserId());
|
|
|
+ if (companyUser == null || companyUser.getDoctorId() == null) {
|
|
|
+ log.error("销售信息获取异常:" + fsUserInformationCollection.getCompanyUserId());
|
|
|
+ throw new CustomException("销售未绑定医生,请稍后再试!");
|
|
|
+ }
|
|
|
+ Long doctorId = companyUser.getDoctorId();
|
|
|
+ fsPrescribe.setDoctorId(doctorId);
|
|
|
+ FsDoctor fsDoctor = doctorMapper.selectFsDoctorByDoctorId(doctorId);
|
|
|
+ if (fsDoctor == null) {
|
|
|
+ log.error("开方医生信息获取异常:" + companyUser.getDoctorId());
|
|
|
+ throw new CustomException("网络异常,请稍后再试!");
|
|
|
+ }
|
|
|
+
|
|
|
+ fsPrescribe.setPrescribeDoctorId(fsDoctor.getDoctorId());
|
|
|
+ fsPrescribe.setPrescribeDoctorSignUrl(fsDoctor.getSignUrl());
|
|
|
+ //分配在线的随机药师
|
|
|
+ FsDoctor fsDrugDoctor = null;
|
|
|
+ try {
|
|
|
+ // 使用新写的轮询服务分配药师,传入处方编号
|
|
|
+ fsDrugDoctor = pollingAssignDoctorService.getNextPharmacist(prescribeCode);
|
|
|
+
|
|
|
+ fsPrescribe.setDrugDoctorId(fsDrugDoctor.getDoctorId());
|
|
|
+ fsPrescribe.setDrugDoctorSignUrl(fsDrugDoctor.getSignUrl());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("分配药师失败 - 处方号:{}", prescribeCode, e);
|
|
|
+ throw new CustomException("网络异常,请稍后再试!");
|
|
|
+ }
|
|
|
+ return fsPrescribe;
|
|
|
+ }
|
|
|
+
|
|
|
+ //检测销售代填条件
|
|
|
+ private void checkSalesFillCondition(FsUserInformationCollectionParam param) {
|
|
|
+ if (param.getFillFlag() != null && param.getFillFlag() == 1 && !getSalesProxyFillConfig()) {
|
|
|
+ throw new CustomException("当前不可代填写患者问题信息,请刷新页面后重试");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -742,6 +838,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ vo.setQwTag(collection.getQwTag());
|
|
|
vo.setIsPackage(collection.getIsPackage());
|
|
|
vo.setId(collection.getId());
|
|
|
vo.setAnswers(JSON.parseArray(collection.getJsonInfo(), AnswerVO.class));
|
|
|
@@ -1388,6 +1485,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
map.setUserId(param.getUserId());
|
|
|
map.setId(param.getCollectionId());
|
|
|
map.setQwTag(1);
|
|
|
+ map.setPersonalCollectStatus(PostPayPrescStatusEnum.USER_BIND.getCode());//个微采集表完善采集表状态
|
|
|
if (fsUserInformationCollectionMapper.updateFsUserInformationCollection(map) > 0) {
|
|
|
//更新信息采集进度表里面的用户id
|
|
|
FsUserInformationCollectionSchedule schedule = scheduleMapper.selectCollectionScheduleRunningByCollectionId(param.getCollectionId());
|
|
|
@@ -1515,6 +1613,34 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Long bindCollectionPackage(bindCollectionPackageParam param) {
|
|
|
+ //校验参数
|
|
|
+ FsUserInformationCollection informationCollection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(param.getId());
|
|
|
+ if (informationCollection == null || informationCollection.getQwTag() == 0 || informationCollection.getCompleteStatus() == 0) {
|
|
|
+ log.error("用户信息采集id:{},条件不符", param.getId());
|
|
|
+ throw new CustomException("信息采集绑定条件不符合");
|
|
|
+ }
|
|
|
+ CompanyUser companyUser = companyUserMapper.selectCompanyUserById(informationCollection.getCompanyUserId());
|
|
|
+ if (companyUser == null) {
|
|
|
+ throw new CustomException("未查询到绑定销售人员");
|
|
|
+ }
|
|
|
+ FsPackage fsPackage = packageMapper.selectFsPackageByPackageId(param.getPackageId());
|
|
|
+ if (fsPackage == null){
|
|
|
+ throw new CustomException("套餐包不存在或已下架");
|
|
|
+ }
|
|
|
+ //套餐包必须是OTC、中药、处方药类型
|
|
|
+ if (fsPackage.getProductType() == 1 || fsPackage.getProductType() == 2 || fsPackage.getProductType() == 3) {
|
|
|
+ informationCollection.setPackageId(param.getPackageId());
|
|
|
+ informationCollection.setPersonalCollectStatus(PostPayPrescStatusEnum.PACKAGE_BIND.getCode());
|
|
|
+ int result = fsUserInformationCollectionMapper.updateFsUserInformationCollection(informationCollection);
|
|
|
+ if (result > 0){
|
|
|
+ return informationCollection.getId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 校验必填备注:对于 open=true 且被勾选的选项,必须填写备注文本
|
|
|
*
|