| | |
| | | package com.ks.app.service.manager; |
| | | |
| | | import com.ks.app.entity.SystemEnum; |
| | | import com.ks.app.entity.config.SystemConfigKey; |
| | | import com.ks.app.service.inter.config.SystemConfigService; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.yeshi.utils.NumberUtil; |
| | | import org.yeshi.utils.StringUtil; |
| | | import org.yeshi.utils.sms.TencentSMSUtil; |
| | | import org.yeshi.utils.sms.VerifyCodeFactory; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.concurrent.TimeUnit; |
| | |
| | | @Resource |
| | | private RedisTemplate<String, String> redisTemplate; |
| | | |
| | | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | /** |
| | | * @return void |
| | | * @author hxh |
| | |
| | | * @param: phone |
| | | * @param: msg 变量为:{验证码} |
| | | **/ |
| | | public void sendSMSSuccess(String phone, String code) { |
| | | public void sendSMSSuccess(SystemEnum system, String phone, String code) { |
| | | |
| | | redisTemplate.opsForValue().set("v-c-p-" + phone, code, 120, TimeUnit.SECONDS); |
| | | redisTemplate.opsForValue().set(String.format("vcp-%s-%s", system.name(), phone), code, 120, TimeUnit.SECONDS); |
| | | |
| | | } |
| | | |
| | |
| | | * @param: phone |
| | | * @param: code |
| | | **/ |
| | | public boolean isPhoneCodeRight(String phone, String code) { |
| | | String oldCode = redisTemplate.opsForValue().get("v-c-p-" + phone); |
| | | public boolean isPhoneCodeRight(SystemEnum system, String phone, String code) { |
| | | |
| | | String value = systemConfigService.getValueCache(system, SystemConfigKey.testAccount); |
| | | //测试账号 |
| | | if (!StringUtil.isNullOrEmpty(value)) { |
| | | String[] sts = value.split("#"); |
| | | if (sts.length > 1 && sts[0].equalsIgnoreCase(phone) && sts[1].equalsIgnoreCase(code)) { |
| | | return true; |
| | | } |
| | | } |
| | | |
| | | |
| | | String oldCode = redisTemplate.opsForValue().get(String.format("vcp-%s-%s", system.name(), phone)); |
| | | return oldCode != null && oldCode.equalsIgnoreCase(code); |
| | | // return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param: code |
| | | **/ |
| | | public boolean isEMailCodeRight(String email, String code) { |
| | | String oldCode = redisTemplate.opsForValue().get("v-c-e-" + StringUtil.Md5(email)); |
| | | return oldCode != null && oldCode.equalsIgnoreCase(code); |
| | | Object oldCode = redisTemplate.opsForValue().get("v-c-e-" + StringUtil.Md5(email)); |
| | | return oldCode != null && oldCode.toString().equalsIgnoreCase(code); |
| | | } |
| | | |
| | | |