拉取房价

This commit is contained in:
zjf committed 2026-10-01 00:07:09 +08:00
1 parent 13dea2f2a4
commit be723cf076
3 files changed
+32

No files matched your search

@@ -89,6 +89,13 @@ public class SmHotelMidController {
return midService.pullRoomsFromUpstream(id);
}
@Operation(summary = "仅拉取上游房价样例(getRoomPrice 今天 1 天)")
@PostMapping("/mid/pullPrice/{id}")
@PreAuthorize("@pms.hasPermission('supermarket_smHotel_edit')")
public R<Map<String, Object>> pullPrice(@PathVariable Long id) {
return midService.pullPriceFromUpstream(id);
}
@Operation(summary = "推送到下游销售方")
@PostMapping("/mid/push/{id}")
@PreAuthorize("@pms.hasPermission('supermarket_smHotel_push')")
@@ -21,6 +21,11 @@ public interface SmHotelMidService {
*/
R<Map<String, Object>> pullRoomsFromUpstream(Long hotelId);
/**
* 仅拉取房价样例(默认今天 1 天 getRoomPrice),用于单独验证房价接口。
*/
R<Map<String, Object>> pullPriceFromUpstream(Long hotelId);
/**
* 仅拉取指定日期区间房价(含房型综合若本地无房型),用于「滚一天」;区间建议 1 天,最长按上游 31 天切片。
*/
@@ -201,6 +201,26 @@ public class SmHotelMidServiceImpl implements SmHotelMidService {
return R.ok(result);
}
@Override
@Transactional(rollbackFor = Exception.class)
public R<Map<String, Object>> pullPriceFromUpstream(Long hotelId) {
// 只拉今天 1 天,便于快速验证 getRoomPrice,避免一次打满 90 天
LocalDate start = LocalDate.now();
LocalDate endExclusive = start.plusDays(1);
R<Map<String, Object>> r = pullPriceRange(hotelId, start, endExclusive);
if (r == null) {
return R.failed("拉取房价返回空");
}
if (r.getCode() != 0) {
return r;
}
Map<String, Object> data = r.getData() == null ? new LinkedHashMap<>() : new LinkedHashMap<>(r.getData());
data.put("sampleStart", start.toString());
data.put("sampleEnd", start.toString());
data.put("sampleDays", 1);
return R.ok(data);
}
@Override
@Transactional(rollbackFor = Exception.class)
public R<Map<String, Object>> pullPriceRange(Long hotelId, LocalDate startInclusive, LocalDate endExclusive) {