orders表sys_user_id字段进行填充
This commit is contained in:
parent
e530955959
commit
b237d3125e
|
|
@ -7,8 +7,6 @@ import cn.hutool.json.JSONUtil;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.modules.app.entity.InviteAchievement;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
|
|
@ -23,7 +21,6 @@ import com.sqx.modules.complet.entity.CompletAward;
|
|||
import com.sqx.modules.complet.service.CompletAwardService;
|
||||
import com.sqx.modules.course.service.CourseService;
|
||||
import com.sqx.modules.invite.dao.InviteDao;
|
||||
import com.sqx.modules.invite.entity.Invite;
|
||||
import com.sqx.modules.invite.service.InviteService;
|
||||
import com.sqx.modules.orders.dao.OrdersDao;
|
||||
import com.sqx.modules.orders.entity.Orders;
|
||||
|
|
@ -160,6 +157,7 @@ public class TempOrdersTask {
|
|||
order.setPayWay(9);
|
||||
order.setStatus(1);
|
||||
order.setPayTime(DateUtils.format(new Date()));
|
||||
ordersService.fillSysUserId(order);
|
||||
|
||||
ordersService.update(order, new LambdaQueryWrapper<Orders>()
|
||||
.eq(Orders::getOrdersId, order.getOrdersId()).eq(Orders::getUserId, order.getUserId()));
|
||||
|
|
|
|||
|
|
@ -65,4 +65,9 @@ public interface OrdersService extends IService<Orders> {
|
|||
Integer countOrderNum(Long userId, String time);
|
||||
|
||||
|
||||
/**
|
||||
* 填充渠道用户id
|
||||
* @param orders
|
||||
*/
|
||||
void fillSysUserId(Orders orders);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@ import com.github.pagehelper.PageInfo;
|
|||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import com.sqx.modules.app.entity.UserVip;
|
||||
import com.sqx.modules.app.entity.VipDetails;
|
||||
import com.sqx.modules.app.entity.*;
|
||||
import com.sqx.modules.app.service.*;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.course.dao.CourseDao;
|
||||
|
|
@ -37,6 +34,8 @@ import com.sqx.modules.orders.service.OrdersService;
|
|||
import com.sqx.modules.pay.controller.app.AliPayController;
|
||||
import com.sqx.modules.pay.service.DyService;
|
||||
import com.sqx.modules.pay.service.WxService;
|
||||
import com.sqx.modules.sys.dao.SysUserDao;
|
||||
import com.sqx.modules.sys.entity.SysUserEntity;
|
||||
import com.sqx.modules.utils.AliPayOrderUtil;
|
||||
import com.sqx.modules.utils.InvitationCodeUtil;
|
||||
import com.sqx.modules.utils.TimeCompleteUtils;
|
||||
|
|
@ -88,6 +87,9 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
@Autowired
|
||||
private CourseDetailsDao courseDetailsDao;
|
||||
|
||||
@Autowired
|
||||
private SysUserDao sysUserDao;
|
||||
|
||||
private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
|
||||
|
||||
|
||||
|
|
@ -319,7 +321,8 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
orders.setCreateTime(df.format(new Date()));
|
||||
//设置订单种类
|
||||
orders.setOrdersType(1);
|
||||
|
||||
// 填充系统用户id
|
||||
fillSysUserId(orders);
|
||||
//不是会员或会员过期直接生成订单直接生成订单
|
||||
int count = baseMapper.insert(orders);
|
||||
result.put("flag", 2);
|
||||
|
|
@ -435,7 +438,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
orders.setCreateTime(df.format(new Date()));
|
||||
//设置订单种类
|
||||
orders.setOrdersType(1);
|
||||
|
||||
fillSysUserId(orders);
|
||||
//不是会员或会员过期直接生成订单直接生成订单
|
||||
int count = baseMapper.insert(orders);
|
||||
result.put("flag", 2);
|
||||
|
|
@ -483,6 +486,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
//设置创建时间
|
||||
orders.setCreateTime(df.format(new Date()));
|
||||
fillSysUserId(orders);
|
||||
//插入到订单表中
|
||||
baseMapper.insert(orders);
|
||||
return Result.success().put("data", orders);
|
||||
|
|
@ -563,6 +567,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
// orders.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
||||
// orders.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
||||
// }
|
||||
fillSysUserId(orders);
|
||||
baseMapper.updateById(orders);
|
||||
insertOrders(orders);
|
||||
return Result.success();
|
||||
|
|
@ -669,7 +674,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
List<Orders> orders = baseMapper.selectOrdersByOrdersNo(ordersNo, status, userId, courseId,
|
||||
flag, time, userName, ordersType, TimeCompleteUtils.completeStartTime(startTime), TimeCompleteUtils.completeEndTime(endTime), sysUserId, qdCode, sysUserName);
|
||||
Set<Long> courseIds = orders.stream().map(Orders::getCourseId).collect(Collectors.toSet());
|
||||
if(CollUtil.isNotEmpty(courseIds)) {
|
||||
if (CollUtil.isNotEmpty(courseIds)) {
|
||||
List<Course> courses = courseDao.selectBatchIds(courseIds);
|
||||
Map<Long, String> map = courses.stream().collect(Collectors.toMap(Course::getCourseId, Course::getTitle));
|
||||
orders.parallelStream().forEach(s -> {
|
||||
|
|
@ -779,4 +784,25 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
public Integer countOrderNum(Long userId, String time) {
|
||||
return baseMapper.countOrderNum(userId, time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillSysUserId(Orders orders) {
|
||||
if (orders.getSysUserId() != null) {
|
||||
return;
|
||||
}
|
||||
orders.setSysUserId(1L);
|
||||
UserEntity userEntity = userService.selectUserById(orders.getUserId());
|
||||
if (userEntity == null) {
|
||||
return;
|
||||
}
|
||||
String qdCode = userEntity.getQdCode();
|
||||
if (StrUtil.isBlank(qdCode)) {
|
||||
return;
|
||||
}
|
||||
SysUserEntity sysUserEntity = sysUserDao.selectOne(Wrappers.<SysUserEntity>lambdaQuery().eq(SysUserEntity::getQdCode, qdCode).last("LIMIT 1"));
|
||||
if (sysUserEntity == null) {
|
||||
return;
|
||||
}
|
||||
orders.setSysUserId(sysUserEntity.getSysUserId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -412,6 +412,7 @@ public class DyServiceImpl implements DyService {
|
|||
orders.setPayWay(7);
|
||||
orders.setStatus(1);
|
||||
orders.setPayTime(DateUtils.format(new Date()));
|
||||
ordersService.fillSysUserId(orders);
|
||||
ordersService.updateById(orders);
|
||||
UserEntity user = userService.selectUserById(orders.getUserId());
|
||||
UserEntity byUser = userService.queryByInvitationCode(user.getInviterCode());
|
||||
|
|
@ -431,6 +432,7 @@ public class DyServiceImpl implements DyService {
|
|||
orders.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
||||
orders.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
||||
}
|
||||
ordersService.fillSysUserId(orders);
|
||||
ordersService.insertOrders(orders);
|
||||
}else{
|
||||
String remark = payDetails.getRemark();
|
||||
|
|
@ -502,6 +504,7 @@ public class DyServiceImpl implements DyService {
|
|||
if(StringUtils.isNotEmpty(currency) && "DIAMOND".equals(currency)){
|
||||
orders.setDiamond(1);
|
||||
}
|
||||
ordersService.fillSysUserId(orders);
|
||||
ordersService.updateById(orders);
|
||||
UserEntity user = userService.selectUserById(orders.getUserId());
|
||||
UserEntity byUser = userService.queryByInvitationCode(user.getInviterCode());
|
||||
|
|
@ -521,6 +524,7 @@ public class DyServiceImpl implements DyService {
|
|||
orders.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
||||
orders.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
||||
}
|
||||
ordersService.fillSysUserId(orders);
|
||||
ordersService.insertOrders(orders);
|
||||
}else{
|
||||
if(StringUtils.isNotEmpty(currency) && "DIAMOND".equals(currency)){
|
||||
|
|
@ -615,5 +619,4 @@ public class DyServiceImpl implements DyService {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ public class KsServiceImpl implements KsService {
|
|||
orders.setPayWay(8);
|
||||
orders.setStatus(1);
|
||||
orders.setPayTime(DateUtils.format(new Date()));
|
||||
ordersService.fillSysUserId(orders);
|
||||
ordersService.updateById(orders);
|
||||
UserEntity user = userService.selectUserById(orders.getUserId());
|
||||
UserEntity byUser = userService.queryByInvitationCode(user.getInviterCode());
|
||||
|
|
@ -207,6 +208,7 @@ public class KsServiceImpl implements KsService {
|
|||
orders.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
||||
orders.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
||||
}
|
||||
ordersService.fillSysUserId(orders);
|
||||
ordersService.insertOrders(orders);
|
||||
}else{
|
||||
userMoneyService.updateMoney(1,payDetails.getUserId(),payDetails.getMoney());
|
||||
|
|
|
|||
|
|
@ -303,6 +303,7 @@ public class WxServiceImpl implements WxService {
|
|||
orders.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
||||
orders.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
||||
}
|
||||
ordersService.fillSysUserId(orders);
|
||||
ordersService.updateById(orders);
|
||||
ordersService.insertOrders(orders);
|
||||
}else{
|
||||
|
|
@ -383,6 +384,7 @@ public class WxServiceImpl implements WxService {
|
|||
orders.setSysUserId(Long.parseLong(String.valueOf(sysUserId)));
|
||||
orders.setQdMoney(new BigDecimal(String.valueOf(map.get("qdMoney"))));
|
||||
}
|
||||
ordersService.fillSysUserId(orders);
|
||||
ordersService.updateById(orders);
|
||||
ordersService.insertOrders(orders);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@
|
|||
|
||||
<select id="selectOrdersCount" resultType="Integer">
|
||||
select count(*) from orders where 1=1
|
||||
<if test="sysUserId!=null">
|
||||
<if test="sysUserId!=null and sysUserId != 1">
|
||||
and sys_user_id=#{sysUserId}
|
||||
</if>
|
||||
<if test="status!=null">
|
||||
|
|
@ -206,7 +206,7 @@
|
|||
<select id="selectOrdersMoney" resultType="Double">
|
||||
select sum(pay_money) from orders
|
||||
where 1=1
|
||||
<if test="sysUserId!=null">
|
||||
<if test="sysUserId!=null and sysUserId != 1">
|
||||
and sys_user_id=#{sysUserId}
|
||||
</if>
|
||||
<if test="status!=null">
|
||||
|
|
|
|||
|
|
@ -26,7 +26,12 @@
|
|||
</select>
|
||||
|
||||
<select id="selectSysUserCashOutSum" resultType="Double">
|
||||
select sum(money) from cash_out where state = 1 and sys_user_id=#{sysUserId} and create_at > #{time}
|
||||
select sum(money) from cash_out where state = 1
|
||||
<if test="sysUserId != null">
|
||||
and user_id=#{sysUserId}
|
||||
</if>
|
||||
and user_type = 2
|
||||
and create_at > #{time}
|
||||
</select>
|
||||
|
||||
<select id="sumMoney" resultType="Double">
|
||||
|
|
|
|||
|
|
@ -1,19 +1,9 @@
|
|||
package com.sqx;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyun.credentials.provider.StaticCredentialsProvider;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import com.aliyun.dytnsapi20200217.Client;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.sqx.modules.app.dao.UserDao;
|
||||
import com.sqx.modules.app.dao.UserMoneyDao;
|
||||
import com.sqx.modules.app.dao.UserMoneyDetailsDao;
|
||||
|
|
@ -25,26 +15,21 @@ import com.sqx.modules.app.service.InviteAchievementService;
|
|||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.job.task.TempOrdersTask;
|
||||
import com.sqx.modules.orders.service.OrdersService;
|
||||
import com.sqx.modules.pay.controller.app.WuyouController;
|
||||
import com.sqx.modules.pay.dao.PayDetailsDao;
|
||||
import com.sqx.modules.pay.entity.PayDetails;
|
||||
import com.sqx.modules.pay.service.PayDetailsService;
|
||||
import com.sqx.modules.pay.wuyou.BaseResp;
|
||||
import com.sqx.modules.sys.service.SysUserService;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ActiveProfiles("pay")
|
||||
|
|
@ -76,14 +61,14 @@ public class Tets {
|
|||
@Autowired
|
||||
private OrdersService ordersService;
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void test4() {
|
||||
UserEntity userEntity = userDao.selectById(1072962203591784209L);
|
||||
UserEntity userEntity2 = userDao.selectById(1072640875319932689L);
|
||||
tempOrdersTask.activities(userEntity, userEntity2);
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void test3() {
|
||||
List<UserMoneyDetails> userMoneyDetails = userMoneyDetailsDao.selectList(new LambdaQueryWrapper<UserMoneyDetails>().in(UserMoneyDetails::getClassify, 6, 1).isNotNull(UserMoneyDetails::getUserId).groupBy(UserMoneyDetails::getUserId).select(UserMoneyDetails::getUserId));
|
||||
Set<Long> useridList = userMoneyDetails.stream().map(UserMoneyDetails::getUserId).collect(Collectors.toSet());
|
||||
|
|
@ -100,12 +85,12 @@ public class Tets {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void test2() {
|
||||
inviteAchievementService.remove(new LambdaQueryWrapper<>());
|
||||
|
||||
List<UserEntity> userinfoList = userService.list();
|
||||
|
||||
//Wrappers.<UserEntity>lambdaQuery().apply("create_time >= str_to_date({0}, '%Y-%m-%d %H:%i:%s')", "2025-01-01 00:00:00");
|
||||
List<UserEntity> userinfoList = userService.list(Wrappers.emptyWrapper());
|
||||
System.out.println(userinfoList.size());
|
||||
userinfoList.parallelStream().forEach((userEntity -> {
|
||||
if (StrUtil.isBlank(userEntity.getInviterCode())) return;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue