统计订单总金额

This commit is contained in:
2025-08-04 07:09:01 +08:00
parent 7883a7291f
commit fe03c3cd01
9 changed files with 537 additions and 1 deletions

View File

@@ -18,6 +18,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -74,4 +75,17 @@ public class BszxOrderController extends BaseController {
return success(result);
}
@Operation(summary = "统计订单总金额")
@GetMapping("/total")
public ApiResult<BigDecimal> total() {
try {
BigDecimal totalAmount = bszxPayService.total();
return success(totalAmount);
} catch (Exception e) {
// 异常时返回0保持接口稳定性
return success(BigDecimal.ZERO);
}
}
}

View File

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.bszx.entity.BszxPay;
import com.gxwebsoft.bszx.param.BszxPayParam;
import com.gxwebsoft.project.entity.Project;
import java.math.BigDecimal;
import java.util.List;
@@ -48,4 +47,11 @@ public interface BszxPayService extends IService<BszxPay> {
String generatePayCert(Integer id) throws Exception;
BigDecimal sumMoney(LambdaQueryWrapper<BszxPay> between);
/**
* 统计捐款总金额
*
* @return 捐款总金额
*/
BigDecimal total();
}

View File

@@ -147,4 +147,23 @@ public class BszxPayServiceImpl extends ServiceImpl<BszxPayMapper, BszxPay> impl
public BigDecimal sumMoney(LambdaQueryWrapper<BszxPay> wrapper) {
return baseMapper.selectSumMoney(wrapper);
}
@Override
public BigDecimal total() {
try {
// 使用数据库聚合查询统计捐款总金额,性能更高
LambdaQueryWrapper<BszxPay> wrapper = new LambdaQueryWrapper<>();
BigDecimal total = baseMapper.selectSumMoney(wrapper);
if (total == null) {
total = BigDecimal.ZERO;
}
return total;
} catch (Exception e) {
// 异常时返回0确保接口稳定性
return BigDecimal.ZERO;
}
}
}

View File

@@ -0,0 +1,32 @@
package com.gxwebsoft.shop.enums;
/**
* 订单状态枚举
*/
public enum OrderStatusEnum {
ALL(-1, "全部"),
WAIT_PAY(0, "待支付"),
WAIT_DELIVERY(1, "待发货"),
WAIT_CONFIRM(2, "待核销"),
WAIT_RECEIVE(3, "待收货"),
WAIT_EVALUATE(4, "待评价"),
COMPLETED(5, "已完成"),
REFUNDED(6, "已退款"),
DELETED(7, "已删除");
private final Integer code;
private final String desc;
OrderStatusEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
public String getDesc() {
return desc;
}
}

View File

@@ -249,4 +249,7 @@ public class ShopOrderParam extends BaseParam {
@QueryField(type = QueryType.EQ)
private Boolean hasTakeGift;
@Schema(description = "订单状态筛选:-1全部0待支付1待发货2待核销3待收货4待评价5已完成6已退款7已删除")
private Integer statusFilter;
}