From 2c5a0e133b64bb0a46b1419c48e9b62a4779e268 Mon Sep 17 00:00:00 2001 From: cloudroam <cloudroam> Date: 星期一, 09 十二月 2024 16:13:17 +0800 Subject: [PATCH] add: 供应商子账号 --- src/main/java/com/mzl/flower/service/system/UserService.java | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/mzl/flower/service/system/UserService.java b/src/main/java/com/mzl/flower/service/system/UserService.java index fca2da7..47b50b4 100644 --- a/src/main/java/com/mzl/flower/service/system/UserService.java +++ b/src/main/java/com/mzl/flower/service/system/UserService.java @@ -13,11 +13,17 @@ import com.mzl.flower.dto.response.system.MenuTreeDTO; import com.mzl.flower.dto.response.system.UserDetailsDTO; import com.mzl.flower.dto.response.system.UserListDTO; +import com.mzl.flower.entity.point.CustomerPoint; +import com.mzl.flower.entity.supplier.SupplierSub; import com.mzl.flower.entity.system.*; import com.mzl.flower.enums.TrueOrFalseEnum; +import com.mzl.flower.mapper.point.CustomerPointMapper; +import com.mzl.flower.mapper.supplier.SupplierSubMapper; import com.mzl.flower.mapper.system.*; import com.mzl.flower.service.customer.CustomerService; import com.mzl.flower.service.partner.PartnerService; +import com.mzl.flower.service.point.CustomerPointService; +import com.mzl.flower.service.supplier.StationService; import com.mzl.flower.service.supplier.SupplierService; import com.mzl.flower.utils.TreeBuilderUtil; import com.mzl.flower.utils.UUIDGenerator; @@ -28,6 +34,7 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; import javax.validation.constraints.NotBlank; import java.util.ArrayList; @@ -73,6 +80,15 @@ @Autowired private EmployeeMapper employeeMapper; + + @Autowired + private CustomerPointMapper customerPointMapper; + @Autowired + private StationService stationService; + + @Autowired + private SupplierSubMapper supplierSubMapper; + public User findUserByOpenId(String openId, String sessionKey, String unionId , String imgUrl, String nickname,String userType){ @@ -188,10 +204,29 @@ if(Constants.USER_TYPE.customer.name().equals(user.getType())){ result.setCustomerDTO(customerService.getCurrentCustomer()); + //查询积分 + CustomerPoint customerPoint = customerPointMapper.selectOne(new LambdaQueryWrapper<CustomerPoint>() + .eq(CustomerPoint::getUserId, userId)); + if(customerPoint == null){ + result.setCurrentPoint(0); + }else{ + Integer currentPoint =customerPoint.getTotalPoint()-customerPoint.getUsedPoint()-customerPoint.getExpiredPoint()-customerPoint.getDeductionPoint(); + result.setCurrentPoint(currentPoint>=0?currentPoint:0); + } }else if(Constants.USER_TYPE.supplier.name().equals(user.getType())){ result.setSupplierDTO(supplierService.getCurrentSupplier()); + SupplierSub sub = supplierSubMapper.getCurrentSupplier(SecurityUtils.getUserId()); + if (!ObjectUtils.isEmpty(sub)) { + result.setIsSubSupplier(true); + result.setSupplierSub(sub); + } else { + result.setIsSubSupplier(false); + result.setSupplierSub(null); + } }else if(Constants.USER_TYPE.partner.name().equals(user.getType())){ result.setPartnerDTO(partnerService.getCurrentPartner()); + }else if (Constants.USER_TYPE.admin.name().equals(user.getType())){ + result.setMainWarehouse(stationService.getMainWarehouse(user.getId())); } result.setBindWechat(wechatMapper.selectCount(new LambdaQueryWrapper<UserWechat>() .eq(UserWechat::getUserId, userId)) > 0); -- Gitblit v1.9.3