| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.mzl.flower.config.GlobalSupplierVariables; |
| | | import com.mzl.flower.config.exception.ValidationException; |
| | | import com.mzl.flower.config.security.SecurityUtils; |
| | | import com.mzl.flower.constant.Constants; |
| | | import com.mzl.flower.dto.request.BindWechatDTO; |
| | | import com.mzl.flower.dto.request.system.*; |
| | | import com.mzl.flower.dto.response.current.CurrentUserDTO; |
| | | import com.mzl.flower.dto.response.supplier.SupplierDTO; |
| | | import com.mzl.flower.dto.response.system.EmployeeDTO; |
| | | 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.SupplierMapper; |
| | | 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; |
| | |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | private CustomerPointMapper customerPointMapper; |
| | | @Autowired |
| | | private StationService stationService; |
| | | |
| | | @Autowired |
| | | private SupplierSubMapper supplierSubMapper; |
| | | |
| | | @Autowired |
| | | private SupplierMapper supplierMapper; |
| | | |
| | | @Autowired |
| | | private GlobalSupplierVariables globalSupplierVariables; |
| | | |
| | | |
| | | public User findUserByOpenId(String openId, String sessionKey, String unionId |
| | |
| | | } |
| | | |
| | | public CurrentUserDTO getCurrentUser() { |
| | | |
| | | String userId = SecurityUtils.getUserId(); |
| | | |
| | | CurrentUserDTO result = new CurrentUserDTO(); |
| | |
| | | if(customerPoint == null){ |
| | | result.setCurrentPoint(0); |
| | | }else{ |
| | | Integer currentPoint =customerPoint.getTotalPoint()-customerPoint.getUsedPoint()-customerPoint.getExpiredPoint(); |
| | | 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()); |
| | | //主账号信息 |
| | | SupplierDTO dto = supplierMapper.getCurrentSupplier(SecurityUtils.getUserId()); |
| | | // if (!ObjectUtils.isEmpty(dto)) { |
| | | // globalSupplierVariables.removeSupplier(String.valueOf(dto.getId())); |
| | | // } |
| | | String tempUserId = ""; |
| | | if (!ObjectUtils.isEmpty(sub)) { |
| | | tempUserId = globalSupplierVariables.getSupplier(String.valueOf(sub.getId())); |
| | | } else { |
| | | tempUserId = globalSupplierVariables.getSupplier(String.valueOf(dto.getId())); |
| | | } |
| | | if (!ObjectUtils.isEmpty(sub)) { |
| | | result.setIsSubSupplier(true); |
| | | result.setSupplierSub(sub); |
| | | result.setSwitchFlag(false); |
| | | } else { |
| | | if (!StringUtils.isBlank(tempUserId)) { |
| | | SupplierSub temSub = supplierSubMapper.getCurrentSupplier(tempUserId); |
| | | result.setIsSubSupplier(true); |
| | | result.setSupplierSub(temSub); |
| | | result.setSwitchFlag(true); |
| | | } else { |
| | | result.setIsSubSupplier(false); |
| | | result.setSupplierSub(null); |
| | | result.setSwitchFlag(true); |
| | | } |
| | | } |
| | | }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); |