| | |
| | | package com.mzl.flower.service.supplier; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | import com.mzl.flower.constant.Constants; |
| | | import com.mzl.flower.dto.request.supplier.*; |
| | | import com.mzl.flower.dto.response.supplier.SupplierDTO; |
| | | import com.mzl.flower.entity.customer.Customer; |
| | | import com.mzl.flower.entity.supplier.Supplier; |
| | | import com.mzl.flower.entity.supplier.SupplierSub; |
| | | import com.mzl.flower.mapper.supplier.SupplierMapper; |
| | | import com.mzl.flower.mapper.supplier.SupplierSubMapper; |
| | | import com.mzl.flower.service.BaseService; |
| | | import com.mzl.flower.utils.DateUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.oauth2.common.OAuth2AccessToken; |
| | | import org.springframework.security.oauth2.common.OAuth2RefreshToken; |
| | | import org.springframework.security.oauth2.provider.token.TokenStore; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | |
| | | private final static String SUPPLIER_STATUS_REJECT = "R"; // 审核拒绝 |
| | | |
| | | private final SupplierMapper supplierMapper; |
| | | |
| | | @Resource |
| | | private SupplierSubMapper supplierSubMapper; |
| | | |
| | | @Resource |
| | | private BaseService baseService; |
| | | |
| | | public SupplierService(SupplierMapper supplierMapper) { |
| | | this.supplierMapper = supplierMapper; |
| | |
| | | throw new ValidationException("当前登录用户不是供应商账号"); |
| | | } |
| | | SupplierDTO dto = supplierMapper.getCurrentSupplier(SecurityUtils.getUserId()); |
| | | //如果是空 查询子账号的供应商ID |
| | | if (ObjectUtils.isEmpty(dto)) { |
| | | SupplierSub sub = supplierSubMapper.getCurrentSupplier(SecurityUtils.getUserId()); |
| | | if (!ObjectUtils.isEmpty(sub)) { |
| | | dto = supplierMapper.findSupplierDetail(sub.getSupplierId()); |
| | | } |
| | | } |
| | | if(ObjectUtils.isEmpty(dto)){ |
| | | throw new ValidationException("供应商信息不存在"); |
| | | } |
| | | return dto; |
| | | } |
| | | |
| | |
| | | } |
| | | if (supplier.getIsEnabled()) { |
| | | supplier.setIsEnabled(false); |
| | | //强制下线 |
| | | baseService.removeToken(supplier.getUserId()); |
| | | } else { |
| | | supplier.setIsEnabled(true); |
| | | } |
| | | supplier.update(SecurityUtils.getUserId()); |
| | | supplierMapper.updateById(supplier); |
| | | } |
| | | |
| | | public Supplier getSupplierById(Long supplierId) { |
| | | return supplierMapper.selectById(supplierId); |
| | | } |
| | | } |