TRX 1 gadu atpakaļ
vecāks
revīzija
801fabce9a

+ 27 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/payment/ExpenseFlowModel.java

@@ -4,6 +4,7 @@ import cn.hutool.json.JSONObject;
 import com.github.microservice.models.type.PaymentDeviceType;
 import com.zhongshu.card.client.model.base.SuperModel;
 import com.zhongshu.card.client.model.school.CardInfoModel;
+import com.zhongshu.card.client.utils.type.OrderType;
 import com.zhongshu.card.client.utils.type.RefundState;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
@@ -21,6 +22,19 @@ import java.math.BigDecimal;
 @NoArgsConstructor
 public class ExpenseFlowModel extends SuperModel {
     //-----------------------------订单信息 start---------------------
+
+    @Schema(description = "订单的总体状态")
+    private OrderType orderType;
+
+    private String orderTypeStr;
+
+    public String getOrderTypeStr() {
+        if (orderType != null) {
+            return orderType.getRemark();
+        }
+        return "";
+    }
+
     @Schema(description = "用户userId")
     private String userId;
 
@@ -30,6 +44,18 @@ public class ExpenseFlowModel extends SuperModel {
     @Schema(description = "消费机设备ID")
     private String deviceId;
 
+    @Schema(description = "所属项目Oid")
+    private String projectOid;
+
+    @Schema(description = "所属项目的code")
+    private String projectCode;
+
+    @Schema(description = "订单所属的商户")
+    private String shopOid;
+
+    @Schema(description = "订单所属的学校")
+    private String schoolOid;
+
     @Schema(description = "卡片的编号,也是终端刷卡的 卡号")
     private String cardNo;
 
@@ -64,7 +90,7 @@ public class ExpenseFlowModel extends SuperModel {
     private Boolean isCreateSuccess = Boolean.TRUE;
 
     @Schema(description = "编辑支付设备和方式")
-    PaymentDeviceType paymentDeviceType;
+    private PaymentDeviceType paymentDeviceType;
 
     @Schema(description = "消费地点")
     private String placeName;

+ 39 - 69
FullCardClient/src/main/java/com/zhongshu/card/client/utils/type/OrderType.java

@@ -1,77 +1,47 @@
 package com.zhongshu.card.client.utils.type;
 
 import lombok.AllArgsConstructor;
+import lombok.Getter;
 
-@AllArgsConstructor
+/**
+ * 订单的总体状态
+ */
 public enum OrderType {
-    /**
-     * 待付款
-     */
-    WAIT_PAYMENT,
-
-    /**
-     * 已支付
-     */
-    HAVE_PAID,
-
-    /**
-     * 待使用
-     */
-    WAIT_USE,
-
-    /**
-     * 已使用
-     */
-    USED,
-    /**
-     * 申请退款
-     */
-    APPLY_REFUND,
-
-    /**
-     * 退款处理中
-     */
-    APPLY_REFUNDING,
-
-    /**
-     * 拒绝退款
-     */
-    REFUSAL_REFUND,
-
-    /**
-     * 取消退款
-     */
-    UN_REFUND,
-
-    /**
-     * 已退款
-     */
-    REFUNDED,
-
-    /**
-     * 自动退款
-     */
-    AOUTO_REFUNDED,
-
-    /**
-     * 关闭订单
-     */
-    CLOSE,
-
-    /**
-     * 申请提现
-     */
-    APPLY_WITHDRAW,
-
-    /**
-     * 提现通过
-     */
-    PASS_WITHDRAW,
-
-    /**
-     * 拒绝提现
-     */
-    REFUSAL_WITHDRAW,
 
+    WAIT_PAYMENT("待付款"),
 
+    PARAM_ERROR("参数验证错误"),
+
+    HAVE_PAID("已支付"),
+
+    WAIT_USE("待使用"),
+
+    USED("已使用"),
+
+    APPLY_REFUND("申请退款"),
+
+    APPLY_REFUNDING("退款处理中"),
+
+    REFUSAL_REFUND("拒绝退款"),
+
+    UN_REFUND("取消退款"),
+
+    REFUNDED("已退款"),
+
+    AOUTO_REFUNDED("自动退款"),
+
+    CLOSE("关闭订单"),
+
+    APPLY_WITHDRAW("申请提现"),
+
+    PASS_WITHDRAW("提现通过"),
+
+    REFUSAL_WITHDRAW("拒绝提现");
+
+    @Getter
+    private String remark;
+
+    OrderType(String remark) {
+        this.remark = remark;
+    }
 }

+ 17 - 2
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/payment/ExpenseFlow.java

@@ -4,6 +4,7 @@ import cn.hutool.json.JSONObject;
 import com.github.microservice.models.type.OrderFromType;
 import com.github.microservice.models.type.PaymentDeviceType;
 import com.github.microservice.models.type.PaymentType;
+import com.zhongshu.card.client.utils.type.OrderType;
 import com.zhongshu.card.client.utils.type.RefundState;
 import com.zhongshu.card.server.core.domain.base.SuperMain;
 import com.zhongshu.card.server.core.domain.org.UserAccount;
@@ -39,6 +40,9 @@ public class ExpenseFlow extends SuperMain {
 
     private String token;
 
+    @Schema(description = "订单的总体状态")
+    private OrderType orderType;
+
     @Schema(description = "消费的用户userId")
     private String userId;
 
@@ -100,7 +104,7 @@ public class ExpenseFlow extends SuperMain {
     private String paymentWay;
 
     @Schema(description = "支付方式")
-    PaymentType paymentType = PaymentType.WxQrCode;
+    private PaymentType paymentType = PaymentType.WxQrCode;
 
     @Schema(description = "付款码内容")
     private String qr;
@@ -117,7 +121,7 @@ public class ExpenseFlow extends SuperMain {
     private Boolean isCreateSuccess = Boolean.TRUE;
 
     @Schema(description = "编辑支付设备和方式")
-    PaymentDeviceType paymentDeviceType;
+    private PaymentDeviceType paymentDeviceType;
 
     @Schema(description = "验证参数是否符合要求")
     private Boolean verifyParamIsSuccess = Boolean.TRUE;
@@ -125,6 +129,17 @@ public class ExpenseFlow extends SuperMain {
     @Schema(description = "验证参数的提示")
     private String verifyParamMsg;
 
+    /**
+     * 设置参数验证错误
+     *
+     * @param error
+     */
+    public void setVerifyError(String error) {
+        verifyParamIsSuccess = Boolean.FALSE;
+        verifyParamMsg = error;
+        orderType = OrderType.PARAM_ERROR;
+    }
+
     //------------------支付结果 start-------------------------
 
     @Schema(description = "支付订单状态")

+ 17 - 31
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/payment/ExpenseFlowServiceImpl.java

@@ -14,6 +14,7 @@ import com.zhongshu.card.client.ret.ResultContent;
 import com.zhongshu.card.client.ret.ResultMessage;
 import com.zhongshu.card.client.service.payment.ExpenseFlowService;
 import com.zhongshu.card.client.utils.type.DataState;
+import com.zhongshu.card.client.utils.type.OrderType;
 import com.zhongshu.card.client.utils.type.RechargeType;
 import com.zhongshu.card.client.utils.type.UserState;
 import com.zhongshu.card.client.utils.type.school.CardState;
@@ -133,6 +134,7 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
         expenseFlow.setPaymentType(iotParam.getPaymentType());
         expenseFlow.setParam(iotParam);
         expenseFlow.setPaymentDeviceType(PaymentDeviceType.HxzConsumTransactions);
+        expenseFlow.setOrderType(OrderType.WAIT_PAYMENT);
 
         // 验证参数、填充数据
         commonVerifyExpenseFlow(expenseFlow);
@@ -258,15 +260,13 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
         // 验证设备
         DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
         if (ObjectUtils.isEmpty(deviceInfo)) {
-            entity.setVerifyParamIsSuccess(Boolean.FALSE);
-            entity.setVerifyParamMsg("业务设备未注册");
+            entity.setVerifyError("业务设备未注册");
             return;
         }
 
         // 设备已停用
         if (deviceInfo.getState() != null && deviceInfo.getState() == DataState.Disable) {
-            entity.setVerifyParamIsSuccess(Boolean.FALSE);
-            entity.setVerifyParamMsg(String.format("设备%s", deviceInfo.getState().getRemark()));
+            entity.setVerifyError(String.format("设备%s", deviceInfo.getState().getRemark()));
             return;
         }
 
@@ -280,14 +280,12 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
         }
 
         if (StringUtils.isEmpty(entity.getSchoolOid())) {
-            entity.setVerifyParamIsSuccess(Boolean.FALSE);
-            entity.setVerifyParamMsg("设备未绑定学校");
+            entity.setVerifyError("设备未绑定学校");
             return;
         }
 
         if (StringUtils.isEmpty(entity.getShopOid())) {
-            entity.setVerifyParamIsSuccess(Boolean.FALSE);
-            entity.setVerifyParamMsg("设备未绑定商户");
+            entity.setVerifyError("设备未绑定商户");
             return;
         }
 
@@ -303,8 +301,7 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
 
         // 验证项目信息
         if (StringUtils.isEmpty(entity.getProjectCode())) {
-            entity.setVerifyParamIsSuccess(Boolean.FALSE);
-            entity.setVerifyParamMsg("未绑定项目信息");
+            entity.setVerifyError("未绑定项目信息");
             return;
         }
 
@@ -314,8 +311,7 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
             CardInfo cardInfo = cardInfoDao.findByCode(entity.getCardNo());
             // 验证卡片
             if (ObjectUtils.isEmpty(cardInfo)) {
-                entity.setVerifyParamIsSuccess(Boolean.FALSE);
-                entity.setVerifyParamMsg("卡片未注册");
+                entity.setVerifyError("卡片未注册");
                 return;
             }
             entity.setCardInfo(cardInfo);
@@ -323,38 +319,33 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
 
             // 判断卡片是否可用
             if (cardInfo.getCardState() != CardState.Enable) {
-                entity.setVerifyParamIsSuccess(Boolean.FALSE);
-                entity.setVerifyParamMsg(String.format("卡片%s", cardInfo.getCardState().getRemark()));
+                entity.setVerifyError(String.format("卡片%s", cardInfo.getCardState().getRemark()));
                 return;
             }
 
             ConsumTransactionsModel iotParam = (ConsumTransactionsModel) entity.getParam();
             if (iotParam.getMode() != 0 && iotParam.getPayType() != 0) {
-                entity.setVerifyParamIsSuccess(Boolean.FALSE);
-                entity.setVerifyParamMsg("消费模式不支持");
+                entity.setVerifyError("消费模式不支持");
                 return;
             }
         }
 
         // 验证用户信息
         if (StringUtils.isEmpty(entity.getUserId())) {
-            entity.setVerifyParamIsSuccess(Boolean.FALSE);
-            entity.setVerifyParamMsg("订单未找到用户");
+            entity.setVerifyError("订单未找到用户");
             return;
         }
 
         UserAccount userAccount = userCountDao.findTopByUserId(entity.getUserId());
         if (ObjectUtils.isEmpty(userAccount)) {
-            entity.setVerifyParamIsSuccess(Boolean.FALSE);
-            entity.setVerifyParamMsg("用户未注册");
+            entity.setVerifyError("用户未注册");
             return;
         }
         entity.setUserName(userAccount.getName());
         entity.setUserAccount(userAccount);
 
         if (userAccount.getState() == UserState.Locked) {
-            entity.setVerifyParamIsSuccess(Boolean.FALSE);
-            entity.setVerifyParamMsg("用户已锁定");
+            entity.setVerifyError("用户已锁定");
             return;
         }
 
@@ -365,14 +356,12 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
             // 钱包信息
             Wallet wallet = walletService.getUserWalletByUserId(entity.getUserId());
             if (wallet.getDataState() != DataState.Enable) {
-                entity.setVerifyParamIsSuccess(Boolean.FALSE);
-                entity.setVerifyParamMsg(String.format("支付失败钱包%s", wallet.getDataState().getRemark()));
+                entity.setVerifyError(String.format("支付失败钱包%s", wallet.getDataState().getRemark()));
                 return;
             }
             // 检查
             if (wallet.getAmount().compareTo(amount) < 0) {
-                entity.setVerifyParamIsSuccess(Boolean.FALSE);
-                entity.setVerifyParamMsg("余额不足");
+                entity.setVerifyError("余额不足");
                 return;
             }
         }
@@ -384,19 +373,16 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
             entity.setPayType("消费");
         }
         if (entity.getPaymentType() == null) {
-            entity.setVerifyParamIsSuccess(Boolean.FALSE);
-            entity.setVerifyParamMsg("支付方式不支持");
+            entity.setVerifyError("支付方式不支持");
             return;
         }
 
         // 金额判断
         BigDecimal payAmount = entity.getPayAmount();
         if (CommonUtil.bigDecimalIsEmpty(payAmount)) {
-            entity.setVerifyParamIsSuccess(Boolean.FALSE);
-            entity.setVerifyParamMsg("消费金额不能为0");
+            entity.setVerifyError("消费金额不能为0");
             return;
         }
-
         entity.setVerifyParamIsSuccess(Boolean.TRUE);
         entity.setVerifyParamMsg("参数验证成功");
     }