12 Commits

Author SHA1 Message Date
a53911aaa5 挂账退款 2026-02-05 10:57:02 +08:00
746c5c83da 判空 2026-02-05 09:24:29 +08:00
625df4c353 退款金额 2026-02-04 16:52:01 +08:00
9784695482 空指针问题 2026-02-04 16:45:28 +08:00
257977a000 退款 2026-02-04 16:38:29 +08:00
624abd31b4 霸王餐金额 2026-02-04 16:29:38 +08:00
7b9dcafc53 板块增加充值金额 2026-02-04 16:07:26 +08:00
04d75589a8 板块增加充值金额 2026-02-04 16:02:07 +08:00
bb76930920 支付成功时间 2026-02-04 15:52:24 +08:00
8ae847d458 支付时间 2026-02-04 15:49:25 +08:00
bb7ca6d05b 统计字段 2026-02-04 15:03:33 +08:00
ee78543ab8 统计 2026-02-04 14:57:15 +08:00
13 changed files with 76 additions and 58 deletions

View File

@@ -126,18 +126,18 @@ public class OrderPayController {
return orderPayService.ltPayOrder(ServletUtil.getClientIP(request), payParam); return orderPayService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
} }
/** // /**
* 正扫 // * 正扫
*/ // */
@PostMapping("/scanPay") // @PostMapping("/scanPay")
@Debounce(value = "#payParam.checkOrderPay.orderId") // @Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) { // public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
payParam.setShopId(shopId); // payParam.setShopId(shopId);
return orderPayService.scanPayOrder(ServletUtil.getClientIP(request), payParam); // return orderPayService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
} // }
/** /**
* * 扫码收款
* authCode 必填 扫描码 * authCode 必填 扫描码
*/ */
@PostMapping("/microPay") @PostMapping("/microPay")

View File

@@ -67,9 +67,13 @@ public class FinanceStsDTO {
private BigDecimal alipay; private BigDecimal alipay;
/** /**
* 主扫收款 * 二维码收款
*/ */
private BigDecimal selfScan; private BigDecimal selfScan;
/**
* 扫码收款
*/
private BigDecimal barScan;
/** /**
* 现金收款 * 现金收款
@@ -182,6 +186,10 @@ public class FinanceStsDTO {
* 现金退款金额 * 现金退款金额
*/ */
private BigDecimal cashRefundAmount; private BigDecimal cashRefundAmount;
/**
* 挂账退款金额
*/
private BigDecimal creditRefundAmount;
/** /**
* 充值退款金额 * 充值退款金额

View File

@@ -182,13 +182,14 @@ public class OrderInfo implements Serializable {
/** /**
* {@link com.czg.order.enums.PayEnums} * {@link com.czg.order.enums.PayEnums}
* 支付类型 * 支付类型
* 主扫 main_scan * 二维码收款 main_scan
* 扫 back_scan * 扫码收款 back_scan
* 微信小程序 wechat_mini * 微信小程序 wechat_mini
* 支付宝小程序 alipay_mini * 支付宝小程序 alipay_mini
* 会员支付 vip_pay * 会员支付 vip_pay
* 现金支付 cash_pay * 现金支付 cash_pay
* 挂账支付 credit_pay * 挂账支付 credit_pay
* 霸王餐支付 free_pay
*/ */
private String payType; private String payType;

View File

@@ -150,9 +150,10 @@ public class OrderPayment implements Serializable {
return orderPayment; 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) { @NotBlank String orderNo, @NonNull BigDecimal amount, Long relatedId, String platformType) {
OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, null, relatedId); OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, null, relatedId);
orderPayment.setChannel(channel);
orderPayment.setPayType(PayTypeConstants.PayType.REFUND); orderPayment.setPayType(PayTypeConstants.PayType.REFUND);
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT); orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
orderPayment.setPlatformType(platformType); orderPayment.setPlatformType(platformType);

View File

@@ -169,22 +169,22 @@ public class ShopOrderStatistic implements Serializable {
/** /**
* 被扫收款金额 * 被扫收款金额
*/ */
@ExcelProperty("扫收款金额") @ExcelProperty("收款金额")
private BigDecimal backScanPayAmount; private BigDecimal backScanPayAmount;
/** /**
* 被扫收款笔数 * 被扫收款笔数
*/ */
@ExcelProperty("扫收款笔数") @ExcelProperty("收款笔数")
private Long backScanPayCount; private Long backScanPayCount;
/** /**
* 主扫收款金额 * 二维码收款金额
*/ */
@ExcelProperty("主扫收款金额") @ExcelProperty("二维码收款金额")
private BigDecimal mainScanPayAmount; private BigDecimal mainScanPayAmount;
/** /**
* 主扫收款笔数 * 二维码收款笔数
*/ */
@ExcelProperty("主扫收款笔数") @ExcelProperty("二维码收款笔数")
private Long mainScanPayCount; private Long mainScanPayCount;
/** /**
* 挂账支付金额 * 挂账支付金额
@@ -221,6 +221,8 @@ public class ShopOrderStatistic implements Serializable {
*/ */
@ExcelProperty("订单退款金额") @ExcelProperty("订单退款金额")
private BigDecimal refundAmount; private BigDecimal refundAmount;
@ExcelProperty("订单挂账退款金额")
private BigDecimal creditRefundAmount;
/** /**
* 订单退款 线上退款金额 * 订单退款 线上退款金额
*/ */

View File

@@ -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", "扫码收款"),
/** /**
* 微信小程序 * 微信小程序
*/ */

View File

@@ -192,7 +192,7 @@ public interface ShopOrderStatisticMapper extends BaseMapper<ShopOrderStatistic>
" AND shop_id = #{shopId}" + " AND shop_id = #{shopId}" +
" AND source_type NOT IN ('memberPay', 'distribution', 'distributionRecharge', 'point' ,'ware')" + " AND source_type NOT IN ('memberPay', 'distribution', 'distributionRecharge', 'point' ,'ware')" +
" AND pay_type != 'refundCompensate'" + " AND pay_type != 'refundCompensate'" +
" AND pay_date = #{tradeDay} ;") " AND DATE(update_time) = #{tradeDay} ;")
ShopOrderStatistic getOnlineStatSingleDate(Long shopId, LocalDate 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 = '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 = '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 = 'vip_pay' THEN 1 ELSE 0 END) as memberPayCount," +
" SUM(CASE WHEN pay_type = 'cash_pay' THEN 1 ELSE 0 END) as cashPayCount," + " 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 = 'main_scan' THEN 1 ELSE 0 END) as mainScanPayCount," +
" SUM(CASE WHEN pay_type = 'credit_pay' THEN 1 ELSE 0 END) as creditPayCount," + " 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(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," + " IFNULL(SUM(new_customer_discount_amount), 0) as newCustomerDiscountAmount," +
" SUM(discount_act_amount) as fullDiscountAmount," + " IFNULL(SUM(discount_act_amount), 0) as fullDiscountAmount," +
" SUM(product_coupon_discount_amount) + SUM(other_coupon_discount_amount) as couponDiscountAmount," + " IFNULL(SUM(product_coupon_discount_amount), 0) + IFNULL(SUM(other_coupon_discount_amount), 0) as couponDiscountAmount," +
" SUM(points_discount_amount) as pointDiscountAmount," + " IFNULL(SUM(points_discount_amount), 0) as pointDiscountAmount," +
" SUM(vip_discount_amount) as memberDiscountAmount," + " IFNULL(SUM(vip_discount_amount), 0) as memberDiscountAmount," +
" SUM(discount_amount) as orderPriceDiscountAmount ," + " IFNULL(SUM(discount_amount), 0) as orderPriceDiscountAmount ," +
" count(1) as orderCount," + " count(1) as orderCount," +
" sum(CASE WHEN seat_num IS NULL OR seat_num <= 0 THEN 1 ELSE seat_num END) as customerCount " + " sum(CASE WHEN seat_num IS NULL OR seat_num <= 0 THEN 1 ELSE seat_num END) as customerCount " +
"FROM" + "FROM" +

View File

@@ -36,10 +36,11 @@ public class FinanceStsServiceImpl implements FinanceStsService {
return new FinanceStsDTO() return new FinanceStsDTO()
.setDate(LocalDateTimeUtil.format(param.getQueryDate(), "yyyy-MM-dd")) .setDate(LocalDateTimeUtil.format(param.getQueryDate(), "yyyy-MM-dd"))
.setTurnover(new FinanceStsDTO.TurnoverSts() .setTurnover(new FinanceStsDTO.TurnoverSts()
.setTurnover(statistic.getPayAmount()) .setTurnover(statistic.getPayAmount().add(statistic.getRechargeAmount()))
.setWechat(statistic.getWechatPayAmount()) .setWechat(statistic.getWechatPayAmount())
.setAlipay(statistic.getAlipayPayAmount()) .setAlipay(statistic.getAlipayPayAmount())
.setSelfScan(statistic.getMainScanPayAmount()) .setSelfScan(statistic.getMainScanPayAmount())
.setBarScan(statistic.getBackScanPayAmount())
.setCash(statistic.getCashPayAmount()) .setCash(statistic.getCashPayAmount())
.setRecharge(statistic.getRechargeAmount()) .setRecharge(statistic.getRechargeAmount())
.setOwed(statistic.getCreditPayAmount()) .setOwed(statistic.getCreditPayAmount())
@@ -58,13 +59,14 @@ public class FinanceStsServiceImpl implements FinanceStsService {
.setPointsDiscountAmount(statistic.getPointDiscountAmount()) .setPointsDiscountAmount(statistic.getPointDiscountAmount())
.setOrderDiscount(statistic.getOrderPriceDiscountAmount())) .setOrderDiscount(statistic.getOrderPriceDiscountAmount()))
.setRefund(new FinanceStsDTO.RefundSts() .setRefund(new FinanceStsDTO.RefundSts()
.setRefundAmount(statistic.getRefundAmount()) .setRefundAmount(statistic.getRefundAmount().add(statistic.getRechargeRefundAmount()))
.setOnlineRefundAmount(statistic.getOnlineRefundAmount()) .setOnlineRefundAmount(statistic.getOnlineRefundAmount())
.setCashRefundAmount(statistic.getCashRefundAmount()) .setCashRefundAmount(statistic.getCashRefundAmount())
.setCreditRefundAmount(statistic.getCreditRefundAmount())
.setMemberRefundAmount(statistic.getMemberRefundAmount())
.setRechargeRefundAmount(statistic.getRechargeRefundAmount()) .setRechargeRefundAmount(statistic.getRechargeRefundAmount())
.setOnlineRechargeRefundAmount(statistic.getOnlineRechargeRefundAmount()) .setOnlineRechargeRefundAmount(statistic.getOnlineRechargeRefundAmount())
.setCashRechargeRefundAmount(statistic.getCashRechargeRefundAmount()) .setCashRechargeRefundAmount(statistic.getCashRechargeRefundAmount()))
.setMemberRefundAmount(statistic.getMemberRefundAmount()))
.setSts(new FinanceStsDTO.Sts() .setSts(new FinanceStsDTO.Sts()
.setCustomerCount(statistic.getCustomerCount()) .setCustomerCount(statistic.getCustomerCount())
.setOrderCount(statistic.getOrderCount()) .setOrderCount(statistic.getOrderCount())

View File

@@ -1050,6 +1050,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
payment.setPayStatus(PayTypeConstants.PayStatus.FAIL); payment.setPayStatus(PayTypeConstants.PayStatus.FAIL);
payment.setPlatformType(notifyRespDTO.getPlatform()); payment.setPlatformType(notifyRespDTO.getPlatform());
payment.setChannel(channel); payment.setChannel(channel);
payment.setPayTime(LocalDateTimeUtil.parse(notifyRespDTO.getPaySuccessTime(), "yyyy-MM-dd HH:mm:ss"));
if ("TRADE_SUCCESS".equals(notifyRespDTO.getStatus())) { if ("TRADE_SUCCESS".equals(notifyRespDTO.getStatus())) {
payment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS); payment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
if (PayTypeConstants.SourceType.ORDER.equals(payment.getSourceType())) { if (PayTypeConstants.SourceType.ORDER.equals(payment.getSourceType())) {
@@ -1196,6 +1197,13 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
if (orderInfo.getCreditBuyerId() != null) { if (orderInfo.getCreditBuyerId() != null) {
upOrderInfo.setCreditBuyerId(orderInfo.getCreditBuyerId()); 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)) { if (ObjectUtil.isNotNull(payType)) {
upOrderInfo.setPayType(payType.getValue()); upOrderInfo.setPayType(payType.getValue());
orderInfo.setPayType(payType.getValue()); orderInfo.setPayType(payType.getValue());

View File

@@ -290,7 +290,7 @@ public class OrderPayServiceImpl implements OrderPayService {
} }
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake(); String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), "")); 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()); payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY, return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
CzgPayBaseReq.jsPayReq(payOrderNo, "扫码支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), CzgPayBaseReq.jsPayReq(payOrderNo, "扫码支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
@@ -358,7 +358,7 @@ public class OrderPayServiceImpl implements OrderPayService {
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(), orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN); 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, "事务环境打印"); rabbitPublisher.sendOrderPrintMsg(printParam, orderInfo.getIsPrint() == 1, "事务环境打印");
} else { } else {
upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId, upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId,
@@ -375,10 +375,7 @@ public class OrderPayServiceImpl implements OrderPayService {
if (orderInfo.getStatus().equals(OrderStatusEnums.CANCELLED.getCode())) { if (orderInfo.getStatus().equals(OrderStatusEnums.CANCELLED.getCode())) {
throw new CzgException("订单已过期不可退单"); throw new CzgException("订单已过期不可退单");
} }
boolean isFirstRefund = true; boolean isFirstRefund = orderInfo.getRefundAmount().compareTo(BigDecimal.ZERO) == 0;
if (orderInfo.getRefundAmount().compareTo(BigDecimal.ZERO) != 0) {
isFirstRefund = false;
}
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId()); ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
Map<String, BigDecimal> returnProMap = new HashMap<>(); Map<String, BigDecimal> returnProMap = new HashMap<>();
boolean isPay = true; boolean isPay = true;
@@ -437,9 +434,8 @@ public class OrderPayServiceImpl implements OrderPayService {
returnProMap.put(Convert.toStr(orderDetail.getProductId()), refundDetail.getNum()); returnProMap.put(Convert.toStr(orderDetail.getProductId()), refundDetail.getNum());
} }
} }
long count = orderDetailService.queryChain() long count = orderDetailService.count(QueryWrapper.create().eq(OrderDetail::getOrderId, orderInfo.getId())
.eq(OrderDetail::getOrderId, orderInfo.getId()) .ne(OrderDetail::getStatus, OrderStatusEnums.REFUND.getCode()));
.ne(OrderDetail::getStatus, OrderStatusEnums.REFUND.getCode()).count();
if (count > 0 && isPay) { if (count > 0 && isPay) {
orderInfo.setStatus(OrderStatusEnums.PART_REFUND.getCode()); orderInfo.setStatus(OrderStatusEnums.PART_REFUND.getCode());
} else if (isPay) { } else if (isPay) {
@@ -447,10 +443,9 @@ public class OrderPayServiceImpl implements OrderPayService {
} }
} else { } else {
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode()); orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
List<OrderDetail> orderDetails = orderDetailService.queryChain() List<OrderDetail> orderDetails = orderDetailService.list(
.select(OrderDetail::getId, OrderDetail::getProductId, OrderDetail::getNum, OrderDetail::getReturnNum, OrderDetail::getPackAmount, OrderDetail::getReturnNum) QueryWrapper.create().select(OrderDetail::getId, OrderDetail::getProductId, OrderDetail::getNum, OrderDetail::getReturnNum, OrderDetail::getPackAmount, OrderDetail::getReturnNum)
.eq(OrderDetail::getOrderId, orderInfo.getId()) .eq(OrderDetail::getOrderId, orderInfo.getId()));
.list();
for (OrderDetail orderDetail : orderDetails) { for (OrderDetail orderDetail : orderDetails) {
if (isPay) { if (isPay) {
if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) { if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) {
@@ -517,7 +512,7 @@ public class OrderPayServiceImpl implements OrderPayService {
@NonNull String refundReason, @NonNull BigDecimal refundAmount) { @NonNull String refundReason, @NonNull BigDecimal refundAmount) {
OrderPayment payment = paymentService.getById(payOrderId); OrderPayment payment = paymentService.getById(payOrderId);
AssertUtil.isNull(payment, "退款失败支付记录不存在"); 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())); refPayOrderNo, refundAmount, payment.getId(), payment.getPlatformType()));
CzgResult<RefundRespDTO> refund = payService.refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(PayService.MONEY_RATE).longValue(), 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()); throw new CzgException(refund.getMsg());
} else { } else {
OrderPayment upPayment = new OrderPayment(); OrderPayment upPayment = new OrderPayment();
upPayment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
upPayment.setPayTime(LocalDateTimeUtil.parse(refund.getData().getRefundTime())); upPayment.setPayTime(LocalDateTimeUtil.parse(refund.getData().getRefundTime()));
upPayment.setTradeNumber(refund.getData().getThirdRefundNo()); upPayment.setTradeNumber(refund.getData().getThirdRefundNo());
upPayment.setRespJson(refund.getData().getOriginalData()); upPayment.setRespJson(refund.getData().getOriginalData());

View File

@@ -108,7 +108,7 @@ public class PayServiceImpl implements PayService {
@NonNull String refundReason, @NonNull BigDecimal refundAmount) { @NonNull String refundReason, @NonNull BigDecimal refundAmount) {
OrderPayment payment = paymentService.getById(payOrderId); OrderPayment payment = paymentService.getById(payOrderId);
AssertUtil.isNull(payment, "退款失败,支付记录不存在"); 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(), 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())); payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), "", payment.getPlatformType()));
OrderPayment uOrderPayment = new OrderPayment(); OrderPayment uOrderPayment = new OrderPayment();

View File

@@ -70,7 +70,7 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
} }
if (day <= 1) { if (day <= 1) {
return List.of(onlineDataAmount); return List.of(onlineDataAmount);
}else { } else {
startDate = currentDate.minusDays(day - 1); startDate = currentDate.minusDays(day - 1);
} }
List<TotalVo> statDateRange = mapper.getStatDateRange(shopId, startDate, currentDate); List<TotalVo> statDateRange = mapper.getStatDateRange(shopId, startDate, currentDate);
@@ -84,7 +84,7 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
if (day <= 1) { if (day <= 1) {
Map<String, BigDecimal> onlinePayTypeDate = mapper.getOnlinePayTypeDate(shopId, currentDate); Map<String, BigDecimal> onlinePayTypeDate = mapper.getOnlinePayTypeDate(shopId, currentDate);
return CountPayTypeVo.realTimeDataByDay(onlinePayTypeDate); return CountPayTypeVo.realTimeDataByDay(onlinePayTypeDate);
}else { } else {
startDate = currentDate.minusDays(day - 1); startDate = currentDate.minusDays(day - 1);
} }
return CountPayTypeVo.mergePayTypeData( return CountPayTypeVo.mergePayTypeData(
@@ -104,7 +104,7 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
} }
if (day <= 1) { if (day <= 1) {
return List.of(onlineProfitRateBarChart); return List.of(onlineProfitRateBarChart);
}else { } else {
startDate = currentDate.minusDays(day - 1); startDate = currentDate.minusDays(day - 1);
} }
List<ProfitRateVO> statDateRange = mapper.profitRateBarChart(shopId, startDate, currentDate); List<ProfitRateVO> statDateRange = mapper.profitRateBarChart(shopId, startDate, currentDate);
@@ -180,10 +180,11 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
result.setTableCount(Optional.ofNullable(tableCount).orElse(0L)); result.setTableCount(Optional.ofNullable(tableCount).orElse(0L));
result.setProductCostAmount(Optional.ofNullable(productCostAmount).orElse(BigDecimal.ZERO)); result.setProductCostAmount(Optional.ofNullable(productCostAmount).orElse(BigDecimal.ZERO));
//会员充值退款 充值退款金额(线上退款+现金退款 //会员充值金额(线上充值+现金充值+霸王餐充值
BigDecimal cashRechargeAmount = Objects.requireNonNullElse(result.getCashRechargeAmount(), BigDecimal.ZERO); BigDecimal cashRechargeAmount = Objects.requireNonNullElse(result.getCashRechargeAmount(), BigDecimal.ZERO);
BigDecimal onlineRechargeAmount = Objects.requireNonNullElse(result.getOnlineRechargeAmount(), 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); result.setRechargeAmount(rechargeAmount);
//会员充值退款 充值退款金额(线上退款+现金退款) //会员充值退款 充值退款金额(线上退款+现金退款)
BigDecimal onlineRechargeRefundAmount = Objects.requireNonNullElse( BigDecimal onlineRechargeRefundAmount = Objects.requireNonNullElse(
@@ -220,9 +221,6 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
.add(creditPayAmount); .add(creditPayAmount);
result.setPayAmount(totalPayAmount); result.setPayAmount(totalPayAmount);
calculateShopOrderStatistic(result); calculateShopOrderStatistic(result);
calculateProfitInfo(result);
calculateTurnoverRate(result);
calculateAvgPayAmount(result);
return result; return result;
} }

View File

@@ -314,7 +314,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
return CzgResult.failure("退款失败,该充值记录不存在"); return CzgResult.failure("退款失败,该充值记录不存在");
} }
String refPayOrderNo = "REFVIP" + IdUtil.getSnowflakeNextId(); 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())); refPayOrderNo, refPayParam.getRefAmount(), inFlow.getId(), payment.getPlatformType()));
CzgResult<RefundRespDTO> refund = payService.refund(refPayParam.getShopId(), new CzgRefundReq(refPayOrderNo, refPayParam.getRemark(), 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(), refPayParam.getRefAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getAmount().multiply(PayService.MONEY_RATE).longValue(),