|
|
@@ -2,9 +2,7 @@ package com.zhongshu.card.server.core.dao.payment.impl;
|
|
|
|
|
|
import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
|
|
|
import com.mongodb.client.MongoCollection;
|
|
|
-import com.zhongshu.card.client.model.payment.ExpenseFlowCount;
|
|
|
-import com.zhongshu.card.client.model.payment.ExpenseFlowSearch;
|
|
|
-import com.zhongshu.card.client.model.payment.ExpenseFlowUnionParam;
|
|
|
+import com.zhongshu.card.client.model.payment.*;
|
|
|
import com.zhongshu.card.client.type.payment.OrderType;
|
|
|
import com.zhongshu.card.server.core.dao.BaseImpl;
|
|
|
import com.zhongshu.card.server.core.dao.payment.extend.ExpenseFlowDaoExtend;
|
|
|
@@ -272,8 +270,121 @@ public class ExpenseFlowDaoImpl extends BaseImpl implements ExpenseFlowDaoExtend
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ public Page<ExpenseFlow> pageOrder(Pageable pageable, ExpenseFlowSearchParam param) {
|
|
|
+ Criteria criteria = new Criteria();
|
|
|
+ //交易时间
|
|
|
+ if (param.getStartTime() != null && param.getEndTime() == null) {
|
|
|
+ criteria.and("createTime").gte(param.getStartTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getStartTime() == null && param.getEndTime() != null) {
|
|
|
+ criteria.and("createTime").lte(param.getEndTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getStartTime() != null && param.getEndTime() != null) {
|
|
|
+ criteria.and("createTime").gte(param.getStartTime()).lte(param.getEndTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ //订单编号
|
|
|
+ if (StringUtils.isNotEmpty(param.getOrderNo())){
|
|
|
+ criteria.and("orderNo").is(param.getOrderNo());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(param.getProjectOid())){
|
|
|
+ criteria.and("projectOid").is(param.getProjectOid());
|
|
|
+ }
|
|
|
+
|
|
|
+ //支付编号
|
|
|
+ if (StringUtils.isNotEmpty(param.getPaymentNo())){
|
|
|
+ criteria.and("paymentNo").is(param.getPaymentNo());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getPaymentType() != null){
|
|
|
+ criteria.and("paymentType").is(param.getPaymentType());
|
|
|
+ }
|
|
|
+
|
|
|
+ //支付时间
|
|
|
+ if (param.getPayStartTime() != null && param.getPayEndTime() == null) {
|
|
|
+ criteria.and("payEndTime").gte(param.getPayStartTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getPayStartTime() == null && param.getPayEndTime() != null) {
|
|
|
+ criteria.and("payEndTime").lte(param.getPayEndTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getPayStartTime() != null && param.getPayEndTime() != null) {
|
|
|
+ criteria.and("payEndTime").gte(param.getPayStartTime()).lte(param.getPayEndTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ //支付金额
|
|
|
+ if (param.getPayAmount() != null){
|
|
|
+ criteria.and("payAmount").is(param.getPayAmount());
|
|
|
+ }
|
|
|
+
|
|
|
+ //订单状态
|
|
|
+ if (param.getOrderState() != null){
|
|
|
+ criteria.and("orderState").is(param.getOrderState());
|
|
|
+ }
|
|
|
+
|
|
|
+ //姓名
|
|
|
+ if (StringUtils.isNotEmpty(param.getUserName())){
|
|
|
+ Pattern userNamePattern = Pattern.compile("^.*" + param.getUserName() + ".*$");
|
|
|
+ criteria.and("paymentNo").is(userNamePattern);
|
|
|
+ }
|
|
|
+
|
|
|
+ //设备编号
|
|
|
+ if (StringUtils.isNotEmpty(param.getDeviceId())){
|
|
|
+ criteria.and("deviceId").is(param.getDeviceId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //设备类型
|
|
|
+ if (param.getDeviceType() != null){
|
|
|
+ criteria.and("deviceType").is(param.getDeviceType());
|
|
|
+ }
|
|
|
+
|
|
|
+ //区域
|
|
|
+ if (StringUtils.isNotEmpty(param.getAreaId())){
|
|
|
+ criteria.and("area.id").is(param.getAreaId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //是否退款
|
|
|
+ if (param.getIsRefund() != null){
|
|
|
+ criteria.and("isRefund").is(param.getIsRefund());
|
|
|
+ }
|
|
|
+
|
|
|
+ //退款编号
|
|
|
+ if (StringUtils.isNotEmpty(param.getRefundNo())){
|
|
|
+ criteria.and("refundNo").is(param.getRefundNo());
|
|
|
+ }
|
|
|
+
|
|
|
+ //退款金额
|
|
|
+ if (param.getRefundAmount() != null){
|
|
|
+ criteria.and("refundAMount").is(param.getRefundAmount());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getRefundState() != null){
|
|
|
+ criteria.and("refundState").is(param.getRefundState());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getRefundStartTime() != null && param.getRefundEndTime() == null) {
|
|
|
+ criteria.and("refundTime").gte(param.getRefundStartTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getRefundStartTime() == null && param.getRefundEndTime() != null) {
|
|
|
+ criteria.and("refundTime").lte(param.getRefundEndTime());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getRefundStartTime() != null && param.getRefundEndTime() != null) {
|
|
|
+ criteria.and("refundTime").gte(param.getRefundStartTime()).lte(param.getRefundEndTime());
|
|
|
+ }
|
|
|
+ Query query = new Query(criteria);
|
|
|
+ query.with(Sort.by(Sort.Direction.DESC, "createTime"));
|
|
|
+
|
|
|
+ return dbHelper.pages(query, pageable, ExpenseFlow.class);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
- public Page<ExpenseFlowUnionWithModel> unionWithRecharge(Pageable pageable, ExpenseFlowUnionParam param) {
|
|
|
+ public Page<OrderUnionWithModel> unionWithRecharge(Pageable pageable, ExpenseFlowUnionParam param) {
|
|
|
List<Document> createTimePipeline = new ArrayList<>();
|
|
|
|
|
|
// 开始时间过滤
|
|
|
@@ -298,16 +409,21 @@ public class ExpenseFlowDaoImpl extends BaseImpl implements ExpenseFlowDaoExtend
|
|
|
|
|
|
List<Document> unionWithPipeline = new ArrayList<>();
|
|
|
|
|
|
+ List<Document> unionWithMatch = new ArrayList<>();
|
|
|
+ if (!createTimePipeline.isEmpty()) {
|
|
|
+ unionWithMatch.addAll(createTimePipeline);
|
|
|
+ }
|
|
|
+ unionWithMatch.add(new Document()
|
|
|
+ .append("$addFields", new Document()
|
|
|
+ .append("type", OrderType.Recharge.name())
|
|
|
+ .append("payAmount", "$total")
|
|
|
+ ));
|
|
|
+
|
|
|
+
|
|
|
unionWithPipeline.add( new Document()
|
|
|
.append("$unionWith", new Document()
|
|
|
.append("coll", "balanceRechargeOrder")
|
|
|
- .append("pipeline", Arrays.asList(
|
|
|
- createTimePipeline,
|
|
|
- new Document()
|
|
|
- .append("$addFields", new Document()
|
|
|
- .append("type", OrderType.Recharge.name())
|
|
|
- )
|
|
|
- )
|
|
|
+ .append("pipeline", unionWithMatch
|
|
|
)
|
|
|
));
|
|
|
|
|
|
@@ -351,7 +467,7 @@ public class ExpenseFlowDaoImpl extends BaseImpl implements ExpenseFlowDaoExtend
|
|
|
count.set(Long.valueOf(String.valueOf(it.get("count"))));
|
|
|
});
|
|
|
|
|
|
- List<ExpenseFlowUnionWithModel> ret = new ArrayList<>();
|
|
|
+ List<OrderUnionWithModel> ret = new ArrayList<>();
|
|
|
collection.aggregate(new ArrayList<>() {{
|
|
|
addAll(pipeline);
|
|
|
add(new Document().append("$skip", pageable.getOffset()));
|
|
|
@@ -359,7 +475,7 @@ public class ExpenseFlowDaoImpl extends BaseImpl implements ExpenseFlowDaoExtend
|
|
|
}}) // 如果内存不够在启用磁盘
|
|
|
.allowDiskUse(false).forEach((document) -> {
|
|
|
Optional.ofNullable(document).ifPresent((it) -> {
|
|
|
- ret.add(this.mongoTemplate.getConverter().read(ExpenseFlowUnionWithModel.class, it));
|
|
|
+ ret.add(this.mongoTemplate.getConverter().read(OrderUnionWithModel.class, it));
|
|
|
});
|
|
|
});
|
|
|
return new PageImpl<>(ret, pageable, count.get());
|