Преглед на файлове

新增现金支付类型payType=4(仅商家创建订单可用,客户端下单拒绝);现金单创建未支付,商家App确认收款置已支付,已取消订单禁止确认

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
qmj преди 1 ден
родител
ревизия
91dde5ef18

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/app/order/OrderLifecycleService.java

@@ -32,6 +32,8 @@ public class OrderLifecycleService {
 
     public static final String PAY_TYPE_OFFLINE = "1";
     public static final String PAY_TYPE_OMG = "2";
+    /** 现金支付:仅商家创建订单可用(客户端下单拒绝);创建时未支付,商家App确认收款后置已支付 */
+    public static final String PAY_TYPE_CASH = "4";
 
     private final IPosOrderService posOrderService;
     private final OrderService billingService;

+ 36 - 0
ruoyi-admin/src/main/java/com/ruoyi/app/order/PosOrderShOprateController.java

@@ -184,6 +184,10 @@ public class PosOrderShOprateController extends BaseController {
             // 设置支付相关信息(从父订单继承)
             posOrder.setPayType(input.getPaymentMethod());
             posOrder.setOrderSource("MERCHANT");
+            // 现金支付(4):创建时未支付,待商家App触发确认收款后置为已支付
+            if (OrderLifecycleService.PAY_TYPE_CASH.equals(input.getPaymentMethod())) {
+                posOrder.setPayStatus(0L);
+            }
             //设置桌号(从父订单继承)
             posOrder.setTableId(input.getTableId());
             posOrder.setTableNo(input.getTableNo());
@@ -370,6 +374,38 @@ public class PosOrderShOprateController extends BaseController {
         return AjaxResult.success();
     }
 
+    /**
+     * 商家确认现金收款:payType=4 的订单 payStatus 0→1(现金单创建时未支付,商家收到现金后在App触发)
+     */
+    @Anonymous
+    @Auth
+    @GetMapping("/confirmCashPayment")
+    public AjaxResult confirmCashPayment(@RequestHeader String token, @RequestParam Long id) {
+        PosOrder order = posOrderService.getOne(new LambdaQueryWrapper<PosOrder>().eq(PosOrder::getId, id));
+        if (order == null) {
+            throw new ServiceException(MessageUtils.message("no.order.not.exist"));
+        }
+        linePayOrderGuard.requireMerchantOwnership(order, currentMerchant(token));
+        if (!OrderLifecycleService.PAY_TYPE_CASH.equals(order.getPayType())) {
+            throw new ServiceException(MessageUtils.message("no.order.paytype.not.cash"));
+        }
+        // 已取消订单不允许确认收款:否则出现 state=4+payStatus=1,无现金退款流程可恢复,只能手工改库
+        if (order.getState() != null && order.getState() == 4L) {
+            throw new ServiceException(MessageUtils.message("no.order.cash.cancelled"));
+        }
+        if (Long.valueOf(1L).equals(order.getPayStatus())) {
+            throw new ServiceException(MessageUtils.message("no.order.cash.already.paid"));
+        }
+        PosOrder update = new PosOrder();
+        update.setId(order.getId());
+        update.setPayStatus(1L);
+        posOrderService.saveOrUpdate(update);
+        InfoUser shUser = infoUserService.getOne(new LambdaQueryWrapper<InfoUser>().eq(InfoUser::getUserId, Long.valueOf(new JwtUtil().getusid(token))));
+        String shName = shUser != null ? shUser.getNickName() : "";
+        orderLogHelper.log(String.valueOf(order.getDdId()), 2, Long.valueOf(new JwtUtil().getusid(token)), shName, "商家" + shName + "确认现金收款");
+        return AjaxResult.success();
+    }
+
     /**
      * 商家取消订单:校验 state IN (0,1),设 state=4
      */

+ 4 - 0
ruoyi-admin/src/main/java/com/ruoyi/app/order/UserOrderController.java

@@ -158,6 +158,10 @@ public class UserOrderController extends BaseController {
             }
             shdz= JSON.toJSONString(usadd);
         }
+        // 现金支付(4)仅商家创建订单可用,客户端下单直接拒绝
+        if (OrderLifecycleService.PAY_TYPE_CASH.equals(input.getPaymentMethod())) {
+            throw new ServiceException(MessageUtils.message("no.paytype.cash.merchant.only"));
+        }
         // === 发票意图(010 Phase 11)===
         // 校验:载具/捐赠/统编验真前置,不通过拦截下单(联网校验用第一个可开票门店的 ezPay 凭证)
         if (!StringUtils.isEmpty(input.getInvoiceChoice()) && !"PAPER".equals(input.getInvoiceChoice())) {

+ 4 - 0
ruoyi-admin/src/main/resources/i18n/messages.properties

@@ -254,3 +254,7 @@ omg.pay.retry.not.available=当前支付状态无法重新发起,请先刷新
 omg.pay.retry.failed=重新发起 OMG 支付失败,请稍后重试
 omg.pay.refund.unavailable.test.environment=OMG 测试环境不支持退款,请在正式环境启用后操作
 omg.pay.refund.failed=OMG 退款操作失败,请稍后重试
+no.paytype.cash.merchant.only=Thanh toán tiền mặt chỉ dành cho đơn hàng do merchant tạo
+no.order.paytype.not.cash=Đơn hàng này không phải thanh toán tiền mặt
+no.order.cash.already.paid=Đơn hàng này đã được xác nhận thu tiền
+no.order.cash.cancelled=Đơn hàng đã bị hủy, không thể xác nhận thu tiền

+ 4 - 0
ruoyi-admin/src/main/resources/i18n/messages_en_US.properties

@@ -257,3 +257,7 @@ omg.pay.retry.not.available=The current payment state cannot be retried; refresh
 omg.pay.retry.failed=The OMG payment could not be retried; please try again later
 omg.pay.refund.unavailable.test.environment=OMG refunds are unavailable in the test environment; enable the production environment first
 omg.pay.refund.failed=The OMG refund operation failed; please try again later
+no.paytype.cash.merchant.only=Cash payment is only available for merchant-created orders
+no.order.paytype.not.cash=This order is not a cash payment order
+no.order.cash.already.paid=Cash payment for this order has already been confirmed
+no.order.cash.cancelled=The order has been cancelled; cash payment cannot be confirmed

+ 4 - 0
ruoyi-admin/src/main/resources/i18n/messages_vi.properties

@@ -257,3 +257,7 @@ omg.pay.retry.not.available=Trạng thái thanh toán hiện tại không thể
 omg.pay.retry.failed=Không thể tạo lại thanh toán OMG; vui lòng thử lại sau
 omg.pay.refund.unavailable.test.environment=Môi trường thử nghiệm OMG không hỗ trợ hoàn tiền; hãy bật môi trường chính thức trước
 omg.pay.refund.failed=Thao tác hoàn tiền OMG thất bại; vui lòng thử lại sau
+no.paytype.cash.merchant.only=Thanh toán tiền mặt chỉ dành cho đơn hàng do merchant tạo
+no.order.paytype.not.cash=Đơn hàng này không phải thanh toán tiền mặt
+no.order.cash.already.paid=Đơn hàng này đã được xác nhận thu tiền
+no.order.cash.cancelled=Đơn hàng đã bị hủy, không thể xác nhận thu tiền

+ 4 - 0
ruoyi-admin/src/main/resources/i18n/messages_zh_CN.properties

@@ -258,3 +258,7 @@ omg.pay.retry.not.available=当前支付状态无法重新发起,请先刷新
 omg.pay.retry.failed=重新发起 OMG 支付失败,请稍后重试
 omg.pay.refund.unavailable.test.environment=OMG 测试环境不支持退款,请在正式环境启用后操作
 omg.pay.refund.failed=OMG 退款操作失败,请稍后重试
+no.paytype.cash.merchant.only=现金支付仅支持商家创建订单
+no.order.paytype.not.cash=该订单不是现金支付订单
+no.order.cash.already.paid=该订单已确认收款
+no.order.cash.cancelled=订单已取消,不能确认收款

+ 4 - 0
ruoyi-admin/src/main/resources/i18n/messages_zh_TW.properties

@@ -258,3 +258,7 @@ omg.pay.retry.not.available=目前付款狀態無法重新發起,請先重新
 omg.pay.retry.failed=重新發起 OMG 付款失敗,請稍後再試
 omg.pay.refund.unavailable.test.environment=OMG 測試環境不支援退款,請在正式環境啟用後操作
 omg.pay.refund.failed=OMG 退款操作失敗,請稍後再試
+no.paytype.cash.merchant.only=現金支付僅支援商家建立訂單
+no.order.paytype.not.cash=該訂單不是現金支付訂單
+no.order.cash.already.paid=該訂單已確認收款
+no.order.cash.cancelled=訂單已取消,不能確認收款

+ 1 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/PosOrder.java

@@ -272,7 +272,7 @@ public class PosOrder {
     private Date sdTime;
 
     /**
-     * 支付方式:1 到付,2 OMG,3 LINE Pay,4 银行卡,5 余额
+     * 支付方式:1 到付,2 OMG,3 LINE Pay,4 现金(仅商家创建订单使用),5 余额,6 蓝新
      */
     private String payType;