From 9a1173507d06c59a7c02e92ad083073e0036eadc Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期四, 26 九月 2024 18:52:35 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java | 107 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 96 insertions(+), 11 deletions(-) diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java index c40aeb7..3b77098 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java @@ -11,11 +11,9 @@ import com.ruoyi.account.api.dto.*; import com.ruoyi.account.api.model.*; import com.ruoyi.account.service.*; -import com.ruoyi.account.util.PointDetailUtil; -import com.ruoyi.account.util.SignDayUtil; +import com.ruoyi.account.util.*; import com.ruoyi.account.util.carBrand.CarBrandUtil; import com.ruoyi.account.wx.model.WeixinProperties; -import com.ruoyi.account.util.GiveVipUtil; import com.ruoyi.common.core.constant.Constants; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.dto.PointChangeDto; @@ -26,6 +24,9 @@ import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.domain.BasePojo; import com.ruoyi.common.core.web.page.BasePage; +import com.ruoyi.common.log.annotation.Log; +import com.ruoyi.common.log.enums.BusinessType; +import com.ruoyi.common.log.enums.OperatorType; import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.auth.AuthUtil; import com.ruoyi.common.security.service.TokenService; @@ -114,6 +115,8 @@ private VipClient vipClient; @Resource private TInviteUserService inviteUserService; + @Resource + private GiveVipUtil giveVipUtil; /** @@ -149,8 +152,9 @@ public R<List<Long>> getUserIdsByPhone(@RequestParam("phone") String phone) { return R.ok(appUserService.list(new QueryWrapper<TAppUser>().like("phone",phone)).stream().map(TAppUser::getId).collect(Collectors.toList())); } - @Resource - private GiveVipUtil giveVipUtil; + + + @ApiOperation(value = "单位管理列表", tags = {"用户管理-单位管理"}) @PostMapping(value = "/unit/page") public R<Page<TCompany>> unitPage(@RequestBody UnitListQueryDto unitListQueryDto) { @@ -180,6 +184,7 @@ @ApiOperation(value = "单位管理添加或编辑", tags = {"用户管理-单位管理"}) @PostMapping(value = "/unit/addOrUpdate") + @Log(title = "【单位管理】添加或编辑单位", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) public R add(@RequestBody TCompany tCompany) { //拿到单位列表 otherClient.unitAddorUpadate(tCompany); @@ -191,6 +196,7 @@ @ApiOperation(value = "单位管理删除", tags = {"用户管理-单位管理"}) @DeleteMapping(value = "/unit/delete") + @Log(title = "【单位管理】删除单位", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) public R add(@RequestParam String ids) { String[] split = ids.split(","); for (String s : split) { @@ -213,6 +219,7 @@ Page<TAppUser> page = appUserService.lambdaQuery() .like(userListQueryDto.getUserPhone() != null && !"".equals(userListQueryDto.getUserPhone()), TAppUser::getPhone, userListQueryDto.getUserPhone()) .eq(userListQueryDto.getCompanyId() != null, TAppUser::getCompanyId, userListQueryDto.getCompanyId()) + .like(userListQueryDto.getProvinceCode() != null && !"".equals(userListQueryDto.getProvinceCode()), TAppUser::getProvinceCode, userListQueryDto.getProvinceCode()) .eq(userListQueryDto.getCityCode() != null && !"".equals(userListQueryDto.getCityCode()), TAppUser::getCityCode, userListQueryDto.getCityCode()) .eq(userListQueryDto.getStatus() != null, TAppUser::getStatus, userListQueryDto.getStatus()) .eq(userListQueryDto.getVipTypeId() != null, TAppUser::getVipId, userListQueryDto.getVipTypeId()) @@ -222,7 +229,7 @@ return R.ok(page); } List<Integer> vipIds = new ArrayList<>(); - vipIds = page.getRecords().stream().map(TAppUser::getVipId).collect(Collectors.toList()); +// vipIds = page.getRecords().stream().map(TAppUser::getVipId).collect(Collectors.toList()); //获取会员map R<Map<Integer, String>> vipMap = otherClient.getVipMap(vipIds); //循环处理 @@ -236,12 +243,28 @@ appUser.setTagName(byIdTag.getData().getName()); } } - //匹配vipMap的值 - appUser.setVipName(vipMap.getData().get(appUser.getVipId())); + if (appUser.getVipEndTime()!=null&&appUser.getVipEndTime().isAfter(LocalDateTime.now())) { + //匹配vipMap的值 + appUser.setVipName(vipMap.getData().get(appUser.getVipId())); + } //累计充电次数 R<Long> useOrderCount = chargingOrderClient.useOrderCount(appUser.getId()); appUser.setOrderCount(useOrderCount.getData()); appUser.setUid(appUser.getId().toString()); + if (appUser.getCompanyId()!=null){ + TCompany data = otherClient.unitDetail(appUser.getCompanyId()).getData(); + if (data!=null){ + appUser.setCompanyName(data.getName()); + } + } + + TAppUserCar one1 = appUserCarService.lambdaQuery().eq(TAppUserCar::getAppUserId, appUser.getId()).orderByDesc(BasePojo::getCreateTime).last("limit 1").one(); + if (one1!=null){ + CarNumDto carNumDto = CarUtil.carNum(one1.getLicensePlate()); + appUser.setPlace(carNumDto.getProvince()+carNumDto.getCity()); + + } + } return R.ok(page); @@ -349,6 +372,7 @@ @ApiOperation(value = "用户添加编辑", tags = {"用户管理-用户列表"}) @PostMapping(value = "/user/addOrUpdate") + @Log(title = "【用户列表】添加编辑用户", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE) public R addOrUpdate(@RequestBody TAppUser tAppUser) { if (tAppUser.getId() != null){ //为编辑操作,要进行vip的逻辑处理 @@ -423,12 +447,21 @@ pointsQueryDto.setUserId(tokenService.getLoginUserApplet().getUserId()); } List<Integer> types = new ArrayList<>(); - if (pointsQueryDto.getType()!=null){ + if (pointsQueryDto.getType()==null){ types.add(1); types.add(2); types.add(3); types.add(4); types.add(5); + types.add(6); + }else if (pointsQueryDto.getType()==1){ + types.add(1); + types.add(2); + types.add(3); + types.add(4); + types.add(5); + }else if (pointsQueryDto.getType()==2){ + types.add(6); } Page<TAppUserIntegralChange> page = integralChangeService.lambdaQuery() .eq(TAppUserIntegralChange::getAppUserId, pointsQueryDto.getUserId()) @@ -466,6 +499,7 @@ @ApiOperation(value = "冻结解冻用户", tags = {"后台-用户管理-用户列表"}) @PostMapping(value = "/user/status/change") + @Log(title = "【用户列表】冻结解冻用户", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) public R pointsDetail(@RequestBody UserChangeDto userChangeDto) { TAppUser appUser = appUserService.getById(userChangeDto.getUserId()); appUser.setStatus(userChangeDto.getStatus()); @@ -476,6 +510,7 @@ @ApiOperation(value = "修改单位", tags = {"后台-用户管理-用户列表"}) @PostMapping(value = "/user/unit/change") + @Log(title = "【用户列表】修改用户单位", businessType = BusinessType.UPDATE,operatorType = OperatorType.MANAGE) public R unitChange(@RequestBody UnitChangeDto unitChangeDto) { for (String s : unitChangeDto.getIds().split(",")) { TAppUser byId = appUserService.getById(s); @@ -487,6 +522,7 @@ @ApiOperation(value = "删除用户", tags = {"后台-用户管理-用户列表"}) @DeleteMapping(value = "/user/delete") + @Log(title = "【用户列表】删除用户", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) public R userDelete(String ids) { String[] split = ids.split(","); for (String s : split) { @@ -596,6 +632,7 @@ @ApiOperation(value = "赠送会员", tags = {"用户管理-用户列表"}) @PostMapping(value = "/user/give/vip") + @Log(title = "【用户列表】赠送会员", businessType = BusinessType.OTHER,operatorType = OperatorType.MANAGE) public R giveVip(@RequestBody GiveVipDto giveVipDto) { String[] split = giveVipDto.getUserIds().split(","); for (String s : split) { @@ -612,7 +649,7 @@ plusDay = 12; } //增加vipDetail - giveVipUtil.sendVip(nowUser, giveVipDto.getVipId(),plusDay); + giveVipUtil.sendVip(nowUser, giveVipDto.getVipId(),plusDay,giveVipDto.getType()); appUserService.updateById(nowUser); } return R.ok(); @@ -748,6 +785,17 @@ if (signService.lambdaQuery().eq(TAppUserSign::getSignDay, LocalDate.now()).eq(TAppUserSign::getAppUserId, userId).count()>0){ return R.fail("今日已签到"); } + + //判断当前生效的vipDetail + TAppUserVipDetail one = tAppUserVipDetailService.lambdaQuery().le(TAppUserVipDetail::getStartTime, LocalDateTime.now()).ge(TAppUserVipDetail::getEndTime, LocalDateTime.now()).eq(TAppUserVipDetail::getAppUserId, userId).last("limit 1").one(); + boolean doubleVip = false; + if (one!=null){ + TVip tVip = JSONObject.parseObject(one.getVipJson(), TVip.class); + if (tVip.getDoubleIntegration()==1){ + doubleVip = true; + } + } + //签到业务 TAppUserSign appUserSign = new TAppUserSign(); appUserSign.setSignDay(LocalDate.now()); @@ -763,6 +811,9 @@ Integer points = 0; Integer point = jsonObject.getInteger("num1"); points= points+point; + if (doubleVip){ + points= points+point; + } JSONArray num2 = jsonObject.getJSONArray("num2"); if (num2!=null) { //获取连续签到的规则放入map @@ -777,6 +828,9 @@ Integer i = map.get(days); if (i!=null){ points= points+i; + if (doubleVip){ + points= points+i; + } appUserSign.setIsGift(1); signService.updateById(appUserSign); } @@ -786,6 +840,8 @@ appUserService.updateById(byId); return R.ok(); } + + //已签到日期 @ApiOperation(value = "本月已签到日期", tags = {"小程序-个人中心-签到"}) @GetMapping(value = "/user/has/sign") @@ -845,6 +901,16 @@ TAppUser byId = appUserService.getById(userId); appUserCar.setAppUserId(userId); + //判断当前生效的vipDetail + TAppUserVipDetail one = tAppUserVipDetailService.lambdaQuery().le(TAppUserVipDetail::getStartTime, LocalDateTime.now()).ge(TAppUserVipDetail::getEndTime, LocalDateTime.now()).eq(TAppUserVipDetail::getAppUserId, userId).last("limit 1").one(); + boolean doubleVip = false; + if (one!=null){ + TVip tVip = JSONObject.parseObject(one.getVipJson(), TVip.class); + if (tVip.getDoubleIntegration()==1){ + doubleVip = true; + } + } + //如果是第一次添加车辆,增加积分 Long count = appUserCarService.lambdaQuery().eq(TAppUserCar::getAppUserId, userId).count(); @@ -858,27 +924,46 @@ Integer point = 0; //增加车牌50分,必填 point = point+jsonObject.getInteger("num1"); + if (doubleVip){ + point = point+jsonObject.getInteger("num1"); + } //增加车型分 if (StringUtils.isNotEmpty(appUserCar.getVehicleModel())){ point = point+jsonObject.getInteger("num2"); + if (doubleVip){ + point = point+jsonObject.getInteger("num2"); + } } //增加车辆用途分 if (StringUtils.isNotEmpty(appUserCar.getVehicleUse())){ point = point+jsonObject.getInteger("num3"); + if (doubleVip){ + point = point+jsonObject.getInteger("num3"); + } } //增加续航分 if (StringUtils.isNotEmpty(appUserCar.getEndurance())){ point = point+jsonObject.getInteger("num4"); + if (doubleVip){ + point = point+jsonObject.getInteger("num4"); + } } //增加积分记录 pointDetailUtil.addDetail(byId.getPoints(),byId.getPoints()+point,5,userId,appUserCar.getLicensePlate(),""); byId.setPoints(byId.getPoints()+point); byId.setFirstAdd(1); - appUserService.updateById(byId); } + CarNumDto carNumDto = CarUtil.carNum(appUserCar.getLicensePlate()); + if (carNumDto==null){ + return R.fail("请输入正确的车牌"); + } + + byId.setCityCode(carNumDto.getAreaCode()); + byId.setProvinceCode(carNumDto.getAreaCode().substring(0,2)+"0000"); + appUserService.updateById(byId); // appUserCarService.saveOrUpdate(appUserCar); -- Gitblit v1.7.1