From a768dc3daa04d35fedfbe75c0a59b9b2545b85c4 Mon Sep 17 00:00:00 2001 From: gongzuming <gongzuming> Date: 星期四, 19 九月 2024 16:59:33 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master-v2' --- src/main/java/com/mzl/flower/service/customer/CustomerService.java | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 52 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/mzl/flower/service/customer/CustomerService.java b/src/main/java/com/mzl/flower/service/customer/CustomerService.java index 68d5b29..1933dc4 100644 --- a/src/main/java/com/mzl/flower/service/customer/CustomerService.java +++ b/src/main/java/com/mzl/flower/service/customer/CustomerService.java @@ -10,27 +10,40 @@ 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; @@ -38,7 +51,12 @@ } 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() { @@ -65,6 +83,7 @@ } customer.create(SecurityUtils.getUserId()); + customer.setIsEnabled(true); customer.setLevelId(Long.valueOf(Constants.DEFAULT_MEMBER_ID)); customerMapper.insert(customer); } else {//重新修改 @@ -201,4 +220,36 @@ } 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; + } + } -- Gitblit v1.9.3