陶杰
2025-01-08 ae1471f378f399f76518539ec8992e64a3673436
src/main/java/com/mzl/flower/service/BaseService.java
@@ -18,11 +18,13 @@
import com.mzl.flower.entity.payment.OrderItemSales;
import com.mzl.flower.entity.payment.OrderSalesItem;
import com.mzl.flower.entity.supplier.Supplier;
import com.mzl.flower.entity.supplier.SupplierSub;
import com.mzl.flower.mapper.customer.CustomerMapper;
import com.mzl.flower.mapper.flower.FlowerCategoryMapper;
import com.mzl.flower.mapper.member.MemberMapper;
import com.mzl.flower.mapper.partner.PartnerMapper;
import com.mzl.flower.mapper.supplier.SupplierMapper;
import com.mzl.flower.mapper.supplier.SupplierSubMapper;
import com.mzl.flower.mapper.system.UserMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -31,6 +33,7 @@
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -53,6 +56,9 @@
    @Autowired
    protected SupplierMapper supplierMapper;
    @Autowired
    protected SupplierSubMapper supplierSubMapper;
    @Autowired
    protected PartnerMapper partnerMapper;
@@ -552,14 +558,19 @@
        return p;
    }
    public Supplier getCurrentSupplier(){
    public Supplier getCurrentSupplier() {
        String userId = SecurityUtils.getUserId();
        Supplier s = supplierMapper.selectOne(new QueryWrapper<Supplier>()
                .eq("user_id", userId));
        if(s == null){
            throw new ValidationException("供应商信息未认证,请到个人中心进行认证");
        if (s == null) {
            SupplierSub sub = supplierSubMapper.getCurrentSupplier(SecurityUtils.getUserId());
            if (!ObjectUtils.isEmpty(sub)) {
                s = supplierMapper.selectById(sub.getSupplierId());
                return s;
            } else {
                throw new ValidationException("供应商信息未认证,请到个人中心进行认证");
            }
        }
        return s;
    }