Browse Source

医保移动支付后推送医生评价

lighter 1 year ago
parent
commit
a6bca45f92

+ 7 - 6
src/main/java/thyyxxk/wxservice_server/controller/CommentController.java

@@ -1,17 +1,13 @@
 package thyyxxk.wxservice_server.controller;
 
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import thyyxxk.wxservice_server.entity.ResultVo;
 import thyyxxk.wxservice_server.entity.comment.request.CommentsInquiry;
 import thyyxxk.wxservice_server.entity.comment.response.CommentsResponse;
 import thyyxxk.wxservice_server.entity.comment.response.WechatPatientComment;
 import thyyxxk.wxservice_server.service.CommentService;
-
-import java.util.List;
+import thyyxxk.wxservice_server.utils.ResultVoUtil;
 
 @RestController
 @RequestMapping("/comment")
@@ -32,4 +28,9 @@ public class CommentController {
     public ResultVo<CommentsResponse> fetchDoctorComments(@RequestBody CommentsInquiry inquiry) {
         return service.fetchDoctorComments(inquiry);
     }
+
+    @GetMapping("/getVisitInfo")
+    public ResultVo<WechatPatientComment> getVisitInfo(@RequestParam("visitId") String visitId) {
+        return ResultVoUtil.success(service.getVisitInfo(visitId));
+    }
 }

+ 33 - 4
src/main/java/thyyxxk/wxservice_server/controller/api/PowersiMiPayPlugin.java

@@ -15,6 +15,7 @@ import thyyxxk.wxservice_server.config.auth.PassToken;
 import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.dao.api.PowersiPluginDao;
 import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.entity.assessment.PushQuestionnaireVisit;
 import thyyxxk.wxservice_server.entity.medinsmobilepay.InsuinfoRequest;
 import thyyxxk.wxservice_server.entity.medinsmobilepay.frompowersiplugin.OrdState;
 import thyyxxk.wxservice_server.entity.medinsmobilepay.frompowersiplugin.request.CommonRequest;
@@ -27,6 +28,7 @@ import thyyxxk.wxservice_server.factory.thmz.ThmzService;
 import thyyxxk.wxservice_server.factory.thmz.model.QueryReceiptRequest;
 import thyyxxk.wxservice_server.factory.thmz.model.SaveMzPayRequest;
 import thyyxxk.wxservice_server.service.IdCardAnalyzeService;
+import thyyxxk.wxservice_server.service.PushWxMessageService;
 import thyyxxk.wxservice_server.utils.DateUtil;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;
 import thyyxxk.wxservice_server.utils.SnowFlakeId;
@@ -44,6 +46,7 @@ public class PowersiMiPayPlugin {
     private final PowersiPluginDao dao;
     private final IdCardAnalyzeService idCardAnalyzeService;
     private final ThmzService thmzService;
+    private final PushWxMessageService messageService;
 
     @Value("${hisMipUrl}")
     private String hisMipUrl;
@@ -51,21 +54,23 @@ public class PowersiMiPayPlugin {
     private final DataHandler dataHandler = DataHandler.newInstance();
 
     @Autowired
-    public PowersiMiPayPlugin(PowersiPluginDao dao, IdCardAnalyzeService idCardAnalyzeService, ThmzService thmzService) throws IOException {
+    public PowersiMiPayPlugin(PowersiPluginDao dao, IdCardAnalyzeService idCardAnalyzeService, ThmzService thmzService, PushWxMessageService messageService) throws IOException {
         this.dao = dao;
         this.idCardAnalyzeService = idCardAnalyzeService;
         this.thmzService = thmzService;
+        this.messageService = messageService;
     }
 
     @PostMapping("/lockOrder")
     public ResultVo<String> lockOrder(@RequestBody InsuinfoRequest request) {
-        dao.lockOrder(request.getHisOrdNum(), 1);
-        return ResultVoUtil.success(TokenUtil.getInstance().getUserOpenid());
+        String openid = TokenUtil.getInstance().getUserOpenid();
+        dao.lockOrder(request.getHisOrdNum(), openid,1);
+        return ResultVoUtil.success(openid);
     }
 
     @PostMapping("/unlockOrder")
     public ResultVo<String> unlockOrder(@RequestBody InsuinfoRequest request) {
-        dao.lockOrder(request.getHisOrdNum(), 0);
+        dao.lockOrder(request.getHisOrdNum(), null, 0);
         return ResultVoUtil.success("操作成功。");
     }
 
@@ -223,6 +228,30 @@ public class PowersiMiPayPlugin {
         if (res.getCode() == ExceptionEnum.SUCCESS.getCode()) {
             dao.updateMzSaved(setlinfo.getPlatformOrderId());
         }
+        pushMessage(setlinfo.getMedOrgOrd(), setlinfo.getUserName());
+    }
+
+    private void pushMessage(String hisOrdNum, String userName) {
+        String[] arr = hisOrdNum.split("_");
+        int times = Integer.parseInt(arr[1]);
+        PushQuestionnaireVisit visit = dao.getVisit(arr[0], times, hisOrdNum);
+        String visitId = hisOrdNum.replaceAll("_", "AND") + "AND" + visit.getDoctorCode() + "AND" + visit.getDeptCode();
+        String url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxbde6b16acad84204&redirect_uri=" +
+                "https://staticweb.hnthyy.cn/wxserver/redirect/page2?to=doctorGradeByPush_" + visitId +
+                "&response_type=code&scope=snsapi_base&state=1#wechat_redirect";
+
+        String msgContent = "{\"touser\":\"" + visit.getOpenid() + "\",\"data\":" +
+                "{\"keyword1\":{\"color\":\"#173177\",\"value\":\"" + userName + "\"}," +
+                "\"keyword2\":{\"color\":\"#173177\",\"value\":\"长沙泰和医院\"}," +
+                "\"keyword3\":{\"color\":\"#173177\",\"value\":\"" + visit.getDeptName() + "\"}," +
+                "\"keyword4\":{\"color\":\"#173177\",\"value\":\"" + visit.getDoctorName() + "\"}," +
+                "\"keyword5\":{\"color\":\"#173177\",\"value\":\"" + visit.getVisitDate() + "\"}," +
+                "\"remark\":{\"color\":\"#FF0000\",\"value\":\"特邀请您对医生服务作出评价。\"}," +
+                "\"first\":{\"color\":\"#FF0000\",\"value\":\"您曾在我院进行诊疗。\"}}," +
+                "\"template_id\":\"G4YAN56RmDjEPpNyP5fpCdr5TghyqspDeWlWaD5Eg2o\"," +
+                "\"url\":\"" + url + "\"}";
+        JSONObject message = JSONObject.parseObject(msgContent);
+        messageService.pushMessage2(message);
     }
 
     @PassToken

+ 16 - 0
src/main/java/thyyxxk/wxservice_server/dao/CommentDao.java

@@ -7,6 +7,7 @@ import thyyxxk.wxservice_server.entity.PureCodeName;
 import thyyxxk.wxservice_server.entity.comment.request.CommentsInquiry;
 import thyyxxk.wxservice_server.entity.comment.response.WechatPatientComment;
 
+import java.util.Date;
 import java.util.List;
 
 @Mapper
@@ -14,6 +15,9 @@ public interface CommentDao {
     @Select("select rtrim(code_rs) as code,rtrim(name) as name from a_employee_mi where code=#{code} ")
     PureCodeName selectDoctorCodeRsAndName(String code);
 
+    @Select("select count(1) from t_wechat_patient_comment where patient_id=#{patNo} and times=#{times}")
+    int selectExistCount(String patNo, int times);
+
     @Insert("insert into t_wechat_patient_comment (doctor_code, doctor_code_rs, doctor_name, patient_id, times, " +
             "patient_name, comment_level, comment_content) " +
             "values (#{doctorCode},#{doctorCodeRs},#{doctorName},#{patientId},#{times}, " +
@@ -26,4 +30,16 @@ public interface CommentDao {
 
     @Select("select count(1) from t_wechat_patient_comment where doctor_code=#{doctorCode} and id<#{minId}")
     int moreCommentsExist(String doctorCode, int minId);
+
+    @Select("select rtrim(name) from mz_patient_mi where patient_id=#{patNo}")
+    String getPatName(String patNo);
+
+    @Select("select rtrim(name) from a_employee_mi where code=#{code}")
+    String getDoctorName(String code);
+
+    @Select("select rtrim(name) from zd_unit_code where code=#{code}")
+    String getDeptName(String code);
+
+    @Select("select visit_date from mz_visit_table where patient_id=#{patNo} and times=#{times}")
+    Date getVisitDate(String patNo, int times);
 }

+ 12 - 3
src/main/java/thyyxxk/wxservice_server/dao/api/PowersiPluginDao.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
+import thyyxxk.wxservice_server.entity.assessment.PushQuestionnaireVisit;
 import thyyxxk.wxservice_server.entity.medinsmobilepay.frompowersiplugin.OrdState;
 import thyyxxk.wxservice_server.entity.medinsmobilepay.frompowersiplugin.request.PowersiMipSetlinfo;
 
@@ -13,9 +14,9 @@ import java.util.List;
 @Mapper
 public interface PowersiPluginDao extends BaseMapper<PowersiMipSetlinfo> {
 
-    @Update("update mz_order_lock set lock_flag=#{flag},update_time=getdate() " +
-            "where his_order_num=#{hisOrdNum}")
-    void lockOrder(String hisOrdNum, int flag);
+    @Update("update mz_order_lock set lock_flag=#{flag},update_time=getdate(), " +
+            "openid=#{openid} where his_order_num=#{hisOrdNum}")
+    void lockOrder(String hisOrdNum, String openid, int flag);
 
     @Select("select rtrim(patient_id) from mz_patient_mi where social_no=#{id}")
     List<String> selectPatientCount(String id);
@@ -34,4 +35,12 @@ public interface PowersiPluginDao extends BaseMapper<PowersiMipSetlinfo> {
 
     @Update("update powersi_mip_setlinfo set mz_saved=1 where platform_order_id=#{id}")
     void updateMzSaved(String id);
+    
+    @Select("select b.openid,visit_date=convert(varchar(19),a.visit_date,21), " +
+            "deptName=(select rtrim(d.name) from zd_unit_code d where d.code=a.visit_dept_code), " +
+            "doctorName=(select rtrim(d.name) from a_employee_mi d where d.code=a.doctor_code), " +
+            "doctorCode=rtrim(a.doctor_code),deptCode=rtrim(a.visit_dept_code) " +
+            "from mz_visit_table a, mz_order_lock b " +
+            "where a.patient_id=#{patNo} and a.times=#{times} and b.his_order_num=#{hisOrdNum}")
+    PushQuestionnaireVisit getVisit(String patNo, int times, String hisOrdNum);
 }

+ 4 - 0
src/main/java/thyyxxk/wxservice_server/entity/comment/response/WechatPatientComment.java

@@ -2,6 +2,8 @@ package thyyxxk.wxservice_server.entity.comment.response;
 
 import lombok.Data;
 
+import java.util.Date;
+
 @Data
 public class WechatPatientComment {
   private Integer id;
@@ -11,11 +13,13 @@ public class WechatPatientComment {
   private String patientId;
   private Integer times;
   private String patientName;
+  private String deptName;
   private String fuzzyName;
   private String commentTime;
   private Integer commentLevel;
   private String commentContent;
   private String hisOrdNum;
+  private Date visitDate;
 
   public String getFuzzyName() {
     StringBuilder sb = new StringBuilder();

+ 1 - 1
src/main/java/thyyxxk/wxservice_server/entity/medinsmobilepay/frompowersiplugin/request/RevokeSettleRequest.java

@@ -54,7 +54,7 @@ public class RevokeSettleRequest {
     /**
      * 退费类型( ALL:全部(医保+现金),CASH:只退现金,HI:只退医保(统筹+个账))
      * */
-    private String refdType = "CASH";
+    private String refdType = "ALL";
 
     /**
      * 退款原因

+ 25 - 0
src/main/java/thyyxxk/wxservice_server/service/CommentService.java

@@ -6,6 +6,7 @@ import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.dao.CommentDao;
 import thyyxxk.wxservice_server.entity.PureCodeName;
 import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.entity.assessment.PushQuestionnaireVisit;
 import thyyxxk.wxservice_server.entity.comment.request.CommentsInquiry;
 import thyyxxk.wxservice_server.entity.comment.response.CommentsResponse;
 import thyyxxk.wxservice_server.entity.comment.response.WechatPatientComment;
@@ -28,6 +29,12 @@ public class CommentService {
             comment.setCommentContent("未填写评价内容。");
         }
         int times = Integer.parseInt(comment.getHisOrdNum().split("_")[1]);
+
+        int exist = dao.selectExistCount(comment.getPatientId(), times);
+        if (exist > 0) {
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您已评价过,请勿重复操作。");
+        }
+
         comment.setTimes(times);
         PureCodeName doctor = dao.selectDoctorCodeRsAndName(comment.getDoctorCode());
         comment.setDoctorCodeRs(doctor.getCode());
@@ -54,4 +61,22 @@ public class CommentService {
         response.setList(list);
         return ResultVoUtil.success(response);
     }
+
+    public WechatPatientComment getVisitInfo(String visitId) {
+        String[] arr = visitId.split("AND");
+        String hisOrdNum = arr[0] + "_" + arr[1] + "_" + arr[2];
+        int times = Integer.parseInt(arr[1]);
+
+        WechatPatientComment visit = new WechatPatientComment();
+        visit.setHisOrdNum(hisOrdNum);
+        visit.setPatientId(arr[0]);
+        visit.setTimes(times);
+        visit.setPatientName(dao.getPatName(arr[0]));
+        visit.setDoctorCode(arr[3]);
+        visit.setDoctorName(dao.getDoctorName(arr[3]));
+        visit.setDeptName(dao.getDeptName(arr[4]));
+        visit.setVisitDate(dao.getVisitDate(arr[0], times));
+
+        return visit;
+    }
 }