财务报表
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.order.dto.FinanceStsDTO;
|
||||
import com.czg.order.param.FinanceStsQueryParam;
|
||||
import com.czg.order.service.FinanceStsService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 管理端/财务统计
|
||||
* @author yjjie
|
||||
* @date 2026/2/2 10:09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/finance")
|
||||
public class FinanceStsController {
|
||||
|
||||
@Resource
|
||||
private FinanceStsService financeStsService;
|
||||
|
||||
/**
|
||||
* 查询财务报表
|
||||
*/
|
||||
@GetMapping("/sts")
|
||||
public CzgResult<FinanceStsDTO> getFinanceSts(@Validated(FinanceStsQueryParam.Query.class) FinanceStsQueryParam param) {
|
||||
return CzgResult.success(financeStsService.getFinanceSts(param));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出财务报表
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
public void exportFinanceSts(@Validated(FinanceStsQueryParam.Export.class) FinanceStsQueryParam param, HttpServletResponse response) {
|
||||
financeStsService.exportFinanceSts(param, response);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.excel.ExcelExportUtil;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.order.entity.ShopTableOrderStatistic;
|
||||
import com.czg.order.param.DataSummaryTradeParam;
|
||||
import com.czg.order.param.TableSummaryParam;
|
||||
import com.czg.order.service.ShopTableOrderStatisticService;
|
||||
import com.czg.order.service.TableSummaryService;
|
||||
import com.czg.order.vo.TableSummaryExportVo;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
@@ -15,6 +15,12 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class ShopUserExportDTO {
|
||||
|
||||
/**
|
||||
* 主店铺Id
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private Long mainShopId;
|
||||
|
||||
@ExcelProperty("手机号")
|
||||
private String phone;
|
||||
|
||||
@@ -99,18 +105,14 @@ public class ShopUserExportDTO {
|
||||
}
|
||||
|
||||
public String getDistributionShopsRemark() {
|
||||
if (StrUtil.isBlank(distributionShops) || !distributionShops.contains("_")) {
|
||||
if (StrUtil.isBlank(distributionShops)) {
|
||||
return "否";
|
||||
}
|
||||
|
||||
String[] split = distributionShops.split("_");
|
||||
if (split.length < 2) {
|
||||
return "否";
|
||||
}
|
||||
if ("0".equals(split[1])) {
|
||||
return "否";
|
||||
if (distributionShops.contains(mainShopId + "_1")) {
|
||||
return "是";
|
||||
}
|
||||
|
||||
return "是";
|
||||
return "否";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,258 @@
|
||||
package com.czg.order.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 财务统计数据
|
||||
* @author yjjie
|
||||
* @date 2026/2/2 09:34
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class FinanceStsDTO {
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
private String date;
|
||||
|
||||
/**
|
||||
* 营业额
|
||||
*/
|
||||
private TurnoverSts turnover;
|
||||
|
||||
/**
|
||||
* 订单
|
||||
*/
|
||||
private OrderSts order;
|
||||
|
||||
/**
|
||||
* 优惠金额
|
||||
*/
|
||||
private DiscountSts discount;
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
private RefundSts refund;
|
||||
|
||||
/**
|
||||
* 数据统计
|
||||
*/
|
||||
private Sts sts;
|
||||
|
||||
/**
|
||||
* 营业额 类
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class TurnoverSts {
|
||||
|
||||
/**
|
||||
* 营业额
|
||||
*/
|
||||
private BigDecimal turnover;
|
||||
|
||||
/**
|
||||
* 微信支付金额
|
||||
*/
|
||||
private BigDecimal wechat;
|
||||
|
||||
/**
|
||||
* 支付宝支付金额
|
||||
*/
|
||||
private BigDecimal alipay;
|
||||
|
||||
/**
|
||||
* 主扫收款
|
||||
*/
|
||||
private BigDecimal selfScan;
|
||||
|
||||
/**
|
||||
* 现金收款
|
||||
*/
|
||||
private BigDecimal cash;
|
||||
|
||||
/**
|
||||
* 充值
|
||||
*/
|
||||
private BigDecimal recharge;
|
||||
|
||||
/**
|
||||
* 挂账
|
||||
*/
|
||||
private BigDecimal owed;
|
||||
|
||||
/**
|
||||
* 余额支付
|
||||
*/
|
||||
private BigDecimal balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单 类
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class OrderSts {
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
/**
|
||||
* 订单总数
|
||||
*/
|
||||
private Long orderCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优惠金额 类
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class DiscountSts {
|
||||
/**
|
||||
* 优惠金额
|
||||
*/
|
||||
private BigDecimal discountAmount;
|
||||
|
||||
/**
|
||||
* 优惠笔数
|
||||
*/
|
||||
private Long discountCount;
|
||||
|
||||
/**
|
||||
* 新客立减
|
||||
*/
|
||||
private BigDecimal newConsumerDiscount;
|
||||
|
||||
/**
|
||||
* 霸王餐
|
||||
*/
|
||||
private BigDecimal freeCashAmount;
|
||||
|
||||
/**
|
||||
* 满减活动
|
||||
*/
|
||||
private BigDecimal fullMinusAmount;
|
||||
|
||||
/**
|
||||
* 优惠券
|
||||
*/
|
||||
private BigDecimal couponAmount;
|
||||
|
||||
/**
|
||||
* 会员折扣
|
||||
*/
|
||||
private BigDecimal memberDiscount;
|
||||
|
||||
/**
|
||||
* 积分抵扣金额
|
||||
*/
|
||||
private BigDecimal pointsDiscountAmount;
|
||||
|
||||
/**
|
||||
* 订单改价
|
||||
*/
|
||||
private BigDecimal orderDiscount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款 类
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class RefundSts {
|
||||
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
/**
|
||||
* 线上退款金额
|
||||
*/
|
||||
private BigDecimal onlineRefundAmount;
|
||||
|
||||
/**
|
||||
* 现金退款金额
|
||||
*/
|
||||
private BigDecimal cashRefundAmount;
|
||||
|
||||
/**
|
||||
* 充值退款金额
|
||||
*/
|
||||
private BigDecimal rechargeRefundAmount;
|
||||
|
||||
/**
|
||||
* 线上充值退款金额
|
||||
*/
|
||||
private BigDecimal onlineRechargeRefundAmount;
|
||||
|
||||
/**
|
||||
* 现金充值退款金额
|
||||
*/
|
||||
private BigDecimal cashRechargeRefundAmount;
|
||||
|
||||
/**
|
||||
* 会员退款金额
|
||||
*/
|
||||
private BigDecimal memberRefundAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据统计 类
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class Sts {
|
||||
/**
|
||||
* 就餐人数
|
||||
*/
|
||||
private Long customerCount;
|
||||
/**
|
||||
* 订单数
|
||||
*/
|
||||
private Long orderCount;
|
||||
/**
|
||||
* 桌台数
|
||||
*/
|
||||
private Long tableCount;
|
||||
/**
|
||||
* 客单价
|
||||
* 实付金额(包含现金支付 包含会员支付 包含挂账)/就餐人数
|
||||
* 没有具体人数时,默认一桌按照1人计算
|
||||
*/
|
||||
private BigDecimal avgPayAmount;
|
||||
/**
|
||||
* 翻台率
|
||||
* (订单数-桌台数)/桌台数*100%
|
||||
*/
|
||||
private BigDecimal turnoverRate;
|
||||
|
||||
/**
|
||||
* 毛利润(订单实付金额-商品成本)
|
||||
*/
|
||||
private BigDecimal profitAmount;
|
||||
/**
|
||||
* 商品成本
|
||||
*/
|
||||
private BigDecimal productCostAmount;
|
||||
/**
|
||||
* 毛利率(订单实付金额-商品成本)/订单实付金额*100%
|
||||
*/
|
||||
private BigDecimal profitRate;
|
||||
/**
|
||||
* 净利润
|
||||
*/
|
||||
private BigDecimal netProfitAmount;
|
||||
/**
|
||||
* 净利润率
|
||||
*/
|
||||
private BigDecimal netProfitRate;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.czg.order.entity;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnore;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -105,249 +107,309 @@ public class ShopOrderStatistic implements Serializable {
|
||||
* 主键ID
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
@ExcelIgnore
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private Long shopId;
|
||||
/**
|
||||
* 统计日期 yyyy-MM-dd
|
||||
*/
|
||||
@ExcelProperty("统计日期")
|
||||
@ColumnWidth(17)
|
||||
private LocalDate statisticDate;
|
||||
//*********************以下为订单金额********************************************************************************
|
||||
|
||||
/**
|
||||
* 订单金额 订单原金额
|
||||
*/
|
||||
@ExcelProperty("订单金额")
|
||||
private BigDecimal originAmount;
|
||||
|
||||
/**
|
||||
* 实付金额 (线上付款 现金支付 会员支付 挂账)
|
||||
*/
|
||||
@ExcelProperty("实付金额")
|
||||
private BigDecimal payAmount;
|
||||
/**
|
||||
* 线上付款金额
|
||||
*/
|
||||
private BigDecimal onlinePayAmount;
|
||||
/**
|
||||
* 订单退款 退款金额(原路返回 现金退款)
|
||||
*/
|
||||
private BigDecimal refundAmount;
|
||||
/**
|
||||
* 订单退款 线上退款金额
|
||||
*/
|
||||
private BigDecimal onlineRefundAmount;
|
||||
/**
|
||||
* 订单退款 线下退款金额/现金退款金额
|
||||
*/
|
||||
private BigDecimal cashRefundAmount;
|
||||
/**
|
||||
* 订单退款 会员退款金额
|
||||
*/
|
||||
private BigDecimal memberRefundAmount;
|
||||
|
||||
/**
|
||||
* 会员消费 会员订单支付金额
|
||||
*/
|
||||
private BigDecimal memberPayAmount;
|
||||
/**
|
||||
* 会员消费笔数
|
||||
*/
|
||||
private Long memberPayCount;
|
||||
|
||||
|
||||
//*********************以下为充值金额********************************************************************************
|
||||
/**
|
||||
* 会员充值 充值金额(包含现金支付) 不包括赠送 多店 按 主店算
|
||||
*/
|
||||
private BigDecimal rechargeAmount;
|
||||
/**
|
||||
* 会员充值 线上充值金额
|
||||
*/
|
||||
private BigDecimal onlineRechargeAmount;
|
||||
/**
|
||||
* 会员充值 现金充值金额
|
||||
*/
|
||||
private BigDecimal cashRechargeAmount;
|
||||
/**
|
||||
* 会员充值 充值赠送金额
|
||||
*/
|
||||
private BigDecimal giveAmount;
|
||||
|
||||
/**
|
||||
* 会员充值退款 充值退款金额(线上退款+现金退款)
|
||||
*/
|
||||
private BigDecimal rechargeRefundAmount;
|
||||
/**
|
||||
* 会员充值退款 线上退款
|
||||
*/
|
||||
private BigDecimal onlineRechargeRefundAmount;
|
||||
/**
|
||||
* 会员充值退款 现金退款金额
|
||||
*/
|
||||
private BigDecimal cashRechargeRefundAmount;
|
||||
/**
|
||||
* 新增会员数
|
||||
*/
|
||||
private Long newMemberCount;
|
||||
|
||||
|
||||
//*********************以下为客单价 翻台率 的计算********************************************************************************
|
||||
/**
|
||||
* 就餐人数
|
||||
*/
|
||||
private Long customerCount;
|
||||
/**
|
||||
* 订单数
|
||||
*/
|
||||
private Long orderCount;
|
||||
/**
|
||||
* 桌台数
|
||||
*/
|
||||
private Long tableCount;
|
||||
/**
|
||||
* 客单价
|
||||
* 实付金额(包含现金支付 包含会员支付 包含挂账)/就餐人数
|
||||
* 没有具体人数时,默认一桌按照1人计算
|
||||
*/
|
||||
private BigDecimal avgPayAmount;
|
||||
/**
|
||||
* 翻台率
|
||||
* (订单数-桌台数)/桌台数*100%
|
||||
*/
|
||||
private BigDecimal turnoverRate;
|
||||
|
||||
/**
|
||||
* 毛利润(订单实付金额-商品成本)
|
||||
*/
|
||||
private BigDecimal profitAmount;
|
||||
/**
|
||||
* 商品成本
|
||||
*/
|
||||
private BigDecimal productCostAmount;
|
||||
/**
|
||||
* 毛利率(订单实付金额-商品成本)/订单实付金额*100%
|
||||
*/
|
||||
private BigDecimal profitRate;
|
||||
/**
|
||||
* 净利润
|
||||
*/
|
||||
private BigDecimal netProfitAmount;
|
||||
/**
|
||||
* 净利润率
|
||||
*/
|
||||
private BigDecimal netProfitRate;
|
||||
|
||||
|
||||
//*********************以下为优惠金额********************************************************************************
|
||||
/**
|
||||
* 优惠总金额
|
||||
*/
|
||||
private BigDecimal discountAmount;
|
||||
/**
|
||||
* 优惠笔数
|
||||
*/
|
||||
private Long discountCount;
|
||||
|
||||
/**
|
||||
* 新客立减金额
|
||||
*/
|
||||
private BigDecimal newCustomerDiscountAmount;
|
||||
/**
|
||||
* 满减活动金额
|
||||
*/
|
||||
private BigDecimal fullDiscountAmount;
|
||||
/**
|
||||
* 优惠券抵扣金额
|
||||
*/
|
||||
private BigDecimal couponDiscountAmount;
|
||||
/**
|
||||
* 积分抵扣金额
|
||||
*/
|
||||
private BigDecimal pointDiscountAmount;
|
||||
/**
|
||||
* 霸王餐金额
|
||||
*/
|
||||
private BigDecimal backDiscountAmount;
|
||||
/**
|
||||
* 会员整单折扣金额
|
||||
*/
|
||||
private BigDecimal memberDiscountAmount;
|
||||
/**
|
||||
* 订单改价金额
|
||||
*/
|
||||
private BigDecimal orderPriceDiscountAmount;
|
||||
|
||||
|
||||
//*********************以下为支付金额********************************************************************************
|
||||
/**
|
||||
* 现金支付金额
|
||||
*/
|
||||
@ExcelProperty("现金支付金额")
|
||||
private BigDecimal cashPayAmount;
|
||||
/**
|
||||
* 现金支付笔数
|
||||
*/
|
||||
@ExcelProperty("现金支付笔数")
|
||||
private Long cashPayCount;
|
||||
/**
|
||||
* 微信小程序支付金额
|
||||
*/
|
||||
@ExcelProperty("微信小程序支付金额")
|
||||
private BigDecimal wechatPayAmount;
|
||||
/**
|
||||
/**
|
||||
* 微信小程序支付笔数
|
||||
*/
|
||||
@ExcelProperty("微信小程序支付笔数")
|
||||
private Long wechatPayCount;
|
||||
/**
|
||||
* 支付宝小程序支付金额
|
||||
*/
|
||||
@ExcelProperty("支付宝小程序支付金额")
|
||||
private BigDecimal alipayPayAmount;
|
||||
/**
|
||||
/**
|
||||
* 支付宝小程序支付笔数
|
||||
*/
|
||||
@ExcelProperty("支付宝小程序支付笔数")
|
||||
private Long alipayPayCount;
|
||||
/**
|
||||
* 被扫收款金额
|
||||
*/
|
||||
@ExcelProperty("被扫收款金额")
|
||||
private BigDecimal backScanPayAmount;
|
||||
/**
|
||||
* 被扫收款笔数
|
||||
*/
|
||||
@ExcelProperty("被扫收款笔数")
|
||||
private Long backScanPayCount;
|
||||
/**
|
||||
* 主扫收款金额
|
||||
*/
|
||||
@ExcelProperty("主扫收款金额")
|
||||
private BigDecimal mainScanPayAmount;
|
||||
/**
|
||||
* 主扫收款笔数
|
||||
*/
|
||||
@ExcelProperty("主扫收款笔数")
|
||||
private Long mainScanPayCount;
|
||||
/**
|
||||
* 挂账支付金额
|
||||
*/
|
||||
@ExcelProperty("挂账支付金额")
|
||||
private BigDecimal creditPayAmount;
|
||||
/**
|
||||
* 挂账支付笔数
|
||||
*/
|
||||
@ExcelProperty("挂账支付笔数")
|
||||
private Long creditPayCount;
|
||||
|
||||
/**
|
||||
* 会员消费 会员订单支付金额
|
||||
*/
|
||||
@ExcelProperty("会员消费金额")
|
||||
private BigDecimal memberPayAmount;
|
||||
/**
|
||||
* 会员消费笔数
|
||||
*/
|
||||
@ExcelProperty("会员消费笔数")
|
||||
private Long memberPayCount;
|
||||
|
||||
//*********************以下为订单金额********************************************************************************
|
||||
|
||||
|
||||
/**
|
||||
* 线上付款金额
|
||||
*/
|
||||
@ExcelProperty("线上付款金额")
|
||||
private BigDecimal onlinePayAmount;
|
||||
/**
|
||||
* 订单退款 退款金额(原路返回 现金退款)
|
||||
*/
|
||||
@ExcelProperty("订单退款金额")
|
||||
private BigDecimal refundAmount;
|
||||
/**
|
||||
* 订单退款 线上退款金额
|
||||
*/
|
||||
@ExcelProperty("订单退款线上金额")
|
||||
private BigDecimal onlineRefundAmount;
|
||||
/**
|
||||
* 订单退款 线下退款金额/现金退款金额
|
||||
*/
|
||||
@ExcelProperty("订单退款线下金额")
|
||||
private BigDecimal cashRefundAmount;
|
||||
/**
|
||||
* 订单退款 会员退款金额
|
||||
*/
|
||||
@ExcelProperty("订单退款会员金额")
|
||||
private BigDecimal memberRefundAmount;
|
||||
|
||||
|
||||
//*********************以下为充值金额********************************************************************************
|
||||
/**
|
||||
* 会员充值 充值金额(包含现金支付) 不包括赠送 多店 按 主店算
|
||||
*/
|
||||
@ExcelProperty("会员充值金额")
|
||||
private BigDecimal rechargeAmount;
|
||||
/**
|
||||
* 会员充值 线上充值金额
|
||||
*/
|
||||
@ExcelProperty("会员线上充值金额")
|
||||
private BigDecimal onlineRechargeAmount;
|
||||
/**
|
||||
* 会员充值 现金充值金额
|
||||
*/
|
||||
@ExcelProperty("会员现金充值金额")
|
||||
private BigDecimal cashRechargeAmount;
|
||||
/**
|
||||
* 会员充值 充值赠送金额
|
||||
*/
|
||||
@ExcelProperty("会员充值赠送金额")
|
||||
private BigDecimal giveAmount;
|
||||
|
||||
/**
|
||||
* 会员充值退款 充值退款金额(线上退款+现金退款)
|
||||
*/
|
||||
@ExcelProperty("会员充值退款金额")
|
||||
private BigDecimal rechargeRefundAmount;
|
||||
/**
|
||||
* 会员充值退款 线上退款
|
||||
*/
|
||||
@ExcelProperty("会员充值线上退款金额")
|
||||
private BigDecimal onlineRechargeRefundAmount;
|
||||
/**
|
||||
* 会员充值退款 现金退款金额
|
||||
*/
|
||||
@ExcelProperty("会员充值线下退款金额")
|
||||
private BigDecimal cashRechargeRefundAmount;
|
||||
/**
|
||||
* 新增会员数
|
||||
*/
|
||||
@ExcelProperty("新增会员数")
|
||||
private Long newMemberCount;
|
||||
|
||||
|
||||
//*********************以下为优惠金额********************************************************************************
|
||||
/**
|
||||
* 优惠总金额
|
||||
*/
|
||||
@ExcelProperty("优惠总金额")
|
||||
private BigDecimal discountAmount;
|
||||
/**
|
||||
* 优惠笔数
|
||||
*/
|
||||
@ExcelProperty("优惠笔数")
|
||||
private Long discountCount;
|
||||
|
||||
/**
|
||||
* 新客立减金额
|
||||
*/
|
||||
@ExcelProperty("新客立减金额")
|
||||
private BigDecimal newCustomerDiscountAmount;
|
||||
/**
|
||||
* 满减活动金额
|
||||
*/
|
||||
@ExcelProperty("满减活动金额")
|
||||
private BigDecimal fullDiscountAmount;
|
||||
/**
|
||||
* 优惠券抵扣金额
|
||||
*/
|
||||
@ExcelProperty("优惠券抵扣金额")
|
||||
private BigDecimal couponDiscountAmount;
|
||||
/**
|
||||
* 积分抵扣金额
|
||||
*/
|
||||
@ExcelProperty("积分抵扣金额")
|
||||
private BigDecimal pointDiscountAmount;
|
||||
/**
|
||||
* 霸王餐金额
|
||||
*/
|
||||
@ExcelProperty("霸王餐金额")
|
||||
private BigDecimal backDiscountAmount;
|
||||
/**
|
||||
* 会员整单折扣金额
|
||||
*/
|
||||
@ExcelProperty("会员整单折扣金额")
|
||||
private BigDecimal memberDiscountAmount;
|
||||
/**
|
||||
* 订单改价金额
|
||||
*/
|
||||
@ExcelProperty("订单改价金额")
|
||||
private BigDecimal orderPriceDiscountAmount;
|
||||
|
||||
|
||||
//*********************以下为客单价 翻台率 的计算********************************************************************************
|
||||
/**
|
||||
* 就餐人数
|
||||
*/
|
||||
@ExcelProperty("就餐人数")
|
||||
private Long customerCount;
|
||||
/**
|
||||
* 订单数
|
||||
*/
|
||||
@ExcelProperty("订单数")
|
||||
private Long orderCount;
|
||||
/**
|
||||
* 桌台数
|
||||
*/
|
||||
@ExcelProperty("桌台数")
|
||||
private Long tableCount;
|
||||
/**
|
||||
* 客单价
|
||||
* 实付金额(包含现金支付 包含会员支付 包含挂账)/就餐人数
|
||||
* 没有具体人数时,默认一桌按照1人计算
|
||||
*/
|
||||
@ExcelProperty("客单价")
|
||||
private BigDecimal avgPayAmount;
|
||||
/**
|
||||
* 翻台率
|
||||
* (订单数-桌台数)/桌台数*100%
|
||||
*/
|
||||
@ExcelProperty("翻台率(%)")
|
||||
private BigDecimal turnoverRate;
|
||||
|
||||
/**
|
||||
* 毛利润(订单实付金额-商品成本)
|
||||
*/
|
||||
@ExcelProperty("毛利率(%)")
|
||||
private BigDecimal profitAmount;
|
||||
/**
|
||||
* 商品成本
|
||||
*/
|
||||
@ExcelProperty("商品成本")
|
||||
private BigDecimal productCostAmount;
|
||||
/**
|
||||
* 毛利率(订单实付金额-商品成本)/订单实付金额*100%
|
||||
*/
|
||||
@ExcelProperty("利润率(%)")
|
||||
private BigDecimal profitRate;
|
||||
/**
|
||||
* 净利润
|
||||
*/
|
||||
@ExcelProperty("净利润")
|
||||
private BigDecimal netProfitAmount;
|
||||
/**
|
||||
* 净利润率
|
||||
*/
|
||||
@ExcelProperty("净利润率(%)")
|
||||
private BigDecimal netProfitRate;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ExcelIgnore
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@ExcelIgnore
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Column(ignore = true)
|
||||
@ExcelIgnore
|
||||
BigDecimal zero = BigDecimal.ZERO;
|
||||
|
||||
/**
|
||||
* 是否有效
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
@ExcelIgnore
|
||||
private Boolean valid = true;
|
||||
|
||||
|
||||
@@ -410,11 +472,19 @@ public class ShopOrderStatistic implements Serializable {
|
||||
* 合并两个统计对象
|
||||
*/
|
||||
public static ShopOrderStatistic mergeStatistics(ShopOrderStatistic stat1, ShopOrderStatistic stat2) {
|
||||
if (stat2 == null) return stat1;
|
||||
if (stat1 == null) return stat2;
|
||||
if (stat2 == null) {
|
||||
return stat1;
|
||||
}
|
||||
if (stat1 == null) {
|
||||
return stat2;
|
||||
}
|
||||
|
||||
if(!stat2.getValid()) return stat1;
|
||||
if(!stat1.getValid()) return stat2;
|
||||
if(!stat2.getValid()) {
|
||||
return stat1;
|
||||
}
|
||||
if(!stat1.getValid()) {
|
||||
return stat2;
|
||||
}
|
||||
|
||||
ShopOrderStatistic result = new ShopOrderStatistic();
|
||||
|
||||
@@ -477,8 +547,12 @@ public class ShopOrderStatistic implements Serializable {
|
||||
* 安全的BigDecimal相加
|
||||
*/
|
||||
private static BigDecimal safeAdd(BigDecimal num1, BigDecimal num2) {
|
||||
if (num1 == null) return num2;
|
||||
if (num2 == null) return num1;
|
||||
if (num1 == null) {
|
||||
return num2;
|
||||
}
|
||||
if (num2 == null) {
|
||||
return num1;
|
||||
}
|
||||
return num1.add(num2);
|
||||
}
|
||||
|
||||
@@ -486,8 +560,12 @@ public class ShopOrderStatistic implements Serializable {
|
||||
* 安全的Long相加
|
||||
*/
|
||||
private static Long safeAdd(Long num1, Long num2) {
|
||||
if (num1 == null) return num2;
|
||||
if (num2 == null) return num1;
|
||||
if (num1 == null) {
|
||||
return num2;
|
||||
}
|
||||
if (num2 == null) {
|
||||
return num1;
|
||||
}
|
||||
return num1 + num2;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.czg.order.param;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 财务报表查询参数
|
||||
* @author yjjie
|
||||
* @date 2026/2/2 10:23
|
||||
*/
|
||||
@Data
|
||||
public class FinanceStsQueryParam implements Serializable {
|
||||
|
||||
public interface Query {}
|
||||
public interface Export {}
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 查询日期 格式:yyyy-MM-dd
|
||||
*/
|
||||
@NotNull(message = "查询日期不能为空", groups = {Export.class, Query.class})
|
||||
private LocalDate queryDate;
|
||||
|
||||
/**
|
||||
* 平台
|
||||
* czg 自己
|
||||
* MTuan 美团
|
||||
* CMeMe 菜么么
|
||||
* KRuYun 客如云
|
||||
*/
|
||||
@NotBlank(message = "平台不能为空", groups = {Export.class})
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 主店id
|
||||
*/
|
||||
private Long mainShopId;
|
||||
|
||||
public boolean notValidDateRange() {
|
||||
if (queryDate == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 检查开始日期是否晚于结束日期
|
||||
return queryDate.isAfter(LocalDate.now());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.czg.order.service;
|
||||
|
||||
import com.czg.order.dto.FinanceStsDTO;
|
||||
import com.czg.order.param.FinanceStsQueryParam;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2026/2/2 10:10
|
||||
*/
|
||||
public interface FinanceStsService {
|
||||
|
||||
/**
|
||||
* 查询财务统计
|
||||
*/
|
||||
FinanceStsDTO getFinanceSts(FinanceStsQueryParam param);
|
||||
|
||||
void exportFinanceSts(FinanceStsQueryParam param, HttpServletResponse response);
|
||||
}
|
||||
@@ -131,7 +131,6 @@ public class AShopUserServiceImpl implements AShopUserService {
|
||||
public void exportUserList(String key, Integer isVip, HttpServletResponse response) {
|
||||
Long mainIdByShopId = shopInfoService.getMainIdByShopId(StpKit.USER.getShopId());
|
||||
ShopInfo shopInfo = shopInfoService.getById(StpKit.USER.getShopId());
|
||||
PageHelper.startPage(PageUtil.buildPageHelp());
|
||||
List<ShopUserDTO> dtoList = shopUserMapper.selectPageByKeyAndIsVip(mainIdByShopId, isVip, key, null);
|
||||
|
||||
// 将 dtoList 转换为 ShopUserExportDTO 列表
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import com.czg.excel.ExcelExportUtil;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.order.dto.FinanceStsDTO;
|
||||
import com.czg.order.entity.ShopOrderStatistic;
|
||||
import com.czg.order.param.FinanceStsQueryParam;
|
||||
import com.czg.order.service.FinanceStsService;
|
||||
import com.czg.order.service.ShopOrderStatisticService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2026/2/2 10:11
|
||||
*/
|
||||
@Service
|
||||
public class FinanceStsServiceImpl implements FinanceStsService {
|
||||
|
||||
@Resource
|
||||
private ShopOrderStatisticService orderStatisticService;
|
||||
|
||||
@Override
|
||||
public FinanceStsDTO getFinanceSts(FinanceStsQueryParam param) {
|
||||
if (param.notValidDateRange()) {
|
||||
throw new CzgException("日期范围无效");
|
||||
}
|
||||
|
||||
ShopOrderStatistic statistic = getStatisticData(param);
|
||||
|
||||
return new FinanceStsDTO()
|
||||
.setDate(LocalDateTimeUtil.format(param.getQueryDate(), "yyyy-MM-dd"))
|
||||
.setTurnover(new FinanceStsDTO.TurnoverSts()
|
||||
.setTurnover(statistic.getPayAmount())
|
||||
.setWechat(statistic.getWechatPayAmount())
|
||||
.setAlipay(statistic.getAlipayPayAmount())
|
||||
.setSelfScan(statistic.getMainScanPayAmount())
|
||||
.setCash(statistic.getCashPayAmount())
|
||||
.setRecharge(statistic.getRechargeAmount())
|
||||
.setOwed(statistic.getCreditPayAmount())
|
||||
.setBalance(statistic.getMemberPayAmount()))
|
||||
.setOrder(new FinanceStsDTO.OrderSts()
|
||||
.setOrderAmount(statistic.getPayAmount())
|
||||
.setOrderCount(statistic.getOrderCount()))
|
||||
.setDiscount(new FinanceStsDTO.DiscountSts()
|
||||
.setDiscountAmount(statistic.getDiscountAmount())
|
||||
.setDiscountCount(statistic.getDiscountCount())
|
||||
.setNewConsumerDiscount(statistic.getNewCustomerDiscountAmount())
|
||||
.setFreeCashAmount(statistic.getBackDiscountAmount())
|
||||
.setFullMinusAmount(statistic.getFullDiscountAmount())
|
||||
.setCouponAmount(statistic.getCouponDiscountAmount())
|
||||
.setMemberDiscount(statistic.getMemberDiscountAmount())
|
||||
.setPointsDiscountAmount(statistic.getPointDiscountAmount())
|
||||
.setOrderDiscount(statistic.getOrderPriceDiscountAmount()))
|
||||
.setRefund(new FinanceStsDTO.RefundSts()
|
||||
.setRefundAmount(statistic.getRefundAmount())
|
||||
.setOnlineRefundAmount(statistic.getOnlineRefundAmount())
|
||||
.setCashRefundAmount(statistic.getCashRefundAmount())
|
||||
.setRechargeRefundAmount(statistic.getRechargeRefundAmount())
|
||||
.setOnlineRechargeRefundAmount(statistic.getOnlineRechargeRefundAmount())
|
||||
.setCashRechargeRefundAmount(statistic.getCashRechargeRefundAmount())
|
||||
.setMemberRefundAmount(statistic.getMemberRefundAmount()))
|
||||
.setSts(new FinanceStsDTO.Sts()
|
||||
.setCustomerCount(statistic.getCustomerCount())
|
||||
.setOrderCount(statistic.getOrderCount())
|
||||
.setTableCount(statistic.getTableCount())
|
||||
.setAvgPayAmount(statistic.getAvgPayAmount())
|
||||
.setTurnoverRate(statistic.getTurnoverRate())
|
||||
.setProfitAmount(statistic.getProfitAmount())
|
||||
.setProductCostAmount(statistic.getProductCostAmount())
|
||||
.setProfitRate(statistic.getProfitRate())
|
||||
.setNetProfitRate(statistic.getNetProfitRate())
|
||||
.setNetProfitRate(statistic.getNetProfitRate()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportFinanceSts(FinanceStsQueryParam param, HttpServletResponse response) {
|
||||
if (param.notValidDateRange()) {
|
||||
throw new CzgException("日期范围无效");
|
||||
}
|
||||
|
||||
ShopOrderStatistic statistic = getStatisticData(param);
|
||||
|
||||
if ("czg".equals(param.getPlatform())) {
|
||||
ExcelExportUtil.exportToResponse(List.of(statistic), ShopOrderStatistic.class, "财务报表", response);
|
||||
return;
|
||||
}
|
||||
throw new CzgException("平台不支持");
|
||||
}
|
||||
|
||||
private ShopOrderStatistic getStatisticData(FinanceStsQueryParam param) {
|
||||
LocalDate today = LocalDate.now();
|
||||
if (param.getQueryDate().equals(today)) {
|
||||
return orderStatisticService.getRealTimeDataByDay(param.getShopId(), param.getQueryDate());
|
||||
}
|
||||
return orderStatisticService.getStatSingleDate(param.getShopId(), param.getQueryDate());
|
||||
}
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
|
||||
BigDecimal rechargeAmount = cashRechargeAmount.add(onlineRechargeAmount);
|
||||
result.setRechargeAmount(rechargeAmount);
|
||||
//会员充值退款 充值退款金额(线上退款+现金退款)
|
||||
BigDecimal onlineRefundAmount = Objects.requireNonNullElse(
|
||||
BigDecimal onlineRechargeRefundAmount = Objects.requireNonNullElse(
|
||||
(onlineStat != null) ? onlineStat.getOnlineRechargeRefundAmount() : null,
|
||||
BigDecimal.ZERO
|
||||
);
|
||||
@@ -194,7 +194,9 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
|
||||
(userFlowStat != null) ? userFlowStat.getCashRechargeRefundAmount() : null,
|
||||
BigDecimal.ZERO
|
||||
);
|
||||
BigDecimal rechargeRefundAmountTotal = onlineRefundAmount.add(userFlowRefundAmount);
|
||||
BigDecimal rechargeRefundAmountTotal = onlineRechargeRefundAmount.add(userFlowRefundAmount);
|
||||
result.setOnlineRefundAmount(onlineStat == null ? BigDecimal.ZERO : onlineStat.getOnlineRefundAmount());
|
||||
result.setOnlineRechargeRefundAmount(onlineStat == null ? BigDecimal.ZERO : onlineStat.getOnlineRechargeRefundAmount());
|
||||
result.setRechargeRefundAmount(rechargeRefundAmountTotal);
|
||||
//实付金额 (线上付款 现金支付 会员支付 挂账)
|
||||
BigDecimal onlinePayAmount = (onlineStat != null)
|
||||
@@ -218,6 +220,9 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
|
||||
.add(creditPayAmount);
|
||||
result.setPayAmount(totalPayAmount);
|
||||
calculateShopOrderStatistic(result);
|
||||
calculateProfitInfo(result);
|
||||
calculateTurnoverRate(result);
|
||||
calculateAvgPayAmount(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user