|  |  |  | 
|---|
|  |  |  | package com.mzl.flower.service.register; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | import com.mzl.flower.config.exception.ValidationException; | 
|---|
|  |  |  | import com.mzl.flower.constant.Constants; | 
|---|
|  |  |  | import com.mzl.flower.dto.request.register.RegisterCustomerDTO; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.mzl.flower.mapper.system.UserWechatMapper; | 
|---|
|  |  |  | import com.mzl.flower.service.customer.CustomerService; | 
|---|
|  |  |  | import com.mzl.flower.service.partner.PartnerService; | 
|---|
|  |  |  | import com.mzl.flower.service.payment.RedisLockService; | 
|---|
|  |  |  | import com.mzl.flower.utils.UUIDGenerator; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.springframework.security.crypto.password.PasswordEncoder; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final UserWechatMapper wechatMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private final RedisLockService lockService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public RegisterService(UserMapper userMapper, | 
|---|
|  |  |  | PasswordEncoder passwordEncoder, | 
|---|
|  |  |  | PartnerService partnerService, | 
|---|
|  |  |  | CustomerService customerService, UserWechatMapper wechatMapper) { | 
|---|
|  |  |  | CustomerService customerService, UserWechatMapper wechatMapper, | 
|---|
|  |  |  | RedisLockService lockService) { | 
|---|
|  |  |  | this.userMapper = userMapper; | 
|---|
|  |  |  | this.passwordEncoder = passwordEncoder; | 
|---|
|  |  |  | this.partnerService = partnerService; | 
|---|
|  |  |  | this.customerService = customerService; | 
|---|
|  |  |  | this.wechatMapper = wechatMapper; | 
|---|
|  |  |  | this.lockService = lockService; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void registerUser(RegisterDTO dto, String userType) { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void registerCustomerUser(RegisterCustomerDTO dto, String userType, String openId, String sessionKey, String unionId) { | 
|---|
|  |  |  | String key = dto.getTel() + "_" + userType; | 
|---|
|  |  |  | boolean lock = lockService.getObjectLock(RedisLockService.LOCK_KEY_CART_, key); | 
|---|
|  |  |  | if(!lock){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | if(checkUserExist(dto.getTel(),userType)){ | 
|---|
|  |  |  | throw new ValidationException("该手机号码已经注册"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | dto.getDto().setUserId(user.getId()); | 
|---|
|  |  |  | customerService.addOrUpdateCustomer(dto.getDto()); | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | lockService.releaseObjectLock(RedisLockService.LOCK_KEY_CART_, key); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|