档口认证短信验证码接口
parent
1032ab5933
commit
acee401913
|
|
@ -10,6 +10,7 @@ import com.ruoyi.common.enums.BusinessType;
|
|||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.web.controller.xkt.vo.PhoneNumberVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.storeCertificate.StoreCertCreateVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.storeCertificate.StoreCertResVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.storeCertificate.StoreCertStepResVO;
|
||||
|
|
@ -78,6 +79,14 @@ public class StoreCertificateController extends XktBaseController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store')")
|
||||
@ApiOperation(value = "发送短信验证码(档口认证相关功能)")
|
||||
@PostMapping("/sendSmsVerificationCode")
|
||||
public R sendSmsVerificationCode(@Validated @RequestBody PhoneNumberVO vo) {
|
||||
storeCertService.sendSmsVerificationCode(vo.getPhoneNumber());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新缓存
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -43,4 +43,19 @@ public interface IStoreCertificateService {
|
|||
* @return StoreCertStepResDTO
|
||||
*/
|
||||
StoreCertStepResDTO getStepCertInfo(Long storeId);
|
||||
|
||||
/**
|
||||
* 发短信验证码(档口认证)
|
||||
*
|
||||
* @param phoneNumber
|
||||
*/
|
||||
void sendSmsVerificationCode(String phoneNumber);
|
||||
|
||||
/**
|
||||
* 验证短信验证码(档口认证)
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @param code
|
||||
*/
|
||||
void validateSmsVerificationCode(String phoneNumber, String code);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,19 +224,4 @@ public interface IStoreService {
|
|||
*/
|
||||
Integer UpdateSpecialAttr(StoreUpdateSpecialDTO specialDTO);
|
||||
|
||||
/**
|
||||
* 发短信验证码(档口认证)
|
||||
*
|
||||
* @param phoneNumber
|
||||
*/
|
||||
void sendSmsVerificationCode(String phoneNumber);
|
||||
|
||||
/**
|
||||
* 验证短信验证码(档口认证)
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @param code
|
||||
*/
|
||||
void validateSmsVerificationCode(String phoneNumber, String code);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
package com.ruoyi.xkt.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.model.ESystemRole;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.framework.sms.SmsClientWrapper;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.xkt.domain.Store;
|
||||
import com.ruoyi.xkt.domain.StoreCertificate;
|
||||
|
|
@ -48,6 +51,7 @@ public class StoreCertificateServiceImpl implements IStoreCertificateService {
|
|||
final StoreSaleDetailMapper saleDetailMapper;
|
||||
final StoreProductMapper storeProdMapper;
|
||||
final ISysUserService userService;
|
||||
final SmsClientWrapper smsClient;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -159,6 +163,25 @@ public class StoreCertificateServiceImpl implements IStoreCertificateService {
|
|||
return certStepDTO;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@Override
|
||||
public void sendSmsVerificationCode(String phoneNumber) {
|
||||
boolean success = smsClient.sendVerificationCode(CacheConstants.SMS_STORE_AUTH_CAPTCHA_CODE_CD_PHONE_NUM_KEY,
|
||||
CacheConstants.SMS_STORE_AUTH_CAPTCHA_CODE_KEY, phoneNumber, RandomUtil.randomNumbers(6));
|
||||
if (!success) {
|
||||
throw new ServiceException("短信发送失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@Override
|
||||
public void validateSmsVerificationCode(String phoneNumber, String code) {
|
||||
boolean match = smsClient.matchVerificationCode(CacheConstants.SMS_STORE_AUTH_CAPTCHA_CODE_KEY, phoneNumber, code);
|
||||
if (!match) {
|
||||
throw new ServiceException("验证码错误或已过期");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增档口认证文件列表
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ public class StoreServiceImpl implements IStoreService {
|
|||
final StoreCustomerMapper storeCusMapper;
|
||||
final StoreFactoryMapper storeFactoryMapper;
|
||||
final IStoreProductDemandTemplateService storeTemplateService;
|
||||
final SmsClientWrapper smsClient;
|
||||
@Value("${es.indexName}")
|
||||
private String ES_INDEX_NAME;
|
||||
|
||||
|
|
@ -599,25 +598,6 @@ public class StoreServiceImpl implements IStoreService {
|
|||
return this.storeMapper.updateById(store);
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@Override
|
||||
public void sendSmsVerificationCode(String phoneNumber) {
|
||||
boolean success = smsClient.sendVerificationCode(CacheConstants.SMS_STORE_AUTH_CAPTCHA_CODE_CD_PHONE_NUM_KEY,
|
||||
CacheConstants.SMS_STORE_AUTH_CAPTCHA_CODE_KEY, phoneNumber, RandomUtil.randomNumbers(6));
|
||||
if (!success) {
|
||||
throw new ServiceException("短信发送失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
@Override
|
||||
public void validateSmsVerificationCode(String phoneNumber, String code) {
|
||||
boolean match = smsClient.matchVerificationCode(CacheConstants.SMS_STORE_AUTH_CAPTCHA_CODE_KEY, phoneNumber, code);
|
||||
if (!match) {
|
||||
throw new ServiceException("验证码错误或已过期");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 档口首页今日销售额
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue