From fd7b8fb7c89832c28a838b0449bbb8a392433ee2 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期二, 22 四月 2025 14:33:02 +0800 Subject: [PATCH] 将华为云短信替换成阿里云短信 --- ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java | 71 ++++++++++++++++++++++++----------- 1 files changed, 49 insertions(+), 22 deletions(-) diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java index 0f8de83..3b4d4f5 100644 --- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java +++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/TechnicianSubscribeServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.other.service.impl; +import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -8,6 +9,7 @@ import com.ruoyi.account.api.feignClient.AppUserShopClient; import com.ruoyi.account.api.model.AppUser; import com.ruoyi.account.api.model.AppUserShop; +import com.ruoyi.account.api.model.UserAddress; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.security.service.TokenService; @@ -28,9 +30,11 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.ZoneOffset; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; /** * <p> @@ -70,18 +74,31 @@ Optional<AppUserShop> first = data.stream().filter(s -> s.getShopId() == shopId.intValue() && s.getRoleType() == 3).findFirst(); Integer technicianId = null; if(first.isPresent()){ - AppUserShop appUserShop = first.get(); - Technician technician = technicianService.getOne(new LambdaQueryWrapper<Technician>().eq(Technician::getAppUserId, appUserShop.getAppUserId()) - .eq(Technician::getShopId, appUserShop.getShopId()).eq(Technician::getDelFlag, 0).eq(Technician::getStatus, 1)); - technicianId = technician.getId(); + //既是店员又是技师,需要取员工身份获取列表数据 + Optional<AppUserShop> first1 = data.stream().filter(s -> s.getShopId() == shopId.intValue() && s.getRoleType() != 3).findFirst(); + if(!first1.isPresent()){ + AppUserShop appUserShop = first.get(); + Technician technician = technicianService.getOne(new LambdaQueryWrapper<Technician>().eq(Technician::getAppUserId, appUserShop.getAppUserId()) + .eq(Technician::getShopId, appUserShop.getShopId()).eq(Technician::getDelFlag, 0).eq(Technician::getStatus, 2)); + if(null != technician){ + technicianId = technician.getId(); + } + } } List<TechnicianSubscribeVO> list = technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop(pageInfo, shopId, status, technicianId); for (TechnicianSubscribeVO technicianSubscribeVO : list) { String id = technicianSubscribeVO.getId(); TechnicianSubscribe technicianSubscribe = this.getById(id); AppUser appUser = appUserClient.getAppUserById(technicianSubscribe.getAppUserId()); - technicianSubscribeVO.setUserName(appUser.getName()); - technicianSubscribeVO.setPhone(appUser.getPhone()); + if(null != appUser){ + technicianSubscribeVO.setUserName(appUser.getName()); + technicianSubscribeVO.setPhone(appUser.getPhone()); + } + Integer serviceMode = technicianSubscribeVO.getServiceMode(); + if(1 == serviceMode){ + UserAddress userAddress = JSON.parseObject(technicianSubscribeVO.getUserAddress(), UserAddress.class); + technicianSubscribeVO.setUserAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getRecieveAddress()); + } } return pageInfo.setRecords(list); } @@ -91,16 +108,39 @@ Integer serviceMode, Integer pageCurr, Integer pageSize) { PageInfo<TechnicianSubscribeVO> pageInfo = new PageInfo(pageCurr, pageSize); List<TechnicianSubscribeVO> technicianSubscribeByUserAndShop1 = technicianSubscribeMapper.getTechnicianSubscribeByUserAndShop1(pageInfo, shopId, status, phone, name, serviceMode); + if (StringUtils.isNotEmpty(name)){ + List<AppUser> nameIds = appUserClient.getAppUserByName(name).getData(); + List<Long> collect = nameIds.stream().map(AppUser::getId).collect(Collectors.toList()); + if (collect.isEmpty())collect.add(-1L); + technicianSubscribeByUserAndShop1 = technicianSubscribeByUserAndShop1.stream().filter(e -> collect.contains(e.getAppUserId())) + .collect(Collectors.toList()); + } + if (StringUtils.isNotEmpty(phone)){ + List<AppUser> phoneIds = appUserClient.getAppUserByPhone(phone).getData(); + List<Long> collect = phoneIds.stream().map(AppUser::getId).collect(Collectors.toList()); + if (collect.isEmpty())collect.add(-1L); + technicianSubscribeByUserAndShop1 = technicianSubscribeByUserAndShop1.stream().filter(e -> collect.contains(e.getAppUserId())) + .collect(Collectors.toList()); + } for (TechnicianSubscribeVO technicianSubscribeVO : technicianSubscribeByUserAndShop1) { AppUser appUser = appUserClient.getAppUserById(technicianSubscribeVO.getAppUserId()); - technicianSubscribeVO.setUserName(appUser.getName()); - technicianSubscribeVO.setPhone(appUser.getPhone()); + if(appUser!=null){ + technicianSubscribeVO.setUserName(appUser.getName()); + technicianSubscribeVO.setPhone(appUser.getPhone()); + } } return pageInfo.setRecords(technicianSubscribeByUserAndShop1); } @Override public IPage<TechnicianSubscribeVO> getTechnicianSubscribeByUser(Page<TechnicianSubscribe> page, Long userId, Integer status) { - return technicianSubscribeMapper.getTechnicianSubscribeByUser(page, userId, status); + IPage<TechnicianSubscribeVO> technicianSubscribeByUser = technicianSubscribeMapper.getTechnicianSubscribeByUser(page, userId, status); + technicianSubscribeByUser.getRecords().forEach(technicianSubscribeVO -> { + UserAddress userAddress = JSON.parseObject(technicianSubscribeVO.getUserAddress(), UserAddress.class); + if (userAddress != null){ + technicianSubscribeVO.setUserAddress(userAddress.getProvince() + userAddress.getCity() + userAddress.getDistrict() + userAddress.getRecieveAddress()); + } + }); + return technicianSubscribeByUser; } @Override @@ -119,19 +159,6 @@ } - @Override - public void switchingTechnician(TechnicianSubscribe technicianSubscribe) { - List<TechnicianSubscribe> list = this.list(new LambdaQueryWrapper<TechnicianSubscribe>().eq(TechnicianSubscribe::getOrderId, technicianSubscribe.getOrderId()) - .eq(TechnicianSubscribe::getDelFlag, 0).eq(TechnicianSubscribe::getStatus, 0)); - for (TechnicianSubscribe subscribe : list) { - if(subscribe.getTechnicianId().equals(technicianSubscribe.getTechnicianId())){ - throw new RuntimeException("不能切换相同的技师"); - } - subscribe.setTechnicianId(technicianSubscribe.getTechnicianId()); - this.updateById(subscribe); - } - - } /** * 定时修改到期状态 -- Gitblit v1.7.1