| | |
| | | import com.mzl.flower.dto.request.customer.ChangePartnerDTO; |
| | | import com.mzl.flower.dto.request.customer.QueryCustomerDTO; |
| | | import com.mzl.flower.dto.request.customer.UpdateCustomerDTO; |
| | | import com.mzl.flower.dto.request.menber.UserGrowthRecordDTO; |
| | | import com.mzl.flower.dto.response.customer.CustomerDTO; |
| | | import com.mzl.flower.dto.response.partner.PartnerDTO; |
| | | import com.mzl.flower.entity.customer.Customer; |
| | | import com.mzl.flower.entity.partner.Partner; |
| | | import com.mzl.flower.enums.TrueOrFalseEnum; |
| | | import com.mzl.flower.mapper.customer.CustomerMapper; |
| | | import com.mzl.flower.mapper.partner.PartnerMapper; |
| | | import com.mzl.flower.service.menber.MemberGrowthRecordService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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 org.springframework.util.ObjectUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | @Transactional |
| | | @Slf4j |
| | | public class CustomerService { |
| | | |
| | | |
| | | private final CustomerMapper customerMapper; |
| | | |
| | | private final PartnerMapper partnerMapper; |
| | | @Resource |
| | | private MemberGrowthRecordService memberGrowthRecordService; |
| | | |
| | | @Resource |
| | | private BaseService baseService; |
| | | |
| | | public CustomerService(CustomerMapper customerMapper, PartnerMapper partnerMapper) { |
| | | this.customerMapper = customerMapper; |
| | |
| | | } |
| | | |
| | | public CustomerDTO getCurrentCustomer() { |
| | | return customerMapper.getCurrentCustomer(SecurityUtils.getUserId()); |
| | | CustomerDTO currentCustomer = customerMapper.getCurrentCustomer(SecurityUtils.getUserId()); |
| | | UserGrowthRecordDTO userGrowthRecordDTO = memberGrowthRecordService.getInfoByUserId(SecurityUtils.getUserId()); |
| | | if(!ObjectUtils.isEmpty(userGrowthRecordDTO)){ |
| | | currentCustomer.setUserGrowthRecord(userGrowthRecordDTO); |
| | | } |
| | | return currentCustomer; |
| | | } |
| | | |
| | | public PartnerDTO getCurrentBindPartner() { |
| | |
| | | } |
| | | |
| | | customer.create(SecurityUtils.getUserId()); |
| | | customer.setIsEnabled(true); |
| | | customer.setLevelId(Long.valueOf(Constants.DEFAULT_MEMBER_ID)); |
| | | customerMapper.insert(customer); |
| | | } else {//重新修改 |
| | |
| | | } |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | | * 根据会员等级获取等级下的customer信息 |
| | | * @param levelId |
| | | * @return |
| | | */ |
| | | public List<Customer> getCustomerListByLevelId(Integer levelId){ |
| | | if(null != levelId){ |
| | | QueryWrapper<Customer> customerQueryWrapper=new QueryWrapper<>(); |
| | | customerQueryWrapper.lambda() |
| | | .eq(Customer::getDeleted, TrueOrFalseEnum.FALSE.isFlag()) |
| | | .eq(Customer::getLevelId,levelId); |
| | | return customerMapper.selectList(customerQueryWrapper); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |