Merge branch 'test' into dev
This commit is contained in:
commit
5bb02d0909
|
|
@ -1,6 +1,7 @@
|
|||
package com.sqx.common.aspect;
|
||||
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.common.utils.SpelUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
|
|
@ -76,7 +77,7 @@ public class DebounceAspect {
|
|||
return joinPoint.proceed();
|
||||
}
|
||||
// 在防抖间隔内,不执行目标方法,直接返回
|
||||
return null;
|
||||
return Result.error("请求频繁,请重试");
|
||||
}
|
||||
|
||||
private Object debounceForSpecificValue(ProceedingJoinPoint joinPoint, String methodSignature, long interval, TimeUnit timeUnit, Object targetValue) throws Throwable {
|
||||
|
|
@ -89,7 +90,7 @@ public class DebounceAspect {
|
|||
return joinPoint.proceed();
|
||||
}
|
||||
// 在防抖间隔内,不执行目标方法,直接返回
|
||||
return null;
|
||||
return Result.error("请求频繁,请重试");
|
||||
}
|
||||
|
||||
public void cleanExpiredRecords() {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSON;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.dto.LoginDTO;
|
||||
import com.sqx.modules.app.dto.RegisterDTO;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.IAppleService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
|
|
@ -19,6 +21,7 @@ import io.swagger.annotations.ApiOperation;
|
|||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import weixin.popular.api.SnsAPI;
|
||||
import weixin.popular.bean.sns.SnsToken;
|
||||
|
|
@ -142,7 +145,6 @@ public class AppLoginController {
|
|||
|
||||
|
||||
@RequestMapping(value = "/registerCode", method = RequestMethod.POST)
|
||||
@ApiOperation("app或h5注册或登录")
|
||||
@ResponseBody
|
||||
@Debounce(interval = 2500, value = "#phone")
|
||||
public Result registerCode(@RequestParam String phone,String msg,String platform,Integer sysPhone,
|
||||
|
|
@ -150,6 +152,21 @@ public class AppLoginController {
|
|||
return userService.registerCode(phone,msg,platform,sysPhone,password,inviterCode,wxId,qdCode);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ResponseBody
|
||||
@Debounce(interval = 2500, value = "#phone")
|
||||
public Result login(@RequestBody @Validated LoginDTO loginDTO) {
|
||||
return userService.login(loginDTO);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/register")
|
||||
@ApiOperation("app或h5注册或登录")
|
||||
@ResponseBody
|
||||
@Debounce(interval = 2500, value = "#phone")
|
||||
public Result register(@RequestBody RegisterDTO registerDTO) {
|
||||
return userService.register(registerDTO);
|
||||
}
|
||||
|
||||
@PostMapping("/bindWxOpenPhone")
|
||||
@ApiOperation("微信公众号绑定手机号")
|
||||
public Result bindWxOpenPhone(Long userId,String phone,String msg){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.sqx.modules.app.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@Data
|
||||
public class LoginDTO {
|
||||
@NotEmpty
|
||||
private String phone;
|
||||
@NotEmpty
|
||||
private String password;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.sqx.modules.app.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@Data
|
||||
public class RegisterDTO {
|
||||
@NotEmpty
|
||||
private String phone;
|
||||
@NotEmpty
|
||||
private String password;
|
||||
@NotEmpty
|
||||
private String msg;
|
||||
@NotEmpty
|
||||
private String platform;
|
||||
private String inviterCode;
|
||||
private String qdCode;
|
||||
private Integer sysPhone;
|
||||
}
|
||||
|
|
@ -207,4 +207,6 @@ public class UserEntity implements Serializable {
|
|||
@TableField(exist = false)
|
||||
private Integer vipType;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import com.sqx.common.utils.PageUtils;
|
|||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.dto.AuthCertNoDTO;
|
||||
import com.sqx.modules.app.dto.AuthDTO;
|
||||
import com.sqx.modules.app.dto.LoginDTO;
|
||||
import com.sqx.modules.app.dto.RegisterDTO;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -158,8 +160,6 @@ public interface UserService extends IService<UserEntity> {
|
|||
*
|
||||
* @param phone 手机号
|
||||
* @param msg 验证按
|
||||
* @param pwd 密码
|
||||
* @param platform 来源 app h5
|
||||
* @return
|
||||
*/
|
||||
Result registerCode(String phone, String msg, String platform, Integer sysPhone,String password,
|
||||
|
|
@ -174,11 +174,8 @@ public interface UserService extends IService<UserEntity> {
|
|||
/**
|
||||
* app或h5登录
|
||||
*
|
||||
* @param phone 手机号
|
||||
* @param pwd 密码
|
||||
* @return
|
||||
*/
|
||||
Result login(String phone, String pwd);
|
||||
Result login(LoginDTO loginDTO);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -235,4 +232,6 @@ public interface UserService extends IService<UserEntity> {
|
|||
void addBlackUser(Long userId,String behavior);
|
||||
|
||||
UserEntity queryByInvitationCodeOrUserId(Long inviterUserId, String invitationCode);
|
||||
|
||||
Result register(RegisterDTO registerDTO);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,7 @@ import com.sqx.common.utils.Result;
|
|||
import com.sqx.modules.app.dao.MsgDao;
|
||||
import com.sqx.modules.app.dao.UserDao;
|
||||
import com.sqx.modules.app.dao.UserVipDao;
|
||||
import com.sqx.modules.app.dto.AuthCertNoDTO;
|
||||
import com.sqx.modules.app.dto.AuthDTO;
|
||||
import com.sqx.modules.app.dto.AuthRespDTO;
|
||||
import com.sqx.modules.app.dto.*;
|
||||
import com.sqx.modules.app.entity.*;
|
||||
import com.sqx.modules.app.mapper.TbUserBlacklistMapper;
|
||||
import com.sqx.modules.app.response.CourseOrderResponse;
|
||||
|
|
@ -885,6 +883,98 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
return getResult(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result login(LoginDTO loginDTO) {
|
||||
//校验手机号是否存在
|
||||
UserEntity userInfo = queryByPhone(loginDTO.getPhone());
|
||||
if (userInfo == null) {
|
||||
return Result.error("未注册, 请先注册");
|
||||
}
|
||||
|
||||
//密码登录
|
||||
if (StringUtils.isEmpty(userInfo.getPassword())) {
|
||||
return Result.error("当前账号未绑定密码,请前往忘记密码中进行重置!");
|
||||
}
|
||||
|
||||
if (!userInfo.getPassword().equals(DigestUtils.sha256Hex(loginDTO.getPassword()))) {
|
||||
return Result.error("账号或密码不正确!");
|
||||
}
|
||||
|
||||
if (userInfo.getStatus().equals(2)) {
|
||||
return Result.error("账号已被禁用,请联系客服处理!");
|
||||
}
|
||||
|
||||
// 实名认证信息
|
||||
UserInfo idCardAuth = userInfoService.getByUserId(userInfo.getUserId());
|
||||
if (idCardAuth != null && StrUtil.isNotBlank(idCardAuth.getCertNo())) {
|
||||
TbUserBlacklist blacklist = tbUserBlacklistMapper.selectOne(Wrappers.<TbUserBlacklist>lambdaQuery().eq(TbUserBlacklist::getIdCardNo, idCardAuth.getCertNo()));
|
||||
// 如果被拉黑了,不要提示的那么直白,需要换个说法
|
||||
if (blacklist != null) {
|
||||
return Result.error("系统正在维护中,请稍后再试!");
|
||||
}
|
||||
}
|
||||
userInfo.setUpdateTime(DateUtil.date().toString());
|
||||
baseMapper.updateById(userInfo);
|
||||
return getResult(userInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result register(RegisterDTO registerDTO) {
|
||||
//校验手机号是否存在
|
||||
UserEntity userInfo = queryByPhone(registerDTO.getPhone());
|
||||
if (userInfo != null) {
|
||||
return Result.error("此号码已注册");
|
||||
}
|
||||
|
||||
Msg msg1 = msgDao.findByPhoneAndCode(registerDTO.getPhone(), registerDTO.getMsg());
|
||||
if (msg1 == null) {
|
||||
return Result.error("验证码不正确!");
|
||||
}
|
||||
|
||||
userInfo = new UserEntity();
|
||||
UserEntity userEntity;
|
||||
if (StringUtils.isNotEmpty(registerDTO.getInviterCode())) {
|
||||
userEntity = queryByInvitationCode(registerDTO.getInviterCode());
|
||||
if (userEntity == null) {
|
||||
return Result.error("邀请码不正确!");
|
||||
}
|
||||
} else {
|
||||
userInfo.setInviterCode(commonInfoService.findOne(88).getValue());
|
||||
userEntity = queryByInvitationCodeOrUserId(userInfo.getInviterUserId(), userInfo.getInviterCode());
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(registerDTO.getQdCode())) {
|
||||
registerDTO.setQdCode(userEntity.getQdCode());
|
||||
} else {
|
||||
SysUserEntity sysUserEntity = sysUserService.selectSysUserByQdCode(registerDTO.getQdCode());
|
||||
if (sysUserEntity == null) {
|
||||
return Result.error("请使用正确的渠道码!");
|
||||
}
|
||||
}
|
||||
userInfo.setQdCode(registerDTO.getQdCode());
|
||||
userInfo.setPhone(registerDTO.getPhone());
|
||||
userInfo.setUserName(registerDTO.getPhone().replaceAll("(\\d{3})\\d*([0-9a-zA-Z]{4})", "$1****$2"));
|
||||
userInfo.setPlatform(registerDTO.getPlatform());
|
||||
userInfo.setCreateTime(DateUtil.date().toString());
|
||||
userInfo.setSysPhone(registerDTO.getSysPhone());
|
||||
userInfo.setPassword(DigestUtils.sha256Hex(registerDTO.getPassword()));
|
||||
userInfo.setStatus(1);
|
||||
userInfo.setUpdateTime(DateUtil.date().toString());
|
||||
userInfo.setRate(new BigDecimal(commonInfoService.findOne(420).getValue()));
|
||||
userInfo.setTwoRate(new BigDecimal(commonInfoService.findOne(421).getValue()));
|
||||
Long snowFlakeId = InvitationCodeUtil.getSnowFlakeId();
|
||||
userInfo.setUserId(snowFlakeId);
|
||||
baseMapper.insert(userInfo);
|
||||
userInfo.setInvitationCode(InvitationCodeUtil.toSerialCode(userInfo.getUserId()));
|
||||
baseMapper.updateById(userInfo);
|
||||
|
||||
msgDao.deleteById(msg1.getId());
|
||||
if (userEntity != null) {
|
||||
inviteService.saveBody(userInfo.getUserId(), userEntity);
|
||||
}
|
||||
return getResult(userInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result registerCode(String phone, String msg, String platform, Integer sysPhone, String password,
|
||||
String inviterCode, String wxId, String qdCode) {
|
||||
|
|
@ -1045,25 +1135,6 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Result login(String phone, String pwd) {
|
||||
UserEntity userEntity = queryByPhone(phone);
|
||||
if (userEntity == null) {
|
||||
return Result.error("手机号未注册!");
|
||||
}
|
||||
if (!userEntity.getPassword().equals(DigestUtils.sha256Hex(pwd))) {
|
||||
return Result.error("密码不正确!");
|
||||
}
|
||||
if (userEntity.getStatus().equals(2)) {
|
||||
return Result.error("账号已被禁用,请联系客服处理!");
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
userEntity.setUpdateTime(sdf.format(new Date()));
|
||||
baseMapper.updateById(userEntity);
|
||||
return getResult(userEntity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Result getResult(UserEntity user) {
|
||||
//生成token
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ public interface CourseCollectDao extends BaseMapper<CourseCollect> {
|
|||
|
||||
|
||||
List<Course> selectClassify1In3(@Param("userId") Long userId);
|
||||
List<Course> selectClassify1In2(@Param("userId") Long userId);
|
||||
List<Course> selectClassify1ByUserId(@Param("userId") Long userId);
|
||||
List<Course> selectClassify2(@Param("userId") Long userId);
|
||||
List<Course> selectClassify3ByUserId(@Param("userId") Long userId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||
try {
|
||||
if (courseCollect.getClassify() == 3) {
|
||||
if (courseCollect.getCourseId() == null || courseCollect.getCourseDetailsId() == null) {
|
||||
return Result.success("操作成功!");
|
||||
return Result.success("操作失败!");
|
||||
}
|
||||
QueryWrapper<CourseCollect> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", courseCollect.getUserId())
|
||||
|
|
@ -67,8 +67,9 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||
if (collect != null) {
|
||||
baseMapper.update(null, new LambdaUpdateWrapper<CourseCollect>()
|
||||
.eq(CourseCollect::getCourseCollectId, collect.getCourseCollectId())
|
||||
.eq(CourseCollect::getUserId, collect.getUserId())
|
||||
.set(CourseCollect::getUpdateTime, DateUtil.now())
|
||||
.set(CourseCollect::getCourseDetailsId, collect.getCourseDetailsId()));
|
||||
.set(CourseCollect::getCourseDetailsId, courseCollect.getCourseDetailsId()));
|
||||
return Result.success("操作成功!");
|
||||
}
|
||||
collect = new CourseCollect()
|
||||
|
|
@ -139,28 +140,30 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||
public Result selectByUserId(Integer page, Integer limit, Long userId, Integer classify) {
|
||||
PageHelper.startPage(page, limit);
|
||||
List<Course> courses = new ArrayList<>();
|
||||
//收藏
|
||||
if (classify.equals(1)) {
|
||||
//查 收藏记录
|
||||
//收藏记录
|
||||
courses = baseMapper.selectClassify1In3(userId);
|
||||
}else if (classify.equals(2)){
|
||||
courses = baseMapper.selectClassify1In2(userId);
|
||||
//点赞
|
||||
courses = baseMapper.selectClassify2(userId);
|
||||
} else {
|
||||
courses = baseMapper.selectClassify1ByUserId(userId);
|
||||
}
|
||||
if (CollectionUtil.isEmpty(courses)) {
|
||||
return Result.success().put("data", PageUtils.page(new PageInfo<>(courses), true));
|
||||
//观看历史
|
||||
courses = baseMapper.selectClassify3ByUserId(userId);
|
||||
}
|
||||
|
||||
//剧id
|
||||
Set<Long> courseIdList = new HashSet<>();
|
||||
//详情id
|
||||
Set<Long> courseDetailIds = new HashSet<>();
|
||||
//剧集-观看记录时间
|
||||
Map<Long,String> upTime = new HashMap<>();
|
||||
courses.forEach(s -> {
|
||||
if (s == null) {
|
||||
return;
|
||||
}
|
||||
courseIdList.add(s.getCourseId());
|
||||
courseDetailIds.add(s.getCourseDetailsId());
|
||||
upTime.put(s.getCourseId(),s.getUpdateTime());
|
||||
});
|
||||
List<Course> courseList = courseIdList.isEmpty() ? new ArrayList<>() :
|
||||
courseDao.selectList(new LambdaQueryWrapper<Course>().in(Course::getCourseId, courseIdList));
|
||||
|
|
@ -169,21 +172,21 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||
courseDetailsService.list(new LambdaQueryWrapper<CourseDetails>().in(CourseDetails::getCourseDetailsId, courseDetailIds));
|
||||
Map<Long, CourseDetails> courseDetailsMap = courseDetails1.stream()
|
||||
.collect(Collectors.toMap(CourseDetails::getCourseId, item -> item, (key1, key2) -> key1));
|
||||
// List<CourseDetails> courseDetails2 = courseIdList.isEmpty() ? new ArrayList<>() : courseDetailsDao.countByCourseId(courseIdList);
|
||||
// Map<Long, Integer> countMap = courseDetails2.stream()
|
||||
// .collect(Collectors.toMap(CourseDetails::getCourseId, CourseDetails::getCourseDetailsCount));
|
||||
|
||||
if (CollectionUtil.isNotEmpty(courseList)) {
|
||||
for (Course course : courseList) {
|
||||
// course.setCourseClassification(courseClassificationDao.selectById(course.getClassifyId()));
|
||||
CourseDetails courseDetails = courseDetailsMap.getOrDefault(course.getCourseId(), null);
|
||||
course.setCourseDetailsCount(courseDetailsDao.countCourseByCourseId(course.getCourseId()));
|
||||
if (courseDetails != null) {
|
||||
course.setCourseDetailsName(courseDetails.getCourseDetailsName());
|
||||
course.setCourseDetailsId(courseDetails.getCourseDetailsId());
|
||||
}
|
||||
if (upTime.containsKey(course.getCourseId())) {
|
||||
course.setUpdateTime(upTime.get(course.getCourseId()));
|
||||
}
|
||||
}
|
||||
courseList.sort(Comparator.comparing(Course::getUpdateTime).reversed());
|
||||
}
|
||||
PageInfo<Course> pageInfo = new PageInfo<>(courseList);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo, true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import cn.hutool.core.util.NumberUtil;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.orders.dto.SummaryDTO;
|
||||
import com.sqx.modules.orders.service.OrdersService;
|
||||
import com.sqx.modules.pay.dao.CashOutDao;
|
||||
import com.sqx.modules.pay.entity.CashOut;
|
||||
|
|
@ -207,4 +208,11 @@ public class OrdersController extends AbstractController {
|
|||
result.put("year", year);
|
||||
return Result.success().put("data", result);
|
||||
}
|
||||
|
||||
@GetMapping("/queryByTradeNo")
|
||||
@ApiOperation("按交易订单号统计相关数据")
|
||||
public Result queryByTradeNo(String outTradeNo) {
|
||||
SummaryDTO data = ordersService.queryByTradeNo(outTradeNo);
|
||||
return Result.success().put("data", data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.sqx.modules.orders.dto;
|
||||
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserInfo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author tankaikai
|
||||
* @since 2025-01-13 19:13
|
||||
*/
|
||||
@Data
|
||||
public class SummaryDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private UserEntity userInfo;
|
||||
private UserInfo authInfo;
|
||||
|
||||
private Map<String,Object> withdrawTotal;
|
||||
private Map<String,Object> payTotal;
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.sqx.modules.orders.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.orders.dto.SummaryDTO;
|
||||
import com.sqx.modules.orders.entity.Orders;
|
||||
|
||||
public interface OrdersService extends IService<Orders> {
|
||||
|
|
@ -70,4 +71,6 @@ public interface OrdersService extends IService<Orders> {
|
|||
* @param orders
|
||||
*/
|
||||
void fillSysUserId(Orders orders);
|
||||
|
||||
SummaryDTO queryByTradeNo(String outTradeNo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package com.sqx.modules.orders.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
|
|
@ -12,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
|
|
@ -29,9 +33,14 @@ import com.sqx.modules.course.service.CourseUserService;
|
|||
import com.sqx.modules.invite.service.InviteMoneyService;
|
||||
import com.sqx.modules.invite.service.InviteService;
|
||||
import com.sqx.modules.orders.dao.OrdersDao;
|
||||
import com.sqx.modules.orders.dto.SummaryDTO;
|
||||
import com.sqx.modules.orders.entity.Orders;
|
||||
import com.sqx.modules.orders.service.OrdersService;
|
||||
import com.sqx.modules.pay.controller.app.AliPayController;
|
||||
import com.sqx.modules.pay.dao.CashOutDao;
|
||||
import com.sqx.modules.pay.dao.PayDetailsDao;
|
||||
import com.sqx.modules.pay.entity.CashOut;
|
||||
import com.sqx.modules.pay.entity.PayDetails;
|
||||
import com.sqx.modules.pay.service.DyService;
|
||||
import com.sqx.modules.pay.service.WxService;
|
||||
import com.sqx.modules.sys.dao.SysUserDao;
|
||||
|
|
@ -89,6 +98,13 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
|
||||
@Autowired
|
||||
private SysUserDao sysUserDao;
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
@Autowired
|
||||
private CashOutDao cashOutDao;
|
||||
|
||||
@Autowired
|
||||
private PayDetailsDao payDetailsDao;
|
||||
|
||||
private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
|
||||
|
||||
|
|
@ -248,7 +264,9 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
log.info("生成商品订单信息接口入参为:{},{}", courseId, userId);
|
||||
// reentrantReadWriteLock.writeLock().lock();
|
||||
try {
|
||||
CourseDetails courseDetail = courseDetailsService.getOne(new LambdaQueryWrapper<CourseDetails>()
|
||||
CourseDetails courseDetail = null;
|
||||
if(courseDetailsId != null){
|
||||
courseDetail = courseDetailsService.getOne(new LambdaQueryWrapper<CourseDetails>()
|
||||
.eq(CourseDetails::getCourseDetailsId, courseDetailsId)
|
||||
.eq(CourseDetails::getCourseId, courseId));
|
||||
if (courseDetail == null) {
|
||||
|
|
@ -257,6 +275,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
if (courseDetail != null && courseDetail.getIsPrice().equals(2)) {
|
||||
return Result.success().put("status", 1);
|
||||
}
|
||||
}
|
||||
CourseUser courseUser1 = courseUserDao.selectCourseUser(courseId, userId);
|
||||
if (courseUser1 != null) {
|
||||
return Result.success().put("status", 1);
|
||||
|
|
@ -805,4 +824,72 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
}
|
||||
orders.setSysUserId(sysUserEntity.getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SummaryDTO queryByTradeNo(String outTradeNo) {
|
||||
String tradeNo = null;
|
||||
Long userId = null;
|
||||
try {
|
||||
// 提现回调单号
|
||||
if (outTradeNo.contains("-") && outTradeNo.contains(":")){
|
||||
tradeNo = outTradeNo.split("-")[0];
|
||||
userId = Convert.toLong(outTradeNo.split("-")[1].split(":")[0]);
|
||||
}
|
||||
// 支付回调单号
|
||||
else if(outTradeNo.contains("-")){
|
||||
tradeNo = outTradeNo.split("-")[0];
|
||||
userId = Convert.toLong(outTradeNo.split("-")[1]);
|
||||
}
|
||||
}catch (Exception e){
|
||||
throw new SqxException("交易订单号不合法");
|
||||
}
|
||||
if(StrUtil.isEmpty(tradeNo) || userId == null){
|
||||
throw new SqxException("交易订单号不合法");
|
||||
}
|
||||
SummaryDTO data = new SummaryDTO();
|
||||
UserEntity user = userService.selectUserById(userId);
|
||||
data.setUserInfo(user);
|
||||
UserInfo realNameAuth = userInfoService.getByUserId(userId);
|
||||
data.setAuthInfo(realNameAuth);
|
||||
|
||||
Map<String, Object> withdrawTotal = new HashMap<>();
|
||||
withdrawTotal.put("success", MapUtil.builder().put("total", BigDecimal.ZERO).put("count", 0).build());
|
||||
withdrawTotal.put("fail", MapUtil.builder().put("total", BigDecimal.ZERO).put("count", 0).build());
|
||||
withdrawTotal.put("auditing", MapUtil.builder().put("total", BigDecimal.ZERO).put("count", 0).build());
|
||||
withdrawTotal.put("other", MapUtil.builder().put("total", BigDecimal.ZERO).put("count", 0).build());
|
||||
data.setWithdrawTotal(withdrawTotal);
|
||||
Map<String, Object> payTotal = new HashMap<>();
|
||||
payTotal.put("success", MapUtil.builder().put("total", BigDecimal.ZERO).put("count", 0).build());
|
||||
payTotal.put("fail", MapUtil.builder().put("total", BigDecimal.ZERO).put("count", 0).build());
|
||||
payTotal.put("unpaid", MapUtil.builder().put("total", BigDecimal.ZERO).put("count", 0).build());
|
||||
data.setPayTotal(payTotal);
|
||||
List<CashOut> cashOutList = cashOutDao.selectList(Wrappers.<CashOut>lambdaQuery().eq(CashOut::getUserId, userId));
|
||||
if (CollUtil.isNotEmpty(cashOutList)) {
|
||||
Map<Integer, BigDecimal> cashOut = cashOutList.stream().collect(Collectors.groupingBy(CashOut::getState, Collectors.reducing(BigDecimal.ZERO, CashOut::getConvertMoney, BigDecimal::add)));
|
||||
Map<Integer, Long> cashOutCount = cashOutList.stream().collect(Collectors.groupingBy(CashOut::getState, Collectors.counting()));
|
||||
withdrawTotal.put("success", MapUtil.builder().put("total", cashOut.containsKey(1) ? cashOut.get(1) : BigDecimal.ZERO).put("count", cashOutCount.containsKey(1) ? cashOutCount.get(1) : 0).build());
|
||||
withdrawTotal.put("fail", MapUtil.builder().put("total", cashOut.containsKey(2) ? cashOut.get(2) : BigDecimal.ZERO).put("count", cashOutCount.containsKey(2) ? cashOutCount.get(2) : 0).build());
|
||||
withdrawTotal.put("auditing", MapUtil.builder().put("total", cashOut.containsKey(3) ? cashOut.get(3) : BigDecimal.ZERO).put("count", cashOutCount.containsKey(3) ? cashOutCount.get(3) : 0).build());
|
||||
Integer[] states = {1, 2, 3};
|
||||
BigDecimal otherMoney = cashOutList.stream().filter(obj -> !ArrayUtil.contains(states, obj.getState())).collect(Collectors.reducing(BigDecimal.ZERO, CashOut::getConvertMoney, BigDecimal::add));
|
||||
Long otherCount = cashOutList.stream().filter(obj -> !ArrayUtil.contains(states, obj.getState())).collect(Collectors.counting());
|
||||
withdrawTotal.put("other", MapUtil.builder().put("total", NumberUtil.null2Zero(otherMoney)).put("count", otherCount == null ? 0 : otherCount.longValue()).build());
|
||||
data.setWithdrawTotal(withdrawTotal);
|
||||
}
|
||||
|
||||
|
||||
List<PayDetails> payDetailsList = payDetailsDao.selectList(Wrappers.<PayDetails>lambdaQuery().eq(PayDetails::getUserId, userId));
|
||||
if (CollUtil.isNotEmpty(payDetailsList)) {
|
||||
Map<Integer, Double> payDetail = payDetailsList.stream().collect(Collectors.groupingBy(PayDetails::getState, Collectors.summingDouble(PayDetails::getMoney)));
|
||||
Map<Integer, Long> payDetailCount = payDetailsList.stream().collect(Collectors.groupingBy(PayDetails::getState, Collectors.counting()));
|
||||
|
||||
payTotal.put("success", MapUtil.builder().put("total", payDetail.containsKey(1) ? payDetail.get(1) : 0d).put("count", payDetailCount.containsKey(1) ? payDetailCount.get(1) : 0).build());
|
||||
payTotal.put("fail", MapUtil.builder().put("total", payDetail.containsKey(2) ? payDetail.get(2) : 0d).put("count", payDetailCount.containsKey(2) ? payDetailCount.get(2) : 0).build());
|
||||
payTotal.put("unpaid", MapUtil.builder().put("total", payDetail.containsKey(0) ? payDetail.get(0) : 0d).put("count", payDetailCount.containsKey(0) ? payDetailCount.get(0) : 0).build());
|
||||
data.setPayTotal(payTotal);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class WuyouController {
|
|||
return Result.error("订单已支付");
|
||||
}
|
||||
if (redisService.setCreateOrderFlagAndCheckLimit(order.getUserId(), orderId)) {
|
||||
userService.addBlackUser(order.getUserId(), "一分钟频繁下单超12次");
|
||||
userService.addBlackUser(order.getUserId(), "一分钟频繁下单超22次");
|
||||
}
|
||||
|
||||
PayDetails payDetails = payDetailsDao.selectByOrderId(order.getOrdersNo());
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public interface CashOutDao extends BaseMapper<CashOut> {
|
|||
|
||||
Double selectCashOutSum(@Param("userId") Long userId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
Integer selectTodayCashCount(@Param("userId") Long userId, @Param("state") Integer state,@Param("time") String time);
|
||||
Integer selectTodayCashCount(@Param("userId") Long userId, @Param("stateList") List<Integer> stateList,@Param("time") String time);
|
||||
|
||||
Double selectSysUserCashOutSum(@Param("sysUserId") Long sysUserId, @Param("time") String time);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.sqx.modules.pay.entity;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
|
@ -151,6 +152,16 @@ public class CashOut implements Serializable {
|
|||
|
||||
private Integer withdrawType;
|
||||
|
||||
/**
|
||||
* 提现金币
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private BigDecimal convertMoney;
|
||||
|
||||
public BigDecimal getConvertMoney() {
|
||||
return Convert.toBigDecimal(money,BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
public void setZhifubao(String zhifubao) {
|
||||
this.zhifubao = zhifubao;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -661,7 +661,7 @@ public class CashOutServiceImpl extends ServiceImpl<CashOutDao, CashOut> impleme
|
|||
// 禁止该姓名的用户提现
|
||||
Integer count = tbWithdrawBlacklistMapper.selectCount(Wrappers.<TbWithdrawBlacklist>lambdaQuery().in(TbWithdrawBlacklist::getRealName, withdrawCheckNameSet));
|
||||
if (count > 0) {
|
||||
userMoneyDetails.setContent("提现-" + money);
|
||||
userMoneyDetails.setContent("提现=" + money);
|
||||
cashOut.setState(3);
|
||||
cashOut.setRelationId("提现黑名单用户,请谨慎审核!");
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.sqx.modules.pay.wuyou;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
|
@ -100,7 +102,7 @@ public class WuyouPay {
|
|||
public void checkCanCash(long userId, WithdrawTypeEnum type, BigDecimal money) {
|
||||
if (WithdrawTypeEnum.MANUAL.equals(type)) {
|
||||
// 查询当日体现次数
|
||||
Integer successCashCount = cashOutDao.selectTodayCashCount(userId, 1, DateUtil.today() + " 00:00:00");
|
||||
Integer successCashCount = cashOutDao.selectTodayCashCount(userId, CollectionUtil.newArrayList(1, 3), DateUtil.today() + " 00:00:00");
|
||||
CommonInfo cashLimit = commonInfoService.findOne(922);
|
||||
if (cashLimit == null || StrUtil.isBlank(cashLimit.getValue())) {
|
||||
logger.warn("提现必要参数未配置,请联系管理员");
|
||||
|
|
|
|||
|
|
@ -354,6 +354,6 @@ public class RedisServiceImpl implements RedisService {
|
|||
redisTemplate.opsForSet().add(key, orderId.toString());
|
||||
redisUtils.expire(key, 60);
|
||||
Set<String> members = redisTemplate.opsForSet().members(key);
|
||||
return members != null && members.size() > 12;
|
||||
return members != null && members.size() > 22;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,34 +33,34 @@
|
|||
<select id="selectClassify1In3" resultType="com.sqx.modules.course.entity.Course">
|
||||
SELECT
|
||||
c1.course_id as courseId,
|
||||
c1.course_details_id as courseDetailsId
|
||||
c1.course_details_id as courseDetailsId,
|
||||
c1.update_time as updateTime
|
||||
FROM
|
||||
`course_collect` c1
|
||||
INNER JOIN course_collect c2 ON c1.course_id = c2.course_id AND c2.user_id = #{userId} AND c2.classify = 1
|
||||
WHERE
|
||||
c1.classify = 3
|
||||
AND c1.user_id = #{userId}
|
||||
order by c1.update_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectClassify1In2" resultType="com.sqx.modules.course.entity.Course">
|
||||
<select id="selectClassify2" resultType="com.sqx.modules.course.entity.Course">
|
||||
SELECT
|
||||
c1.course_id as courseId,
|
||||
c1.course_details_id as courseDetailsId
|
||||
c1.course_details_id as courseDetailsId,
|
||||
c1.update_time as updateTime
|
||||
FROM
|
||||
`course_collect` c1
|
||||
WHERE
|
||||
c1.classify = 2
|
||||
AND c1.user_id = #{userId}
|
||||
order by c1.update_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectClassify1ByUserId" resultType="com.sqx.modules.course.entity.Course">
|
||||
<select id="selectClassify3ByUserId" resultType="com.sqx.modules.course.entity.Course">
|
||||
SELECT c1.course_id as courseId,
|
||||
c1.course_details_id as courseDetailsId
|
||||
c1.course_details_id as courseDetailsId,
|
||||
c1.update_time as updateTime
|
||||
FROM `course_collect` c1
|
||||
WHERE c1.classify = 3
|
||||
AND c1.user_id = #{userId}
|
||||
order by c1.update_time desc
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -188,7 +188,13 @@
|
|||
</select>
|
||||
|
||||
<select id="selectTodayCashCount" resultType="java.lang.Integer">
|
||||
select count(*) from cash_out where create_at > #{time} and user_id=#{userId} and state=#{state} and withdraw_type=1;
|
||||
select count(*) from cash_out where create_at > #{time} and user_id=#{userId}
|
||||
and state in
|
||||
<foreach collection="stateList" item="state" open="(" separator="," close=")">
|
||||
#{state}
|
||||
</foreach>
|
||||
and state=#{state}
|
||||
and withdraw_type=1;
|
||||
</select>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue