Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -8,14 +8,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.sqx.common.utils.DateUtils;
|
import com.sqx.common.utils.DateUtils;
|
||||||
import com.sqx.modules.app.entity.InviteAchievement;
|
import com.sqx.modules.app.entity.*;
|
||||||
import com.sqx.modules.app.entity.UserEntity;
|
import com.sqx.modules.app.service.*;
|
||||||
import com.sqx.modules.app.entity.UserMoney;
|
|
||||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
|
||||||
import com.sqx.modules.app.service.InviteAchievementService;
|
|
||||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
|
||||||
import com.sqx.modules.app.service.UserMoneyService;
|
|
||||||
import com.sqx.modules.app.service.UserService;
|
|
||||||
import com.sqx.modules.common.service.CommonInfoService;
|
import com.sqx.modules.common.service.CommonInfoService;
|
||||||
import com.sqx.modules.complet.entity.CompletAward;
|
import com.sqx.modules.complet.entity.CompletAward;
|
||||||
import com.sqx.modules.complet.service.CompletAwardService;
|
import com.sqx.modules.complet.service.CompletAwardService;
|
||||||
@@ -47,6 +41,8 @@ import javax.annotation.Resource;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -83,13 +79,15 @@ public class TempOrdersTask {
|
|||||||
private final InviteAchievementService inviteAchievementService;
|
private final InviteAchievementService inviteAchievementService;
|
||||||
private final CourseService courseService;
|
private final CourseService courseService;
|
||||||
private final SysUserMoneyDetailsService sysUserMoneyDetailsService;
|
private final SysUserMoneyDetailsService sysUserMoneyDetailsService;
|
||||||
|
private final UserInfoService userInfoService;
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(getClass());
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
public TempOrdersTask(InviteAchievementService inviteAchievementService, CourseService courseService, SysUserMoneyDetailsService sysUserMoneyDetailsService) {
|
public TempOrdersTask(InviteAchievementService inviteAchievementService, CourseService courseService, SysUserMoneyDetailsService sysUserMoneyDetailsService, UserInfoService userInfoService) {
|
||||||
this.inviteAchievementService = inviteAchievementService;
|
this.inviteAchievementService = inviteAchievementService;
|
||||||
this.courseService = courseService;
|
this.courseService = courseService;
|
||||||
this.sysUserMoneyDetailsService = sysUserMoneyDetailsService;
|
this.sysUserMoneyDetailsService = sysUserMoneyDetailsService;
|
||||||
|
this.userInfoService = userInfoService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 0/10 * * * ? ")
|
@Scheduled(cron = "0 0/10 * * * ? ")
|
||||||
@@ -255,11 +253,17 @@ public class TempOrdersTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = inviteAchievementService.count(
|
// int count = inviteAchievementService.count(
|
||||||
new LambdaQueryWrapper<InviteAchievement>()
|
// new LambdaQueryWrapper<InviteAchievement>()
|
||||||
.eq(InviteAchievement::getUserId, sourceUser.getUserId())
|
// .eq(InviteAchievement::getUserId, sourceUser.getUserId())
|
||||||
.eq(InviteAchievement::getState, 1));
|
// .eq(InviteAchievement::getState, 1));
|
||||||
logger.info("邀请人员: {}", count);
|
Set<Long> byUserIdList = inviteAchievementService.list(new LambdaQueryWrapper<InviteAchievement>().eq(InviteAchievement::getUserId, sourceUser.getUserId())
|
||||||
|
.eq(InviteAchievement::getState, 1).select(InviteAchievement::getTargetUserId)).stream().map(InviteAchievement::getTargetUserId).collect(Collectors.toSet());
|
||||||
|
int count = 0;
|
||||||
|
if (!byUserIdList.isEmpty()) {
|
||||||
|
count = userInfoService.count(new LambdaQueryWrapper<UserInfo>().in(UserInfo::getUserId, byUserIdList).isNotNull(UserInfo::getAccountNo));
|
||||||
|
}
|
||||||
|
logger.info("邀请达标人员: {}", count);
|
||||||
//count 邀请的已达标人数
|
//count 邀请的已达标人数
|
||||||
for (CompletAward completAward : completAwardService.list(new QueryWrapper<CompletAward>().eq("invite_count", count).eq("status", 1))) {
|
for (CompletAward completAward : completAwardService.list(new QueryWrapper<CompletAward>().eq("invite_count", count).eq("status", 1))) {
|
||||||
QueryWrapper<UserMoneyDetails> moneyDetailsQuery = new QueryWrapper<>();
|
QueryWrapper<UserMoneyDetails> moneyDetailsQuery = new QueryWrapper<>();
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import com.sqx.modules.pay.wuyou.BaseResp;
|
|||||||
import com.sqx.modules.pay.wuyou.Encrypt;
|
import com.sqx.modules.pay.wuyou.Encrypt;
|
||||||
import com.sqx.modules.pay.wuyou.NotifyDto;
|
import com.sqx.modules.pay.wuyou.NotifyDto;
|
||||||
import com.sqx.modules.pay.wuyou.WuyouPay;
|
import com.sqx.modules.pay.wuyou.WuyouPay;
|
||||||
|
import com.sqx.modules.redisService.RedisService;
|
||||||
import com.sqx.modules.sys.entity.SysUserEntity;
|
import com.sqx.modules.sys.entity.SysUserEntity;
|
||||||
import com.sqx.modules.sys.service.SysUserService;
|
import com.sqx.modules.sys.service.SysUserService;
|
||||||
import com.sqx.modules.utils.AliPayOrderUtil;
|
import com.sqx.modules.utils.AliPayOrderUtil;
|
||||||
@@ -74,12 +75,14 @@ public class WuyouController {
|
|||||||
private final CashOutDao cashOutDao;
|
private final CashOutDao cashOutDao;
|
||||||
private final WuyouPay wuyouPay;
|
private final WuyouPay wuyouPay;
|
||||||
private final TempOrdersTask ordersTask;
|
private final TempOrdersTask ordersTask;
|
||||||
|
private final UserService userService;
|
||||||
|
private final RedisService redisService;
|
||||||
@Resource
|
@Resource
|
||||||
private WuyouCallbackService wuyouCallbackService;
|
private WuyouCallbackService wuyouCallbackService;
|
||||||
|
|
||||||
WuyouController(OrdersService ordersService, PayDetailsDao payDetailsDao, CashOutDao cashOutDao, UserMoneyService userMoneyService,
|
WuyouController(OrdersService ordersService, PayDetailsDao payDetailsDao, CashOutDao cashOutDao, UserMoneyService userMoneyService,
|
||||||
UserMoneyDetailsService userMoneyDetailsService, TempOrdersTask ordersTask,
|
UserMoneyDetailsService userMoneyDetailsService, TempOrdersTask ordersTask,
|
||||||
WuyouPay wuyouPay) {
|
WuyouPay wuyouPay, UserService userService, RedisService redisService) {
|
||||||
this.ordersService = ordersService;
|
this.ordersService = ordersService;
|
||||||
this.payDetailsDao = payDetailsDao;
|
this.payDetailsDao = payDetailsDao;
|
||||||
this.cashOutDao = cashOutDao;
|
this.cashOutDao = cashOutDao;
|
||||||
@@ -87,6 +90,8 @@ public class WuyouController {
|
|||||||
this.userMoneyDetailsService = userMoneyDetailsService;
|
this.userMoneyDetailsService = userMoneyDetailsService;
|
||||||
this.wuyouPay = wuyouPay;
|
this.wuyouPay = wuyouPay;
|
||||||
this.ordersTask = ordersTask;
|
this.ordersTask = ordersTask;
|
||||||
|
this.userService = userService;
|
||||||
|
this.redisService = redisService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Debounce(interval = 1000, value = "#orderId")
|
@Debounce(interval = 1000, value = "#orderId")
|
||||||
@@ -101,6 +106,9 @@ public class WuyouController {
|
|||||||
if (order.getStatus() != 0) {
|
if (order.getStatus() != 0) {
|
||||||
return Result.error("订单已支付");
|
return Result.error("订单已支付");
|
||||||
}
|
}
|
||||||
|
if (redisService.setCreateOrderFlagAndCheckLimit(order.getUserId(), orderId)) {
|
||||||
|
userService.addBlackUser(order.getUserId(), "一分钟频繁下单超12次");
|
||||||
|
}
|
||||||
|
|
||||||
PayDetails payDetails = payDetailsDao.selectByOrderId(order.getOrdersNo());
|
PayDetails payDetails = payDetailsDao.selectByOrderId(order.getOrdersNo());
|
||||||
if (payDetails == null) {
|
if (payDetails == null) {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class WuyouCallbackServiceImpl implements WuyouCallbackService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public int executeExtractCallback(CashOut cashOut, int status, String reason) {
|
public int executeExtractCallback(CashOut cashOut, int status, String reason) {
|
||||||
if (StringUtils.isNotBlank(reason) && reason.contains("已驳回")) {
|
if (StringUtils.isNotBlank(reason) && reason.contains("已驳回")) {
|
||||||
reason = "提现失败,请检查支付宝账号与收款人姓名后重试。";
|
reason = "提现失败,请检查收款账号与收款人姓名后重试。";
|
||||||
}
|
}
|
||||||
BigDecimal money = new BigDecimal(cashOut.getMoney());
|
BigDecimal money = new BigDecimal(cashOut.getMoney());
|
||||||
if (status == 1) {
|
if (status == 1) {
|
||||||
|
|||||||
@@ -30,4 +30,6 @@ public interface RedisService {
|
|||||||
void setCanCashFlag(Long userId, Long id);
|
void setCanCashFlag(Long userId, Long id);
|
||||||
|
|
||||||
boolean isCanCash(Long userId);
|
boolean isCanCash(Long userId);
|
||||||
|
|
||||||
|
boolean setCreateOrderFlagAndCheckLimit(Long userId, Long orderId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,4 +342,13 @@ public class RedisServiceImpl implements RedisService {
|
|||||||
String s = redisUtils.get(key);
|
String s = redisUtils.get(key);
|
||||||
return StrUtil.isNotBlank(s);
|
return StrUtil.isNotBlank(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setCreateOrderFlagAndCheckLimit(Long userId, Long orderId) {
|
||||||
|
String key = "createOrder:" + userId;
|
||||||
|
redisTemplate.opsForSet().add(key, orderId.toString());
|
||||||
|
redisUtils.expire(key, 60);
|
||||||
|
Set<String> members = redisTemplate.opsForSet().members(key);
|
||||||
|
return members != null && members.size() > 12;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,21 +9,21 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
@Service
|
//@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class NsqConfig {
|
public class NsqConfig {
|
||||||
// /**
|
/**
|
||||||
// * 端口号
|
* 端口号
|
||||||
// */
|
*/
|
||||||
// @Value("${nsq.port}")
|
@Value("${nsq.port.consumer}")
|
||||||
// private int port;
|
private int port;
|
||||||
//
|
|
||||||
// @Value("${nsq.address}")
|
@Value("${nsq.address}")
|
||||||
// private String address;
|
private String address;
|
||||||
//
|
|
||||||
// @PostConstruct
|
// @PostConstruct
|
||||||
// public void startNSQChannel() {
|
public void startNSQChannel() {
|
||||||
// new NSQConsumers(address, port, "test", "ch1", new Print2MessageHandlerAdapter());
|
new NSQConsumers(address, port, "test", "ch1", new Print2MessageHandlerAdapter());
|
||||||
// new NSQConsumers(address, port, "test", "ch2", new PrintMessageHandlerAdapter());
|
new NSQConsumers(address, port, "test", "ch2", new PrintMessageHandlerAdapter());
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
53
src/main/java/com/sqx/nsqChannel/config/NsqProduce.java
Normal file
53
src/main/java/com/sqx/nsqChannel/config/NsqProduce.java
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
package com.sqx.nsqChannel.config;
|
||||||
|
|
||||||
|
import com.github.brainlag.nsq.NSQProducer;
|
||||||
|
import com.github.brainlag.nsq.exceptions.NSQException;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
//@Component
|
||||||
|
public class NsqProduce {
|
||||||
|
@Value("${nsq.port.produce}")
|
||||||
|
private int port;
|
||||||
|
|
||||||
|
@Value("${nsq.address}")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
|
||||||
|
private NSQProducer producer;
|
||||||
|
private static boolean is_start = false;
|
||||||
|
private static final byte[] LOCK = new byte[0];
|
||||||
|
|
||||||
|
public NsqProduce() {
|
||||||
|
producer = new NSQProducer();
|
||||||
|
producer.addAddress(address, port).start();
|
||||||
|
is_start = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NSQProducer getProducer() {
|
||||||
|
if (!is_start) {
|
||||||
|
log.info("========================NSQProduce no start====================");
|
||||||
|
}
|
||||||
|
if (producer == null) {
|
||||||
|
synchronized (LOCK) {
|
||||||
|
if (producer == null) {
|
||||||
|
producer = new NSQProducer();
|
||||||
|
producer.addAddress(address, port).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return producer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMsgToTestTopic(String topic,String msg) {
|
||||||
|
try {
|
||||||
|
this.getProducer().produce(topic, msg.getBytes());
|
||||||
|
} catch (NSQException | TimeoutException e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
4
src/main/java/com/sqx/nsqChannel/enums/TopicEnums.java
Normal file
4
src/main/java/com/sqx/nsqChannel/enums/TopicEnums.java
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package com.sqx.nsqChannel.enums;
|
||||||
|
|
||||||
|
public enum TopicEnums {
|
||||||
|
}
|
||||||
@@ -10,7 +10,9 @@ server:
|
|||||||
|
|
||||||
nsq:
|
nsq:
|
||||||
address: 47.122.26.160
|
address: 47.122.26.160
|
||||||
port: 4161
|
port:
|
||||||
|
produce: 4150
|
||||||
|
consumer: 4161
|
||||||
|
|
||||||
# 数据源的一些配置
|
# 数据源的一些配置
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ server:
|
|||||||
|
|
||||||
nsq:
|
nsq:
|
||||||
address: 47.122.26.160
|
address: 47.122.26.160
|
||||||
port: 4161
|
port:
|
||||||
|
produce: 4150
|
||||||
|
consumer: 4161
|
||||||
|
|
||||||
# 数据源的一些配置
|
# 数据源的一些配置
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ server:
|
|||||||
|
|
||||||
nsq:
|
nsq:
|
||||||
address: 127.0.0.1
|
address: 127.0.0.1
|
||||||
port: 4161
|
port:
|
||||||
|
produce: 4150
|
||||||
|
consumer: 4161
|
||||||
|
|
||||||
# 数据源的一些配置
|
# 数据源的一些配置
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
|||||||
Reference in New Issue
Block a user