소스 검색

改版信息采集表

cgp 4 일 전
부모
커밋
5f239b1156

+ 2 - 2
fs-company/src/main/java/com/fs/hisStore/controller/FsUserInformationCollectionController.java

@@ -256,8 +256,8 @@ public class FsUserInformationCollectionController extends BaseController
      * 根据用户id最新审核通过处方信息
      * */
     @GetMapping("/getLastAuditPassPrescribeInfo")
-    public AjaxResult getLastAuditPassPrescribeInfo(@RequestParam Long userId){
-        FsPrescribe fsPrescribe = prescribeService.selectNewestAuditedPrescribeByUserId(userId);
+    public AjaxResult getLastAuditPassPrescribeInfo(@RequestParam Long collectionId){
+        FsPrescribe fsPrescribe = prescribeService.selectNewestAuditedPrescribeByCollectionId(collectionId);
         return AjaxResult.success(fsPrescribe);
     }
 

+ 7 - 0
fs-service/src/main/java/com/fs/course/param/CollectionInfoConfirmParam.java

@@ -1,5 +1,6 @@
 package com.fs.course.param;
 
+import com.fs.his.domain.FsPatient;
 import com.fs.his.vo.AnswerVO;
 import lombok.Data;
 
@@ -18,4 +19,10 @@ public class CollectionInfoConfirmParam {
      * 模板问题以及答案
      */
     private List<AnswerVO> answers;
+
+    /**
+     * 患者信息
+     * */
+    private FsPatient patientInfo;
+
 }

+ 5 - 0
fs-service/src/main/java/com/fs/his/mapper/FsPrescribeMapper.java

@@ -334,4 +334,9 @@ public interface FsPrescribeMapper
      * 根据用户id查询最新审核通过的处方信息
      * */
     FsPrescribe selectNewestAuditedPrescribeByUserId(@Param("userId") Long userId);
+
+    /**
+     * 根据采集信息主键id查询最新审核通过的处方信息
+     * */
+    FsPrescribe selectNewestAuditedPrescribeByCollectionId(@Param("collectionId") Long collectionId);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/his/service/IFsPrescribeService.java

@@ -159,4 +159,9 @@ public interface IFsPrescribeService
      * 根据用户id查询最新审核通过的处方信息
      * */
     FsPrescribe selectNewestAuditedPrescribeByUserId(Long userId);
+
+    /**
+     * 根据用户id查询最新审核通过的处方信息
+     * */
+    FsPrescribe selectNewestAuditedPrescribeByCollectionId(Long collectionId);
 }

+ 15 - 3
fs-service/src/main/java/com/fs/his/service/impl/FsPackageOrderServiceImpl.java

@@ -32,6 +32,7 @@ import com.fs.config.cloud.CloudHostProper;
 import com.fs.core.config.WxMaConfiguration;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
+import com.fs.enums.PostPayPrescStatusEnum;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.*;
 import com.fs.his.dto.PackageConfigDTO;
@@ -703,7 +704,14 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                     return R.error("联系销售添加默认收货地址");
                 }
-                if(collection.getStatus()!=null&&collection.getStatus()==2){
+                if(collection.getStatus()!=null&&collection.getStatus()==2&&collection.getQwTag()==0){
+                    //企微用户信息采集订单避免重复创建
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    logger.info("订单已创建!,采集信息collectionId:{},订单id:{}",collection.getId(),collection.getPackageOrderCode());
+                    return R.ok();
+                }
+                if(collection.getStatus()!=null&& Objects.equals(collection.getPersonalCollectStatus(), PostPayPrescStatusEnum.ORDER_PAID.getCode()) &&collection.getQwTag()==1){
+                    //个微用户信息采集订单避免重复创建
                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                     logger.info("订单已创建!,采集信息collectionId:{},订单id:{}",collection.getId(),collection.getPackageOrderCode());
                     return R.ok();
@@ -865,6 +873,10 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                     FsUserInformationCollection collectionUser = new FsUserInformationCollection();
                     collectionUser.setId(collection.getId());
                     collectionUser.setPackageOrderCode(orderSn);
+                    if (collection.getQwTag() == 1){
+                        //个微用户信息采集需要更新状态
+                        collectionUser.setPersonalCollectStatus(PostPayPrescStatusEnum.ORDER_PAID.getCode());
+                    }
                     userInformationCollectionMapper.updateFsUserInformationCollection(collectionUser);
 
                     //信息采集关联套餐包且意向金额小于等于0处理为已支付的订单
@@ -1055,7 +1067,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
         FsPackageOrder order=null;
         HuifuOrderConfirmResult result = null;
         if(type.equals(1)){
-            FsStorePayment storePayment = fsStorePaymentMapper.selectFsStorePaymentByPaymentCode(payCode);
+            FsStorePayment storePayment = fsStorePaymentMapper.selectFsStorePaymentByPaymentCode(payCode);//支付单号
             if (storePayment!=null){
                 if(storePayment.getStatus().equals(0)){
 
@@ -1082,7 +1094,7 @@ public class FsPackageOrderServiceImpl implements IFsPackageOrderService
                         paymentMap.setBankTransactionId(orderResult.getBankTrxId());
                     }
 
-                    order=fsPackageOrderMapper.selectFsPackageOrderByOrderId(Long.parseLong(storePayment.getBusinessId()));
+                    order=fsPackageOrderMapper.selectFsPackageOrderByOrderId(Long.parseLong(storePayment.getBusinessId()));//订单id主键
 //                    FsPackage fsPackage = fsPackageMapper.selectFsPackageByPackageId(order.getPackageId());
 //                    BigDecimal divAmount = null;
 //                    //默认全部进入中医院

+ 5 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeServiceImpl.java

@@ -1646,4 +1646,9 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         return fsPrescribeMapper.selectNewestAuditedPrescribeByUserId(userId);
     }
 
+    @Override
+    public FsPrescribe selectNewestAuditedPrescribeByCollectionId(Long collectionId) {
+        return fsPrescribeMapper.selectNewestAuditedPrescribeByCollectionId(collectionId);
+    }
+
 }

+ 17 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -331,6 +331,9 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
     @Autowired
     private IFsAmountsShareMerchantService amountsShareMerchantService;
 
+    @Autowired
+    private IFsPrescribeService prescribeService;
+
     //ERP 类型到服务的映射
     private Map<Integer, IErpOrderService> erpServiceMap;
     @Autowired
@@ -1188,6 +1191,20 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService {
             order.setFollowStatus(0);
         }
         if (fsStoreOrderMapper.insertFsStoreOrder(order) > 0) {
+
+            if(!isPre){
+                //创建支付回调订单后 个微用户的订单需要特殊处理  这个是先开方后付款
+                FsPrescribe fsPrescribe = prescribeService.selectNewestAuditedPrescribeByCollectionId(collection.getId());
+                if (fsPrescribe == null){
+                    logger.error("个微信息采集未找到匹配的开方数据,采集信息id:{}",collection.getId());
+                }else {
+                    //处方绑定订单id
+                    fsPrescribe.setStoreOrderId(order.getOrderId());
+                    prescribeService.updateFsPrescribe(fsPrescribe);
+                    //回调订单绑定处方id
+                    order.setPrescribeId(fsPrescribe.getPrescribeId());
+                }
+            }
             //插入生成订单档期日志
             FsOrderSopLog fsOrderSopLog = new FsOrderSopLog();
             fsOrderSopLog.setOrderId(order.getOrderId());

+ 10 - 0
fs-service/src/main/java/com/fs/hisStore/dto/FsUserInformationCollectionOverviewDTO.java

@@ -33,6 +33,16 @@ public class FsUserInformationCollectionOverviewDTO  extends BaseEntity {
     //个微状态
     private Integer personalCollectStatus;
 
+    /*
+     *套餐包名称
+     * */
+    private String packageName;
+
+    /**
+     * 订单号
+     */
+    private String packageOrderCode;
+
     @ApiModelProperty(value = "页码,默认为1")
     private Integer pageNum =1;
 

+ 51 - 20
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserInformationCollectionServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fs.hisStore.service.impl;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.function.Function;
@@ -380,7 +381,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         return fsUserInformationCollection;
     }
 
-    //个微信息采集确认并生成医生待开处方
+    //个微信息采集用户确认并生成医生待开处方
     @Override
     @Transactional(rollbackFor = Exception.class)
     public R generateFormalPrescription(CollectionInfoConfirmParam param) {
@@ -397,8 +398,8 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         collection.setPersonalCollectStatus(PostPayPrescStatusEnum.FULLY_COLLECTED_DATA.getCode());
         if (fsUserInformationCollectionMapper.updateFsUserInformationCollection(collection) > 0) {
             //新增fs_prescribe处方信息
-            FsPrescribe fsPrescribe = transformCollectionDtoToFsPrescribe(param, collection);
-            fsPrescribe.setCollectionId(collection.getId());
+            FsPrescribe fsPrescribe = transformCollectionParamToFsPrescribe(param, collection);
+
             int addPrescribeResult = fsPrescribeMapper.insertFsPrescribe(fsPrescribe);
 
             //存入医生确认统计时间数据
@@ -415,7 +416,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         return R.error("用户确认失败");
     }
 
-    private FsPrescribe transformCollectionDtoToFsPrescribe(CollectionInfoConfirmParam param, FsUserInformationCollection fsUserInformationCollection) {
+    private FsPrescribe transformCollectionParamToFsPrescribe(CollectionInfoConfirmParam param, FsUserInformationCollection fsUserInformationCollection) {
         //构建处方编号
         String prescribeCode = IdUtil.getSnowflake(0, 0).nextIdStr();
         FsPrescribe fsPrescribe = new FsPrescribe();
@@ -424,21 +425,8 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         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());
+        fsPrescribe.setCollectionId(fsUserInformationCollection.getId());
         //查询销售绑定医生
         CompanyUser companyUser = companyUserMapper.selectCompanyUserByCompanyUserId(fsUserInformationCollection.getCompanyUserId());
         if (companyUser == null || companyUser.getDoctorId() == null) {
@@ -452,7 +440,6 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
             log.error("开方医生信息获取异常:" + companyUser.getDoctorId());
             throw new CustomException("网络异常,请稍后再试!");
         }
-
         fsPrescribe.setPrescribeDoctorId(fsDoctor.getDoctorId());
         fsPrescribe.setPrescribeDoctorSignUrl(fsDoctor.getSignUrl());
         //分配在线的随机药师
@@ -467,6 +454,14 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
             log.error("分配药师失败 - 处方号:{}", prescribeCode, e);
             throw new CustomException("网络异常,请稍后再试!");
         }
+        //组装处方表里的患者信息
+        String birthday = String.valueOf(param.getPatientInfo().getBirthday());
+        fsPrescribe.setPatientBirthday(birthday);
+        fsPrescribe.setPatientAge(String.valueOf(calculateAge(birthday)));
+        fsPrescribe.setPatientId(param.getPatientInfo().getPatientId());
+        fsPrescribe.setPatientName(param.getPatientInfo().getPatientName());
+        fsPrescribe.setPatientTel(param.getPatientInfo().getMobile());
+        fsPrescribe.setPatientGender(String.valueOf(param.getPatientInfo().getSex()));
         return fsPrescribe;
     }
 
@@ -477,6 +472,42 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
         }
     }
 
+    /**
+     * 根据出生日期计算年龄
+     * @param birthday 出生日期,格式:yyyy-MM-dd
+     * @return Integer类型的年龄,如果入参无效返回null
+     */
+    public static Integer calculateAge(String birthday) {
+        if (org.apache.commons.lang3.StringUtils.isBlank(birthday)) {
+            return null;
+        }
+
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            sdf.setLenient(false);
+            Date birthDate = sdf.parse(birthday);
+
+            Calendar birthCal = Calendar.getInstance();
+            birthCal.setTime(birthDate);
+
+            Calendar nowCal = Calendar.getInstance();
+
+            int age = nowCal.get(Calendar.YEAR) - birthCal.get(Calendar.YEAR);
+
+            // 如果今年还没过生日,年龄减1
+            if (nowCal.get(Calendar.MONTH) < birthCal.get(Calendar.MONTH) ||
+                    (nowCal.get(Calendar.MONTH) == birthCal.get(Calendar.MONTH) &&
+                            nowCal.get(Calendar.DAY_OF_MONTH) < birthCal.get(Calendar.DAY_OF_MONTH))) {
+                age--;
+            }
+
+            return age;
+
+        } catch (ParseException e) {
+            throw new CustomException("用户年龄计算异常", 500);
+        }
+    }
+
     /**
      * 批量删除用户信息采集
      *
@@ -1646,7 +1677,7 @@ public class FsUserInformationCollectionServiceImpl extends ServiceImpl<FsUserIn
     @Override
     public List<FsUserInformationCollectionOverviewVo> fullyCollectionInfoList(FsUserInformationCollectionOverviewDTO queryDto) {
         queryDto.setCompleteStatus(1);//已完善信息标识
-        queryDto.setQwTag(1);//个微采集表
+        queryDto.setQwTag(1);//个微标识
         PageHelper.startPage(queryDto.getPageNum(), queryDto.getPageSize());
         List<FsUserInformationCollectionOverviewVo> resultList=fsUserInformationCollectionMapper.selectUserInformationCollectionOverviewByPage(queryDto);
         if (CollectionUtils.isEmpty(resultList)){

+ 10 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsUserInformationCollectionOverviewVo.java

@@ -75,6 +75,16 @@ public class FsUserInformationCollectionOverviewVo {
     @Excel(name = "处方图片URL")
     private String prescribeImgUrlString;
 
+    /*
+    *套餐包名称
+    * */
+    private String packageName;
+
+    /**
+     * 订单号
+     */
+    private String packageOrderCode;
+
     /**
      * 信息采集标识 0-企微信息采集 1-个微信息采集
      */

+ 11 - 0
fs-service/src/main/resources/mapper/his/FsPrescribeMapper.xml

@@ -510,6 +510,17 @@
         LIMIT 1
     </select>
 
+    <select id="selectNewestAuditedPrescribeByCollectionId" resultType="com.fs.his.domain.FsPrescribe">
+        select *
+        from fs_prescribe fp
+        where fp.collection_id = #{collectionId}
+          and fp.status = 1
+          and fp.doctor_confirm = 1
+          and fp.prescribe_img_url is not null
+        ORDER BY fp.audit_time DESC
+        LIMIT 1
+    </select>
+
     <update id="updateFsPrescribeListDataCPWByPrescribeIds" parameterType="java.util.List">
         update fs_prescribe
         set

+ 12 - 0
fs-service/src/main/resources/mapper/hisStore/FsUserInformationCollectionMapper.xml

@@ -58,6 +58,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="doctorName"    column="doctor_name"    />
         <result property="qwTag" column="qw_tag"/>
         <result property="personalCollectStatus" column="personal_collect_status"/>
+        <result property="packageName" column="package_name"/>
+        <result property="packageOrderCode" column="package_order_code"/>
     </resultMap>
 
     <sql id="selectFsUserInformationCollectionVo">
@@ -139,11 +141,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         infocollect.remark,
         infocollect.qw_tag,
         infocollect.personal_collect_status,
+        infocollect.package_order_code,
+        package.package_name,
         cu.nick_name,
         fd.doctor_name
         FROM fs_user_information_collection infocollect
         LEFT JOIN company_user cu ON infocollect.company_user_id = cu.user_id
         LEFT JOIN fs_doctor fd ON infocollect.doctor_id = fd.doctor_id
+        LEFT JOIN fs_package package ON infocollect.package_id = package.package_id
+
         <where>
             infocollect.user_id is NOT NULL
             <if test="questionId != null">
@@ -170,6 +176,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="doctorName != null and doctorName != ''">
                 AND fd.doctor_name LIKE CONCAT('%', #{doctorName}, '%')
             </if>
+            <if test="packageOrderCode != null and packageOrderCode != ''">
+                AND infocollect.package_order_code LIKE CONCAT('%', #{packageOrderCode}, '%')
+            </if>
+            <if test="packageName != null and packageName != ''">
+                AND package.package_name LIKE CONCAT('%', #{packageName}, '%')
+            </if>
         </where>
         ORDER BY infocollect.create_time DESC
     </select>