| | |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.Pattern; |
| | | |
| | | import com.panzhihua.common.model.dtos.community.microCommercialStreet.LoginWithPhoneDTO; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | private McsConfigDAO mcsConfigDAO; |
| | | @Resource |
| | | private McsGameDAO mcsGameDAO; |
| | | @Resource |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | |
| | | /** |
| | | * 新增数字商业街商家 |
| | |
| | | //添加user |
| | | R addUserResult = userService.addMcsMerchantUser(mcsMerchantDTO); |
| | | if (R.isOk(addUserResult)) { |
| | | Long merchantUserId = ((Integer) addUserResult.getData()).longValue(); |
| | | mcsMerchant.setUserId(merchantUserId); |
| | | LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(JSONObject.toJSONString(addUserResult.getData()), LoginUserInfoVO.class); |
| | | mcsMerchant.setUserId(loginUserInfoVO.getUserId()); |
| | | this.baseMapper.updateById(mcsMerchant); |
| | | } else { |
| | | throw new ServiceException("406", addUserResult.getMsg()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 验证码登录 |
| | | * @param loginDTO |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R loginWithPhone(LoginWithPhoneDTO loginDTO) { |
| | | String phone = loginDTO.getPhone(); |
| | | String redisKey = String.join("::", phone, loginDTO.getCode()); |
| | | Boolean hasKey = stringRedisTemplate.hasKey(redisKey); |
| | | if (hasKey) { |
| | | //通过验证 |
| | | R r = userService.getSysUserByPhone(phone, 11); |
| | | if (R.isOk(r)) { |
| | | if (nonNull(r.getData())) { |
| | | //已有用户 |
| | | LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(JSONObject.toJSONString(r.getData()), LoginUserInfoVO.class); |
| | | stringRedisTemplate.delete(redisKey); |
| | | return R.ok(loginUserInfoVO); |
| | | } else { |
| | | //自动创建用户 |
| | | McsMerchantDTO mcsMerchantDTO = new McsMerchantDTO(); |
| | | mcsMerchantDTO.setAccount(phone); |
| | | mcsMerchantDTO.setPassword("88888888"); |
| | | mcsMerchantDTO.setAccountStatus(1); |
| | | mcsMerchantDTO.setPhone(phone); |
| | | R addUserResult = userService.addMcsMerchantUser(mcsMerchantDTO); |
| | | if (R.isOk(addUserResult)) { |
| | | LoginUserInfoVO loginUserInfoVO = JSONObject.parseObject(JSONObject.toJSONString(addUserResult.getData()), LoginUserInfoVO.class); |
| | | stringRedisTemplate.delete(redisKey); |
| | | return R.ok(loginUserInfoVO); |
| | | } |
| | | return addUserResult; |
| | | } |
| | | } |
| | | return r; |
| | | } else { |
| | | return R.fail("验证码错误"); |
| | | } |
| | | } |
| | | |
| | | private void retrieveMerchantSurplusLitDays(McsMerchantVO merchantVO) { |
| | | Integer publishLimit = merchantVO.getPublishLimit(); |
| | | Integer publishCount = mcsGameDAO.selectPublishCount(merchantVO.getId()); |