订单统计需求
This commit is contained in:
@@ -120,6 +120,15 @@ public class OrdersController extends AbstractController {
|
|||||||
result.put("tuiMemberOrdersMoney", tuiMemberOrdersMoney);
|
result.put("tuiMemberOrdersMoney", tuiMemberOrdersMoney);
|
||||||
result.put("cashCount", cashCount == null ? 0 : cashCount);
|
result.put("cashCount", cashCount == null ? 0 : cashCount);
|
||||||
result.put("cashSum", cashSum == null ? 0 : new BigDecimal(cashSum).setScale(2, RoundingMode.HALF_UP));
|
result.put("cashSum", cashSum == null ? 0 : new BigDecimal(cashSum).setScale(2, RoundingMode.HALF_UP));
|
||||||
|
|
||||||
|
double signInAwardMoney = ordersService.selectSignInAwardMoney(flag, time, sysUserId);
|
||||||
|
double shareAwardMoney = ordersService.selectShareAwardMoney(flag, time, sysUserId);
|
||||||
|
double newUserTaskDoneAwardMoney = ordersService.selectNewUserTaskDoneAwardMoney(flag, time, sysUserId);
|
||||||
|
double inviteTaskDoneAwardMoney = ordersService.selectInviteTaskDoneAwardMoney(flag, time, sysUserId);
|
||||||
|
result.put("signInAwardMoney", signInAwardMoney);
|
||||||
|
result.put("shareAwardMoney", shareAwardMoney);
|
||||||
|
result.put("newUserTaskDoneAwardMoney", newUserTaskDoneAwardMoney);
|
||||||
|
result.put("inviteTaskDoneAwardMoney", inviteTaskDoneAwardMoney);
|
||||||
return Result.success().put("data", result);
|
return Result.success().put("data", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,4 +45,36 @@ public interface OrdersDao extends BaseMapper<Orders> {
|
|||||||
|
|
||||||
Integer countOrderNum(Long userId, String time);
|
Integer countOrderNum(Long userId, String time);
|
||||||
BigDecimal sumPayByCourseId(Long courseId);
|
BigDecimal sumPayByCourseId(Long courseId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下级签到奖励金额总和
|
||||||
|
* @param flag 1-天,2-月,3-年
|
||||||
|
* @param time 时间范围,格式:2019-01-01,2019-01-31
|
||||||
|
* @return 签到奖励金额总和
|
||||||
|
*/
|
||||||
|
Double selectSignInAwardMoney(Integer flag, String time, Long sysUserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分享达标奖励金额总和
|
||||||
|
* @param flag 1-天,2-月,3-年
|
||||||
|
* @param time 时间范围,格式:2019-01-01,2019-01-31
|
||||||
|
* @return 分享达标奖励金额总和
|
||||||
|
*/
|
||||||
|
Double selectShareAwardMoney(Integer flag, String time, Long sysUserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新人福利任务完成奖励金额总和
|
||||||
|
* @param flag 1-天,2-月,3-年
|
||||||
|
* @param time 时间范围,格式:2019-01-01,2019-01-31
|
||||||
|
* @return 新人福利任务完成奖励金额总和
|
||||||
|
*/
|
||||||
|
Double selectNewUserTaskDoneAwardMoney(Integer flag, String time, Long sysUserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请15人完成达标任务奖励金额总和
|
||||||
|
* @param flag 1-天,2-月,3-年
|
||||||
|
* @param time 时间范围,格式:2019-01-01,2019-01-31
|
||||||
|
* @return 邀请15人完成达标任务奖励金额总和
|
||||||
|
*/
|
||||||
|
Double selectInviteTaskDoneAwardMoney(Integer flag, String time, Long sysUserId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,4 +73,28 @@ public interface OrdersService extends IService<Orders> {
|
|||||||
void fillSysUserId(Orders orders);
|
void fillSysUserId(Orders orders);
|
||||||
|
|
||||||
SummaryDTO queryByTradeNo(String outTradeNo);
|
SummaryDTO queryByTradeNo(String outTradeNo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下级签到奖励金额总和
|
||||||
|
* @return 签到奖励金额总和
|
||||||
|
*/
|
||||||
|
double selectSignInAwardMoney(Integer flag, String time, Long sysUserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分享达标奖励金额总和
|
||||||
|
* @return 分享达标奖励金额总和
|
||||||
|
*/
|
||||||
|
double selectShareAwardMoney(Integer flag, String time, Long sysUserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新人福利任务完成奖励金额总和
|
||||||
|
* @return 新人福利任务完成奖励金额总和
|
||||||
|
*/
|
||||||
|
double selectNewUserTaskDoneAwardMoney(Integer flag, String time, Long sysUserId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请15人完成达标任务奖励金额总和
|
||||||
|
* @return 邀请15人完成达标任务奖励金额总和
|
||||||
|
*/
|
||||||
|
double selectInviteTaskDoneAwardMoney(Integer flag, String time, Long sysUserId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import cn.hutool.core.map.MapUtil;
|
|||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.db.Db;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -19,6 +20,7 @@ import com.sqx.common.exception.SqxException;
|
|||||||
import com.sqx.common.utils.DateUtils;
|
import com.sqx.common.utils.DateUtils;
|
||||||
import com.sqx.common.utils.PageUtils;
|
import com.sqx.common.utils.PageUtils;
|
||||||
import com.sqx.common.utils.Result;
|
import com.sqx.common.utils.Result;
|
||||||
|
import com.sqx.common.utils.SqlFetcher;
|
||||||
import com.sqx.modules.app.entity.*;
|
import com.sqx.modules.app.entity.*;
|
||||||
import com.sqx.modules.app.service.*;
|
import com.sqx.modules.app.service.*;
|
||||||
import com.sqx.modules.common.service.CommonInfoService;
|
import com.sqx.modules.common.service.CommonInfoService;
|
||||||
@@ -47,9 +49,11 @@ import com.sqx.modules.sys.entity.SysUserEntity;
|
|||||||
import com.sqx.modules.utils.AliPayOrderUtil;
|
import com.sqx.modules.utils.AliPayOrderUtil;
|
||||||
import com.sqx.modules.utils.InvitationCodeUtil;
|
import com.sqx.modules.utils.InvitationCodeUtil;
|
||||||
import com.sqx.modules.utils.TimeCompleteUtils;
|
import com.sqx.modules.utils.TimeCompleteUtils;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -103,6 +107,10 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
@Autowired
|
||||||
|
private SqlFetcher sqlFetcher;
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String profiles;
|
||||||
|
|
||||||
private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
|
private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
|
||||||
|
|
||||||
@@ -279,7 +287,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||||||
// reentrantReadWriteLock.writeLock().lock();
|
// reentrantReadWriteLock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
CourseDetails courseDetail = null;
|
CourseDetails courseDetail = null;
|
||||||
if(courseDetailsId != null){
|
if (courseDetailsId != null) {
|
||||||
courseDetail = courseDetailsService.getOne(new LambdaQueryWrapper<CourseDetails>()
|
courseDetail = courseDetailsService.getOne(new LambdaQueryWrapper<CourseDetails>()
|
||||||
.eq(CourseDetails::getCourseDetailsId, courseDetailsId)
|
.eq(CourseDetails::getCourseDetailsId, courseDetailsId)
|
||||||
.eq(CourseDetails::getCourseId, courseId));
|
.eq(CourseDetails::getCourseId, courseId));
|
||||||
@@ -845,19 +853,19 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||||||
Long userId = null;
|
Long userId = null;
|
||||||
try {
|
try {
|
||||||
// 提现回调单号
|
// 提现回调单号
|
||||||
if (outTradeNo.contains("-") && outTradeNo.contains(":")){
|
if (outTradeNo.contains("-") && outTradeNo.contains(":")) {
|
||||||
tradeNo = outTradeNo.split("-")[0];
|
tradeNo = outTradeNo.split("-")[0];
|
||||||
userId = Convert.toLong(outTradeNo.split("-")[1].split(":")[0]);
|
userId = Convert.toLong(outTradeNo.split("-")[1].split(":")[0]);
|
||||||
}
|
}
|
||||||
// 支付回调单号
|
// 支付回调单号
|
||||||
else if(outTradeNo.contains("-")){
|
else if (outTradeNo.contains("-")) {
|
||||||
tradeNo = outTradeNo.split("-")[0];
|
tradeNo = outTradeNo.split("-")[0];
|
||||||
userId = Convert.toLong(outTradeNo.split("-")[1]);
|
userId = Convert.toLong(outTradeNo.split("-")[1]);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
throw new SqxException("交易订单号不合法");
|
throw new SqxException("交易订单号不合法");
|
||||||
}
|
}
|
||||||
if(StrUtil.isEmpty(tradeNo) || userId == null){
|
if (StrUtil.isEmpty(tradeNo) || userId == null) {
|
||||||
throw new SqxException("交易订单号不合法");
|
throw new SqxException("交易订单号不合法");
|
||||||
}
|
}
|
||||||
SummaryDTO data = new SummaryDTO();
|
SummaryDTO data = new SummaryDTO();
|
||||||
@@ -906,4 +914,52 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SneakyThrows
|
||||||
|
public double selectSignInAwardMoney(Integer flag, String time, Long sysUserId) {
|
||||||
|
Map<String,Object> param = new HashMap<>(3);
|
||||||
|
param.put("flag", flag);
|
||||||
|
param.put("time", time);
|
||||||
|
param.put("sysUserId", sysUserId);
|
||||||
|
String sql = sqlFetcher.getSqlFromXml("com.sqx.modules.orders.dao.OrdersDao.selectSignInAwardMoney", param);
|
||||||
|
System.out.println(sql);
|
||||||
|
return Db.use(profiles).queryNumber(sql).doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SneakyThrows
|
||||||
|
public double selectShareAwardMoney(Integer flag, String time, Long sysUserId) {
|
||||||
|
Map<String,Object> param = new HashMap<>(3);
|
||||||
|
param.put("flag", flag);
|
||||||
|
param.put("time", time);
|
||||||
|
param.put("sysUserId", sysUserId);
|
||||||
|
String sql = sqlFetcher.getSqlFromXml("com.sqx.modules.orders.dao.OrdersDao.selectShareAwardMoney", param);
|
||||||
|
System.out.println(sql);
|
||||||
|
return Db.use(profiles).queryNumber(sql).doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SneakyThrows
|
||||||
|
public double selectNewUserTaskDoneAwardMoney(Integer flag, String time, Long sysUserId) {
|
||||||
|
Map<String,Object> param = new HashMap<>(3);
|
||||||
|
param.put("flag", flag);
|
||||||
|
param.put("time", time);
|
||||||
|
param.put("sysUserId", sysUserId);
|
||||||
|
String sql = sqlFetcher.getSqlFromXml("com.sqx.modules.orders.dao.OrdersDao.selectNewUserTaskDoneAwardMoney", param);
|
||||||
|
System.out.println(sql);
|
||||||
|
return Db.use(profiles).queryNumber(sql).doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SneakyThrows
|
||||||
|
public double selectInviteTaskDoneAwardMoney(Integer flag, String time, Long sysUserId) {
|
||||||
|
Map<String,Object> param = new HashMap<>(3);
|
||||||
|
param.put("flag", flag);
|
||||||
|
param.put("time", time);
|
||||||
|
param.put("sysUserId", sysUserId);
|
||||||
|
String sql = sqlFetcher.getSqlFromXml("com.sqx.modules.orders.dao.OrdersDao.selectInviteTaskDoneAwardMoney", param);
|
||||||
|
System.out.println(sql);
|
||||||
|
return Db.use(profiles).queryNumber(sql).doubleValue();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -330,5 +330,97 @@
|
|||||||
and course_id = #{courseId}
|
and course_id = #{courseId}
|
||||||
group by course_id
|
group by course_id
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectSignInAwardMoney" resultType="java.lang.Double">
|
||||||
|
select
|
||||||
|
ifnull(sum(x.money),0)
|
||||||
|
from v_user_money_detail_temp x
|
||||||
|
where 1=1
|
||||||
|
and x.classify = 6
|
||||||
|
and x.type = 1
|
||||||
|
and x.state = 2
|
||||||
|
and x.user_id !=1
|
||||||
|
and x.title = '签到奖励'
|
||||||
|
<if test="sysUserId!=null and sysUserId != 1">
|
||||||
|
and x.sys_user_id=#{sysUserId}
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==1">
|
||||||
|
and date_format(x.create_time,'%Y-%m-%d')=date_format('${time}','%Y-%m-%d')
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==2">
|
||||||
|
and date_format(x.create_time,'%Y-%m')=date_format('${time}','%Y-%m')
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==3">
|
||||||
|
and date_format(x.create_time,'%Y')=date_format('${time}','%Y')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<select id="selectShareAwardMoney" resultType="java.lang.Double">
|
||||||
|
select
|
||||||
|
ifnull(sum(x.money),0)
|
||||||
|
from v_user_money_detail_temp x
|
||||||
|
where 1=1
|
||||||
|
and x.classify = 6
|
||||||
|
and x.type = 1
|
||||||
|
and x.state = 2
|
||||||
|
and x.user_id !=1
|
||||||
|
and x.title = '分享达标奖励'
|
||||||
|
<if test="sysUserId!=null and sysUserId != 1">
|
||||||
|
and x.sys_user_id=#{sysUserId}
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==1">
|
||||||
|
and date_format(x.create_time,'%Y-%m-%d')=date_format('${time}','%Y-%m-%d')
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==2">
|
||||||
|
and date_format(x.create_time,'%Y-%m')=date_format('${time}','%Y-%m')
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==3">
|
||||||
|
and date_format(x.create_time,'%Y')=date_format('${time}','%Y')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<select id="selectNewUserTaskDoneAwardMoney" resultType="java.lang.Double">
|
||||||
|
select
|
||||||
|
ifnull(sum(x.money),0)
|
||||||
|
from v_user_money_detail_temp x
|
||||||
|
where 1=1
|
||||||
|
and x.classify = 7
|
||||||
|
and x.type = 1
|
||||||
|
and x.state = 2
|
||||||
|
and x.user_id !=1
|
||||||
|
and x.money_type = 1
|
||||||
|
<if test="sysUserId!=null and sysUserId != 1">
|
||||||
|
and x.sys_user_id=#{sysUserId}
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==1">
|
||||||
|
and date_format(x.create_time,'%Y-%m-%d')=date_format('${time}','%Y-%m-%d')
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==2">
|
||||||
|
and date_format(x.create_time,'%Y-%m')=date_format('${time}','%Y-%m')
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==3">
|
||||||
|
and date_format(x.create_time,'%Y')=date_format('${time}','%Y')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<select id="selectInviteTaskDoneAwardMoney" resultType="java.lang.Double">
|
||||||
|
select
|
||||||
|
ifnull(sum(x.money),0)
|
||||||
|
from v_user_money_detail_temp x
|
||||||
|
where 1=1
|
||||||
|
and x.classify = 6
|
||||||
|
and x.type = 1
|
||||||
|
and x.state = 2
|
||||||
|
and x.user_id !=1
|
||||||
|
and x.title = '[分享达标额外奖励]'
|
||||||
|
<if test="sysUserId!=null and sysUserId != 1">
|
||||||
|
and x.sys_user_id=#{sysUserId}
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==1">
|
||||||
|
and date_format(x.create_time,'%Y-%m-%d')=date_format('${time}','%Y-%m-%d')
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==2">
|
||||||
|
and date_format(x.create_time,'%Y-%m')=date_format('${time}','%Y-%m')
|
||||||
|
</if>
|
||||||
|
<if test="flag!=null and flag==3">
|
||||||
|
and date_format(x.create_time,'%Y')=date_format('${time}','%Y')
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user