diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/integration/shangyou/ShangyouHotelClient.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/integration/shangyou/ShangyouHotelClient.java index e70781a8..eba5b47e 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/integration/shangyou/ShangyouHotelClient.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/integration/shangyou/ShangyouHotelClient.java @@ -700,8 +700,9 @@ public class ShangyouHotelClient { return ShangyouOrderCallResult.uncertain("取 Token 失败: " + e.getMessage(), null); } String url = props().resolveBizBaseUrl() + path; - log.info("shangyou order request path={} retried={} busyRound={} bodyKeys={}", path, retried, busyRound, - body.keySet()); + // 完整业务体落日志(密码脱敏),便于与上游对「到底传了什么」 + log.info("|上游订单请求|path={}|retried={}|busyRound={}|body={}|", path, retried, busyRound, + maskOrderBodyForLog(body)); try (HttpResponse response = HttpRequest.post(url) .header("Authorization", "Bearer " + token) .header("Accept", "*/*") @@ -798,6 +799,26 @@ public class ShangyouHotelClient { body.put("cardPassWord", props().getCardPassword()); } + /** 应用日志用:复制 body 并脱敏密码,避免明文进日志 */ + private static String maskOrderBodyForLog(JSONObject body) { + if (body == null) { + return "null"; + } + try { + JSONObject copy = JSON.parseObject(body.toJSONString()); + if (copy.containsKey("cardPassWord")) { + copy.put("cardPassWord", "***"); + } + if (copy.containsKey("cardPassword")) { + copy.put("cardPassword", "***"); + } + return copy.toJSONString(); + } + catch (Exception e) { + return String.valueOf(body.keySet()); + } + } + private List parseMemberLevels() { if (StrUtil.isBlank(props().getMemberLevels())) { return Collections.emptyList(); diff --git a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmHotelOrderServiceImpl.java b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmHotelOrderServiceImpl.java index 6d553bdc..3ce84a5c 100644 --- a/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmHotelOrderServiceImpl.java +++ b/pjcloud-supermarket/pjcloud-supermarket-biz/src/main/java/com/bsd/pjcloud/supermarket/service/impl/SmHotelOrderServiceImpl.java @@ -2784,7 +2784,9 @@ public class SmHotelOrderServiceImpl extends ServiceImpl implements SmHotelOrderUpstreamLogService { - private static final int JSON_MAX = 8000; + /** 下单报文含 dailyPriceList,留足空间便于事后对账 */ + private static final int JSON_MAX = 16000; + + private static final Set SECRET_KEYS = Set.of("cardPassWord", "cardPassword", "password", "secret", + "appSecret", "accessToken", "token"); @Override public void saveCall(Long orderId, String channel, String action, HotelUpstreamOrderResult result, String reqJson, @@ -53,7 +60,7 @@ public class SmHotelOrderUpstreamLogServiceImpl row.setSuccess(success ? "1" : "0"); row.setBizCode(StrUtil.sub(bizCode, 0, 64)); row.setMessage(StrUtil.sub(message, 0, 500)); - row.setReqJson(clip(reqJson)); + row.setReqJson(clip(maskSecrets(reqJson))); row.setRespJson(clip(respJson)); row.setCostMs(costMs); baseMapper.insert(row); @@ -73,6 +80,27 @@ public class SmHotelOrderUpstreamLogServiceImpl .orderByAsc(SmHotelOrderUpstreamLogEntity::getCreateTime)); } + /** 落库前脱敏,避免 cardPassWord 等进流水 */ + static String maskSecrets(String raw) { + if (StrUtil.isBlank(raw) || !StrUtil.startWith(raw.trim(), "{")) { + return raw; + } + try { + JSONObject obj = JSONUtil.parseObj(raw); + boolean changed = false; + for (String key : SECRET_KEYS) { + if (obj.containsKey(key) && obj.get(key) != null && StrUtil.isNotBlank(String.valueOf(obj.get(key)))) { + obj.set(key, "***"); + changed = true; + } + } + return changed ? obj.toString() : raw; + } + catch (Exception e) { + return raw; + } + } + private static String clip(String s) { if (s == null) { return null;