2 Commits d46a37d29e ... a2c5c443b1

Tác giả SHA1 Thông báo Ngày
  Guos a2c5c443b1 Merge remote-tracking branch 'origin/master' 6 giờ trước cách đây
  Guos 01f3ac4904 tulin线上信息同步接口对接 6 giờ trước cách đây

+ 24 - 18
fs-service/src/main/java/com/fs/tulin/service/impl/TulinInfoSyncLogServiceImpl.java

@@ -35,6 +35,10 @@ public class TulinInfoSyncLogServiceImpl implements ITulinInfoSyncLogService {
 
     private final Environment environment;
 
+    private final String PROD_URL = "https://papi.xiangyue.life/api/v1/mp/sync/student?sign=%s&t=%d";
+    private final String DEV_URL = "https://api.xiangyue.life/api/v1/mp/sync/student?sign=%s&t=%d";
+
+
     @Override
     public void syncInfo() {
         // 获取当前激活的profile
@@ -53,8 +57,27 @@ public class TulinInfoSyncLogServiceImpl implements ITulinInfoSyncLogService {
                 studentInfo.setAppid("wx6688e6b9b6fb8700");
                 studentInfo.setColumn_name(ColumnNameEnum.GYBNX.getName());
                 studentInfo.setPharmacy_id(PharmacyEnum.YJKYSY.getPharmacyId());
+                studentInfo.setService_phone("15141712344");
+                try {
+                    TulinInfoSyncLog tulinInfoSyncLog = SyncStudentInfoService.send(PROD_URL,"lRz72QOIYBxJW2RBAp2UYe1ckjVpixHL", studentInfo);
+                    tulinInfoSyncLog.setFsUserId(qwExUserInfo.getFs_user_id());
+                    insert(tulinInfoSyncLog);
+                } catch (JsonProcessingException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+        if(activeProfile.equals("dev")) {
+            log.info("线下开始执行数据同步");
+            for (QwExUserInfo qwExUserInfo : qwExUserInfos) {
+                StudentInfo studentInfo = new StudentInfo();
+                BeanUtils.copyProperties(qwExUserInfo, studentInfo);
+                studentInfo.setAppid("wx6688e6b9b6fb8700");
+                studentInfo.setColumn_name(ColumnNameEnum.GYBNX.getName());
+                studentInfo.setPharmacy_id(PharmacyEnum.YJKYSY.getPharmacyId());
+                studentInfo.setService_phone("15141712344");
                 try {
-                    TulinInfoSyncLog tulinInfoSyncLog = SyncStudentInfoService.send("PNBnO6MajM0tAd8t", studentInfo);
+                    TulinInfoSyncLog tulinInfoSyncLog = SyncStudentInfoService.send(PROD_URL,"lRz72QOIYBxJW2RBAp2UYe1ckjVpixHL", studentInfo);
                     tulinInfoSyncLog.setFsUserId(qwExUserInfo.getFs_user_id());
                     insert(tulinInfoSyncLog);
                 } catch (JsonProcessingException e) {
@@ -62,23 +85,6 @@ public class TulinInfoSyncLogServiceImpl implements ITulinInfoSyncLogService {
                 }
             }
         }
-//        if(activeProfile.equals("dev")) {
-//            log.info("线下开始执行数据同步");
-//            for (QwExUserInfo qwExUserInfo : qwExUserInfos) {
-//                StudentInfo studentInfo = new StudentInfo();
-//                BeanUtils.copyProperties(qwExUserInfo, studentInfo);
-//                studentInfo.setAppid("wx6688e6b9b6fb8700");
-//                studentInfo.setColumn_name(ColumnNameEnum.GYBNX.getName());
-//                studentInfo.setPharmacy_id(PharmacyEnum.YJKYSY.getPharmacyId());
-//                try {
-//                    TulinInfoSyncLog tulinInfoSyncLog = SyncStudentInfoService.send("PNBnO6MajM0tAd8t", studentInfo);
-//                    tulinInfoSyncLog.setFsUserId(qwExUserInfo.getFs_user_id());
-//                    insert(tulinInfoSyncLog);
-//                } catch (JsonProcessingException e) {
-//                    throw new RuntimeException(e);
-//                }
-//            }
-//        }
     }
 
 

+ 3 - 3
fs-service/src/main/java/com/fs/tulin/utils/SyncStudentInfoService.java

@@ -56,16 +56,16 @@ public class SyncStudentInfoService {
      * @return 请求结果
      * @throws JsonProcessingException
      */
-    public static TulinInfoSyncLog send(String corpId, StudentInfo studentInfo) throws JsonProcessingException {
+    public static TulinInfoSyncLog send(String url, String corpId, StudentInfo studentInfo) throws JsonProcessingException {
         String sortedJson = JsonSortUtils.toSortedJson(studentInfo);
         long timestamp = generateTimestamp();
         String sign = generateSign(corpId, sortedJson, timestamp);
-        String url = String.format("https://api.xiangyue.life/api/v1/mp/sync/student?sign=%s&t=%d", sign, timestamp);
+        String newUrl = String.format(url, sign, timestamp);
         Map<String, Object> request = new HashMap<>();
         request.put("corp_id", corpId);
         request.put("data", Collections.singletonList(studentInfo));
         String jsonBody = JsonSortUtils.toSortedJson(request);
-        return sendHttpPost(url, jsonBody);
+        return sendHttpPost(newUrl, jsonBody);
     }
 
     /**

+ 2 - 2
fs-service/src/main/resources/mapper/tulin/TulinInfoSyncLogMapper.xml

@@ -74,9 +74,9 @@
         FROM qw_user AS qu
         INNER JOIN qw_external_contact AS qec ON qu.id = qec.qw_user_id
         inner join fs_user as fu on fu.qw_ext_id = qec.id
-        left join tulin_info_sync_log as tisl on tisl.fs_user_id = fu.user_id
+        left join tulin_info_sync_log as tisl on tisl.fs_user_id = fu.user_id and tisl.result = 0
         where fu.union_id is not null and fu.ma_open_id is not null
-        and tisl.result = 0
+
     </select>
 
 </mapper>