|
@@ -8,25 +8,43 @@ import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
|
+import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
|
|
+import cn.hutool.core.date.DateUnit;
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.fs.common.BeanCopyUtils;
|
|
import com.fs.common.BeanCopyUtils;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
|
|
+import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
|
|
+import com.fs.core.config.WxMaConfiguration;
|
|
|
|
|
+import com.fs.course.param.CollectionInfoConfirmParam;
|
|
|
|
|
+import com.fs.course.vo.FsUserInfoCollectionUVO;
|
|
|
|
|
+import com.fs.his.config.FsSysConfig;
|
|
|
import com.fs.his.domain.FsDoctor;
|
|
import com.fs.his.domain.FsDoctor;
|
|
|
import com.fs.his.mapper.FsDoctorMapper;
|
|
import com.fs.his.mapper.FsDoctorMapper;
|
|
|
import com.fs.his.service.IFsDoctorService;
|
|
import com.fs.his.service.IFsDoctorService;
|
|
|
import com.fs.his.service.IFsQuestionAndAnswerService;
|
|
import com.fs.his.service.IFsQuestionAndAnswerService;
|
|
|
|
|
+import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.his.vo.AnswerVO;
|
|
import com.fs.his.vo.AnswerVO;
|
|
|
import com.fs.his.vo.FsQuestionAndAnswerVO;
|
|
import com.fs.his.vo.FsQuestionAndAnswerVO;
|
|
|
import com.fs.hisStore.param.FsUserInformationCollectionListDParam;
|
|
import com.fs.hisStore.param.FsUserInformationCollectionListDParam;
|
|
|
import com.fs.hisStore.param.FsUserInformationCollectionParam;
|
|
import com.fs.hisStore.param.FsUserInformationCollectionParam;
|
|
|
import com.fs.hisStore.vo.FsUserInformationCollectionListDVO;
|
|
import com.fs.hisStore.vo.FsUserInformationCollectionListDVO;
|
|
|
import com.fs.hisStore.vo.FsUserInformationCollectionVO;
|
|
import com.fs.hisStore.vo.FsUserInformationCollectionVO;
|
|
|
|
|
+import com.fs.store.domain.FsDoctorConfirm;
|
|
|
|
|
+import com.fs.store.service.IFsDoctorConfirmService;
|
|
|
|
|
+import com.fs.system.oss.CloudStorageService;
|
|
|
|
|
+import com.fs.system.oss.OSSFactory;
|
|
|
|
|
+import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.fs.hisStore.mapper.FsUserInformationCollectionMapper;
|
|
import com.fs.hisStore.mapper.FsUserInformationCollectionMapper;
|
|
@@ -42,7 +60,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserInformationCollectionMapper, FsUserInformationCollection> implements IFsUserInformationCollectionService {
|
|
public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserInformationCollectionMapper, FsUserInformationCollection> implements IFsUserInformationCollectionService {
|
|
|
-
|
|
|
|
|
|
|
+ Logger logger= LoggerFactory.getLogger(getClass());
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private CompanyUserMapper companyUserMapper;
|
|
private CompanyUserMapper companyUserMapper;
|
|
|
|
|
|
|
@@ -58,6 +76,15 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private FsUserInformationCollectionMapper fsUserInformationCollectionMapper;
|
|
private FsUserInformationCollectionMapper fsUserInformationCollectionMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ConfigUtil configUtil;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IFsDoctorConfirmService doctorConfirmService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ RedisCache redisCache;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询用户信息采集
|
|
* 查询用户信息采集
|
|
|
*
|
|
*
|
|
@@ -148,6 +175,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
vo.setAmount(fsUserInformationCollection.getAmount());
|
|
vo.setAmount(fsUserInformationCollection.getAmount());
|
|
|
vo.setPackageId(fsUserInformationCollection.getPackageId());
|
|
vo.setPackageId(fsUserInformationCollection.getPackageId());
|
|
|
vo.setPayType(fsUserInformationCollection.getPayType());
|
|
vo.setPayType(fsUserInformationCollection.getPayType());
|
|
|
|
|
+ vo.setIsPackage(fsUserInformationCollection.getIsPackage());
|
|
|
if (map.getQuestionId() == null) {
|
|
if (map.getQuestionId() == null) {
|
|
|
FsQuestionAndAnswerVO questionAndAnswerVO = questionAndAnswerService.selectFsQuestionAndAnswerById(fsUserInformationCollection.getQuestionId());
|
|
FsQuestionAndAnswerVO questionAndAnswerVO = questionAndAnswerService.selectFsQuestionAndAnswerById(fsUserInformationCollection.getQuestionId());
|
|
|
List<AnswerVO> answerVOS = JSON.parseArray(fsUserInformationCollection.getJsonInfo(), AnswerVO.class);
|
|
List<AnswerVO> answerVOS = JSON.parseArray(fsUserInformationCollection.getJsonInfo(), AnswerVO.class);
|
|
@@ -200,6 +228,45 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
return vo;
|
|
return vo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R getWxaCodePackageOrderUnLimit(Long collectionId) {
|
|
|
|
|
+ FsSysConfig sysConfig = configUtil.getSysConfig();
|
|
|
|
|
+
|
|
|
|
|
+ final WxMaService wxMaService = WxMaConfiguration.getMaService(sysConfig.getAppid());
|
|
|
|
|
+
|
|
|
|
|
+ String scene="collectionId="+ collectionId ;
|
|
|
|
|
+ byte[] file;
|
|
|
|
|
+ try {
|
|
|
|
|
+ file = wxMaService.getQrcodeService().createWxaCodeUnlimitBytes(
|
|
|
|
|
+ scene,
|
|
|
|
|
+ "pages_order/confirmUserinfo",
|
|
|
|
|
+ true,
|
|
|
|
|
+ "release",
|
|
|
|
|
+ 430,
|
|
|
|
|
+ true,
|
|
|
|
|
+ null,
|
|
|
|
|
+ false);
|
|
|
|
|
+
|
|
|
|
|
+ // 上传图片到存储桶
|
|
|
|
|
+ String suffix = ".png";
|
|
|
|
|
+ CloudStorageService storage = OSSFactory.build();
|
|
|
|
|
+ String url;
|
|
|
|
|
+ try {
|
|
|
|
|
+ url = storage.uploadSuffix(file, suffix);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ // 记录错误日志
|
|
|
|
|
+ logger.error("生成图片失败:{}",e.getMessage(),e);
|
|
|
|
|
+ return R.error("生成图片失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 返回成功信息
|
|
|
|
|
+ return R.ok().put("url",url);
|
|
|
|
|
+
|
|
|
|
|
+ } catch (WxErrorException e) {
|
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
|
+ return R.error("微信接口调用失败: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public R doctorConfirm(FsUserInformationCollection collection) {
|
|
public R doctorConfirm(FsUserInformationCollection collection) {
|
|
|
FsUserInformationCollection fsUserInformationCollection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(collection.getId());
|
|
FsUserInformationCollection fsUserInformationCollection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(collection.getId());
|
|
@@ -212,16 +279,102 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
if (fsUserInformationCollection.getDoctorConfirm() == 1){
|
|
if (fsUserInformationCollection.getDoctorConfirm() == 1){
|
|
|
return R.error("医生已确认");
|
|
return R.error("医生已确认");
|
|
|
}
|
|
}
|
|
|
|
|
+ List<AnswerVO> answerVOS = null;
|
|
|
|
|
+ //医生确认确认状态为true(用于封档)
|
|
|
|
|
+ if (StringUtils.isNotEmpty(fsUserInformationCollection.getJsonInfo()) ){
|
|
|
|
|
+ answerVOS = JSONArray.parseArray(fsUserInformationCollection.getJsonInfo(), AnswerVO.class);
|
|
|
|
|
+ answerVOS.forEach(answerVO -> {
|
|
|
|
|
+ answerVO.setFlag(true);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
FsUserInformationCollection map = new FsUserInformationCollection();
|
|
FsUserInformationCollection map = new FsUserInformationCollection();
|
|
|
|
|
+ if (answerVOS != null && !answerVOS.isEmpty()) {
|
|
|
|
|
+ map.setJsonInfo(JSON.toJSONString(answerVOS));
|
|
|
|
|
+ }
|
|
|
map.setId(collection.getId());
|
|
map.setId(collection.getId());
|
|
|
map.setDoctorAdvice(collection.getDoctorAdvice());
|
|
map.setDoctorAdvice(collection.getDoctorAdvice());
|
|
|
map.setDoctorConfirm(1);
|
|
map.setDoctorConfirm(1);
|
|
|
if (fsUserInformationCollectionMapper.updateFsUserInformationCollection(map) > 0) {
|
|
if (fsUserInformationCollectionMapper.updateFsUserInformationCollection(map) > 0) {
|
|
|
|
|
+
|
|
|
|
|
+ //更新医生确认信息
|
|
|
|
|
+ FsDoctorConfirm doctorConfirm = redisCache.getCacheObject("doctorConfirm:" + collection.getId());
|
|
|
|
|
+ if(doctorConfirm == null) {
|
|
|
|
|
+ return R.error("没有医生确认信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ doctorConfirm.setDoctorEndTime(DateUtils.getNowDate());
|
|
|
|
|
+ Long seconds = DateUtil.between(doctorConfirm.getStartTime(), doctorConfirm.getDoctorEndTime(), DateUnit.SECOND);
|
|
|
|
|
+ doctorConfirm.setConfirmSecond(seconds);
|
|
|
|
|
+ doctorConfirmService.updateFsDoctorConfirm(doctorConfirm);
|
|
|
|
|
+ redisCache.deleteObject("doctorConfirm:" + collection.getId());
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
return R.error("医生确认失败");
|
|
return R.error("医生确认失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public FsUserInfoCollectionUVO info(Long id) {
|
|
|
|
|
+ FsUserInfoCollectionUVO vo = new FsUserInfoCollectionUVO();
|
|
|
|
|
+ FsUserInformationCollection collection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(id);
|
|
|
|
|
+ if (collection != null) {
|
|
|
|
|
+ if (collection.getIsPackage() == 1) {
|
|
|
|
|
+ vo.setPackageId(collection.getPackageId());
|
|
|
|
|
+ vo.setPayType(collection.getPayType());
|
|
|
|
|
+ vo.setAmount(collection.getAmount());
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ vo.setIsPackage(collection.getIsPackage());
|
|
|
|
|
+ vo.setId(collection.getId());
|
|
|
|
|
+ vo.setAnswers(JSON.parseArray(collection.getJsonInfo(), AnswerVO.class));
|
|
|
|
|
+ vo.setStatus(collection.getStatus());
|
|
|
|
|
+ }
|
|
|
|
|
+ return vo;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R userConfirm(CollectionInfoConfirmParam param) {
|
|
|
|
|
+ if (param.getId() == null) {
|
|
|
|
|
+ return R.error("参数错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ FsUserInformationCollection collection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(param.getId());
|
|
|
|
|
+ if (collection == null) {
|
|
|
|
|
+ return R.error("没有用户采集信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (collection.getStatus() == 1 ){
|
|
|
|
|
+ if (collection.getUserConfirm() == 1){
|
|
|
|
|
+ return R.error("用户已确认");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ FsUserInformationCollection map = new FsUserInformationCollection();
|
|
|
|
|
+ map.setId(param.getId());
|
|
|
|
|
+ map.setUserConfirm(1);
|
|
|
|
|
+ map.setUserAdvice(param.getUserAdvice());
|
|
|
|
|
+
|
|
|
|
|
+ //绑定了套餐包的用户第二次确认清空所有确认状态 未绑定的医生确认清空所有确认状态
|
|
|
|
|
+ if(collection.getIsPackage() == 1){
|
|
|
|
|
+ //第一次确认
|
|
|
|
|
+ if (collection.getStatus() == 1) {
|
|
|
|
|
+ map.setStatus(2);
|
|
|
|
|
+
|
|
|
|
|
+ //存入医生确认统计时间数据
|
|
|
|
|
+ FsDoctorConfirm doctorConfirm = new FsDoctorConfirm();
|
|
|
|
|
+ doctorConfirm.setCollectionId(collection.getId());
|
|
|
|
|
+ doctorConfirm.setDoctorId(collection.getDoctorId());
|
|
|
|
|
+ doctorConfirm.setStartTime(DateUtils.getNowDate());
|
|
|
|
|
+ doctorConfirmService.insertFsDoctorConfirm(doctorConfirm);
|
|
|
|
|
+ redisCache.setCacheObject("doctorConfirm:" + collection.getId(), doctorConfirm);
|
|
|
|
|
+
|
|
|
|
|
+ } else if (collection.getStatus() == 2) {
|
|
|
|
|
+ map.setStatus(1);
|
|
|
|
|
+ map.setDoctorConfirm(0);
|
|
|
|
|
+ map.setUserConfirm(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (fsUserInformationCollectionMapper.updateFsUserInformationCollection(map) > 0) {
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.error("用户确认失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private List<AnswerVO> getAnswerVOs(List<AnswerVO> target,List<AnswerVO> source) {
|
|
private List<AnswerVO> getAnswerVOs(List<AnswerVO> target,List<AnswerVO> source) {
|
|
|
target.addAll(source);
|
|
target.addAll(source);
|
|
|
return target.stream()
|
|
return target.stream()
|
|
@@ -248,6 +401,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
|
|
|
fsUserInformationCollection.setPackageId(param.getPackageId());
|
|
fsUserInformationCollection.setPackageId(param.getPackageId());
|
|
|
fsUserInformationCollection.setPayType(param.getPayType());
|
|
fsUserInformationCollection.setPayType(param.getPayType());
|
|
|
fsUserInformationCollection.setAmount(param.getAmount());
|
|
fsUserInformationCollection.setAmount(param.getAmount());
|
|
|
|
|
+ fsUserInformationCollection.setIsPackage(param.getIsPackage());
|
|
|
//获取医生信息
|
|
//获取医生信息
|
|
|
CompanyUser companyUser = companyUserMapper.selectCompanyUserById(param.getCompanyUserId());
|
|
CompanyUser companyUser = companyUserMapper.selectCompanyUserById(param.getCompanyUserId());
|
|
|
if (companyUser == null) {
|
|
if (companyUser == null) {
|