pull/1121/head
parent
ac3e79e819
commit
c31baa48d3
|
|
@ -6,6 +6,7 @@ import cn.hutool.core.lang.Assert;
|
|||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
|
|
@ -95,7 +96,8 @@ public class StoreUserController extends BaseController {
|
|||
@ApiOperation(value = "发送子账号创建短信验证码 - 档口")
|
||||
@PostMapping("/sendSmsVerificationCode")
|
||||
public R sendSmsVerificationCode(@Validated @RequestBody PhoneNumberVO vo) {
|
||||
loginService.sendSmsVerificationCode(vo.getPhoneNumber(), false, null, null);
|
||||
loginService.sendSmsVerificationCode(vo.getPhoneNumber(),
|
||||
CacheConstants.SMS_REGISTER_CAPTCHA_CODE_CD_PHONE_NUM_KEY, false, null, null);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,8 @@ public class SysLoginController {
|
|||
if (!captchaPass) {
|
||||
return R.fail("验证失败");
|
||||
}
|
||||
loginService.sendSmsVerificationCode(vo.getPhoneNumber(), false, null, null);
|
||||
loginService.sendSmsVerificationCode(vo.getPhoneNumber(),
|
||||
CacheConstants.SMS_LOGIN_CAPTCHA_CODE_CD_PHONE_NUM_KEY, false, null, null);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.web.controller.system;
|
||||
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
|
|
@ -91,7 +92,7 @@ public class SysRegisterController extends BaseController {
|
|||
return R.ok(!unique);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "发送登录短信验证码")
|
||||
@ApiOperation(value = "发送注册短信验证码")
|
||||
@PostMapping("/sendSmsVerificationCode")
|
||||
public R sendSmsVerificationCode(@Validated @RequestBody LoginSmsReqVO vo) {
|
||||
boolean captchaPass = aliAuthManager.validate(vo.getLot_number(), vo.getCaptcha_output(),
|
||||
|
|
@ -99,7 +100,8 @@ public class SysRegisterController extends BaseController {
|
|||
if (!captchaPass) {
|
||||
return R.fail("验证失败");
|
||||
}
|
||||
loginService.sendSmsVerificationCode(vo.getPhoneNumber(), false, null, null);
|
||||
loginService.sendSmsVerificationCode(vo.getPhoneNumber(),
|
||||
CacheConstants.SMS_REGISTER_CAPTCHA_CODE_CD_PHONE_NUM_KEY, false, null, null);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ public class CacheConstants {
|
|||
/**
|
||||
* 短信验证码CD中号码
|
||||
*/
|
||||
public static final String SMS_CAPTCHA_CODE_CD_PHONE_NUM_KEY = "sms_captcha_code_cd_phone_nums:";
|
||||
public static final String SMS_ASSET_CAPTCHA_CODE_CD_PHONE_NUM_KEY = "sms_asset_captcha_code_cd_phone_nums:";
|
||||
public static final String SMS_LOGIN_CAPTCHA_CODE_CD_PHONE_NUM_KEY = "sms_login_captcha_code_cd_phone_nums:";
|
||||
public static final String SMS_REGISTER_CAPTCHA_CODE_CD_PHONE_NUM_KEY = "sms_register_captcha_code_cd_phone_nums:";
|
||||
|
||||
/**
|
||||
* 扫码登录浏览器ID
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.ruoyi.framework.sms;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.framework.sms.ali.AliSmsServer;
|
||||
|
|
@ -52,20 +51,21 @@ public class SmsClientWrapper {
|
|||
/**
|
||||
* 发送短信验证码
|
||||
*
|
||||
* @param cdCacheKeyPrefix
|
||||
* @param cacheKeyPrefix
|
||||
* @param phoneNumber
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public boolean sendVerificationCode(String cacheKeyPrefix, String phoneNumber, String code) {
|
||||
String checkKey = CacheConstants.SMS_CAPTCHA_CODE_CD_PHONE_NUM_KEY + phoneNumber;
|
||||
if (redisCache.exists(checkKey)) {
|
||||
public boolean sendVerificationCode(String cdCacheKeyPrefix, String cacheKeyPrefix, String phoneNumber, String code) {
|
||||
String cdCheckKey = cdCacheKeyPrefix + phoneNumber;
|
||||
if (redisCache.exists(cdCheckKey)) {
|
||||
throw new ServiceException("验证码发送间隔需大于60S");
|
||||
}
|
||||
boolean success = sendSms(verificationCodeSignName, phoneNumber, verificationCodeTemplateCode,
|
||||
"{\"code\":\"" + code + "\"}");
|
||||
if (success) {
|
||||
redisCache.setCacheObject(checkKey, "1", 60, TimeUnit.SECONDS);
|
||||
redisCache.setCacheObject(cdCheckKey, "1", 60, TimeUnit.SECONDS);
|
||||
redisCache.setCacheObject(cacheKeyPrefix + phoneNumber, code, 300, TimeUnit.SECONDS);
|
||||
}
|
||||
return success;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@ import com.ruoyi.common.core.domain.model.UserInfo;
|
|||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.enums.UserStatus;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.exception.user.*;
|
||||
import com.ruoyi.common.exception.user.BlackListException;
|
||||
import com.ruoyi.common.exception.user.CaptchaException;
|
||||
import com.ruoyi.common.exception.user.CaptchaExpireException;
|
||||
import com.ruoyi.common.exception.user.UserNotExistsException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
|
@ -230,17 +233,19 @@ public class SysLoginService {
|
|||
/**
|
||||
* 发送登录/注册短信验证码
|
||||
*
|
||||
* @param phoneNumber 电话号码
|
||||
* @param checkPicCode 校验图形验证码
|
||||
* @param code 图形验证码code
|
||||
* @param uuid 图形验证码uuid
|
||||
* @param phoneNumber 电话号码
|
||||
* @param cdCacheKeyPrefix 发送间隔缓存前缀
|
||||
* @param checkPicCode 校验图形验证码
|
||||
* @param code 图形验证码code
|
||||
* @param uuid 图形验证码uuid
|
||||
*/
|
||||
public void sendSmsVerificationCode(String phoneNumber, boolean checkPicCode, String code, String uuid) {
|
||||
public void sendSmsVerificationCode(String phoneNumber, String cdCacheKeyPrefix, boolean checkPicCode, String code,
|
||||
String uuid) {
|
||||
if (checkPicCode) {
|
||||
validateCaptcha(null, code, uuid);
|
||||
}
|
||||
boolean success = smsClient.sendVerificationCode(CacheConstants.SMS_LOGIN_CAPTCHA_CODE_KEY, phoneNumber,
|
||||
RandomUtil.randomNumbers(6));
|
||||
boolean success = smsClient.sendVerificationCode(cdCacheKeyPrefix, CacheConstants.SMS_LOGIN_CAPTCHA_CODE_KEY,
|
||||
phoneNumber, RandomUtil.randomNumbers(6));
|
||||
if (!success) {
|
||||
throw new ServiceException("短信发送失败");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,8 +332,8 @@ public class AssetServiceImpl implements IAssetService {
|
|||
|
||||
@Override
|
||||
public void sendSmsVerificationCode(String phoneNumber) {
|
||||
boolean success = smsClient.sendVerificationCode(CacheConstants.SMS_ASSET_CAPTCHA_CODE_KEY, phoneNumber,
|
||||
RandomUtil.randomNumbers(6));
|
||||
boolean success = smsClient.sendVerificationCode(CacheConstants.SMS_ASSET_CAPTCHA_CODE_CD_PHONE_NUM_KEY,
|
||||
CacheConstants.SMS_ASSET_CAPTCHA_CODE_KEY, phoneNumber, RandomUtil.randomNumbers(6));
|
||||
if (!success) {
|
||||
throw new ServiceException("短信发送失败");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1212,6 +1212,15 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
|
|||
orderDetail.setRefundReasonCode(afterSaleDTO.getRefundReasonCode());
|
||||
orderDetail.setVersion(0L);
|
||||
orderDetail.setDelFlag(Constants.UNDELETED);
|
||||
if (EOrderStatus.SHIPPED.getValue().equals(originOrderDetail.getDetailStatus())
|
||||
|| EOrderStatus.COMPLETED.getValue().equals(originOrderDetail.getDetailStatus())) {
|
||||
//已发货不退运费
|
||||
orderDetail.setTotalAmount(NumberUtil.sub(originOrderDetail.getTotalAmount(),
|
||||
originOrderDetail.getExpressFee()));
|
||||
orderDetail.setRealTotalAmount(NumberUtil.sub(originOrderDetail.getRealTotalAmount(),
|
||||
originOrderDetail.getExpressFee()));
|
||||
orderDetail.setExpressFee(BigDecimal.ZERO);
|
||||
}
|
||||
//计算订单费用
|
||||
orderGoodsQuantity = orderGoodsQuantity + orderDetail.getGoodsQuantity();
|
||||
orderGoodsAmount = NumberUtil.add(orderGoodsAmount, orderDetail.getGoodsAmount());
|
||||
|
|
@ -1381,7 +1390,7 @@ public class StoreOrderServiceImpl implements IStoreOrderService {
|
|||
throw new ServiceException(CharSequenceUtil.format("订单明细[{}]不存在或与订单[{}]不匹配",
|
||||
storeOrderDetailId, storeOrderId));
|
||||
}
|
||||
if (!EOrderStatus.COMPLETED.getValue().equals(orderDetail.getDetailStatus())
|
||||
if (!EOrderStatus.AFTER_SALE_COMPLETED.getValue().equals(orderDetail.getDetailStatus())
|
||||
|| !EPayStatus.PAYING.getValue().equals(orderDetail.getPayStatus())) {
|
||||
throw new ServiceException(CharSequenceUtil.format("订单明细[{}]状态异常", storeOrderDetailId));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue