集成ES 20250117
This commit is contained in:
parent
d3bf44183c
commit
4c3961ec06
|
|
@ -1,18 +1,17 @@
|
|||
package com.sqx;
|
||||
|
||||
import org.dromara.easyes.starter.register.EsMapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@EnableCaching
|
||||
@EnableScheduling
|
||||
@EsMapperScan("com.sqx.modules.es.mapper")
|
||||
@SpringBootApplication
|
||||
public class SqxApplication {
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,10 @@ import io.swagger.annotations.ApiModel;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.dromara.easyes.annotation.IndexField;
|
||||
import org.dromara.easyes.annotation.IndexId;
|
||||
import org.dromara.easyes.annotation.IndexName;
|
||||
import org.dromara.easyes.annotation.rely.FieldType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -114,6 +116,7 @@ public class UserMoneyDetails implements Serializable {
|
|||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
@ApiModelProperty("创建时间")
|
||||
private String createTime;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.easyes.annotation.IndexField;
|
||||
import org.dromara.easyes.annotation.IndexId;
|
||||
import org.dromara.easyes.annotation.IndexName;
|
||||
import org.dromara.easyes.annotation.rely.FieldType;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
|
@ -59,16 +61,19 @@ public class CourseCollect implements Serializable {
|
|||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String updateTime;
|
||||
/**
|
||||
* 1 写入 2 删除
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private Integer type;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.annotation.*;
|
|||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import org.dromara.easyes.annotation.IndexField;
|
||||
import org.dromara.easyes.annotation.IndexId;
|
||||
import org.dromara.easyes.annotation.IndexName;
|
||||
import org.dromara.easyes.annotation.rely.FieldType;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
|
@ -63,17 +65,21 @@ public class CourseUser implements Serializable {
|
|||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private String avatar;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private String courseCount;
|
||||
|
||||
public CourseUser() {}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.extension.activerecord.Model;
|
|||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import org.dromara.easyes.annotation.IndexField;
|
||||
import org.dromara.easyes.annotation.IndexId;
|
||||
import org.dromara.easyes.annotation.IndexName;
|
||||
import org.dromara.easyes.annotation.rely.FieldType;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
|
@ -43,13 +45,16 @@ public class DiscSpinningRecord extends Model<DiscSpinningRecord> {
|
|||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long targetId;
|
||||
//抽奖日期
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd")
|
||||
private String drawDay;
|
||||
//创建时间
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String createTime;
|
||||
//来源 task 任务 order 订单
|
||||
private String source = "order";
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long discSpinningId;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package com.sqx.modules.es.controller;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.es.dao.EsCashOutDao;
|
||||
import com.sqx.modules.es.mapper.EsUserMoneyDetailsMapper;
|
||||
import com.sqx.modules.es.service.EsCoreService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
|
@ -21,14 +23,19 @@ import java.util.Map;
|
|||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(value = "/es/core")
|
||||
public class EsCoreController {
|
||||
@Autowired
|
||||
private EsCoreService esCoreService;
|
||||
private final EsCoreService esCoreService;
|
||||
private final EsUserMoneyDetailsMapper esUserMoneyDetailsMapper;
|
||||
private final EsCashOutDao esCashOutDao;
|
||||
|
||||
@ApiOperation("同步")
|
||||
@PostMapping("/sync")
|
||||
public Result sync(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||
//Double aDouble = esCashOutDao.selectCashOutSum(1L, DateUtil.parseDate("2025-01-01"), DateUtil.parseDate("2025-01-17"));
|
||||
//System.out.println(aDouble);
|
||||
|
||||
esCoreService.sync();
|
||||
return Result.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,102 @@
|
|||
package com.sqx.modules.es.dao;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.sqx.modules.es.mapper.EsCashOutMapper;
|
||||
import com.sqx.modules.pay.dao.CashOutDao;
|
||||
import com.sqx.modules.pay.entity.CashOut;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author tankaikai
|
||||
* @since 2025-01-15 18:29
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class EsCashOutDao {
|
||||
|
||||
private final EsCashOutMapper esCashOutMapper;
|
||||
|
||||
private final CashOutDao cashOutDao;
|
||||
|
||||
public EsCashOutMapper getBaseEsMapper() {
|
||||
return this.esCashOutMapper;
|
||||
}
|
||||
|
||||
public CashOutDao getOriginalDao() {
|
||||
return this.cashOutDao;
|
||||
}
|
||||
|
||||
public List<CashOut> selectCashOutLimit3() {
|
||||
LambdaEsQueryWrapper<CashOut> wrapper = new LambdaEsQueryWrapper<>();
|
||||
wrapper.eq(CashOut::getState, 1);
|
||||
wrapper.orderByDesc(CashOut::getOutAt);
|
||||
wrapper.limit(3);
|
||||
return esCashOutMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
public List<CashOut> selectYesterday() {
|
||||
LambdaEsQueryWrapper<CashOut> wrapper = new LambdaEsQueryWrapper<>();
|
||||
wrapper.eq(CashOut::getState, 0);
|
||||
wrapper.eq(CashOut::getUserType, 1);
|
||||
wrapper.lt(CashOut::getCreateAt, DateUtil.today() + " 00:00:00");
|
||||
LocalDate date = LocalDate.now().plusDays(-1);
|
||||
wrapper.gt(CashOut::getCreateAt, date + " 00:00:00");
|
||||
return esCashOutMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
public List<CashOut> selectTemp(DateTime time) {
|
||||
LambdaEsQueryWrapper<CashOut> wrapper = new LambdaEsQueryWrapper<>();
|
||||
wrapper.in(CashOut::getState, 0, 4);
|
||||
wrapper.isNotNull(CashOut::getOrderNumber);
|
||||
wrapper.lt(CashOut::getCreateAt, time.toString());
|
||||
List<CashOut> cashOutList = esCashOutMapper.selectList(wrapper);
|
||||
return cashOutList.stream().filter(row -> !"".equals(row.getOrderNumber())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Double selectCashOutSum(Long userId, Date startTime, Date endTime) {
|
||||
LambdaEsQueryWrapper<CashOut> wrapper = new LambdaEsQueryWrapper<>();
|
||||
wrapper.select(CashOut::getMoney);
|
||||
wrapper.in(CashOut::getState, 0, 1);
|
||||
//wrapper.eq(CashOut::getUserId, userId);
|
||||
wrapper.ge(CashOut::getCreateAt, DateUtil.formatDate(startTime) + " 00:00:00");
|
||||
wrapper.le(CashOut::getCreateAt, DateUtil.formatDate(endTime) + " 23:59:59");
|
||||
List<CashOut> list = esCashOutMapper.selectList(wrapper);
|
||||
BigDecimal sumMoney = list.stream().map(obj-> Convert.toBigDecimal(obj.getMoney())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
return sumMoney.doubleValue();
|
||||
}
|
||||
|
||||
public Double selectSysUserCashOutSum(Long sysUserId, String time) {
|
||||
LambdaEsQueryWrapper<CashOut> wrapper = new LambdaEsQueryWrapper<>();
|
||||
wrapper.sum(CashOut::getMoney);
|
||||
if (sysUserId != null) {
|
||||
wrapper.eq(CashOut::getSysUserId, sysUserId);
|
||||
}
|
||||
wrapper.in(CashOut::getUserType, 2);
|
||||
wrapper.ge(CashOut::getCreateAt, time);
|
||||
SearchResponse search = esCashOutMapper.search(wrapper);
|
||||
JSONObject data = JSONUtil.parseObj(search.getAggregations().getAsMap());
|
||||
BigDecimal sumMoney = data.getJSONObject("moneySum").getBigDecimal("value");
|
||||
return sumMoney.doubleValue();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
LocalDate date = LocalDate.now().plusDays(-1);
|
||||
System.out.println(date + " 00:00:00");
|
||||
DateTime dateTime = DateUtil.offsetMinute(DateUtil.date(), 15);
|
||||
System.out.println(dateTime.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
package com.sqx.modules.es.dao;
|
||||
|
||||
import com.sqx.modules.course.dao.CourseCollectDao;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import com.sqx.modules.course.entity.CourseCollect;
|
||||
import com.sqx.modules.es.mapper.EsCourseCollectMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tankaikai
|
||||
* @since 2025-01-16 15:19
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class EsCourseCollectDao {
|
||||
private final EsCourseCollectMapper esCourseCollectMapper;
|
||||
|
||||
private final CourseCollectDao courseCollectDao;
|
||||
|
||||
public EsCourseCollectMapper getBaseEsMapper() {
|
||||
return this.esCourseCollectMapper;
|
||||
}
|
||||
|
||||
public CourseCollectDao getOriginalDao() {
|
||||
return this.courseCollectDao;
|
||||
}
|
||||
|
||||
|
||||
public List<Course> selectClassify2(Long userId) {
|
||||
List<CourseCollect> list = esCourseCollectMapper.selectList(new LambdaEsQueryWrapper<CourseCollect>()
|
||||
.select(CourseCollect::getCourseId, CourseCollect::getCourseDetailsId, CourseCollect::getUpdateTime)
|
||||
.eq(CourseCollect::getClassify, 2)
|
||||
.eq(CourseCollect::getUserId, userId)
|
||||
);
|
||||
List<Course> ret = new ArrayList<>();
|
||||
list.parallelStream().forEach(courseCollect -> {
|
||||
Course course = new Course();
|
||||
course.setCourseId(courseCollect.getCourseId());
|
||||
course.setCourseDetailsId(courseCollect.getCourseDetailsId());
|
||||
course.setUpdateTime(courseCollect.getUpdateTime());
|
||||
ret.add(course);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<Course> selectClassify3ByUserId(Long userId) {
|
||||
List<CourseCollect> list = esCourseCollectMapper.selectList(new LambdaEsQueryWrapper<CourseCollect>()
|
||||
.select(CourseCollect::getCourseId, CourseCollect::getCourseDetailsId, CourseCollect::getUpdateTime)
|
||||
.eq(CourseCollect::getClassify, 3)
|
||||
.eq(CourseCollect::getUserId, userId)
|
||||
);
|
||||
List<Course> ret = new ArrayList<>();
|
||||
list.parallelStream().forEach(courseCollect -> {
|
||||
Course course = new Course();
|
||||
course.setCourseId(courseCollect.getCourseId());
|
||||
course.setCourseDetailsId(courseCollect.getCourseDetailsId());
|
||||
course.setUpdateTime(courseCollect.getUpdateTime());
|
||||
ret.add(course);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.sqx.modules.es.dao;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.sqx.modules.discSpinning.dao.DiscSpinningRecordDao;
|
||||
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
|
||||
import com.sqx.modules.es.mapper.EsDiscSpinningRecordMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
|
||||
import org.dromara.easyes.core.kernel.EsWrappers;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author tankaikai
|
||||
* @since 2025-01-15 18:29
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class EsDiscSpinningRecordDao {
|
||||
|
||||
private final EsDiscSpinningRecordMapper esDiscSpinningRecordMapper;
|
||||
|
||||
private final DiscSpinningRecordDao discSpinningRecordDao;
|
||||
|
||||
public EsDiscSpinningRecordMapper getBaseEsMapper() {
|
||||
return this.esDiscSpinningRecordMapper;
|
||||
}
|
||||
|
||||
public DiscSpinningRecordDao getOriginalDao() {
|
||||
return this.discSpinningRecordDao;
|
||||
}
|
||||
|
||||
public int countDraw(Long userId){
|
||||
LambdaEsQueryWrapper<DiscSpinningRecord> wrapper = EsWrappers.lambdaQuery(DiscSpinningRecord.class)
|
||||
.eq(DiscSpinningRecord::getUserId, userId)
|
||||
.eq(DiscSpinningRecord::getSource, "order")
|
||||
.eq(DiscSpinningRecord::getDrawDay, DateUtil.today());
|
||||
Long count = esDiscSpinningRecordMapper.selectCount(wrapper);
|
||||
return count == null ? 0 : count.intValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.sqx.modules.es.dao;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.sqx.modules.es.mapper.EsOrdersMapper;
|
||||
import com.sqx.modules.orders.dao.OrdersDao;
|
||||
import com.sqx.modules.orders.entity.Orders;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author tankaikai
|
||||
* @since 2025-01-16 11:46
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class EsOrdersDao {
|
||||
private final EsOrdersMapper esOrdersMapper;
|
||||
|
||||
private final OrdersDao ordersDao;
|
||||
|
||||
public EsOrdersMapper getBaseEsMapper() {
|
||||
return this.esOrdersMapper;
|
||||
}
|
||||
|
||||
public OrdersDao getOriginalDao() {
|
||||
return this.ordersDao;
|
||||
}
|
||||
|
||||
public String selectMaxCode(String newData) {
|
||||
String indexName = esOrdersMapper.getIndex().getMappings().keySet().stream().findFirst().get();
|
||||
Map<String, Object> params = MapUtil.<String, Object>builder().put("indexName", indexName).put("newData", newData).build();
|
||||
String sql = StrUtil.format("select max(orders_no) code from {indexName} where orders_no like '%{newData}%'", params);
|
||||
String jsonResult = esOrdersMapper.executeSQL(sql);
|
||||
// {"columns":[{"name":"code","type":"text"}],"rows":[["1000002138610995"]]}
|
||||
// {"columns":[{"name":"code","type":"text"}],"rows":[[null]]}
|
||||
String maxCode = JSONUtil.parseObj(jsonResult).getJSONArray("rows").getJSONArray(0).getStr(0);
|
||||
return maxCode;
|
||||
}
|
||||
|
||||
public Orders selectOrdersByCourseIdAndUserId(Long userId, Long courseId){
|
||||
Orders orders = esOrdersMapper.selectOne(new LambdaEsQueryWrapper<Orders>()
|
||||
.eq(Orders::getUserId, userId)
|
||||
.eq(Orders::getCourseId, courseId)
|
||||
.eq(Orders::getStatus, 1)
|
||||
.orderByDesc(Orders::getCreateTime)
|
||||
.limit(1)
|
||||
);
|
||||
return orders;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
package com.sqx.modules.es.dao;
|
||||
|
||||
import com.sqx.modules.es.mapper.EsPayDetailsMapper;
|
||||
import com.sqx.modules.pay.dao.PayDetailsDao;
|
||||
import com.sqx.modules.pay.entity.PayDetails;
|
||||
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author tankaikai
|
||||
* @since 2025-01-15 18:29
|
||||
*/
|
||||
@Component
|
||||
public class EsPayDetailDao {
|
||||
|
||||
@Resource
|
||||
private EsPayDetailsMapper baseEsMapper;
|
||||
|
||||
@Resource
|
||||
private PayDetailsDao originalDao;
|
||||
|
||||
public EsPayDetailsMapper getBaseEsMapper() {
|
||||
return this.baseEsMapper;
|
||||
}
|
||||
|
||||
public PayDetailsDao getOriginalDao() {
|
||||
return this.originalDao;
|
||||
}
|
||||
|
||||
public PayDetails selectByRemark(String remark) {
|
||||
return baseEsMapper.selectOne(new LambdaEsQueryWrapper<PayDetails>().eq(PayDetails::getRemark, remark));
|
||||
}
|
||||
|
||||
|
||||
public PayDetails selectByOrderId(String orderId) {
|
||||
return baseEsMapper.selectOne(new LambdaEsQueryWrapper<PayDetails>().eq(PayDetails::getOrderId, orderId));
|
||||
}
|
||||
|
||||
|
||||
public PayDetails selectOneByLimit(String orderId) {
|
||||
return baseEsMapper.selectOne(new LambdaEsQueryWrapper<PayDetails>().eq(PayDetails::getOrderId, orderId).orderByDesc(PayDetails::getId).limit(1));
|
||||
}
|
||||
|
||||
|
||||
public PayDetails selectByTradeNo(String tradeNo) {
|
||||
return baseEsMapper.selectOne(new LambdaEsQueryWrapper<PayDetails>().eq(PayDetails::getTradeNo, tradeNo));
|
||||
}
|
||||
|
||||
|
||||
public int selectPayCount(Long userId) {
|
||||
Long count = baseEsMapper.selectCount(new LambdaEsQueryWrapper<PayDetails>().eq(PayDetails::getState, 1).eq(PayDetails::getUserId, userId));
|
||||
return count == null ? 0 : count.intValue();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
package com.sqx.modules.es.dao;
|
||||
|
||||
import com.sqx.modules.es.mapper.EsPayDetailsMapper;
|
||||
import com.sqx.modules.pay.dao.PayDetailsDao;
|
||||
import com.sqx.modules.pay.entity.PayDetails;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author tankaikai
|
||||
* @since 2025-01-15 18:29
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class EsPayDetailsDao {
|
||||
|
||||
private final EsPayDetailsMapper esPayDetailsMapper;
|
||||
|
||||
private final PayDetailsDao payDetailsDao;
|
||||
|
||||
public EsPayDetailsMapper getBaseEsMapper() {
|
||||
return this.esPayDetailsMapper;
|
||||
}
|
||||
|
||||
public PayDetailsDao getOriginalDao() {
|
||||
return this.payDetailsDao;
|
||||
}
|
||||
|
||||
public PayDetails selectByRemark(String remark) {
|
||||
return esPayDetailsMapper.selectOne(new LambdaEsQueryWrapper<PayDetails>().eq(PayDetails::getRemark, remark));
|
||||
}
|
||||
|
||||
|
||||
public PayDetails selectByOrderId(String orderId) {
|
||||
return esPayDetailsMapper.selectOne(new LambdaEsQueryWrapper<PayDetails>().eq(PayDetails::getOrderId, orderId));
|
||||
}
|
||||
|
||||
|
||||
public PayDetails selectOneByLimit(String orderId) {
|
||||
return esPayDetailsMapper.selectOne(new LambdaEsQueryWrapper<PayDetails>().eq(PayDetails::getOrderId, orderId).orderByDesc(PayDetails::getId).limit(1));
|
||||
}
|
||||
|
||||
|
||||
public PayDetails selectByTradeNo(String tradeNo) {
|
||||
return esPayDetailsMapper.selectOne(new LambdaEsQueryWrapper<PayDetails>().eq(PayDetails::getTradeNo, tradeNo));
|
||||
}
|
||||
|
||||
|
||||
public int selectPayCount(Long userId) {
|
||||
Long count = esPayDetailsMapper.selectCount(new LambdaEsQueryWrapper<PayDetails>().eq(PayDetails::getState, 1).eq(PayDetails::getUserId, userId));
|
||||
return count == null ? 0 : count.intValue();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.sqx.modules.es.dao;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.sqx.modules.app.dao.UserMoneyDetailsDao;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import com.sqx.modules.es.mapper.EsUserMoneyDetailsMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
|
||||
import org.dromara.easyes.core.kernel.EsWrappers;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author tankaikai
|
||||
* @since 2025-01-16 15:19
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class EsUserMoneyDetailsDao {
|
||||
private final EsUserMoneyDetailsMapper esUserMoneyDetailsMapper;
|
||||
|
||||
private final UserMoneyDetailsDao userMoneyDetailsDao;
|
||||
|
||||
public EsUserMoneyDetailsMapper getBaseEsMapper() {
|
||||
return this.esUserMoneyDetailsMapper;
|
||||
}
|
||||
|
||||
public UserMoneyDetailsDao getOriginalDao() {
|
||||
return this.userMoneyDetailsDao;
|
||||
}
|
||||
|
||||
public Double monthIncome(String date, Long userId) {
|
||||
LambdaEsQueryWrapper<UserMoneyDetails> wrapper = EsWrappers.lambdaQuery(UserMoneyDetails.class)
|
||||
.sum(UserMoneyDetails::getMoney)
|
||||
.eq(UserMoneyDetails::getUserId, userId)
|
||||
.eq(UserMoneyDetails::getClassify, 4)
|
||||
.eq(UserMoneyDetails::getType, 2)
|
||||
.eq(UserMoneyDetails::getState, 2)
|
||||
.likeRight(UserMoneyDetails::getCreateTime, DateUtil.parseDate(date).toString("yyyy-MM"));
|
||||
SearchResponse search = esUserMoneyDetailsMapper.search(wrapper);
|
||||
JSONObject data = JSONUtil.parseObj(search.getAggregations().getAsMap());
|
||||
BigDecimal sumMoney = data.getJSONObject("moneySum").getBigDecimal("value");
|
||||
return sumMoney.doubleValue();
|
||||
}
|
||||
|
||||
public Double queryUserInviteMoney(Long userId) {
|
||||
LambdaEsQueryWrapper<UserMoneyDetails> wrapper = EsWrappers.lambdaQuery(UserMoneyDetails.class)
|
||||
.sum(UserMoneyDetails::getMoney)
|
||||
.eq(UserMoneyDetails::getUserId, userId)
|
||||
.in(UserMoneyDetails::getClassify, 1, 6)
|
||||
.eq(UserMoneyDetails::getType, 1)
|
||||
.eq(UserMoneyDetails::getState, 2)
|
||||
.eq(UserMoneyDetails::getMoneyType, 1);
|
||||
SearchResponse search = esUserMoneyDetailsMapper.search(wrapper);
|
||||
JSONObject data = JSONUtil.parseObj(search.getAggregations().getAsMap());
|
||||
BigDecimal sumMoney = data.getJSONObject("moneySum").getBigDecimal("value");
|
||||
return sumMoney.doubleValue();
|
||||
}
|
||||
|
||||
public Double queryUserInviteGoldMoney(Long userId) {
|
||||
LambdaEsQueryWrapper<UserMoneyDetails> wrapper = EsWrappers.lambdaQuery(UserMoneyDetails.class)
|
||||
.sum(UserMoneyDetails::getMoney)
|
||||
.eq(UserMoneyDetails::getUserId, userId)
|
||||
.in(UserMoneyDetails::getClassify, 1, 6)
|
||||
.eq(UserMoneyDetails::getType, 1)
|
||||
.eq(UserMoneyDetails::getState, 2)
|
||||
.eq(UserMoneyDetails::getMoneyType, 2);
|
||||
//List<UserMoneyDetails> list = esUserMoneyDetailsMapper.selectList(wrapper);
|
||||
//BigDecimal sumMoney = list.stream().collect(Collectors.reducing(BigDecimal.ZERO, UserMoneyDetails::getMoney, BigDecimal::add));
|
||||
SearchResponse search = esUserMoneyDetailsMapper.search(wrapper);
|
||||
JSONObject data = JSONUtil.parseObj(search.getAggregations().getAsMap());
|
||||
BigDecimal sumMoney = data.getJSONObject("moneySum").getBigDecimal("value");
|
||||
return sumMoney.doubleValue();
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
** Dao层实现MyBatis中ES可以实现的查询方法
|
||||
|
|
@ -20,10 +20,10 @@ import com.sqx.modules.pay.entity.CashOut;
|
|||
import com.sqx.modules.pay.entity.PayDetails;
|
||||
import com.sqx.modules.taskCenter.dao.TaskCenterRecordDao;
|
||||
import com.sqx.modules.taskCenter.entity.TaskCenterRecord;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
|
@ -34,45 +34,30 @@ import java.util.concurrent.CompletableFuture;
|
|||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class EsCoreServiceImpl implements EsCoreService {
|
||||
|
||||
@Resource
|
||||
private OrdersDao ordersDao;
|
||||
@Resource
|
||||
private CashOutDao cashOutDao;
|
||||
@Resource
|
||||
private CourseCollectDao courseCollectDao;
|
||||
@Resource
|
||||
private CourseUserDao courseUserDao;
|
||||
@Resource
|
||||
private DiscSpinningRecordDao discSpinningRecordDao;
|
||||
@Resource
|
||||
private PayDetailsDao payDetailsDao;
|
||||
@Resource
|
||||
private UserMoneyDetailsDao userMoneyDetailsDao;
|
||||
@Resource
|
||||
private TaskCenterRecordDao taskCenterRecordDao;
|
||||
private final OrdersDao ordersDao;
|
||||
private final CashOutDao cashOutDao;
|
||||
private final CourseCollectDao courseCollectDao;
|
||||
private final CourseUserDao courseUserDao;
|
||||
private final DiscSpinningRecordDao discSpinningRecordDao;
|
||||
private final PayDetailsDao payDetailsDao;
|
||||
private final UserMoneyDetailsDao userMoneyDetailsDao;
|
||||
private final TaskCenterRecordDao taskCenterRecordDao;
|
||||
|
||||
@Resource
|
||||
private EsOrdersMapper esOrdersMapper;
|
||||
private final EsOrdersMapper esOrdersMapper;
|
||||
|
||||
@Resource
|
||||
private EsCashOutMapper esCashOutMapper;
|
||||
private final EsCashOutMapper esCashOutMapper;
|
||||
|
||||
@Resource
|
||||
private EsCourseCollectMapper esCourseCollectMapper;
|
||||
private final EsCourseCollectMapper esCourseCollectMapper;
|
||||
|
||||
@Resource
|
||||
private EsCourseUserMapper esCourseUserMapper;
|
||||
@Resource
|
||||
private EsDiscSpinningRecordMapper esDiscSpinningRecordMapper;
|
||||
@Resource
|
||||
private EsPayDetailsMapper esPayDetailsMapper;
|
||||
private final EsCourseUserMapper esCourseUserMapper;
|
||||
private final EsDiscSpinningRecordMapper esDiscSpinningRecordMapper;
|
||||
private final EsPayDetailsMapper esPayDetailsMapper;
|
||||
|
||||
@Resource
|
||||
private EsUserMoneyDetailsMapper esUserMoneyDetailsMapper;
|
||||
@Resource
|
||||
private EsTaskCenterRecordMapper esTaskCenterRecordMapper;
|
||||
private final EsUserMoneyDetailsMapper esUserMoneyDetailsMapper;
|
||||
private final EsTaskCenterRecordMapper esTaskCenterRecordMapper;
|
||||
|
||||
@Override
|
||||
public void sync() {
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import lombok.Data;
|
||||
import org.dromara.easyes.annotation.IndexField;
|
||||
import org.dromara.easyes.annotation.IndexId;
|
||||
import org.dromara.easyes.annotation.IndexName;
|
||||
import org.dromara.easyes.annotation.rely.FieldType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -60,6 +62,7 @@ public class Orders implements Serializable {
|
|||
private String courseDetailsIds;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
/**
|
||||
* 短剧对象
|
||||
*/
|
||||
|
|
@ -84,6 +87,7 @@ public class Orders implements Serializable {
|
|||
*/
|
||||
private Integer payWay;
|
||||
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String payTime;
|
||||
|
||||
|
||||
|
|
@ -95,6 +99,7 @@ public class Orders implements Serializable {
|
|||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String createTime;
|
||||
/**
|
||||
* 退款原因
|
||||
|
|
@ -143,15 +148,19 @@ public class Orders implements Serializable {
|
|||
private Long twoUserId;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private String title;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private String userName;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private String qdCode;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private String sysUserName;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import org.dromara.easyes.annotation.IndexField;
|
||||
import org.dromara.easyes.annotation.IndexId;
|
||||
import org.dromara.easyes.annotation.IndexName;
|
||||
import org.dromara.easyes.annotation.rely.FieldType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -37,11 +39,13 @@ public class CashOut implements Serializable {
|
|||
/**
|
||||
* 申请时间
|
||||
*/
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String createAt;
|
||||
|
||||
/**
|
||||
* 是否转账
|
||||
*/
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String outAt;
|
||||
|
||||
/**
|
||||
|
|
@ -112,45 +116,54 @@ public class CashOut implements Serializable {
|
|||
private Integer userType;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private String startTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private String endTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private Integer status;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private String sysUserName;
|
||||
|
||||
/**
|
||||
* 是否同意提现 0不同意 1同意
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private Integer isAgree;
|
||||
|
||||
/**
|
||||
* 成功提现金额总和
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private BigDecimal total;
|
||||
|
||||
/**
|
||||
* 成功提现次数
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long count;
|
||||
/**
|
||||
* 待复审金额
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private BigDecimal verifyTotal;
|
||||
|
||||
/**
|
||||
* 待复审笔数
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long verifyCount;
|
||||
|
||||
|
|
@ -160,6 +173,7 @@ public class CashOut implements Serializable {
|
|||
* 提现金币
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private BigDecimal convertMoney;
|
||||
|
||||
public BigDecimal getConvertMoney() {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import org.dromara.easyes.annotation.IndexField;
|
||||
import org.dromara.easyes.annotation.IndexId;
|
||||
import org.dromara.easyes.annotation.IndexName;
|
||||
import org.dromara.easyes.annotation.rely.FieldType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -71,11 +73,13 @@ public class PayDetails implements Serializable {
|
|||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 支付时间
|
||||
*/
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String payTime;
|
||||
|
||||
/**
|
||||
|
|
@ -95,9 +99,11 @@ public class PayDetails implements Serializable {
|
|||
private Integer diamond;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private String refundContent;
|
||||
|
||||
@TableField(exist = false)
|
||||
@IndexField(exist = false)
|
||||
private String outRequestNo;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
|||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.dromara.easyes.annotation.IndexField;
|
||||
import org.dromara.easyes.annotation.IndexId;
|
||||
import org.dromara.easyes.annotation.IndexName;
|
||||
import org.dromara.easyes.annotation.rely.FieldType;
|
||||
|
||||
/**
|
||||
* 任务领取记录(TaskCenterRecord)表实体类
|
||||
|
|
@ -45,7 +47,9 @@ public class TaskCenterRecord extends Model<TaskCenterRecord> {
|
|||
private Long targetId;
|
||||
@ApiModelProperty("数量")
|
||||
private Integer number;
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String createTime;
|
||||
@IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd")
|
||||
private String updateTime;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue