Przeglądaj źródła

加入律师通知接口

zhangchen 3 tygodni temu
rodzic
commit
c086b02625

+ 4 - 18
alien-lawyer/src/main/java/shop/alien/lawyer/service/impl/LawyerClientConsultationOrderServiceImpl.java

@@ -38,6 +38,7 @@ import shop.alien.mapper.LawyerUserMapper;
 import shop.alien.mapper.LifeNoticeMapper;
 import shop.alien.mapper.LifeUserMapper;
 import shop.alien.util.common.constant.LawyerStatusEnum;
+import shop.alien.util.common.constant.OrderActionType;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
 
@@ -49,21 +50,6 @@ import java.util.stream.Collectors;
 import java.util.Objects;
 
 /**
- * 操作类型常量
- */
-class OrderActionType {
-    /**
-     * 接单
-     */
-    static final String ACCEPT = "1";
-    
-    /**
-     * 取消
-     */
-    static final String CANCEL = "2";
-}
-
-/**
  * 咨询订单 服务实现类
  *
  * @author system
@@ -670,8 +656,8 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
 
         // 操作类型格式校验
         String trimmedActionType = actionType.trim();
-        if (!OrderActionType.ACCEPT.equals(trimmedActionType) 
-                && !OrderActionType.CANCEL.equals(trimmedActionType)) {
+        OrderActionType actionTypeEnum = OrderActionType.getByCode(trimmedActionType);
+        if (actionTypeEnum == null) {
             log.warn("律师确认订单失败:操作类型无效,actionType={}", actionType);
             return R.fail("操作类型无效,1-接单,2-取消");
         }
@@ -705,7 +691,7 @@ public class LawyerClientConsultationOrderServiceImpl extends ServiceImpl<Lawyer
         }
 
         // 根据操作类型处理
-        if (OrderActionType.ACCEPT.equals(trimmedActionType)) {
+        if (actionTypeEnum == OrderActionType.ACCEPT) {
             // 接单:更新订单状态为进行中
             Integer inProgressStatus = LawyerStatusEnum.INPROGRESS.getStatus();
             Date acceptTime = new Date();

+ 51 - 0
alien-util/src/main/java/shop/alien/util/common/constant/OrderActionType.java

@@ -0,0 +1,51 @@
+package shop.alien.util.common.constant;
+
+/**
+ * 订单操作类型枚举
+ */
+public enum OrderActionType {
+    /**
+     * 接单
+     */
+    ACCEPT("1", "接单"),
+    
+    /**
+     * 取消
+     */
+    CANCEL("2", "取消");
+
+    private final String code;
+    private final String description;
+
+    OrderActionType(String code, String description) {
+        this.code = code;
+        this.description = description;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    /**
+     * 根据code获取枚举
+     *
+     * @param code 操作类型代码
+     * @return 枚举值,如果不存在则返回null
+     */
+    public static OrderActionType getByCode(String code) {
+        if (code == null) {
+            return null;
+        }
+        for (OrderActionType type : OrderActionType.values()) {
+            if (type.code.equals(code)) {
+                return type;
+            }
+        }
+        return null;
+    }
+}
+