Prechádzať zdrojové kódy

add
微信手机号获取

18339543638 6 mesiacov pred
rodič
commit
8cc3e8e662

+ 3 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/service/IBizWxUserService.java

@@ -1,5 +1,6 @@
 package cn.tr.module.smart.common.service;
 
+import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
 import cn.hutool.core.lang.Pair;
 import cn.tr.module.smart.common.dto.BizWxUserDTO;
 import cn.tr.module.smart.common.dto.BizWxUserQueryDTO;
@@ -86,4 +87,6 @@ public interface IBizWxUserService{
      * @param hospitalId
      */
     void bindHospital(String currentUserId, String hospitalId);
+
+    void updatePhoneById(String currentUserId, WxMaPhoneNumberInfo phoneNumber);
 }

+ 11 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/common/service/impl/BizWxUserServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.tr.module.smart.common.service.impl;
 
+import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.tr.core.annotation.TenantIgnore;
@@ -190,4 +191,14 @@ public class BizWxUserServiceImpl implements IBizWxUserService {
         wxUserHospitalRepository.insert(insertSource);
         return;
     }
+
+    @Override
+    public void updatePhoneById(String currentUserId, WxMaPhoneNumberInfo phoneNumber) {
+        BizWxUserPO userPO = baseRepository.selectById(currentUserId);
+        if (ObjectUtil.isNull(userPO)) {
+            return;
+        }
+        userPO.setPhone(phoneNumber.getPhoneNumber());
+        baseRepository.updateById(userPO);
+    }
 }

+ 0 - 17
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/wx/controller/BizWxAppletClinicController.java

@@ -8,7 +8,6 @@ import cn.tr.core.validation.Update;
 import cn.tr.module.smart.common.service.IBizClinicRoomService;
 import cn.tr.module.smart.common.service.IBizClinicRoomWxUserService;
 import cn.tr.module.smart.wx.controller.vo.BizWxAppletClinicDetailVO;
-import cn.tr.module.smart.wx.controller.vo.BizWxDeptQuestionVO;
 import cn.tr.module.smart.wx.dto.BizClinicAddOrEditDTO;
 import cn.tr.module.smart.wx.dto.BizWxAppletClinicQueryDTO;
 import cn.tr.module.smart.wx.dto.BizWxAppletClinicShiftCareDTO;
@@ -88,20 +87,4 @@ public class BizWxAppletClinicController extends BaseController{
     public CommonResult<BizWxAppletClinicDetailVO> detail(@PathVariable("id") String id) {
         return CommonResult.success(clinicRoomService.stdSelectWxAppletById(id));
     }
-
-    @ApiOperationSupport(author = "zzy",order = 8)
-    @GetMapping("/preSurgeryQuestionnaire/{clinicId}")
-    @ApiOperation(value = "术前问卷",notes = "权限: 无")
-    @Deprecated
-    public CommonResult<List<BizWxDeptQuestionVO> > preSurgeryQuestionnaire(@PathVariable("clinicId") String clinicId){
-        return CommonResult.success(clinicRoomService.selectPreSurgeryQuestionnaire(clinicId));
-    }
-
-    @ApiOperationSupport(author = "lf",order = 9)
-    @GetMapping("/validate/patientCode/{patientCode}")
-    @ApiOperation(value = "住院号校验",notes = "权限: 无")
-    @Deprecated
-    public CommonResult<Boolean> validatePatientCode(@PathVariable("patientCode") String patientCode){
-        return CommonResult.success(Boolean.TRUE);
-    }
 }

+ 26 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/wx/controller/WxAppletUserController.java

@@ -1,13 +1,16 @@
 package cn.tr.module.smart.wx.controller;
 
 import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
 import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
 import cn.binarywang.wx.miniapp.util.WxMaConfigHolder;
+import cn.tr.core.annotation.TenantIgnore;
 import cn.tr.core.exception.ServiceException;
 import cn.tr.core.exception.TRExcCode;
 import cn.tr.core.pojo.CommonResult;
 import cn.tr.core.strategy.LoginUserStrategy;
 import cn.tr.module.smart.common.service.IBizWxUserService;
+import cn.tr.module.smart.wx.dto.BizWxAppletGetUserPhoneNumberDTO;
 import cn.tr.module.smart.wx.dto.BizWxUserShiftHospitalDTO;
 import cn.tr.module.smart.wx.dto.WxAppletEncodeInfoDTO;
 import cn.tr.module.smart.wx.controller.vo.BizWxUserBindHospitalVO;
@@ -16,6 +19,9 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import java.util.*;
 /**
@@ -33,6 +39,7 @@ public class WxAppletUserController {
     private final WxMaService wxMaService;
 
     private final IBizWxUserService wxUserService;
+
     /**
      * <pre>
      * 获取用户信息接口
@@ -81,4 +88,23 @@ public class WxAppletUserController {
         return CommonResult.success(Boolean.TRUE);
     }
 
+
+
+    @PostMapping("/getUserPhoneNumber")
+    @ApiOperation(value = "快速手机号验证",position = 6)
+    public CommonResult<String> getUserPhoneNumber(@RequestBody@Validated BizWxAppletGetUserPhoneNumberDTO source) throws WxErrorException {
+        log.info("\n手机号快速验证:appid = [{}], accessToken = [{}]",
+                source.getAppid(), source.getAccessToken());
+        if (StringUtils.isAnyBlank(source.getAppid(), source.getAccessToken())) {
+            throw new IllegalArgumentException("请求参数非法,请核实!");
+        }
+        if (!wxMaService.switchover(source.getAppid())) {
+            throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", source.getAppid()));
+        }
+        WxMaPhoneNumberInfo phoneNumber = wxMaService.getUserService().getPhoneNumber(source.getAccessToken());
+        //更新当前用户的手机号
+        wxUserService.updatePhoneById(LoginUserStrategy.tr.getCurrentUserId(),phoneNumber);
+        return CommonResult.success(phoneNumber.getPhoneNumber());
+    }
+
 }

+ 14 - 0
tr-modules/tr-module-smartFollowUp/src/main/java/cn/tr/module/smart/wx/dto/BizWxAppletGetUserPhoneNumberDTO.java

@@ -0,0 +1,14 @@
+package cn.tr.module.smart.wx.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+@Data
+public class BizWxAppletGetUserPhoneNumberDTO {
+    @NotBlank(message = "appid不能为空")
+    private String appid;
+    @NotBlank(message = "accessToken不能为空")
+    private String accessToken;
+}

+ 1 - 1
tr-test/src/main/resources/log4j2.xml

@@ -2,7 +2,7 @@
 <Configuration status="WARN" shutdownHook="disable">
     <Properties>
         <Property name="LOG_DIR">./logs</Property>
-        <Property name="FILE_NAME">hdis</Property>
+        <Property name="FILE_NAME">smart</Property>
         <Property name="FILE_PATTERN">${FILE_NAME}-%d{yyyy-MM-dd}-%i.log.gz</Property>
     </Properties>