feat: 用户端邮箱
This commit is contained in:
@@ -161,6 +161,10 @@ public class AliPayController extends AbstractAliPayApiController {
|
||||
String returnUrl = aliPayBean.getDomain() + RETURN_URL;
|
||||
// String notifyUrl = aliPayBean.getDomain() + NOTIFY_URL;
|
||||
String notifyUrl = aliPayBean.getDomain() + PRE_NOTIFY_URL + NOTIFY_URL;
|
||||
if (StrUtil.isNotBlank(aliPayBean.getTestDomain())) {
|
||||
notifyUrl = aliPayBean.getTestDomain() + PRE_NOTIFY_URL + NOTIFY_URL;
|
||||
}
|
||||
|
||||
|
||||
AlipayTradeWapPayModel model = new AlipayTradeWapPayModel();
|
||||
model.setBody(body);
|
||||
|
||||
@@ -98,6 +98,11 @@
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wfc</groupId>
|
||||
<artifactId>wfc-common-mail</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.wfc.user.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.wfc.common.core.constant.Constants;
|
||||
import org.wfc.common.core.constant.GlobalConstants;
|
||||
import org.wfc.common.core.domain.R;
|
||||
import org.wfc.common.core.utils.MessageUtils;
|
||||
import org.wfc.common.core.web.controller.BaseController;
|
||||
import org.wfc.common.mail.config.properties.MailProperties;
|
||||
import org.wfc.common.mail.utils.MailUtils;
|
||||
import org.wfc.common.redis.service.RedisService;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 邮件功能
|
||||
*
|
||||
* @author cyc
|
||||
*/
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/email")
|
||||
public class UEmailController extends BaseController {
|
||||
|
||||
private final MailProperties mailProperties;
|
||||
private final RedisService redisService;
|
||||
|
||||
/**
|
||||
* 邮箱验证码
|
||||
*
|
||||
* @param email 邮箱
|
||||
*/
|
||||
@GetMapping("/code")
|
||||
public R<Void> emailCode(@NotBlank(message = "{user.email.not.blank}") String email) {
|
||||
if (!mailProperties.getEnabled()) {
|
||||
return R.fail(MessageUtils.message("user.email.not.enable"));
|
||||
}
|
||||
String key = GlobalConstants.CAPTCHA_CODE_KEY + email;
|
||||
String code = RandomUtil.randomNumbers(4);
|
||||
redisService.setCacheObject(key, code, Constants.MAIL_CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
|
||||
try {
|
||||
MailUtils.sendText(email, "Registration verification code", "Your verification code is: " + code + ", The validity period is " + Constants.MAIL_CAPTCHA_EXPIRATION + " minutes, please fill in as soon as possible.");
|
||||
} catch (Exception e) {
|
||||
log.error("验证码短信发送异常 => {}", e.getMessage());
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -97,6 +97,7 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
UAccount account = accountService.getOne(Wrappers.<UAccount>lambdaQuery().eq(UAccount::getUserId, order.getUserId()), false);
|
||||
Long accountId = null;
|
||||
boolean isValid = false;
|
||||
BigDecimal oldBalance = BigDecimal.ZERO;
|
||||
if (ObjectUtil.isNull(account)) {
|
||||
account = new UAccount();
|
||||
account.setUserId(order.getUserId());
|
||||
@@ -104,6 +105,7 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
account.setBalanceUsed(BigDecimal.ZERO);
|
||||
} else {
|
||||
accountId = account.getId();
|
||||
oldBalance = account.getBalance();
|
||||
isValid = AccountUtil.isValid(account, new Date());
|
||||
}
|
||||
if (OrderTypeEnum.PACKAGE.getCode().equals(order.getType())) {
|
||||
@@ -126,7 +128,7 @@ public class UOrderServiceImpl extends ServiceImpl<UOrderMapper, UOrder> impleme
|
||||
if (StrUtil.isNotBlank(client.getSiteId())) {
|
||||
wifiApi.authClient(client.getSiteId(), client.getClientMac());
|
||||
// 套餐生效已授权时,调reconnect重连接口,以便截取时间
|
||||
if (isValid) {
|
||||
if (isValid && !(OrderTypeEnum.RECHARGE.getCode().equals(order.getType()) && oldBalance.compareTo(BigDecimal.ZERO) > 0)) {
|
||||
wifiApi.reconnectClient(client.getSiteId(), client.getClientMac());
|
||||
}
|
||||
// 带宽限速
|
||||
|
||||
Reference in New Issue
Block a user