From aebd7f67d3b1d89efb44a303c23a0c06c8ff2e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Thu, 26 Sep 2024 18:09:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B09.26?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fleet/controller/FleetInfoController.java | 5 ++ .../fleet/service/FleetInfoService.java | 2 + .../service/impl/FleetInfoServiceImpl.java | 23 +++++ .../impl/IntegralSettingsServiceImpl.java | 90 +++++++++++-------- 4 files changed, 83 insertions(+), 37 deletions(-) diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java index 389380323..d935f98aa 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/controller/FleetInfoController.java @@ -104,5 +104,10 @@ public class FleetInfoController extends BaseController { public ResponseObject addFleetInfo(@RequestBody FleetInfo fleetInfo) { return getSuccessResult(fleetInfoService.addFleetInfo(fleetInfo)); } + + @GetMapping("/getFleetInfoByFleetId") + public ResponseObject getFleetInfoByFleetId(@Param("fleetId")Integer fleetId){ + return getSuccessResult(fleetInfoService.queryByFleetId(fleetId)); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java index 095bc2185..b68f4f509 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/FleetInfoService.java @@ -75,4 +75,6 @@ public interface FleetInfoService { * @return */ int addFleetInfo(FleetInfo fleetInfo); + + FleetInfoUniVo queryByFleetId(Integer fleetId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java index 396015b0f..08085e757 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetInfoServiceImpl.java @@ -296,6 +296,29 @@ public class FleetInfoServiceImpl extends ServiceImpl } } + @Override + public FleetInfoUniVo queryByFleetId(Integer fleetId) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + //查询当前登录人的车队信息 + FleetMember fleetMembers = fleetMemberMapper.selectOne(new LambdaQueryWrapper() + .eq(FleetMember::getFleetId, fleetId) + .eq(FleetMember::getUserId, nowAccountInfo.getId())); + //获取所在车队的id集合 +// List fleetIds = fleetMembers.stream().map(FleetMember::getFleetId).collect(Collectors.toList()); + if (ObjectUtil.isEmpty(fleetMembers)) { + throw new RuntimeException("未绑定车队"); + } + + FleetInfo fleetInfo = baseMapper.selectOne(new LambdaQueryWrapper() + .eq(FleetInfo::getId, fleetId)); + + + FleetInfoUniVo fleetInfoUniVo = BeanUtil.copyProperties(fleetInfo, FleetInfoUniVo.class); + fleetInfoUniVo.setStoreName(mtStoreMapper.selectById(fleetInfo.getStoreId()).getName()); + + return fleetInfoUniVo; + } + /** * 创建用户的基础信息 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/service/impl/IntegralSettingsServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/service/impl/IntegralSettingsServiceImpl.java index 9a9067cad..0ed05e610 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/service/impl/IntegralSettingsServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/service/impl/IntegralSettingsServiceImpl.java @@ -350,52 +350,68 @@ public class IntegralSettingsServiceImpl implements IntegralSettingsService { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(IntegralSettings::getStoreId, storeId); IntegralSettings integralSettings = integralSettingsMapper.selectOne(queryWrapper); - JSONArray jsonArray = JSONArray.parseArray(integralSettings.getPointsObtained()); IntegralSettingsVo integralSettingsVo = new IntegralSettingsVo(); List integralSettingsList = new ArrayList<>(); - for (int i = 0; i < jsonArray.size(); i++) { - String day = jsonArray.getJSONObject(i).get("day").toString(); - Integer points = Integer.parseInt(jsonArray.getJSONObject(i).get("integral").toString()); - IntegralSettingsBo integralSettings1 = new IntegralSettingsBo(); - integralSettings1.setIntegralName(day); - integralSettings1.setIntegral(points); - integralSettingsList.add(integralSettings1); - } - integralSettingsVo.setIntegralSettings(integralSettingsList); + if (ObjectUtil.isNotEmpty(integralSettings)) { + JSONArray jsonArray = JSONArray.parseArray(integralSettings.getPointsObtained()); + if (ObjectUtil.isNotEmpty(integralSettings.getSignApplicableRules()) && integralSettings.getSignApplicableRules() == 0) { + int length = 30; + for (int i = 0; i < length; i++) { + IntegralSettingsBo integralSettings1 = new IntegralSettingsBo(); + if (ObjectUtil.isNotEmpty(jsonArray.getJSONObject(0))) { + Integer points = Integer.parseInt(jsonArray.getJSONObject(0).get("integral").toString()); + integralSettings1.setIntegral(points); + } + integralSettings1.setIntegralName("第" + i + 1 + "天"); + integralSettingsList.add(integralSettings1); + } + }else if (ObjectUtil.isNotEmpty(integralSettings.getSignApplicableRules()) && integralSettings.getSignApplicableRules() == 1) { + for (int i = 0; i < jsonArray.size(); i++) { + String day = jsonArray.getJSONObject(i).get("day").toString(); + Integer points = Integer.parseInt(jsonArray.getJSONObject(i).get("integral").toString()); + IntegralSettingsBo integralSettings1 = new IntegralSettingsBo(); +// integralSettings1.setIntegralName(day); + integralSettings1.setIntegralName("第" +( i + 1 )+ "天"); + integralSettings1.setIntegral(points); + integralSettingsList.add(integralSettings1); + } + integralSettingsVo.setIntegralSettings(integralSettingsList); + } - DateTime now = DateUtil.date(); - DateTime yesterDay = DateUtil.offsetDay(now, -1); - //查询连续签到天数 - IntegralDetail integralDetail = integralDetailMapper.selectOne(new LambdaQueryWrapper() - .eq(IntegralDetail::getUserId, nowAccountInfo.getId()) - .eq(IntegralDetail::getStoreId, storeId) - .eq(IntegralDetail::getType, "签到赠送") - .between(IntegralDetail::getCreateTime, DateUtil.beginOfDay(yesterDay), now) - .orderBy(true, false, IntegralDetail::getCreateTime).last("limit 1")); + DateTime now = DateUtil.date(); + DateTime yesterDay = DateUtil.offsetDay(now, -1); + //查询连续签到天数 + IntegralDetail integralDetail = integralDetailMapper.selectOne(new LambdaQueryWrapper() + .eq(IntegralDetail::getUserId, nowAccountInfo.getId()) + .eq(IntegralDetail::getStoreId, storeId) + .eq(IntegralDetail::getType, "签到赠送") + .between(IntegralDetail::getCreateTime, DateUtil.beginOfDay(yesterDay), now) + .orderBy(true, false, IntegralDetail::getCreateTime).last("limit 1")); // if (CollUtil.isNotEmpty(day)) { // IntegralDetail integralDetail = day.get(0); - if (ObjectUtil.isNotEmpty(integralDetail)) { - // 正则表达式,匹配数字 - Pattern pattern = Pattern.compile("\\d+"); - Matcher matcher = pattern.matcher(integralDetail.getChangeReason()); - StringBuilder numbers = new StringBuilder(); - numbers.append(0); - while (matcher.find()) { - numbers.append(matcher.group()); - } - if (StrUtil.isEmpty(numbers)) { - integralSettingsVo.setSignInDays("0"); - } - String str = numbers.toString(); - if (Integer.parseInt(str) >= 10) { - numbers.deleteCharAt(0); - } - integralSettingsVo.setSignInDays(numbers.toString()); - }else { + if (ObjectUtil.isNotEmpty(integralDetail)) { + // 正则表达式,匹配数字 + Pattern pattern = Pattern.compile("\\d+"); + Matcher matcher = pattern.matcher(integralDetail.getChangeReason()); + StringBuilder numbers = new StringBuilder(); + numbers.append(0); + while (matcher.find()) { + numbers.append(matcher.group()); + } + if (StrUtil.isEmpty(numbers)) { + integralSettingsVo.setSignInDays("0"); + } + String str = numbers.toString(); + if (Integer.parseInt(str) >= 10) { + numbers.deleteCharAt(0); + } + integralSettingsVo.setSignInDays(numbers.toString()); + } else { integralSettingsVo.setSignInDays("0"); } // } + } return integralSettingsVo; }