Pārlūkot izejas kodu

小程序接口

lighter 1 gadu atpakaļ
vecāks
revīzija
5ae464f84e

+ 21 - 0
src/main/java/thyyxxk/wxservice_server/api/WxAppletApi.java

@@ -102,6 +102,9 @@ public class WxAppletApi {
         if (null == orderType) {
             return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "订单类别不能为空。");
         }
+        if (StringUtil.isBlank(order.getDescription())) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "商品描述不能为空。");
+        }
         String appId = appletType == AppletType.HOSPITAL_SERVICE ?
                 PropertiesUtil.getLocalProperty("appletAppId") :
                 PropertiesUtil.getLocalProperty("appletMallAppId");
@@ -432,4 +435,22 @@ public class WxAppletApi {
         inquiry.setOpenId(makeSpecialOpenId(appletType, inquiry.getOpenId()));
         return electronicHealthCardService.linkHealthCard(inquiry.getHealthCode(), inquiry.getOpenId());
     }
+
+    @PostMapping("/setDefaultCard")
+    public ResultVo<String> setDefaultCard(@RequestBody BaseInquiry inquiry) {
+        AppletType appletType = inquiry.getAppletType();
+        if (null == appletType) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "小程序类别不能为空。");
+        }
+        if (StringUtil.isBlank(inquiry.getOpenId())) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "openId不能为空。");
+        }
+        if (StringUtil.isBlank(inquiry.getPatientId())) {
+            return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "patientId不能为空。");
+        }
+        String openId = makeSpecialOpenId(appletType, inquiry.getOpenId());
+        log.info("设置默认就诊卡:{}", JSONObject.toJSON(inquiry));
+        appletDao.updateDefaultCard(inquiry.getPatientId(), openId);
+        return ResultVoUtil.success();
+    }
 }

+ 5 - 0
src/main/java/thyyxxk/wxservice_server/dao/AppletDao.java

@@ -94,4 +94,9 @@ public interface AppletDao {
     @Update("update t_applet_mall_cart set trade_state=#{tradeState},refund_date_time=#{refundDateTime}," +
             "refund_reason=#{refundReason},refund_id=#{refundId},refund_op_code=#{refundOpCode} where id=#{id}")
     void updateCartRefund(AppletMallCart cart);
+
+    @Update("update t_wechat_patient_bind set is_default=0 where open_id=#{openId};" +
+            "update t_wechat_patient_bind set is_default=1 where open_id=#{openId} and patient_id=#{patientId}")
+    void updateDefaultCard(@Param("patientId") String patientId,
+                           @Param("openId") String openId);
 }