Compare commits
16 Commits
ec1bc6a156
...
test
| Author | SHA1 | Date | |
|---|---|---|---|
| a53911aaa5 | |||
| 746c5c83da | |||
| 625df4c353 | |||
| 9784695482 | |||
| 257977a000 | |||
| 624abd31b4 | |||
| 7b9dcafc53 | |||
| 04d75589a8 | |||
| bb76930920 | |||
| 8ae847d458 | |||
| bb7ca6d05b | |||
| ee78543ab8 | |||
| 4deba098ce | |||
| 9da67fc67f | |||
|
|
65f6978612 | ||
|
|
ad24a91a28 |
@@ -40,8 +40,8 @@ public class ShopInfoController {
|
||||
@SaAdminCheckRole("管理员")
|
||||
@SaAdminCheckPermission(parentName = "店铺管理接口", value = "shopInfo:list", name = "店铺列表")
|
||||
@GetMapping
|
||||
public CzgResult<Page<ShopInfo>> get(PageDTO pageDTO, String shopName, Integer status, Integer isHeadShop) {
|
||||
return CzgResult.success(shopInfoService.get(pageDTO, shopName, status, isHeadShop));
|
||||
public CzgResult<Page<ShopInfo>> get(PageDTO pageDTO, String profiles, String phone, String shopName, Integer status, Integer isHeadShop) {
|
||||
return CzgResult.success(shopInfoService.get(pageDTO, profiles, phone, shopName, status, isHeadShop));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -126,18 +126,18 @@ public class OrderPayController {
|
||||
return orderPayService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 正扫
|
||||
*/
|
||||
@PostMapping("/scanPay")
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return orderPayService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
// /**
|
||||
// * 正扫
|
||||
// */
|
||||
// @PostMapping("/scanPay")
|
||||
// @Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
// public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
// payParam.setShopId(shopId);
|
||||
// return orderPayService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 反扫
|
||||
* 扫码收款
|
||||
* authCode 必填 扫描码
|
||||
*/
|
||||
@PostMapping("/microPay")
|
||||
|
||||
@@ -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 "否";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class ShopInfo implements Serializable {
|
||||
private String businessTime;
|
||||
|
||||
/**
|
||||
* trial试用版,release正式
|
||||
* probation试用版,release正式
|
||||
*/
|
||||
private String profiles;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface ShopInfoService extends IService<ShopInfo> {
|
||||
*/
|
||||
boolean checkSwitch(Long shopId, ShopSwitchTypeEnum switchType) throws ValidateException;
|
||||
|
||||
Page<ShopInfo> get(PageDTO pageDTO, String shopName, Integer status, Integer isHeadShop);
|
||||
Page<ShopInfo> get(PageDTO pageDTO, String profiles, String phone, String shopName, Integer status, Integer isHeadShop);
|
||||
|
||||
Page<ShopInfo> getShopByMainId(PageDTO pageDTO, String shopName, Integer status);
|
||||
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
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 barScan;
|
||||
|
||||
/**
|
||||
* 现金收款
|
||||
*/
|
||||
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 creditRefundAmount;
|
||||
|
||||
/**
|
||||
* 充值退款金额
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -182,13 +182,14 @@ public class OrderInfo implements Serializable {
|
||||
/**
|
||||
* {@link com.czg.order.enums.PayEnums}
|
||||
* 支付类型
|
||||
* 主扫 main_scan
|
||||
* 被扫 back_scan
|
||||
* 二维码收款 main_scan
|
||||
* 扫码收款 back_scan
|
||||
* 微信小程序 wechat_mini
|
||||
* 支付宝小程序 alipay_mini
|
||||
* 会员支付 vip_pay
|
||||
* 现金支付 cash_pay
|
||||
* 挂账支付 credit_pay
|
||||
* 霸王餐支付 free_pay
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
|
||||
@@ -150,9 +150,10 @@ public class OrderPayment implements Serializable {
|
||||
return orderPayment;
|
||||
}
|
||||
|
||||
public static OrderPayment refund(@NonNull Long shopId, @NonNull Long sourceId, @NotBlank String sourceType,
|
||||
public static OrderPayment refund(@NonNull String channel,@NonNull Long shopId, @NonNull Long sourceId, @NotBlank String sourceType,
|
||||
@NotBlank String orderNo, @NonNull BigDecimal amount, Long relatedId, String platformType) {
|
||||
OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, null, relatedId);
|
||||
orderPayment.setChannel(channel);
|
||||
orderPayment.setPayType(PayTypeConstants.PayType.REFUND);
|
||||
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
|
||||
orderPayment.setPlatformType(platformType);
|
||||
|
||||
@@ -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,311 @@ 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 creditRefundAmount;
|
||||
/**
|
||||
* 订单退款 线上退款金额
|
||||
*/
|
||||
@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 +474,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 +549,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 +562,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,12 @@ public enum PayEnums {
|
||||
/**
|
||||
* 主扫
|
||||
*/
|
||||
MAIN_SCAN("main_scan", "主扫"),
|
||||
MAIN_SCAN("main_scan", "二维码收款"),
|
||||
/**
|
||||
* 被扫
|
||||
*/
|
||||
BACK_SCAN("back_scan", "被扫"),
|
||||
// BACK_SCAN("back_scan", "被扫"),
|
||||
BACK_SCAN("back_scan", "扫码收款"),
|
||||
/**
|
||||
* 微信小程序
|
||||
*/
|
||||
|
||||
@@ -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 列表
|
||||
|
||||
@@ -113,8 +113,14 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ShopInfo> get(PageDTO pageDTO, String shopName, Integer status, Integer isHeadShop) {
|
||||
public Page<ShopInfo> get(PageDTO pageDTO, String profiles, String phone, String shopName, Integer status, Integer isHeadShop) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
if (StrUtil.isNotBlank(profiles)) {
|
||||
queryWrapper.eq(ShopInfo::getProfiles, profiles);
|
||||
}
|
||||
if (StrUtil.isNotBlank(phone)) {
|
||||
queryWrapper.like(ShopInfo::getPhone, phone);
|
||||
}
|
||||
if (StrUtil.isNotBlank(shopName)) {
|
||||
queryWrapper.like(ShopInfo::getShopName, shopName);
|
||||
}
|
||||
@@ -125,7 +131,8 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
queryWrapper.eq(ShopInfo::getIsHeadShop, isHeadShop);
|
||||
}
|
||||
|
||||
List<ShopInfo> shopAllList = getMapper().selectListByQuery(query().select(ShopInfo::getId, ShopInfo::getShopName));
|
||||
List<ShopInfo> shopAllList = getMapper().selectListByQuery(query().select(ShopInfo::getId, ShopInfo::getShopName)
|
||||
.eq(ShopInfo::getIsHeadShop, 1).ne(ShopInfo::getShopType, ShopTypeEnum.ONLY.getValue()));
|
||||
Map<Long, String> shopKv = shopAllList.stream().collect(Collectors.toMap(ShopInfo::getId, ShopInfo::getShopName));
|
||||
queryWrapper.orderBy(ShopInfo::getCreateTime, false);
|
||||
Page<ShopInfo> page = page(new Page<>(pageDTO.page(), pageDTO.size()), queryWrapper);
|
||||
|
||||
@@ -192,7 +192,7 @@ public interface ShopOrderStatisticMapper extends BaseMapper<ShopOrderStatistic>
|
||||
" AND shop_id = #{shopId}" +
|
||||
" AND source_type NOT IN ('memberPay', 'distribution', 'distributionRecharge', 'point' ,'ware')" +
|
||||
" AND pay_type != 'refundCompensate'" +
|
||||
" AND pay_date = #{tradeDay} ;")
|
||||
" AND DATE(update_time) = #{tradeDay} ;")
|
||||
ShopOrderStatistic getOnlineStatSingleDate(Long shopId, LocalDate tradeDay);
|
||||
|
||||
/**
|
||||
@@ -210,6 +210,7 @@ public interface ShopOrderStatisticMapper extends BaseMapper<ShopOrderStatistic>
|
||||
" SUM(CASE WHEN pay_type = 'free_pay' THEN order_amount ELSE 0 END) AS backDiscountAmount," +
|
||||
" " +
|
||||
" SUM(CASE WHEN pay_type = 'vip_pay' THEN refund_amount ELSE 0 END) AS memberRefundAmount," +
|
||||
" SUM(CASE WHEN pay_type = 'credit_pay' THEN refund_amount ELSE 0 END) AS creditRefundAmount," +
|
||||
" " +
|
||||
" SUM(CASE WHEN pay_type = 'vip_pay' THEN 1 ELSE 0 END) as memberPayCount," +
|
||||
" SUM(CASE WHEN pay_type = 'cash_pay' THEN 1 ELSE 0 END) as cashPayCount," +
|
||||
@@ -219,15 +220,15 @@ public interface ShopOrderStatisticMapper extends BaseMapper<ShopOrderStatistic>
|
||||
" SUM(CASE WHEN pay_type = 'main_scan' THEN 1 ELSE 0 END) as mainScanPayCount," +
|
||||
" SUM(CASE WHEN pay_type = 'credit_pay' THEN 1 ELSE 0 END) as creditPayCount," +
|
||||
" " +
|
||||
" SUM(refund_amount) as refundAmount," +
|
||||
" IFNULL(SUM(refund_amount), 0) as refundAmount," +
|
||||
" SUM(CASE WHEN refund_type = 'cash' or pay_type = 'cash_pay' THEN refund_amount ELSE 0 END) as cashRefundAmount," +
|
||||
" " +
|
||||
" SUM(new_customer_discount_amount) as newCustomerDiscountAmount," +
|
||||
" SUM(discount_act_amount) as fullDiscountAmount," +
|
||||
" SUM(product_coupon_discount_amount) + SUM(other_coupon_discount_amount) as couponDiscountAmount," +
|
||||
" SUM(points_discount_amount) as pointDiscountAmount," +
|
||||
" SUM(vip_discount_amount) as memberDiscountAmount," +
|
||||
" SUM(discount_amount) as orderPriceDiscountAmount ," +
|
||||
" IFNULL(SUM(new_customer_discount_amount), 0) as newCustomerDiscountAmount," +
|
||||
" IFNULL(SUM(discount_act_amount), 0) as fullDiscountAmount," +
|
||||
" IFNULL(SUM(product_coupon_discount_amount), 0) + IFNULL(SUM(other_coupon_discount_amount), 0) as couponDiscountAmount," +
|
||||
" IFNULL(SUM(points_discount_amount), 0) as pointDiscountAmount," +
|
||||
" IFNULL(SUM(vip_discount_amount), 0) as memberDiscountAmount," +
|
||||
" IFNULL(SUM(discount_amount), 0) as orderPriceDiscountAmount ," +
|
||||
" count(1) as orderCount," +
|
||||
" sum(CASE WHEN seat_num IS NULL OR seat_num <= 0 THEN 1 ELSE seat_num END) as customerCount " +
|
||||
"FROM" +
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
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().add(statistic.getRechargeAmount()))
|
||||
.setWechat(statistic.getWechatPayAmount())
|
||||
.setAlipay(statistic.getAlipayPayAmount())
|
||||
.setSelfScan(statistic.getMainScanPayAmount())
|
||||
.setBarScan(statistic.getBackScanPayAmount())
|
||||
.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().add(statistic.getRechargeRefundAmount()))
|
||||
.setOnlineRefundAmount(statistic.getOnlineRefundAmount())
|
||||
.setCashRefundAmount(statistic.getCashRefundAmount())
|
||||
.setCreditRefundAmount(statistic.getCreditRefundAmount())
|
||||
.setMemberRefundAmount(statistic.getMemberRefundAmount())
|
||||
.setRechargeRefundAmount(statistic.getRechargeRefundAmount())
|
||||
.setOnlineRechargeRefundAmount(statistic.getOnlineRechargeRefundAmount())
|
||||
.setCashRechargeRefundAmount(statistic.getCashRechargeRefundAmount()))
|
||||
.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());
|
||||
}
|
||||
}
|
||||
@@ -1050,6 +1050,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
payment.setPayStatus(PayTypeConstants.PayStatus.FAIL);
|
||||
payment.setPlatformType(notifyRespDTO.getPlatform());
|
||||
payment.setChannel(channel);
|
||||
payment.setPayTime(LocalDateTimeUtil.parse(notifyRespDTO.getPaySuccessTime(), "yyyy-MM-dd HH:mm:ss"));
|
||||
if ("TRADE_SUCCESS".equals(notifyRespDTO.getStatus())) {
|
||||
payment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
|
||||
if (PayTypeConstants.SourceType.ORDER.equals(payment.getSourceType())) {
|
||||
@@ -1196,6 +1197,13 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
if (orderInfo.getCreditBuyerId() != null) {
|
||||
upOrderInfo.setCreditBuyerId(orderInfo.getCreditBuyerId());
|
||||
}
|
||||
if (PayEnums.FREE_PAY.equals(payType)) {
|
||||
if (orderInfo.getDiscountAllAmount() == null) {
|
||||
upOrderInfo.setDiscountAllAmount(orderInfo.getOrderAmount());
|
||||
} else {
|
||||
upOrderInfo.setDiscountAllAmount(orderInfo.getDiscountAllAmount().add(orderInfo.getOrderAmount()));
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(payType)) {
|
||||
upOrderInfo.setPayType(payType.getValue());
|
||||
orderInfo.setPayType(payType.getValue());
|
||||
|
||||
@@ -290,7 +290,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
}
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||
upOrderPayInfo(orderInfo.getId(), PayCst.Type.ALIPAY.equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||
CzgPayBaseReq.jsPayReq(payOrderNo, "扫码支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
@@ -358,7 +358,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN);
|
||||
// 事务成功提交后执行消息发送
|
||||
String printParam = orderInfo.getId() + "_" + (!"after-pay".equals( orderInfo.getPayMode()) ? 1 : 0) + "_1";
|
||||
String printParam = orderInfo.getId() + "_" + (!"after-pay".equals(orderInfo.getPayMode()) ? 1 : 0) + "_1";
|
||||
rabbitPublisher.sendOrderPrintMsg(printParam, orderInfo.getIsPrint() == 1, "事务环境打印");
|
||||
} else {
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId,
|
||||
@@ -375,10 +375,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
if (orderInfo.getStatus().equals(OrderStatusEnums.CANCELLED.getCode())) {
|
||||
throw new CzgException("订单已过期不可退单");
|
||||
}
|
||||
boolean isFirstRefund = true;
|
||||
if (orderInfo.getRefundAmount().compareTo(BigDecimal.ZERO) != 0) {
|
||||
isFirstRefund = false;
|
||||
}
|
||||
boolean isFirstRefund = orderInfo.getRefundAmount().compareTo(BigDecimal.ZERO) == 0;
|
||||
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
|
||||
Map<String, BigDecimal> returnProMap = new HashMap<>();
|
||||
boolean isPay = true;
|
||||
@@ -437,9 +434,8 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
returnProMap.put(Convert.toStr(orderDetail.getProductId()), refundDetail.getNum());
|
||||
}
|
||||
}
|
||||
long count = orderDetailService.queryChain()
|
||||
.eq(OrderDetail::getOrderId, orderInfo.getId())
|
||||
.ne(OrderDetail::getStatus, OrderStatusEnums.REFUND.getCode()).count();
|
||||
long count = orderDetailService.count(QueryWrapper.create().eq(OrderDetail::getOrderId, orderInfo.getId())
|
||||
.ne(OrderDetail::getStatus, OrderStatusEnums.REFUND.getCode()));
|
||||
if (count > 0 && isPay) {
|
||||
orderInfo.setStatus(OrderStatusEnums.PART_REFUND.getCode());
|
||||
} else if (isPay) {
|
||||
@@ -447,10 +443,9 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
}
|
||||
} else {
|
||||
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
|
||||
List<OrderDetail> orderDetails = orderDetailService.queryChain()
|
||||
.select(OrderDetail::getId, OrderDetail::getProductId, OrderDetail::getNum, OrderDetail::getReturnNum, OrderDetail::getPackAmount, OrderDetail::getReturnNum)
|
||||
.eq(OrderDetail::getOrderId, orderInfo.getId())
|
||||
.list();
|
||||
List<OrderDetail> orderDetails = orderDetailService.list(
|
||||
QueryWrapper.create().select(OrderDetail::getId, OrderDetail::getProductId, OrderDetail::getNum, OrderDetail::getReturnNum, OrderDetail::getPackAmount, OrderDetail::getReturnNum)
|
||||
.eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
for (OrderDetail orderDetail : orderDetails) {
|
||||
if (isPay) {
|
||||
if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) {
|
||||
@@ -517,7 +512,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
||||
OrderPayment payment = paymentService.getById(payOrderId);
|
||||
AssertUtil.isNull(payment, "退款失败支付记录不存在");
|
||||
Long refundId = payService.initPayment(OrderPayment.refund(shopId, orderId, PayTypeConstants.SourceType.ORDER,
|
||||
Long refundId = payService.initPayment(OrderPayment.refund(payment.getChannel(), shopId, orderId, PayTypeConstants.SourceType.ORDER,
|
||||
refPayOrderNo, refundAmount, payment.getId(), payment.getPlatformType()));
|
||||
|
||||
CzgResult<RefundRespDTO> refund = payService.refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(PayService.MONEY_RATE).longValue(),
|
||||
@@ -529,6 +524,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
throw new CzgException(refund.getMsg());
|
||||
} else {
|
||||
OrderPayment upPayment = new OrderPayment();
|
||||
upPayment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
|
||||
upPayment.setPayTime(LocalDateTimeUtil.parse(refund.getData().getRefundTime()));
|
||||
upPayment.setTradeNumber(refund.getData().getThirdRefundNo());
|
||||
upPayment.setRespJson(refund.getData().getOriginalData());
|
||||
|
||||
@@ -108,7 +108,7 @@ public class PayServiceImpl implements PayService {
|
||||
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
||||
OrderPayment payment = paymentService.getById(payOrderId);
|
||||
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
|
||||
Long refundId = initPayment(OrderPayment.refund(shopId, sourceId, payment.getSourceType(), refPayOrderNo, refundAmount, payment.getId(), payment.getPlatformType()));
|
||||
Long refundId = initPayment(OrderPayment.refund(payment.getChannel(), shopId, sourceId, payment.getSourceType(), refPayOrderNo, refundAmount, payment.getId(), payment.getPlatformType()));
|
||||
CzgResult<RefundRespDTO> refund = refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(MONEY_RATE).longValue(),
|
||||
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), "", payment.getPlatformType()));
|
||||
OrderPayment uOrderPayment = new OrderPayment();
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
|
||||
}
|
||||
if (day <= 1) {
|
||||
return List.of(onlineDataAmount);
|
||||
}else {
|
||||
} else {
|
||||
startDate = currentDate.minusDays(day - 1);
|
||||
}
|
||||
List<TotalVo> statDateRange = mapper.getStatDateRange(shopId, startDate, currentDate);
|
||||
@@ -84,7 +84,7 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
|
||||
if (day <= 1) {
|
||||
Map<String, BigDecimal> onlinePayTypeDate = mapper.getOnlinePayTypeDate(shopId, currentDate);
|
||||
return CountPayTypeVo.realTimeDataByDay(onlinePayTypeDate);
|
||||
}else {
|
||||
} else {
|
||||
startDate = currentDate.minusDays(day - 1);
|
||||
}
|
||||
return CountPayTypeVo.mergePayTypeData(
|
||||
@@ -104,7 +104,7 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
|
||||
}
|
||||
if (day <= 1) {
|
||||
return List.of(onlineProfitRateBarChart);
|
||||
}else {
|
||||
} else {
|
||||
startDate = currentDate.minusDays(day - 1);
|
||||
}
|
||||
List<ProfitRateVO> statDateRange = mapper.profitRateBarChart(shopId, startDate, currentDate);
|
||||
@@ -180,13 +180,14 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
|
||||
result.setTableCount(Optional.ofNullable(tableCount).orElse(0L));
|
||||
result.setProductCostAmount(Optional.ofNullable(productCostAmount).orElse(BigDecimal.ZERO));
|
||||
|
||||
//会员充值退款 充值退款金额(线上退款+现金退款)
|
||||
//会员充值金额(线上充值+现金充值+霸王餐充值)
|
||||
BigDecimal cashRechargeAmount = Objects.requireNonNullElse(result.getCashRechargeAmount(), BigDecimal.ZERO);
|
||||
BigDecimal onlineRechargeAmount = Objects.requireNonNullElse(result.getOnlineRechargeAmount(), BigDecimal.ZERO);
|
||||
BigDecimal rechargeAmount = cashRechargeAmount.add(onlineRechargeAmount);
|
||||
BigDecimal freeRechargeAmount = Objects.requireNonNullElse(onlineStat != null ? onlineStat.getBackDiscountAmount() : null, BigDecimal.ZERO);
|
||||
BigDecimal rechargeAmount = cashRechargeAmount.add(onlineRechargeAmount).add(freeRechargeAmount);
|
||||
result.setRechargeAmount(rechargeAmount);
|
||||
//会员充值退款 充值退款金额(线上退款+现金退款)
|
||||
BigDecimal onlineRefundAmount = Objects.requireNonNullElse(
|
||||
BigDecimal onlineRechargeRefundAmount = Objects.requireNonNullElse(
|
||||
(onlineStat != null) ? onlineStat.getOnlineRechargeRefundAmount() : null,
|
||||
BigDecimal.ZERO
|
||||
);
|
||||
@@ -194,7 +195,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)
|
||||
|
||||
@@ -314,7 +314,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
return CzgResult.failure("退款失败,该充值记录不存在");
|
||||
}
|
||||
String refPayOrderNo = "REFVIP" + IdUtil.getSnowflakeNextId();
|
||||
refPaymentId = payService.initPayment(OrderPayment.refund(refPayParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN,
|
||||
refPaymentId = payService.initPayment(OrderPayment.refund(payment.getChannel(), refPayParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN,
|
||||
refPayOrderNo, refPayParam.getRefAmount(), inFlow.getId(), payment.getPlatformType()));
|
||||
CzgResult<RefundRespDTO> refund = payService.refund(refPayParam.getShopId(), new CzgRefundReq(refPayOrderNo, refPayParam.getRemark(),
|
||||
refPayParam.getRefAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
|
||||
Reference in New Issue
Block a user