|
|
@@ -214,12 +214,11 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public Long insertFsUserInformationCollection(FsUserInformationCollectionParam param)
|
|
|
- {
|
|
|
- FsUserInformationCollection fsUserInformationCollection = getFsUserInformationCollection(param);
|
|
|
- if (param.getIsPackage() == 1) {
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Long insertFsUserInformationCollection(FsUserInformationCollectionParam 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)) {
|
|
|
+ if (fsPackage != null && !(fsPackage.getProductType() == 1 || fsPackage.getProductType() == 2 || fsPackage.getProductType() == 3)) {
|
|
|
throw new CustomException("该套餐不支持用户信息采集");
|
|
|
}
|
|
|
}
|
|
|
@@ -227,25 +226,20 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
FsUserInformationCollection queryCondition = new FsUserInformationCollection();
|
|
|
queryCondition.setUserId(param.getUserId());
|
|
|
List<FsUserInformationCollection> fsUserInformationCollections = baseMapper.selectFsUserInformationCollectionList(queryCondition);
|
|
|
- if (!CollectionUtils.isEmpty(fsUserInformationCollections)&&fsUserInformationCollections.size()>1){
|
|
|
- log.info("用户已存在采集信息,用户id:{}",param.getUserId());
|
|
|
+ if (!CollectionUtils.isEmpty(fsUserInformationCollections) && fsUserInformationCollections.size() > 1) {
|
|
|
+ log.info("用户已存在采集信息,用户id:{}", param.getUserId());
|
|
|
throw new CustomException("用户已存在采集信息");
|
|
|
}
|
|
|
- fsUserInformationCollection.setAge(param.getAge());
|
|
|
- fsUserInformationCollection.setCreateTime(DateUtils.getNowDate());
|
|
|
- baseMapper.insertFsUserInformationCollection(fsUserInformationCollection);
|
|
|
- //新增用户信息采集表的同时记录用户信息采集进度
|
|
|
+ //构建用户信息采集信息
|
|
|
+ FsUserInformationCollection fsUserInformationCollection = buildUserInfoCollection(param);
|
|
|
try {
|
|
|
- fsUserInformationCollection.setPackageId(param.getPackageId());
|
|
|
- fsUserInformationCollection.setCompanyUserId(param.getCompanyUserId());
|
|
|
- fsUserInformationCollection.setCompanyId(param.getCompanyId());
|
|
|
+ baseMapper.insertFsUserInformationCollection(fsUserInformationCollection);
|
|
|
//构建采集进度信息
|
|
|
- FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule = assembleCreateSchedule(fsUserInformationCollection);
|
|
|
- fsUserInformationCollectionSchedule.setCompanyUserId(param.getCompanyUserId());
|
|
|
+ FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule = buildUserInfoSchedule(fsUserInformationCollection);
|
|
|
scheduleMapper.insertFsUserInformationCollectionSchedule(fsUserInformationCollectionSchedule);
|
|
|
- log.info("新增用户信息采集进度数据,信息采集数据id:{}",fsUserInformationCollectionSchedule.getCollectionId());
|
|
|
- }catch (Exception e){
|
|
|
- logger.error("新增用户信息采集进度数据失败",e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("新增---用户id:{},新增用户信息采集进度失败", param.getUserId(), e);
|
|
|
+ throw new CustomException("用户信息采集进度新增失败");
|
|
|
}
|
|
|
return fsUserInformationCollection.getId();
|
|
|
}
|
|
|
@@ -265,7 +259,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
}
|
|
|
FsUserInformationCollection collection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(param.getId());
|
|
|
if (collection == null) {
|
|
|
- throw new CustomException("没有用户采集信息");
|
|
|
+ throw new CustomException("用户:"+param.getUserId()+"没有用户采集信息");
|
|
|
}
|
|
|
if (collection.getUserConfirm() == 1 && collection.getUserConfirm2() == 0) {
|
|
|
throw new CustomException("确认中,暂无法修改");
|
|
|
@@ -276,33 +270,26 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
throw new CustomException("该疗法不支持用户信息采集");
|
|
|
}
|
|
|
}
|
|
|
- //编辑用户信息采集信息时,同时新增采集进度数据(先中止再新增)
|
|
|
- //获取当前用户正在运行的信息采集进度
|
|
|
+ //编辑用户信息采集信息时,需要新增采集进度数据(先取消进度再新增进度)
|
|
|
FsUserInformationCollectionSchedule schedule = scheduleMapper.selectCollectionScheduleRunningByCollectionId(collection.getId());
|
|
|
if (schedule != null){
|
|
|
- log.info("用户信息采集进度未终止,进度id:{}",schedule.getId());
|
|
|
- throw new CustomException("请先终止此用户信息的采集进度");
|
|
|
+ log.info("用户信息采集进度未取消,进度id:{}",schedule.getId());
|
|
|
+ throw new CustomException("请先取消此用户信息的采集进度");
|
|
|
}
|
|
|
+ FsUserInformationCollection fsUserInformationCollection = buildUserInfoCollection(param);
|
|
|
try {
|
|
|
- FsUserInformationCollection condition = getFsUserInformationCollection(param);
|
|
|
- if (param.getIsPackage() != null&& param.getIsPackage() == 1){
|
|
|
- condition.setPackageId(param.getPackageId());
|
|
|
- }
|
|
|
-
|
|
|
- FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule = assembleCreateSchedule(condition);
|
|
|
- fsUserInformationCollectionSchedule.setCompanyUserId(param.getCompanyUserId());
|
|
|
+ FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule = buildUserInfoSchedule(fsUserInformationCollection);
|
|
|
scheduleMapper.insertFsUserInformationCollectionSchedule(fsUserInformationCollectionSchedule);
|
|
|
- log.info("编辑用户信息采集信息重新新增进度数据,信息采集数据id:{}",fsUserInformationCollectionSchedule.getCollectionId());
|
|
|
}catch (Exception e){
|
|
|
- logger.error("新增用户信息采集进度数据失败",e);
|
|
|
- throw new CustomException("新增用户信息采集进度数据失败");
|
|
|
+ logger.error("编辑---用户id:{},新增用户信息采集进度失败",param.getUserId(),e);
|
|
|
+ throw new CustomException("用户信息采集进度新增失败");
|
|
|
}
|
|
|
//清空订单号
|
|
|
fsUserInformationCollectionMapper.collectionOderCodeNULL(param.getId());
|
|
|
- FsUserInformationCollection fsUserInformationCollection = getFsUserInformationCollection(param);
|
|
|
fsUserInformationCollection.setUserConfirm2(0);
|
|
|
fsUserInformationCollection.setUserConfirm(0);
|
|
|
fsUserInformationCollection.setDoctorConfirm(0);
|
|
|
+ fsUserInformationCollection.setFillFlag(0);//填写标识 0:未填写
|
|
|
fsUserInformationCollection.setStatus(1);
|
|
|
fsUserInformationCollection.setUpdateTime(DateUtils.getNowDate());
|
|
|
fsUserInformationCollection.setRemark(param.getRemark());
|
|
|
@@ -312,80 +299,42 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
if (param.getIsPackage() != null && param.getIsPackage() == 1){
|
|
|
fsUserInformationCollection.setPackageId(param.getPackageId());
|
|
|
}
|
|
|
-
|
|
|
fsUserInformationCollection.setUserPhoneFour(param.getUserPhoneFour());
|
|
|
fsUserInformationCollection.setAllergy(param.getAllergy());
|
|
|
fsUserInformationCollection.setPayType(param.getPayType());
|
|
|
fsUserInformationCollection.setQuestionId(param.getQuestionId());
|
|
|
fsUserInformationCollection.setAmount(param.getAmount());
|
|
|
fsUserInformationCollection.setAge(param.getAge());
|
|
|
+ //更新用户信息采集信息
|
|
|
baseMapper.updateFsUserInformationCollection(fsUserInformationCollection);
|
|
|
return fsUserInformationCollection.getId();
|
|
|
}
|
|
|
|
|
|
|
|
|
+ //简化版信息采集创建时没有用户id
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Long createSimpleUserInfo(FsUserInformationCollectionParam param) {
|
|
|
- if (param.getId() == null || param.getId() < 1) {
|
|
|
- throw new CustomException("参数错误");
|
|
|
- }
|
|
|
- FsUserInformationCollection collection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(param.getId());
|
|
|
- if (collection == null) {
|
|
|
- throw new CustomException("没有用户采集信息");
|
|
|
- }
|
|
|
- if (collection.getUserConfirm() == 1 && collection.getUserConfirm2() == 0) {
|
|
|
- throw new CustomException("确认中,暂无法修改");
|
|
|
- }
|
|
|
- if (param.getIsPackage() == 1) {
|
|
|
+ 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)) {
|
|
|
- throw new CustomException("该疗法不支持用户信息采集");
|
|
|
+ if (fsPackage != null && !(fsPackage.getProductType() == 1 || fsPackage.getProductType() == 2 || fsPackage.getProductType() == 3)) {
|
|
|
+ throw new CustomException("该套餐不支持用户信息采集");
|
|
|
}
|
|
|
}
|
|
|
- //编辑用户信息采集信息时,同时新增采集进度数据(先中止再新增)
|
|
|
- //获取当前用户正在运行的信息采集进度
|
|
|
- FsUserInformationCollectionSchedule schedule = scheduleMapper.selectCollectionScheduleRunningByCollectionId(collection.getId());
|
|
|
- if (schedule != null){
|
|
|
- log.info("用户信息采集进度未终止,进度id:{}",schedule.getId());
|
|
|
- throw new CustomException("请先终止此用户信息的采集进度");
|
|
|
- }
|
|
|
- try {
|
|
|
- FsUserInformationCollection condition = getFsUserInformationCollection(param);
|
|
|
- if (param.getIsPackage() != null&& param.getIsPackage() == 1){
|
|
|
- condition.setPackageId(param.getPackageId());
|
|
|
- }
|
|
|
|
|
|
- FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule = assembleCreateSchedule(condition);
|
|
|
- fsUserInformationCollectionSchedule.setCompanyUserId(param.getCompanyUserId());
|
|
|
+ //构建用户信息采集对象
|
|
|
+ FsUserInformationCollection fsUserInformationCollection = buildUserInfoCollection(param);
|
|
|
+ try {
|
|
|
+ baseMapper.insertFsUserInformationCollection(fsUserInformationCollection);
|
|
|
+ //构建采集进度对象
|
|
|
+ FsUserInformationCollectionSchedule fsUserInformationCollectionSchedule = buildUserInfoSchedule(fsUserInformationCollection);
|
|
|
+ //新增用户信息采集进度
|
|
|
scheduleMapper.insertFsUserInformationCollectionSchedule(fsUserInformationCollectionSchedule);
|
|
|
- log.info("编辑用户信息采集信息重新新增进度数据,信息采集数据id:{}",fsUserInformationCollectionSchedule.getCollectionId());
|
|
|
- }catch (Exception e){
|
|
|
- logger.error("新增用户信息采集进度数据失败",e);
|
|
|
- throw new CustomException("新增用户信息采集进度数据失败");
|
|
|
- }
|
|
|
- //清空订单号
|
|
|
- fsUserInformationCollectionMapper.collectionOderCodeNULL(param.getId());
|
|
|
- FsUserInformationCollection fsUserInformationCollection = getFsUserInformationCollection(param);
|
|
|
- fsUserInformationCollection.setUserConfirm2(0);
|
|
|
- fsUserInformationCollection.setUserConfirm(0);
|
|
|
- fsUserInformationCollection.setDoctorConfirm(0);
|
|
|
- fsUserInformationCollection.setStatus(1);
|
|
|
- fsUserInformationCollection.setUpdateTime(DateUtils.getNowDate());
|
|
|
- fsUserInformationCollection.setRemark(param.getRemark());
|
|
|
- fsUserInformationCollection.setSex(param.getSex());
|
|
|
- fsUserInformationCollection.setIsPackage(param.getIsPackage());
|
|
|
- fsUserInformationCollection.setUserName(param.getUserName());
|
|
|
- if (param.getIsPackage() != null && param.getIsPackage() == 1){
|
|
|
- fsUserInformationCollection.setPackageId(param.getPackageId());
|
|
|
+ log.info("新增用户信息采集进度数据,信息采集数据id:{}", fsUserInformationCollectionSchedule.getCollectionId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("极速版-----用户信息采集进度创建失败", e);
|
|
|
+ throw new CustomException("信息采集进度创建失败");
|
|
|
}
|
|
|
-
|
|
|
- fsUserInformationCollection.setUserPhoneFour(param.getUserPhoneFour());
|
|
|
- fsUserInformationCollection.setAllergy(param.getAllergy());
|
|
|
- fsUserInformationCollection.setPayType(param.getPayType());
|
|
|
- fsUserInformationCollection.setQuestionId(param.getQuestionId());
|
|
|
- fsUserInformationCollection.setAmount(param.getAmount());
|
|
|
- fsUserInformationCollection.setAge(param.getAge());
|
|
|
- baseMapper.updateFsUserInformationCollection(fsUserInformationCollection);
|
|
|
return fsUserInformationCollection.getId();
|
|
|
}
|
|
|
|
|
|
@@ -1114,7 +1063,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
return R.error("未找到采集信息");
|
|
|
}
|
|
|
if (collection.getStatus() == 2 && collection.getUserConfirm2() == 1) {
|
|
|
- return R.error("用户信息采集已完成,无法终止");
|
|
|
+ return R.error("用户信息采集已完成,无法取消");
|
|
|
}
|
|
|
//清空订单号
|
|
|
fsUserInformationCollectionMapper.collectionOderCodeNULL(param.getCollectionId());
|
|
|
@@ -1133,11 +1082,11 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
}else {
|
|
|
schedule = scheduleMapper.selectCollectionScheduleByCollectionId(param.getCollectionId());
|
|
|
}
|
|
|
- // "用户采集进度"中止时间
|
|
|
+ // "用户采集进度"取消时间
|
|
|
schedule.setTerminatedTime(DateUtils.getNowDate());
|
|
|
- // "用户采集进度"中止标识
|
|
|
+ // "用户采集进度"取消标识
|
|
|
schedule.setStatus(CollectionTaskStatusEnum.TERMINATED.getCode());
|
|
|
- // "用户采集进度"中止原因
|
|
|
+ // "用户采集进度"取消原因
|
|
|
schedule.setRemark(param.getRemark());
|
|
|
// "用户采集进度"中止操作人员
|
|
|
schedule.setTerminatedBy(operateId);
|
|
|
@@ -1146,7 +1095,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
//获取订单信息
|
|
|
FsStoreOrder fsStoreOrder = storeOrderService.selectFsStoreOrderByOrderCode(param.getOrderCode());
|
|
|
if (fsStoreOrder != null&&"0".equals(fsStoreOrder.getRefundStatus())&&( fsStoreOrder.getStatus()==2||fsStoreOrder.getStatus()==3)){
|
|
|
- //如果传入订单号不为空则在终止时需要执行退款操作
|
|
|
+ //如果传入订单号不为空则在取消时需要执行退款操作
|
|
|
map.setPackageOrderCode(param.getOrderCode());
|
|
|
autoRefund(map,operateType);
|
|
|
}
|
|
|
@@ -1154,7 +1103,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
}
|
|
|
return R.ok();
|
|
|
}
|
|
|
- return R.error("终止失败");
|
|
|
+ return R.error("取消失败");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1327,8 +1276,13 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- private FsUserInformationCollection getFsUserInformationCollection(FsUserInformationCollectionParam param) {
|
|
|
+ /**
|
|
|
+ * 辅助方法:组装信息采集对象
|
|
|
+ * */
|
|
|
+ private FsUserInformationCollection buildUserInfoCollection(FsUserInformationCollectionParam param) {
|
|
|
FsUserInformationCollection fsUserInformationCollection = new FsUserInformationCollection();
|
|
|
+
|
|
|
+ // 处理 answers 的 flag
|
|
|
if (!CollectionUtils.isEmpty(param.getAnswers())) {
|
|
|
param.getAnswers().forEach(answer -> {
|
|
|
if (answer.getFlag() == null) {
|
|
|
@@ -1336,12 +1290,18 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ // 所有基础属性赋值
|
|
|
+ Integer fillFlag = param.getFillFlag() == null ? 1 : param.getFillFlag();
|
|
|
+ fsUserInformationCollection.setFillFlag(fillFlag);
|
|
|
fsUserInformationCollection.setJsonInfo(JSON.toJSONString(param.getAnswers()));
|
|
|
fsUserInformationCollection.setUserId(param.getUserId());
|
|
|
fsUserInformationCollection.setCompanyUserId(param.getCompanyUserId());
|
|
|
fsUserInformationCollection.setQuestionId(param.getQuestionId());
|
|
|
fsUserInformationCollection.setId(param.getId());
|
|
|
- fsUserInformationCollection.setPackageId(param.getPackageId());
|
|
|
+ if (param.getIsPackage() != null&¶m.getIsPackage() == 1){
|
|
|
+ fsUserInformationCollection.setPackageId(param.getPackageId());
|
|
|
+ }
|
|
|
fsUserInformationCollection.setPayType(param.getPayType());
|
|
|
fsUserInformationCollection.setAmount(param.getAmount());
|
|
|
fsUserInformationCollection.setIsPackage(param.getIsPackage());
|
|
|
@@ -1350,7 +1310,11 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
fsUserInformationCollection.setSex(param.getSex());
|
|
|
fsUserInformationCollection.setAllergy(param.getAllergy());
|
|
|
fsUserInformationCollection.setRemark(param.getRemark());
|
|
|
- //获取医生信息
|
|
|
+ fsUserInformationCollection.setAge(param.getAge());
|
|
|
+ fsUserInformationCollection.setCompanyId(param.getCompanyId());
|
|
|
+ fsUserInformationCollection.setCreateTime(DateUtils.getNowDate());
|
|
|
+
|
|
|
+ // 根据销售人员获取医生信息
|
|
|
CompanyUser companyUser = companyUserMapper.selectCompanyUserById(param.getCompanyUserId());
|
|
|
if (companyUser == null) {
|
|
|
throw new CustomException("销售不存在");
|
|
|
@@ -1362,7 +1326,6 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
doctorId = doctor.getDoctorId();
|
|
|
}
|
|
|
} else {
|
|
|
- //随机获取医生id
|
|
|
doctorId = iFsDoctorService.selectFsDoctorDoctorByPackage();
|
|
|
}
|
|
|
fsUserInformationCollection.setDoctorId(doctorId);
|
|
|
@@ -1371,22 +1334,30 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
}
|
|
|
|
|
|
//辅助方法:组装用户信息采集进度对象
|
|
|
- private FsUserInformationCollectionSchedule assembleCreateSchedule(FsUserInformationCollection fsUserInformationCollection){
|
|
|
+ private FsUserInformationCollectionSchedule buildUserInfoSchedule(FsUserInformationCollection param){
|
|
|
FsUserInformationCollectionSchedule shedule = new FsUserInformationCollectionSchedule();
|
|
|
- shedule.setCollectionId(fsUserInformationCollection.getId());
|
|
|
- shedule.setUserId(fsUserInformationCollection.getUserId());
|
|
|
- shedule.setDoctorId(fsUserInformationCollection.getDoctorId());
|
|
|
- shedule.setPackageId(fsUserInformationCollection.getPackageId());
|
|
|
- shedule.setCreateTime(DateUtils.getNowDate());
|
|
|
- shedule.setCompanyUserId(fsUserInformationCollection.getCompanyUserId());
|
|
|
- shedule.setCompanyId(fsUserInformationCollection.getCompanyId());
|
|
|
+ shedule.setCollectionId(param.getId());
|
|
|
+ shedule.setUserId(param.getUserId());
|
|
|
+ shedule.setDoctorId(param.getDoctorId());
|
|
|
+ shedule.setCompanyUserId(param.getCompanyUserId());
|
|
|
+ shedule.setCompanyId(param.getCompanyId());
|
|
|
//任务状态:"进行中"
|
|
|
shedule.setStatus(CollectionTaskStatusEnum.PROCESSING.getCode());
|
|
|
//当前流程节点:"待用户第一次确认"
|
|
|
shedule.setCurrentStep(PrescriptionTaskStepEnum.WAITING_FIRST_CONFIRM.getCode());
|
|
|
- FsPackage fsPackage = packageService.selectFsPackageByPackageId(fsUserInformationCollection.getPackageId());
|
|
|
- if (fsPackage != null){
|
|
|
- shedule.setPackageName(fsPackage.getPackageName());
|
|
|
+ Date currentTime = DateUtils.getNowDate();
|
|
|
+ shedule.setCreateTime(currentTime);
|
|
|
+ if (param.getFillFlag() == 1){
|
|
|
+ //如果填写了就记录填写时间
|
|
|
+ shedule.setFillTime(currentTime);
|
|
|
+ }
|
|
|
+ Long packageId = param.getPackageId();
|
|
|
+ if (packageId != null&¶m.getIsPackage() == 1){
|
|
|
+ shedule.setPackageId(packageId);
|
|
|
+ FsPackage fsPackage = packageService.selectFsPackageByPackageId(param.getPackageId());
|
|
|
+ if (fsPackage != null){
|
|
|
+ shedule.setPackageName(fsPackage.getPackageName());
|
|
|
+ }
|
|
|
}
|
|
|
return shedule;
|
|
|
}
|