|
|
@@ -0,0 +1,1018 @@
|
|
|
+package com.fs.his.service.impl;
|
|
|
+
|
|
|
+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.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.core.redis.RedisCache;
|
|
|
+import com.fs.common.exception.CustomException;
|
|
|
+import com.fs.common.utils.DateUtils;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.company.domain.CompanyUser;
|
|
|
+import com.fs.company.mapper.CompanyUserMapper;
|
|
|
+import com.fs.company.service.ICompanyService;
|
|
|
+import com.fs.core.config.WxMaConfiguration;
|
|
|
+import com.fs.core.config.WxPayProperties;
|
|
|
+import com.fs.core.utils.OrderCodeUtils;
|
|
|
+import com.fs.his.config.FsSysConfig;
|
|
|
+import com.fs.his.domain.*;
|
|
|
+import com.fs.his.dto.FsUserInformationCollectionDTO;
|
|
|
+import com.fs.his.enums.FsStoreOrderStatusEnum;
|
|
|
+import com.fs.his.mapper.*;
|
|
|
+import com.fs.his.param.*;
|
|
|
+import com.fs.his.service.*;
|
|
|
+import com.fs.his.utils.ConfigUtil;
|
|
|
+import com.fs.his.vo.*;
|
|
|
+import com.fs.huifuPay.domain.HuiFuRefundResult;
|
|
|
+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.im.service.OpenIMService;
|
|
|
+import com.fs.system.domain.SysConfig;
|
|
|
+import com.fs.system.mapper.SysConfigMapper;
|
|
|
+import com.fs.system.oss.CloudStorageService;
|
|
|
+import com.fs.system.oss.OSSFactory;
|
|
|
+import com.fs.system.service.ISysConfigService;
|
|
|
+import com.fs.tzBankPay.TzBankService.TzBankService;
|
|
|
+import com.fs.tzBankPay.doman.RefundParam;
|
|
|
+import com.fs.tzBankPay.doman.RefundResult;
|
|
|
+import com.fs.tzBankPay.doman.TzBankResult;
|
|
|
+import com.fs.ybPay.dto.RefundDTO;
|
|
|
+import com.fs.ybPay.service.IPayService;
|
|
|
+import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
|
|
|
+import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
|
+import com.github.binarywang.wxpay.bean.result.WxPayRefundQueryResult;
|
|
|
+import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
|
|
|
+import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
|
+import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
+import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.google.gson.Gson;
|
|
|
+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.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 用户信息采集Service业务层处理
|
|
|
+ *
|
|
|
+ * @author fs
|
|
|
+ * @date 2025-10-14
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserInformationCollectionMapper, FsUserInformationCollection> implements IFsUserInformationCollectionService {
|
|
|
+ Logger logger= LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService configService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SysConfigMapper sysConfigMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WxPayProperties wxPayProperties;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WxPayService wxPayService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IPayService payService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TzBankService tzBankService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private HuiFuService huiFuService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CompanyUserMapper companyUserMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsDoctorMapper doctorMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsDoctorService iFsDoctorService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsQuestionAndAnswerService questionAndAnswerService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsUserInformationCollectionMapper fsUserInformationCollectionMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ConfigUtil configUtil;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsDoctorConfirmService doctorConfirmService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ RedisCache redisCache;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsPackageMapper packageMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsStoreOrderService storeOrderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsPackageOrderMapper packageOrderMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsPrescribeMapper fsPrescribeMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsPrescribeService prescribeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICompanyService companyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsStorePaymentMapper fsStorePaymentMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsStoreOrderLogsMapper fsStoreOrderLogsMapper;
|
|
|
+ @Autowired
|
|
|
+ private DoctorMsgMapper doctorMsgMapper;
|
|
|
+ @Autowired
|
|
|
+ private IFsInquiryOrderService fsInquiryOrderService;
|
|
|
+ @Autowired
|
|
|
+ private OpenIMService openIMService;
|
|
|
+ /**
|
|
|
+ * 查询用户信息采集
|
|
|
+ *
|
|
|
+ * @param id 用户信息采集主键
|
|
|
+ * @return 用户信息采集
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public FsUserInformationCollection selectFsUserInformationCollectionById(Long id)
|
|
|
+ {
|
|
|
+ return baseMapper.selectFsUserInformationCollectionById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询用户信息采集列表
|
|
|
+ *
|
|
|
+ * @param fsUserInformationCollection 用户信息采集
|
|
|
+ * @return 用户信息采集
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<FsUserInformationCollection> selectFsUserInformationCollectionList(FsUserInformationCollection fsUserInformationCollection)
|
|
|
+ {
|
|
|
+ return baseMapper.selectFsUserInformationCollectionList(fsUserInformationCollection);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FsUserInformationCollection> selectFsUserInformationCollectionByDoctorType2(UserInformationDoctorType2Param userInformationDoctorType2Param) {
|
|
|
+ return fsUserInformationCollectionMapper.selectFsUserInformationCollectionByDoctorType2(userInformationDoctorType2Param);
|
|
|
+
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public List<FsUserInformationCollection> selectFsUserInformationCollectionByDoctorType1(UserInformationDoctorType2Param userInformationDoctorType2Param) {
|
|
|
+ return fsUserInformationCollectionMapper.selectFsUserInformationCollectionByDoctorType1(userInformationDoctorType2Param);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增用户信息采集
|
|
|
+ *
|
|
|
+ * @param param 用户信息采集
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Long insertFsUserInformationCollection(FsUserInformationCollectionParam param)
|
|
|
+ {
|
|
|
+
|
|
|
+ FsUserInformationCollection fsUserInformationCollection = getFsUserInformationCollection(param);
|
|
|
+ fsUserInformationCollection.setCreateTime(DateUtils.getNowDate());
|
|
|
+ baseMapper.insertFsUserInformationCollection(fsUserInformationCollection);
|
|
|
+ return fsUserInformationCollection.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改用户信息采集
|
|
|
+ *
|
|
|
+ * @param param 用户信息采集
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Long update(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("确认中,暂无法修改");
|
|
|
+ }
|
|
|
+ FsUserInformationCollection fsUserInformationCollection = getFsUserInformationCollection(param);
|
|
|
+ fsUserInformationCollection.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ baseMapper.updateFsUserInformationCollection(fsUserInformationCollection);
|
|
|
+ return fsUserInformationCollection.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改用户信息采集
|
|
|
+ *
|
|
|
+ * @param param 用户信息采集
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Long updateFsUserInformationCollection(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("确认中,暂无法修改");
|
|
|
+ }
|
|
|
+ //清空订单号
|
|
|
+ fsUserInformationCollectionMapper.collectionOderCodeNULL(param.getId());
|
|
|
+ FsUserInformationCollection fsUserInformationCollection = getFsUserInformationCollection(param);
|
|
|
+ fsUserInformationCollection.setUserConfirm2(0);
|
|
|
+ fsUserInformationCollection.setUserConfirm(0);
|
|
|
+ fsUserInformationCollection.setDoctorConfirm(0);
|
|
|
+ fsUserInformationCollection.setStatus(1);
|
|
|
+ fsUserInformationCollection.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ baseMapper.updateFsUserInformationCollection(fsUserInformationCollection);
|
|
|
+ return fsUserInformationCollection.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量删除用户信息采集
|
|
|
+ *
|
|
|
+ * @param ids 需要删除的用户信息采集主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteFsUserInformationCollectionByIds(Long[] ids)
|
|
|
+ {
|
|
|
+ return baseMapper.deleteFsUserInformationCollectionByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除用户信息采集信息
|
|
|
+ *
|
|
|
+ * @param id 用户信息采集主键
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public int deleteFsUserInformationCollectionById(Long id)
|
|
|
+ {
|
|
|
+ return baseMapper.deleteFsUserInformationCollectionById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public FsUserInformationCollectionVO getInfo(FsUserInformationCollection map) {
|
|
|
+ FsUserInformationCollectionVO vo = new FsUserInformationCollectionVO();
|
|
|
+ Long userId = map.getUserId();
|
|
|
+ Long questionId = map.getQuestionId();
|
|
|
+// FsUserInformationCollection fsUserInformationCollection = baseMapper.selectByUserId(userId);
|
|
|
+ FsUserInformationCollection fsUserInformationCollection = null;
|
|
|
+ if (map.getId() != null){
|
|
|
+ fsUserInformationCollection = baseMapper.selectFsUserInformationCollectionById(map.getId());
|
|
|
+ }
|
|
|
+ if (fsUserInformationCollection != null) {
|
|
|
+ //组装返回数据
|
|
|
+ vo.setQuestionId(fsUserInformationCollection.getQuestionId());
|
|
|
+ vo.setId(fsUserInformationCollection.getId());
|
|
|
+ vo.setAmount(fsUserInformationCollection.getAmount());
|
|
|
+ vo.setPackageId(fsUserInformationCollection.getPackageId());
|
|
|
+ vo.setPayType(fsUserInformationCollection.getPayType());
|
|
|
+ vo.setIsPackage(fsUserInformationCollection.getIsPackage());
|
|
|
+ vo.setSex(fsUserInformationCollection.getSex());
|
|
|
+ vo.setUserPhoneFour(fsUserInformationCollection.getUserPhoneFour());
|
|
|
+ vo.setUserName(fsUserInformationCollection.getUserName());
|
|
|
+ vo.setRemark(fsUserInformationCollection.getRemark());
|
|
|
+ vo.setAllergy(fsUserInformationCollection.getAllergy());
|
|
|
+ if (map.getQuestionId() == null) {
|
|
|
+ FsQuestionAndAnswerVO questionAndAnswerVO = questionAndAnswerService.selectFsQuestionAndAnswerById(fsUserInformationCollection.getQuestionId());
|
|
|
+ List<AnswerVO> answerVOS = JSON.parseArray(fsUserInformationCollection.getJsonInfo(), AnswerVO.class);
|
|
|
+ List<AnswerVO> collect = getAnswerVOs(answerVOS, questionAndAnswerVO.getAnswers());
|
|
|
+ vo.setAnswers(collect);
|
|
|
+ } else {
|
|
|
+ vo.setAnswers(JSON.parseArray(fsUserInformationCollection.getJsonInfo(), AnswerVO.class));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (questionId != null) {
|
|
|
+ vo.setQuestionId(questionId);
|
|
|
+ //问答数据
|
|
|
+ FsQuestionAndAnswerVO questionAndAnswerVO = questionAndAnswerService.selectFsQuestionAndAnswerById(questionId);
|
|
|
+ if (questionAndAnswerVO != null) {
|
|
|
+ questionAndAnswerVO.getAnswers().forEach(answerVO -> {
|
|
|
+ answerVO.setFlag(false);
|
|
|
+ });
|
|
|
+ if (fsUserInformationCollection != null) {
|
|
|
+ vo.getAnswers().addAll(questionAndAnswerVO.getAnswers());
|
|
|
+ vo.setAnswers(getAnswerVOs(vo.getAnswers(),questionAndAnswerVO.getAnswers()));
|
|
|
+ } else {
|
|
|
+ //返回问答
|
|
|
+ vo.setAnswers(questionAndAnswerVO.getAnswers());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(vo.getAnswers())){
|
|
|
+ vo.getAnswers().forEach(answerVO -> {
|
|
|
+ if (answerVO.getSort() == null) {
|
|
|
+ if (answerVO.getTitle().contains("糖尿病")) {
|
|
|
+ answerVO.setSort(1);
|
|
|
+ } else if (answerVO.getTitle().contains("心脑血管")) {
|
|
|
+ answerVO.setSort(2);
|
|
|
+ } else if (answerVO.getTitle().contains("风湿骨病")) {
|
|
|
+ answerVO.setSort(3);
|
|
|
+ } else if (answerVO.getTitle().contains("肝胆")) {
|
|
|
+ answerVO.setSort(4);
|
|
|
+ } else if (answerVO.getTitle().contains("其他")) {
|
|
|
+ answerVO.setSort(5);
|
|
|
+ } else if (answerVO.getTitle().contains("特殊")) {
|
|
|
+ answerVO.setSort(6);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(answerVO.getFlag() == null) {
|
|
|
+ answerVO.setFlag(false);
|
|
|
+ }
|
|
|
+ if (answerVO.getValue() == null) {
|
|
|
+ answerVO.setValue(new ArrayList<>());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //有值且为true排前面
|
|
|
+// List<AnswerVO> collect = vo.getAnswers().stream()
|
|
|
+// .sorted(Comparator.comparing(AnswerVO::getValue, Comparator.nullsFirst(Integer::compareTo)).reversed()).collect(Collectors.toList())
|
|
|
+// .stream()
|
|
|
+// .sorted((a,b)-> Boolean.compare(b.getFlag(),a.getFlag())).collect(Collectors.toList());
|
|
|
+ //List<AnswerVO> collect = vo.getAnswers().stream()
|
|
|
+ // .sorted(Comparator.comparing(AnswerVO::getValue, Comparator.nullsFirst(List::indexOf)).reversed()).collect(Collectors.toList())
|
|
|
+ // .stream()
|
|
|
+ // .sorted((a,b)-> Boolean.compare(b.getFlag(),a.getFlag())).collect(Collectors.toList());
|
|
|
+ List<AnswerVO> collect = vo.getAnswers().stream()
|
|
|
+ .sorted(Comparator.comparing(AnswerVO::getSort)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ vo.setAnswers(collect);
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<FsUserInformationCollectionListDVO> selectFsUserInformationCollectionListDVO(FsUserInformationCollectionListDParam param) {
|
|
|
+ return fsUserInformationCollectionMapper.selectFsUserInformationCollectionListDVO(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public FsUserInformationCollectionVO detail(Long id) {
|
|
|
+ FsUserInformationCollectionVO vo = new FsUserInformationCollectionVO();
|
|
|
+ FsUserInformationCollection collection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(id);
|
|
|
+ if (collection != null) {
|
|
|
+ vo.setAllergy(collection.getAllergy());
|
|
|
+ vo.setRemark(collection.getRemark());
|
|
|
+ vo.setAnswers(JSON.parseArray(collection.getJsonInfo(), AnswerVO.class));
|
|
|
+ List<AnswerVO> answers = vo.getAnswers();
|
|
|
+ if (!CollectionUtils.isEmpty(answers)){
|
|
|
+ List<AnswerVO> collect = answers
|
|
|
+ .stream()
|
|
|
+ .filter(answerVO -> !answerVO.getValue().isEmpty())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(collect)) {
|
|
|
+ collect.forEach(answerVO -> {
|
|
|
+ List<Integer> value = answerVO.getValue();
|
|
|
+ List<AnswerVO.Options> options = answerVO.getOptions();
|
|
|
+ List<AnswerVO.Options> filterOptions = Lists.newArrayList();
|
|
|
+ for (AnswerVO.Options option : options) {
|
|
|
+ if (value.contains(option.getValue())) {
|
|
|
+ filterOptions.add(option);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ answerVO.setOptions(filterOptions);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ vo.setAnswers(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getWxaCodePackageOrderUnLimit(Long collectionId) {
|
|
|
+ logger.info("生成用户信息采集二维码");
|
|
|
+ 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",//release trial
|
|
|
+ 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
|
|
|
+ @Transactional
|
|
|
+ public R doctorConfirm(FsUserInformationCollection collection) {
|
|
|
+ FsUserInformationCollection fsUserInformationCollection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(collection.getId());
|
|
|
+ if (fsUserInformationCollection == null) {
|
|
|
+ return R.error("没有用户采集信息");
|
|
|
+ }
|
|
|
+ if (fsUserInformationCollection.getUserConfirm() == 0){
|
|
|
+ return R.error("用户未确认");
|
|
|
+ }
|
|
|
+ if (fsUserInformationCollection.getDoctorConfirm() == 1){
|
|
|
+ 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();
|
|
|
+ map.setId(collection.getId());
|
|
|
+ map.setDoctorAdvice(collection.getDoctorAdvice());
|
|
|
+ map.setDoctorConfirm(1);
|
|
|
+ //医生确认时间
|
|
|
+ map.setDoctorConfirmTime(DateUtils.getNowDate());
|
|
|
+ //写入医生签名
|
|
|
+ FsDoctor fsDoctor = doctorMapper.selectFsDoctorByDoctorId(fsUserInformationCollection.getDoctorId());
|
|
|
+ map.setDoctorSign(fsDoctor.getSignUrl());
|
|
|
+ map.setDoctorAdvice(collection.getDoctorAdvice());
|
|
|
+ if (answerVOS != null && !answerVOS.isEmpty()) {
|
|
|
+ map.setJsonInfo(JSON.toJSONString(answerVOS));
|
|
|
+ }
|
|
|
+// if (fsUserInformationCollection.getIsPackage() == 1) {
|
|
|
+// //插入生成处方签定时任务数据
|
|
|
+// if(fsUserInformationCollection.getPackageOrderCode() != null) {
|
|
|
+// //套餐包订单
|
|
|
+// FsPackageOrder fsPackageOrder = packageOrderMapper.selectByOderCode(fsUserInformationCollection.getPackageOrderCode());
|
|
|
+// if (fsPackageOrder != null && fsPackageOrder.getIsPay() == 1) {
|
|
|
+// //套餐包信息
|
|
|
+// FsPackage fsPackage = JSON.parseObject(fsPackageOrder.getPackageJson(), FsPackage.class);
|
|
|
+//
|
|
|
+// //套餐包为药品生成处方信息
|
|
|
+// if(fsPackage != null && (fsPackage.getProductType() == 1 || fsPackage.getProductType() == 2 || fsPackage.getProductType() == 3)) {
|
|
|
+// FsStoreOrder fsStoreOrder = storeOrderService.selectFsStoreOrderByOrderCode(fsUserInformationCollection.getPackageOrderCode());
|
|
|
+// if (fsStoreOrder != null && fsStoreOrder.getIsPay() == 1 ) {
|
|
|
+// if (fsStoreOrder.getPrescribeId() != null) {
|
|
|
+//// FsPrescribeParam fsPrescribeParam = new FsPrescribeParam();
|
|
|
+//// fsPrescribeParam.setPrescribeId(fsStoreOrder.getPrescribeId());
|
|
|
+//// prescribeService.confirmPrescribe(fsPrescribeParam);
|
|
|
+// prescribeService.collectionPrescribe(fsStoreOrder.getPrescribeId());
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// throw new CustomException("生成处方信息中......");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// //没有关联套餐包医生确认清空所有状态
|
|
|
+// map.setUserConfirm2(1);
|
|
|
+// }
|
|
|
+
|
|
|
+ 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());
|
|
|
+
|
|
|
+ openIMService.doctorSendMsgToUser(collection.getUserId(),collection.getDoctorId());
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ return R.error("医生确认失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public R doctorType2Confirm(FsUserInformationCollection collection) {
|
|
|
+ FsUserInformationCollection fsUserInformationCollection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(collection.getId());
|
|
|
+ if (fsUserInformationCollection == null) {
|
|
|
+ return R.error("没有用户采集信息");
|
|
|
+ }
|
|
|
+ if (fsUserInformationCollection.getUserConfirm() == 0){
|
|
|
+ return R.error("用户未确认");
|
|
|
+ }
|
|
|
+ if (fsUserInformationCollection.getDoctorType2Confirm() == 1){
|
|
|
+ return R.error("药师已确认");
|
|
|
+ }
|
|
|
+ if (fsUserInformationCollection.getDoctorConfirm() != 1) {
|
|
|
+ return R.error("医生未签字无法确认");
|
|
|
+ }
|
|
|
+ if(StringUtils.isEmpty(fsUserInformationCollection.getPackageOrderCode())){
|
|
|
+ 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();
|
|
|
+ map.setId(collection.getId());
|
|
|
+ map.setDoctorType2Confirm(1);
|
|
|
+ //医生确认时间
|
|
|
+ map.setDoctorConfirmTime(DateUtils.getNowDate());
|
|
|
+ //写入药师签名
|
|
|
+ FsDoctor fsDoctor = doctorMapper.selectFsDoctorByDoctorId(fsUserInformationCollection.getDoctorType2Id());
|
|
|
+ if(fsDoctor.getDoctorType()!=2){
|
|
|
+ return R.error("不是药师身份,无法确认");
|
|
|
+ }
|
|
|
+ map.setDoctorType2Sign(fsDoctor.getSignUrl());
|
|
|
+ map.setDoctorAdvice(collection.getDoctorAdvice());
|
|
|
+ if (answerVOS != null && !answerVOS.isEmpty()) {
|
|
|
+ map.setJsonInfo(JSON.toJSONString(answerVOS));
|
|
|
+ }
|
|
|
+//
|
|
|
+
|
|
|
+ if (fsUserInformationCollectionMapper.updateFsUserInformationCollection(map) > 0) {
|
|
|
+ FsPackageOrder fsPackageOrder = packageOrderMapper.selectFsPackageOrderByOrderSn(collection.getPackageOrderCode());
|
|
|
+ if(fsPackageOrder.getStoreOrderId()==null||fsPackageOrder.getStoreOrderId()==0){
|
|
|
+ return R.error("用户未支付,无需确认");
|
|
|
+ }
|
|
|
+ FsStoreOrder fsStoreOrder = storeOrderService.selectFsStoreOrderByOrderId(fsPackageOrder.getStoreOrderId());
|
|
|
+ fsStoreOrder.setDoctorType2Confirm(1);
|
|
|
+ storeOrderService.updateFsStoreOrder(fsStoreOrder);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ return R.error("药师确认失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public FsUserInfoCollectionUVO info(Long id, Long userId) {
|
|
|
+ FsUserInfoCollectionUVO vo = new FsUserInfoCollectionUVO();
|
|
|
+ FsUserInformationCollection collection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionById(id);
|
|
|
+
|
|
|
+ if (collection != null) {
|
|
|
+
|
|
|
+// if (!Objects.equals(collection.getUserId(), userId)) {
|
|
|
+// return vo;
|
|
|
+// }
|
|
|
+ if (collection.getIsPackage() == 1) {
|
|
|
+ vo.setPackageId(collection.getPackageId());
|
|
|
+ vo.setPayType(collection.getPayType());
|
|
|
+ vo.setAmount(collection.getAmount());
|
|
|
+ FsPackage fsPackage = new FsPackage();
|
|
|
+ FsPackage fsPackage1 = packageMapper.selectFsPackageByPackageId(collection.getPackageId());
|
|
|
+ if (fsPackage1 != null) {
|
|
|
+ fsPackage = fsPackage1;
|
|
|
+ }
|
|
|
+ vo.setFsPackage(fsPackage);
|
|
|
+ CompanyUser companyUser = companyUserMapper.selectCompanyUserById(collection.getCompanyUserId());
|
|
|
+ if (companyUser == null) {
|
|
|
+ throw new CustomException("销售不存在");
|
|
|
+ }
|
|
|
+ vo.setCompanyUserId(collection.getCompanyUserId());
|
|
|
+ vo.setCompanyId(companyUser.getCompanyId());
|
|
|
+ vo.setPackageOrderCode(collection.getPackageOrderCode());
|
|
|
+ FsPackageOrder fsPackageOrder = packageOrderMapper.selectFsPackageOrderByOrderSn(collection.getPackageOrderCode());
|
|
|
+ if(fsPackageOrder!=null) {
|
|
|
+ vo.setOrderStatus(fsPackageOrder.getIsPay());
|
|
|
+ vo.setOrderId(fsPackageOrder.getOrderId());
|
|
|
+ vo.setPatientJson(fsPackageOrder.getPatientJson());
|
|
|
+ if((fsPackage.getProductType() == 1 || fsPackage.getProductType() == 2 || fsPackage.getProductType() == 3) && fsPackageOrder.getIsPay() == 1) {
|
|
|
+ //套餐包为药品且已支付的查询处方订单拿到处方签
|
|
|
+ FsStoreOrder fsStoreOrder = storeOrderService.selectFsStoreOrderByOrderCode(collection.getPackageOrderCode());
|
|
|
+ if (fsStoreOrder != null) {
|
|
|
+ Long prescribeId = fsStoreOrder.getPrescribeId();
|
|
|
+ FsPrescribe fsPrescribe = fsPrescribeMapper.selectFsPrescribeByPrescribeId(prescribeId);
|
|
|
+ if (fsPrescribe != null) {
|
|
|
+ vo.setPrescribeImgUrl(fsPrescribe.getPrescribeImgUrl());
|
|
|
+ vo.setPrescribeStatus(fsPrescribe.getStatus());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new CustomException("没有处方订单");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vo.setIsPackage(collection.getIsPackage());
|
|
|
+ vo.setId(collection.getId());
|
|
|
+ vo.setAnswers(JSON.parseArray(collection.getJsonInfo(), AnswerVO.class));
|
|
|
+ vo.setStatus(collection.getStatus());
|
|
|
+ vo.setUserConfirm(collection.getUserConfirm());
|
|
|
+ vo.setUserConfirm2(collection.getUserConfirm2());
|
|
|
+ vo.setDoctorConfirm(collection.getDoctorConfirm());
|
|
|
+ vo.setUserAdvice(collection.getUserAdvice());
|
|
|
+ vo.setDoctorAdvice(collection.getDoctorAdvice());
|
|
|
+ vo.setDoctor(doctorMapper.selectFsDoctorByDoctorId(collection.getDoctorId()));
|
|
|
+ vo.setAllergy(collection.getAllergy());
|
|
|
+ vo.setRemark(collection.getRemark());
|
|
|
+ vo.setSex(collection.getSex());
|
|
|
+ vo.setUserPhoneFour(collection.getUserPhoneFour());
|
|
|
+ vo.setUserName(collection.getUserName());
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ 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("用户已确认");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!Objects.equals(collection.getUserId(), param.getUserId())) {
|
|
|
+ return R.error("用户信息不匹配,无法确认");
|
|
|
+ }
|
|
|
+ FsUserInformationCollection map = new FsUserInformationCollection();
|
|
|
+ map.setId(param.getId());
|
|
|
+ map.setUserConfirm(1);
|
|
|
+ map.setUserAdvice(param.getUserAdvice());
|
|
|
+ if (param.getPatientId() == null|| param.getPatientId() == 0) {
|
|
|
+ return R.error("请提交就诊人信息");
|
|
|
+ }
|
|
|
+ map.setPatientId(param.getPatientId());
|
|
|
+ if (collection.getStatus() == 1) {
|
|
|
+
|
|
|
+ openIMService.sendUserInformation(collection.getUserId(),collection.getDoctorId(),collection.getId());
|
|
|
+ //用户确认后创建一个问诊订单,待医生接单
|
|
|
+// FsInquiryOrderCreateParam fsInquiryOrderCreateParam = new FsInquiryOrderCreateParam();
|
|
|
+// fsInquiryOrderCreateParam.setIsUserInformation(1);
|
|
|
+// fsInquiryOrderCreateParam.setUserId(collection.getUserId());
|
|
|
+// fsInquiryOrderCreateParam.setPatientId(collection.getPatientId());
|
|
|
+// fsInquiryOrderCreateParam.setOrderType(1);
|
|
|
+// fsInquiryOrderCreateParam.setInquiryType(1);
|
|
|
+// fsInquiryOrderCreateParam.setIsVisit("1");
|
|
|
+// fsInquiryOrderCreateParam.setInquirySubType(3);
|
|
|
+// fsInquiryOrderService.createOrder(fsInquiryOrderCreateParam);
|
|
|
+// //用户第一次确认添加医生消息
|
|
|
+// DoctorMsg msg = new DoctorMsg();
|
|
|
+// String name = collection.getUserName() != null ? collection.getUserName() : "-";
|
|
|
+// //没套餐包的添加医生信息采集建议消息
|
|
|
+// msg.setTitle("用户采集信息建议");
|
|
|
+// msg.setType(3);
|
|
|
+// msg.setContent("患者:" + name + "的信息采集,前往建议");
|
|
|
+// msg.setDoctorId(collection.getDoctorId());
|
|
|
+// msg.setCreateTime(DateUtils.getNowDate());
|
|
|
+// //插入医生消息
|
|
|
+// doctorMsgMapper.insertDoctorMsg(msg);
|
|
|
+// //第一次确认
|
|
|
+ map.setStatus(2);
|
|
|
+ baseMapper.updateFsUserInformationCollection(map);
|
|
|
+ }
|
|
|
+// if (fsUserInformationCollectionMapper.updateFsUserInformationCollection(map) > 0) {
|
|
|
+// //存入医生确认统计时间数据
|
|
|
+// 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);
|
|
|
+// return R.ok();
|
|
|
+// }
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void autoRefund(FsUserInformationCollection collection) {
|
|
|
+
|
|
|
+ //清空订单号
|
|
|
+ fsUserInformationCollectionMapper.collectionOderCodeNULL(collection.getId());
|
|
|
+
|
|
|
+ //更新采集信息状态
|
|
|
+ FsUserInformationCollection map = new FsUserInformationCollection();
|
|
|
+ map.setId(collection.getId());
|
|
|
+ map.setUserConfirm2(0);
|
|
|
+ map.setStatus(1);
|
|
|
+ map.setUserConfirm(0);
|
|
|
+ map.setDoctorConfirm(0);
|
|
|
+ //更新用户信息采集状态
|
|
|
+ fsUserInformationCollectionMapper.updateFsUserInformationCollection(map);
|
|
|
+
|
|
|
+ //退款操作
|
|
|
+ FsStoreOrder fsStoreOrder = storeOrderService.selectFsStoreOrderByOrderCode(collection.getPackageOrderCode());
|
|
|
+ if (fsStoreOrder == null) {
|
|
|
+ throw new CustomException("没有处方订单");
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新处方单信息
|
|
|
+ FsStoreOrder mapStoreOrder = new FsStoreOrder();
|
|
|
+ mapStoreOrder.setOrderId(fsStoreOrder.getOrderId());
|
|
|
+ mapStoreOrder.setStatus(-2);
|
|
|
+ mapStoreOrder.setRefundTime(DateUtils.getNowDate());
|
|
|
+ storeOrderService.updateFsStoreOrder(mapStoreOrder);
|
|
|
+
|
|
|
+ //订单日志
|
|
|
+ FsStoreOrderLogs Logs = new FsStoreOrderLogs();
|
|
|
+ Logs.setChangeMessage(FsStoreOrderStatusEnum.REFUND_STATUS_2.getDesc());
|
|
|
+ Logs.setOrderId(fsStoreOrder.getOrderId());
|
|
|
+ Logs.setChangeTime(new DateTime());
|
|
|
+ Logs.setChangeType(FsStoreOrderStatusEnum.REFUND_STATUS_2.getValue().toString());
|
|
|
+ fsStoreOrderLogsMapper.insertFsStoreOrderLogs(Logs);
|
|
|
+
|
|
|
+ String orderType = "store";
|
|
|
+ Long orderId = fsStoreOrder.getOrderId();
|
|
|
+ if (fsStoreOrder.getPackageOrderId() != null) {
|
|
|
+ orderType = "package";
|
|
|
+
|
|
|
+ FsPackageOrder fsPackageOrder = packageOrderMapper.selectFsPackageOrderByOrderSn(collection.getPackageOrderCode());
|
|
|
+ if (fsPackageOrder == null) {
|
|
|
+ throw new CustomException("没有套餐订单");
|
|
|
+ }
|
|
|
+ orderId = fsStoreOrder.getPackageOrderId();
|
|
|
+
|
|
|
+ //更新套餐单信息
|
|
|
+ FsPackageOrder mapPackageOrder = new FsPackageOrder();
|
|
|
+ mapPackageOrder.setOrderId(fsPackageOrder.getOrderId());
|
|
|
+ mapPackageOrder.setStatus(-2);
|
|
|
+ mapPackageOrder.setRefundStatus(2);
|
|
|
+ packageOrderMapper.updateFsPackageOrder(fsPackageOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fsStoreOrder.getCompanyId() != null) {
|
|
|
+ companyService.refundCompanyMoney(fsStoreOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取支付明细
|
|
|
+ List<FsStorePayment> payments = fsStorePaymentMapper.selectFsStorePaymentByPay(2, fsStoreOrder.getOrderId());
|
|
|
+ if (fsStoreOrder.getPackageOrderId() != null) {
|
|
|
+
|
|
|
+ payments = fsStorePaymentMapper.selectFsStorePaymentByPay(3, fsStoreOrder.getPackageOrderId());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (payments != null && !payments.isEmpty()) {
|
|
|
+ FsStorePayment payment = payments.get(0);
|
|
|
+ String json = configService.selectConfigByKey("his.pay");
|
|
|
+ if (payment.getPayMode().equals("wx")) {
|
|
|
+ WxPayConfig payConfig = new WxPayConfig();
|
|
|
+ SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
|
|
|
+ FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
|
|
|
+ payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
+ payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
+ payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
+ payConfig.setKeyPath(wxPayProperties.getKeyPath());
|
|
|
+ payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+ payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
+ wxPayService.setConfig(payConfig);
|
|
|
+ WxPayRefundRequest refundRequest = new WxPayRefundRequest();
|
|
|
+ refundRequest.setOutTradeNo(orderType + "-" + payment.getPayCode());
|
|
|
+ refundRequest.setOutRefundNo(orderType + "-" + payment.getPayCode());
|
|
|
+ refundRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(payment.getPayMoney().toString()));
|
|
|
+ refundRequest.setRefundFee(WxPayUnifiedOrderRequest.yuanToFen(payment.getPayMoney().toString()));
|
|
|
+ try {
|
|
|
+ WxPayRefundResult refundResult = wxPayService.refund(refundRequest);
|
|
|
+ WxPayRefundQueryResult refundQueryResult = wxPayService.refundQuery("", refundResult.getOutTradeNo(), refundResult.getOutRefundNo(), refundResult.getRefundId());
|
|
|
+ if (refundQueryResult != null && refundQueryResult.getResultCode().equals("SUCCESS")) {
|
|
|
+ FsStorePayment paymentMap = new FsStorePayment();
|
|
|
+ paymentMap.setPaymentId(payment.getPaymentId());
|
|
|
+ paymentMap.setStatus(-1);
|
|
|
+ paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
+ paymentMap.setRefundMoney(payment.getPayMoney());
|
|
|
+ fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
+ } else {
|
|
|
+ throw new CustomException("退款请求失败" + refundQueryResult.getReturnMsg());
|
|
|
+ }
|
|
|
+ } catch (WxPayException e) {
|
|
|
+ throw new CustomException("退款请求失败" + e.getReturnMsg());
|
|
|
+ }
|
|
|
+ } else if (payment.getPayMode().equals("yb")) {
|
|
|
+ //易宝
|
|
|
+ RefundDTO refundDTO = new RefundDTO();
|
|
|
+ refundDTO.setRefundMoney(payment.getPayMoney().toString());
|
|
|
+ refundDTO.setLowRefundNo(orderType + "-" + payment.getPayCode());
|
|
|
+ refundDTO.setUpOrderId(payment.getTradeNo());
|
|
|
+ com.fs.ybPay.domain.RefundResult result = payService.refund(refundDTO);
|
|
|
+ logger.info("订单退款返回结果:退款订单id:" + orderId + result);
|
|
|
+ if (result.getState().equals("5")) {
|
|
|
+ FsStorePayment paymentMap = new FsStorePayment();
|
|
|
+ paymentMap.setPaymentId(payment.getPaymentId());
|
|
|
+ paymentMap.setStatus(-1);
|
|
|
+ paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
+ paymentMap.setRefundMoney(payment.getPayMoney());
|
|
|
+ fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
+ } else {
|
|
|
+ throw new CustomException("退款请求失败" + result.getMessage());
|
|
|
+ }
|
|
|
+ } else if (payment.getPayMode().equals("tz")) {
|
|
|
+ RefundParam tzBankResult = new RefundParam();
|
|
|
+ // 使用set方法为对象的字段赋值
|
|
|
+ //商户原支付订单号
|
|
|
+ tzBankResult.setOldPayOutOrderNo(orderType + payment.getPayCode());
|
|
|
+ // 商户退款订单号 对接平台系统里自己生成的退款订单号
|
|
|
+ tzBankResult.setRefundOrderNo(orderType + payment.getPayCode());
|
|
|
+ // 交易发送时间 yyyyMMddHHmmss
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ tzBankResult.setTrxSendTime(sdf.format(new Date()));
|
|
|
+ // 退款金额
|
|
|
+ tzBankResult.setRefundOrdTransAmt(payment.getPayMoney().doubleValue());
|
|
|
+ TzBankResult<RefundResult> result = tzBankService.refund(tzBankResult);
|
|
|
+ logger.info("订单退款返回结果:退款订单id:" + orderId + result);
|
|
|
+ if (result.getBody().getRefundOrdStatus().equals("90") || result.getBody().getRefundOrdStatus().equals("60")) {
|
|
|
+ FsStorePayment paymentMap = new FsStorePayment();
|
|
|
+ paymentMap.setPaymentId(payment.getPaymentId());
|
|
|
+ paymentMap.setStatus(-1);
|
|
|
+ paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
+ paymentMap.setRefundMoney(payment.getPayMoney());
|
|
|
+ fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
+ } else {
|
|
|
+ throw new CustomException("退款请求失败" + result.getRetMsg());
|
|
|
+ }
|
|
|
+ } else if (payment.getPayMode().equals("hf")) {
|
|
|
+ if (payment.getIsShare() == 1 && payment.getShareStatus() == 1) {
|
|
|
+ V2TradePaymentDelaytransConfirmrefundRequest confirmRefundRequest = new V2TradePaymentDelaytransConfirmrefundRequest();
|
|
|
+ //Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
+ String orderCode = OrderCodeUtils.getOrderSn();
|
|
|
+ if (StringUtils.isEmpty(orderCode)) {
|
|
|
+ throw new CustomException("订单生成失败,请重试");
|
|
|
+ }
|
|
|
+ confirmRefundRequest.setReqSeqId(orderCode);
|
|
|
+ confirmRefundRequest.setOrgReqSeqId(payment.getShareCode());
|
|
|
+// confirmRefundRequest.setOrgReqDate(payment.getShareDate());
|
|
|
+ //多汇付使用appID todo
|
|
|
+// HuifuConfirmrefundResult result = huiFuService.confirmRefund(confirmRefundRequest, null);
|
|
|
+// if (result.getResp_code().equals("00000000") && (result.getTrans_stat().equals("S") || result.getTrans_stat().equals("P"))) {
|
|
|
+// refund(payment, orderType, orderId);
|
|
|
+// } else {
|
|
|
+// throw new CustomException("交易确认退款请求失败" + result.getResp_desc());
|
|
|
+// }
|
|
|
+ } else {
|
|
|
+ refund(payment, orderType, orderId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new CustomException("未找的支付明细");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ private void refund(FsStorePayment payment, String orderType, Long orderId) {
|
|
|
+ V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
|
|
|
+ request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
+ request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
+ request.setReqSeqId("refund-" + payment.getPayCode());
|
|
|
+ Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
+ extendInfoMap.put("org_req_seq_id", orderType + "-" + payment.getPayCode());
|
|
|
+ request.setExtendInfo(extendInfoMap);
|
|
|
+ HuiFuRefundResult refund = huiFuService.refund(request);
|
|
|
+ logger.info("订单退款返回结果:退款订单id:" + orderId + refund);
|
|
|
+ if ((refund.getResp_code().equals("00000000") || refund.getResp_code().equals("00000100")) && (refund.getTrans_stat().equals("S") || refund.getTrans_stat().equals("P"))) {
|
|
|
+ FsStorePayment paymentMap = new FsStorePayment();
|
|
|
+ paymentMap.setPaymentId(payment.getPaymentId());
|
|
|
+ paymentMap.setStatus(-1);
|
|
|
+ paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
+ paymentMap.setRefundMoney(payment.getPayMoney());
|
|
|
+ fsStorePaymentMapper.updateFsStorePayment(paymentMap);
|
|
|
+ } else {
|
|
|
+ throw new CustomException("退款请求失败" + refund.getResp_desc());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public FsUserInformationCollectionVO getCollectionByUserId(Long userId) {
|
|
|
+ FsUserInformationCollectionVO vo = new FsUserInformationCollectionVO();
|
|
|
+ FsUserInformationCollection collection = fsUserInformationCollectionMapper.selectFsUserInformationCollectionByUserId(userId);
|
|
|
+ if (collection != null) {
|
|
|
+ vo.setAnswers(JSON.parseArray(collection.getJsonInfo(), AnswerVO.class));
|
|
|
+ //医生建议
|
|
|
+ if (collection.getDoctorAdvice() != null){
|
|
|
+ vo.setDoctorAdvice(collection.getDoctorAdvice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public FsUserInformationCollectionDTO selectFsUserInformationCollectionDTOById(Long id) {
|
|
|
+ return fsUserInformationCollectionMapper.selectFsUserInformationCollectionDTOById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int updatePackageOrderCode(FsUserInformationCollection fsUserInformationCollection) {
|
|
|
+ return fsUserInformationCollectionMapper.updateFsUserInformationCollection(fsUserInformationCollection);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<AnswerVO> getAnswerVOs(List<AnswerVO> target,List<AnswerVO> source) {
|
|
|
+ target.addAll(source);
|
|
|
+ return target.stream()
|
|
|
+ .collect(Collectors.groupingBy(AnswerVO::getTitle))
|
|
|
+ .values().stream()
|
|
|
+ .map(group -> group.stream().reduce((a, b) -> a).orElse(null))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private FsUserInformationCollection getFsUserInformationCollection(FsUserInformationCollectionParam param) {
|
|
|
+ FsUserInformationCollection fsUserInformationCollection = new FsUserInformationCollection();
|
|
|
+ if (!CollectionUtils.isEmpty(param.getAnswers())) {
|
|
|
+ param.getAnswers().forEach(answer -> {
|
|
|
+ if (answer.getFlag() == null) {
|
|
|
+ answer.setFlag(false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ fsUserInformationCollection.setPayType(param.getPayType());
|
|
|
+ fsUserInformationCollection.setAmount(param.getAmount());
|
|
|
+ fsUserInformationCollection.setIsPackage(param.getIsPackage());
|
|
|
+ fsUserInformationCollection.setUserName(param.getUserName());
|
|
|
+ fsUserInformationCollection.setUserPhoneFour(param.getUserPhoneFour());
|
|
|
+ fsUserInformationCollection.setSex(param.getSex());
|
|
|
+ fsUserInformationCollection.setAllergy(param.getAllergy());
|
|
|
+ fsUserInformationCollection.setRemark(param.getRemark());
|
|
|
+ fsUserInformationCollection.setPatientId(param.getPatientId());
|
|
|
+ fsUserInformationCollection.setDoctorSign(param.getDoctorSign());
|
|
|
+ //获取医生信息
|
|
|
+ CompanyUser companyUser = companyUserMapper.selectCompanyUserById(param.getCompanyUserId());
|
|
|
+ if (companyUser == null) {
|
|
|
+ throw new CustomException("销售不存在");
|
|
|
+ }
|
|
|
+ Long doctorId = null;
|
|
|
+ if (companyUser.getDoctorId() != null) {
|
|
|
+ FsDoctor doctor = doctorMapper.selectFsDoctorByDoctorId(companyUser.getDoctorId());
|
|
|
+ if (doctor != null) {
|
|
|
+ doctorId = doctor.getDoctorId();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //随机获取医生id
|
|
|
+ doctorId = iFsDoctorService.selectFsDoctorDoctorByPackage();
|
|
|
+ }
|
|
|
+ fsUserInformationCollection.setDoctorId(doctorId);
|
|
|
+
|
|
|
+ return fsUserInformationCollection;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+// String str1 = "[{\"options\":[{\"flag\":false,\"name\":\"通天\",\"value\":0},{\"flag\":false,\"name\":\"哈哈\",\"value\":1}],\"title\":\"测试标题1\",\"value\":1},{\"options\":[{\"flag\":false,\"name\":\"呼呼\",\"value\":0},{\"flag\":false,\"name\":\"嘻嘻\",\"value\":1}],\"title\":\"测试标题2\",\"value\":1},{\"options\":[{\"flag\":false,\"name\":\"胸痛\",\"value\":0},{\"flag\":false,\"name\":\"胸闷\",\"value\":1},{\"flag\":false,\"name\":\"头晕\",\"value\":2},{\"flag\":false,\"name\":\"肢体麻木\",\"value\":3},{\"flag\":false,\"name\":\"无\",\"value\":4}],\"title\":\"您目前是否有心脑血管相关症状,如胸痛、胸闷、头晕、肢体麻木等?\",\"value\":1}]";
|
|
|
+// String str2 = "[{\"options\":[{\"flag\":true,\"name\":\"胸痛\",\"value\":0},{\"flag\":true,\"name\":\"胸闷\",\"value\":1},{\"flag\":true,\"name\":\"头晕\",\"value\":2},{\"flag\":true,\"name\":\"肢体麻木\",\"value\":3},{\"flag\":true,\"name\":\"无\",\"value\":4}],\"title\":\"您目前是否有心脑血管相关症状,如胸痛、胸闷、头晕、肢体麻木等?\",\"value\":1},{\"options\":[{\"flag\":false,\"name\":\"胃疼\",\"value\":0},{\"flag\":false,\"name\":\"反酸\",\"value\":1},{\"flag\":false,\"name\":\"恶心\",\"value\":2},{\"flag\":false,\"name\":\"呕吐\",\"value\":3},{\"flag\":false,\"name\":\"黑便\",\"value\":4},{\"flag\":false,\"name\":\"无\",\"value\":5}],\"title\":\"您近期是否出现胃部不适症状,如胃痛、反酸、恶心、呕吐或黑便?\",\"value\":1}]";
|
|
|
+// List<AnswerVO> vo1 = null;
|
|
|
+// List<AnswerVO> vo2 = JSON.parseArray(str2, AnswerVO.class);
|
|
|
+// System.out.println(vo1);
|
|
|
+// System.out.println(vo2);
|
|
|
+// vo2.addAll(vo1);
|
|
|
+// Map<String, List<AnswerVO>> collect = vo2.stream()
|
|
|
+// .collect(Collectors.groupingBy(AnswerVO::getTitle));
|
|
|
+// List<AnswerVO> collect1 = vo2.stream()
|
|
|
+// .collect(Collectors.groupingBy(AnswerVO::getTitle))
|
|
|
+// .values().stream()
|
|
|
+// .map(group -> group.stream().reduce((a, b) -> a).orElse(null)).collect(Collectors.toList());
|
|
|
+// System.out.println(JSON.toJSONString(collect));
|
|
|
+// System.out.println(JSON.toJSONString(collect1));
|
|
|
+ boolean contains = "是否有糖尿病相关疾病?".contains("糖尿病");
|
|
|
+ }
|
|
|
+}
|