cloudroam
2024-09-10 33a30da7b2795fc60ebab8e89760087f5dfdd3a0
src/main/java/com/mzl/flower/service/customer/CustomerService.java
@@ -16,11 +16,13 @@
import com.mzl.flower.entity.partner.Partner;
import com.mzl.flower.mapper.customer.CustomerMapper;
import com.mzl.flower.mapper.partner.PartnerMapper;
import com.mzl.flower.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
@Service
@@ -31,6 +33,9 @@
    private final CustomerMapper customerMapper;
    private final PartnerMapper partnerMapper;
    @Resource
    private BaseService baseService;
    public CustomerService(CustomerMapper customerMapper, PartnerMapper partnerMapper) {
        this.customerMapper = customerMapper;
@@ -65,6 +70,7 @@
            }
            customer.create(SecurityUtils.getUserId());
            customer.setIsEnabled(true);
            customerMapper.insert(customer);
        } else {//重新修改
            customer = customerMapper.selectById(dto.getId());
@@ -200,4 +206,19 @@
        }
        return null;
    }
    public void isEnable(Long id) {
        Customer customer = customerMapper.selectById(id);
        if (customer == null) {
            throw new ValidationException("商户信息不存在");
        }
        if (customer.getIsEnabled()) {
            customer.setIsEnabled(false);
            //强制下线
            baseService.removeToken(customer.getUserId());
        } else {
            customer.setIsEnabled(true);
        }
        customer.update(SecurityUtils.getUserId());
        customerMapper.updateById(customer);
    }
}