This commit is contained in:
dzc committed 2026-06-17 20:22:38 +08:00
1 parent 78aeb77cd6
commit db02c79d9b
2 files changed
+27 -7

No files matched your search

@@ -60,12 +60,12 @@ public class WalletSettingController {
/* ************************************* start android start ************************************* */
@GetMapping("/ad/get-discounts-list")
@Cacheable(
value = CacheConstants.WALLET_USER_DISCOUNTS_LIST,
key = "#userId + ':' + #hardId",
condition = "#userId != null && #hardId != null",
unless = "#result == null || #result.data == null"
)
// @Cacheable(
// value = CacheConstants.WALLET_USER_DISCOUNTS_LIST,
// key = "#userId + ':' + #hardId",
// condition = "#userId != null && #hardId != null",
// unless = "#result == null || #result.data == null"
// )
public R<List<WalletXfjDiscounts>> androidGetDiscountsList(@RequestParam String hardId, @RequestParam Long userId) {
return R.ok(walletSettingService.androidGetDiscountsList(hardId, userId));
}
@@ -57,19 +57,36 @@ public class WalletSettingServiceImpl extends ServiceImpl<WalletSettingMapper, W
*/
@Override
public List<WalletXfjDiscounts> androidGetDiscountsList(String hardId, Long userId) {
long startTime = System.currentTimeMillis();
List<WalletXfjDiscounts> discountsList = new ArrayList<>();
// 远程调用: 获取用户信息
long remoteUserStart = System.currentTimeMillis();
UserInfo userInfo = remoteUserService.getInnerByUserId(userId).getData();
long remoteUserEnd = System.currentTimeMillis();
log.info("[性能监控] androidGetDiscountsList - 远程调用获取用户信息耗时: {}ms", remoteUserEnd - remoteUserStart);
if (ObjectUtil.isEmpty(userInfo) || ObjectUtil.isEmpty(userInfo.getSysUser())) {
return List.of();
}
// SQL查询: 获取钱包设置
long sqlSettingStart = System.currentTimeMillis();
WalletSettingVo setting = getSetting();
long sqlSettingEnd = System.currentTimeMillis();
log.info("[性能监控] androidGetDiscountsList - SQL查询钱包设置耗时: {}ms", sqlSettingEnd - sqlSettingStart);
if (ObjectUtil.isEmpty(setting)) {
return List.of();
}
SysUser sysUser = userInfo.getSysUser();
// 在自营食堂
// SQL查询: 获取用户所属食堂
long sqlMchStart = System.currentTimeMillis();
MchManageVo userMch = mchManageService.getViewsCanteenMchByDeptId(sysUser.getDeptId());
long sqlMchEnd = System.currentTimeMillis();
log.info("[性能监控] androidGetDiscountsList - SQL查询用户食堂信息耗时: {}ms", sqlMchEnd - sqlMchStart);
boolean isSelfCatering = ObjectUtil.isNotEmpty(userMch);
List<WalletSettingEntity.WalletXfjDiscounts> list = new ArrayList<>();
@@ -110,6 +127,9 @@ public class WalletSettingServiceImpl extends ServiceImpl<WalletSettingMapper, W
}).toList()
);
}
long endTime = System.currentTimeMillis();
log.info("[性能监控] androidGetDiscountsList - 总耗时: {}ms", endTime - startTime);
return discountsList;
}