Browse Source

// 20230217优化

ZIPZAP 2 years ago
parent
commit
9c085be1ef

+ 30 - 14
ali-manager/ali-biz/src/main/java/com/qls/ali/biz/service/fz/impl/HotelServiceImpl.java

@@ -140,11 +140,10 @@ public class HotelServiceImpl implements HotelService {
         List<Long> hotelCodes = new ArrayList<>();
         //  获取飞猪标准酒店
         QueryWrapper<HtAliHotel> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("hotel_code", htHotelinfo.getHotelCode()).eq("store_id", storeId);
+        queryWrapper.eq("hotel_code", htHotelinfo.getHotelCode());
         HtAliHotel htAliHotel = htAliHotelService.getOne(queryWrapper);
         if (htAliHotel == null) {
             htAliHotel = getMatchHotel(htHotelinfo, appKey, session, secret);
-            htAliHotel.setStoreId(storeId);
         }
         if (htAliHotel == null) {
             log.warn("飞猪标准酒店 ({}):自动匹配失败", htHotelinfo.getHotelCode());
@@ -160,7 +159,12 @@ public class HotelServiceImpl implements HotelService {
         JSONObject xhotel_update_response = (JSONObject) r1.get("xhotel_update_response");
         JSONObject xhotel = (JSONObject) xhotel_update_response.get("xhotel");
         Long hid = xhotel.getLong("hid");
-        htAliHotel.setHid(hid);
+        JSONObject matchData = new JSONObject();
+        if (htAliHotel.getMatchData() != null) {
+            matchData = JSONUtil.parseObj(htAliHotel.getMatchData());
+        }
+        matchData.put(Convert.toStr(storeId), hid);
+        htAliHotel.setMatchData(JSONUtil.toJsonStr(matchData));
         //  自主匹配标准酒店以及卖家酒店
         Long hotelCode = htHotelinfo.getHotelCode();
         com.alibaba.fastjson.JSONObject matchObj = new com.alibaba.fastjson.JSONObject();
@@ -288,9 +292,15 @@ public class HotelServiceImpl implements HotelService {
         Long hotelCode = hotelCodes.get(0);
         List<HtSellRoom> htSellRoomList = new ArrayList<>();
         QueryWrapper<HtAliHotel> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("hotel_code", hotelCode).eq("store_id", storeId);
+        queryWrapper.eq("hotel_code", hotelCode);
         HtAliHotel htAliHotel = htAliHotelService.getOne(queryWrapper);
-        String getMatchRoomResult = FzUtil.getMatchRoom(htAliHotel.getHid(), appKey, session, secret);
+        JSONObject matchData = JSONUtil.parseObj(htAliHotel.getMatchData());
+        String hid = matchData.getStr(Convert.toStr(storeId));
+        if (hid == null) {
+            log.warn("酒店{}:异常", hotelCode);
+            return htSellRoomList;
+        }
+        String getMatchRoomResult = FzUtil.getMatchRoom(Convert.toLong(hid), appKey, session, secret);
         if (getMatchRoomResult == null || !getMatchRoomResult.contains("alitrip_hotel_hstdf_shotel_exportsroomtype_response")) {
             log.warn("酒店{}:查询卖家酒店下的所有标准房型,失败原因:{}", hotelCode, getMatchRoomResult);
             return htSellRoomList;
@@ -310,7 +320,7 @@ public class HotelServiceImpl implements HotelService {
                 continue;
             }
             QueryWrapper<HtAliRoom> htAliRoomQueryWrapper = new QueryWrapper<>();
-            htAliRoomQueryWrapper.eq("room_code",roomCode).eq("store_id", storeId);
+            htAliRoomQueryWrapper.eq("room_code", roomCode).eq("store_id", storeId);
             HtAliRoom htAliRoom = htAliRoomService.getOne(htAliRoomQueryWrapper);
             Long srid = 0L;
             Long rid = 0L;
@@ -685,15 +695,15 @@ public class HotelServiceImpl implements HotelService {
         htHotelService.saveOrUpdate(htHotel);
         htAliHotel.setMatchType(1);
         htAliHotel.setHotelCode(hotelCode);
-        if (storeIds.isEmpty()){
+        if (storeIds.isEmpty()) {
             //  更新阿里标准酒店信息
             htAliHotelService.saveOrUpdate(htAliHotel);
-        }else{
+        } else {
             for (Integer storeId : storeIds) {
                 QueryWrapper<HtAliHotel> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("hotel_code", hotelCode).eq("store_id", storeId);
+                queryWrapper.eq("hotel_code", hotelCode);
                 HtAliHotel oldHtAliHotel = htAliHotelService.getOne(queryWrapper);
-                if (oldHtAliHotel != null){
+                if (oldHtAliHotel != null) {
                     htAliHotel.setId(oldHtAliHotel.getId());
                     htAliHotelService.saveOrUpdate(htAliHotel);
                 }
@@ -719,9 +729,15 @@ public class HotelServiceImpl implements HotelService {
         String sessionKey = dtStore.getSessionKey();
         String secret = dtStore.getSecret();
         QueryWrapper<HtAliHotel> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("hotel_code", hotelCode).eq("store_id", storeId);
+        queryWrapper.eq("hotel_code", hotelCode);
         HtAliHotel htAliHotel = htAliHotelService.getOne(queryWrapper);
-        String getMatchRoomResult = FzUtil.getMatchRoom(htAliHotel.getHid(), appKey, sessionKey, secret);
+        JSONObject matchData = JSONUtil.parseObj(htAliHotel.getMatchData());
+        String hid = matchData.getStr(Convert.toStr(storeId));
+        if (hid == null) {
+            log.warn("酒店{}:异常", hotelCode);
+            return null;
+        }
+        String getMatchRoomResult = FzUtil.getMatchRoom(Convert.toLong(hid), appKey, sessionKey, secret);
         if (getMatchRoomResult == null || !getMatchRoomResult.contains("alitrip_hotel_hstdf_shotel_exportsroomtype_response")) {
             log.warn("酒店{}:查询卖家酒店下的所有标准房型,失败原因:{}", hotelCode, getMatchRoomResult);
             return null;
@@ -754,9 +770,9 @@ public class HotelServiceImpl implements HotelService {
         queryWrapper2.eq("room_code", roomCode).eq("store_id", storeId);
         HtAliRoom oldHtAliRoom = htAliRoomService.getOne(queryWrapper2);
         String ok = "xhotel_roomtype_add_response";
-        if (oldHtAliRoom == null){
+        if (oldHtAliRoom == null) {
             htAliRoom.setRoomCode(roomCode);
-        }else{
+        } else {
             htAliRoom.setId(oldHtAliRoom.getId());
         }
         String result = FzUtil.pushRoom(htRoomType, appKey, sessionKey, secret);

+ 3 - 3
common/core/src/main/java/com/qls/core/entity/HtAliHotel.java

@@ -20,10 +20,10 @@ public class HtAliHotel implements Serializable {
     @JSONField(name = "id")
     private Long id;
     /**
-     * 店铺id
+     * 卖家酒店匹配信息
      */
-    @JSONField(name = "store_id")
-    private Integer storeId;
+    @JSONField(name = "match_data")
+    private String matchData;
     /**
      * 阿里标准酒店id
      */

+ 1 - 1
consumer-manager/consumer-store/src/main/java/com/qls/consumer/store/config/RabbitListenerConfig.java

@@ -19,8 +19,8 @@ public class RabbitListenerConfig {
         factory.setConnectionFactory(connectionFactory);
         factory.setBatchListener(true);
         factory.setConsumerBatchEnabled(true);
+        factory.setPrefetchCount(30);
         factory.setConcurrentConsumers(15);
-        factory.setBatchSize(5);
         factory.setMaxConcurrentConsumers(30);
         return factory;
     }