| | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.account.api.dto.UnitListQueryDto; |
| | | import com.ruoyi.account.api.dto.UserDetailDto; |
| | | import com.ruoyi.account.api.dto.UserListQueryDto; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserCar; |
| | | import com.ruoyi.account.api.model.TAppUserTag; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.service.TAppUserCarService; |
| | | import com.ruoyi.account.service.TAppUserService; |
| | | import com.ruoyi.account.service.TAppUserTagService; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import com.ruoyi.account.api.dto.*; |
| | | import com.ruoyi.account.api.model.*; |
| | | import com.ruoyi.account.service.*; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.feignClient.ExchangeOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TExchangeOrder; |
| | | import com.ruoyi.other.api.domain.TCompany; |
| | | import com.ruoyi.other.api.domain.TUserTag; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | |
| | | @Resource |
| | | private TAppUserCarService appUserCarService; |
| | | |
| | | @Resource |
| | | private TAppUserIntegralChangeService integralChangeService; |
| | | |
| | | @Resource |
| | | private ExchangeOrderClient exchangeOrderClient; |
| | | @ApiOperation(value = "单位管理列表", tags = {"用户管理-单位管理"}) |
| | | @PostMapping(value = "/unit/page") |
| | | public R<Page<TCompany>> unitPage(@RequestBody UnitListQueryDto unitListQueryDto) { |
| | |
| | | @PostMapping(value = "/user/page") |
| | | public R<Page<TAppUser>> userPage(@RequestBody UserListQueryDto userListQueryDto) { |
| | | List<Long> userIds = new ArrayList<>(); |
| | | |
| | | //如果要筛选标签。用标签获取useids |
| | | if (userListQueryDto.getUserTagId() != null){ |
| | | userIds = appUserTagService.lambdaQuery().eq(TAppUserTag::getUserTagId, userListQueryDto.getUserTagId()).list().stream().map(TAppUserTag::getAppUserId).collect(Collectors.toList()); |
| | | } |
| | | |
| | | |
| | | |
| | | //列表查询 |
| | | Page<TAppUser> page = appUserService.lambdaQuery() |
| | | .like(userListQueryDto.getUserPhone() != null && !"".equals(userListQueryDto.getUserPhone()), TAppUser::getPhone, userListQueryDto.getUserPhone()) |
| | |
| | | .eq(userListQueryDto.getVipTypeId() != null, TAppUser::getVipId, userListQueryDto.getVipTypeId()) |
| | | .in(!userIds.isEmpty(),TAppUser::getId,userIds) |
| | | .page(Page.of(userListQueryDto.getPageCurr(), userListQueryDto.getPageSize())); |
| | | |
| | | if (page.getRecords().isEmpty()){ |
| | | return R.ok(page); |
| | | } |
| | |
| | | } |
| | | //匹配vipMap的值 |
| | | appUser.setVipName(vipMap.getData().get(appUser.getVipId())); |
| | | //累计充电次数 |
| | | R<Long> useOrderCount = chargingOrderClient.useOrderCount(appUser.getId()); |
| | | appUser.setOrderCount(useOrderCount.getData()); |
| | | |
| | | } |
| | | return R.ok(page); |
| | | } |
| | |
| | | userDetailDto.setTagName(tagMap.getData().values().toString()); |
| | | return R.ok(userDetailDto); |
| | | } |
| | | |
| | | @ApiOperation(value = "用户详情积分明细", tags = {"用户管理-用户列表"}) |
| | | @PostMapping(value = "/user/points/page") |
| | | public R<Page<TAppUserIntegralChange>> pointsDetail(@RequestBody PointsQueryDto pointsQueryDto) { |
| | | List<Integer> types = new ArrayList<>(); |
| | | if (pointsQueryDto.getType()!=null){ |
| | | types.add(1); |
| | | types.add(2); |
| | | types.add(3); |
| | | types.add(4); |
| | | types.add(5); |
| | | } |
| | | Page<TAppUserIntegralChange> page = integralChangeService.lambdaQuery() |
| | | .eq(TAppUserIntegralChange::getAppUserId, pointsQueryDto.getUserId()) |
| | | .orderByDesc(TAppUserIntegralChange::getCreateTime) |
| | | .eq(pointsQueryDto.getChangeType() != null, TAppUserIntegralChange::getChangeType, pointsQueryDto.getChangeType()) |
| | | .in(!types.isEmpty(), TAppUserIntegralChange::getChangeType, types).page(Page.of(pointsQueryDto.getPageCurr(), pointsQueryDto.getPageSize())); |
| | | |
| | | for (TAppUserIntegralChange record : page.getRecords()) { |
| | | if (record.getChangeType()==2){ |
| | | R<TChargingOrder> tChargingOrderR = chargingOrderClient.orderDetail(Long.valueOf(record.getExtension())); |
| | | if (tChargingOrderR.getData()!=null) { |
| | | record.setOrderNum(tChargingOrderR.getData().getCode()); |
| | | } |
| | | } |
| | | if (record.getChangeType()==6){ |
| | | R<TExchangeOrder> tExchangeOrderR = exchangeOrderClient.orderDetail(Long.valueOf(record.getExtension())); |
| | | if (tExchangeOrderR.getData()!=null){ |
| | | record.setOrderNum(tExchangeOrderR.getData().getCode()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return R.ok(page); |
| | | |
| | | } |
| | | |
| | | @ApiOperation(value = "用户详情积分明细", tags = {"用户管理-用户列表"}) |
| | | @PostMapping(value = "/user/status/change") |
| | | public R pointsDetail(@RequestBody UserChangeDto userChangeDto) { |
| | | TAppUser appUser = appUserService.getById(userChangeDto.getUserId()); |
| | | appUser.setStatus(userChangeDto.getStatus()); |
| | | appUserService.updateById(appUser); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "赠送会员", tags = {"用户管理-用户列表"}) |
| | | @PostMapping(value = "/user/give/vip") |
| | | public R giveVip(@RequestBody GiveVipDto giveVipDto) { |
| | | TAppUser nowUser = appUserService.getById(giveVipDto.getUserId()); |
| | | |
| | | |
| | | //如果vipEndTime为空或已过期,直接增加 |
| | | if (nowUser.getVipEndTime()==null||nowUser.getVipEndTime().isBefore(LocalDateTime.now())) { |
| | | if (giveVipDto.getType() == 1) { |
| | | nowUser.setVipEndTime(LocalDateTime.now().plusDays(31)); |
| | | //直接增加vipDetail |
| | | } else if (giveVipDto.getType() == 2) { |
| | | nowUser.setVipEndTime(LocalDateTime.now().plusDays(93)); |
| | | } else if (giveVipDto.getType() == 3) { |
| | | nowUser.setVipEndTime(LocalDateTime.now().plusDays(365)); |
| | | } |
| | | //直接赠送优惠卷 |
| | | }else { |
| | | if (giveVipDto.getType() == 1) { |
| | | nowUser.setVipEndTime(nowUser.getVipEndTime().plusDays(31)); |
| | | //如果有这个类型的vip,累加,没有的话,从entTime新增 |
| | | } else if (giveVipDto.getType() == 2) { |
| | | nowUser.setVipEndTime(nowUser.getVipEndTime().plusDays(93)); |
| | | } else if (giveVipDto.getType() == 3) { |
| | | nowUser.setVipEndTime(nowUser.getVipEndTime().plusDays(365)); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | return R.ok(); |
| | | } |
| | | } |
| | | |