xdd 1 ماه پیش
والد
کامیت
15092da440

+ 31 - 51
fs-service/src/main/java/com/fs/core/utils/OrderCodeUtils.java

@@ -2,6 +2,7 @@ package com.fs.core.utils;
 
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
 import cn.hutool.json.JSONUtil;
 import com.fs.common.config.FSConfig;
 import com.fs.common.core.redis.RedisCache;
@@ -11,12 +12,14 @@ import com.fs.common.utils.spring.SpringUtils;
 //import org.redisson.api.RedissonClient;
 import com.fs.common.vo.SmsSendVO;
 import com.fs.core.vo.OrderCodeVO;
+import lombok.extern.slf4j.Slf4j;
 import org.redisson.api.RLock;
 import org.redisson.api.RedissonClient;
 
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
+@Slf4j
 public class OrderCodeUtils {
 
     public static String genOrderSn(){
@@ -44,59 +47,36 @@ public class OrderCodeUtils {
 
     }
     public static String getOrderSn(){
-        String url= FSConfig.getCommonApi()+ "/app/common/genOrderCode";
-        String json = HttpRequest.get(url)
-                .execute().body();
-        OrderCodeVO vo= JSONUtil.toBean(json, OrderCodeVO.class);
-        if(vo.getCode()==200){
-            return vo.getOrderCode();
-        }
-        else return null;
+        String url = FSConfig.getCommonApi() + "/app/common/genOrderCode";
 
-    }
+        log.info("开始请求订单号生成接口,URL: {}", url);
 
-    public static String getH5RedPacketOrderSn(){
-        String url= FSConfig.getH5CommonApi()+ "/app/common/genOrderCode";
-        String json = HttpRequest.get(url)
-                .execute().body();
-        OrderCodeVO vo= JSONUtil.toBean(json, OrderCodeVO.class);
-        if(vo.getCode()==200){
-            return vo.getOrderCode();
-        }
-        else return null;
+        try {
+            HttpResponse response = HttpRequest.get(url).execute();
 
-    }
+            log.info("请求方法: GET");
+            log.info("请求URL: {}", url);
+            log.info("响应状态码: {}", response.getStatus());
+            log.info("响应头信息: {}", response.headers());
+
+            String responseBody = response.body();
+            log.info("响应Body: {}", responseBody);
 
-//    public static String genOrderSn() {
-//
-//        JedisPool jedisPool = SpringUtils.getBean(JedisPool.class);
-//        try (Jedis jedis = jedisPool.getResource()) {
-//            String lockKey = "myLock";
-//            String lockValue = UUID.randomUUID().toString();
-//
-//            // 尝试获取锁,设置锁的超时时间防止死锁
-////            try {
-////                Thread.sleep(10000); // 10秒等待
-////            } catch (InterruptedException e) {
-////                Thread.currentThread().interrupt();
-////            }
-//            SetParams params = new SetParams().nx().px(100);
-//            String result = jedis.set(lockKey, lockValue, params);
-//
-//            if ("OK".equals(result)) {
-//                try {
-//                    // 业务逻辑
-//                    return String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
-//                } finally {
-//                    jedis.del(lockKey); // 释放锁
-//                }
-//            } else {
-//                return null;
-//            }
-//        } catch (JedisConnectionException e) {
-//            // 处理连接异常,例如重试或记录日志
-//            e.printStackTrace();
-//            return null;
-//        }
-//    }
+            // 解析响应
+            OrderCodeVO vo = JSONUtil.toBean(responseBody, OrderCodeVO.class);
+
+            if (vo.getCode() == 200) {
+                log.info("订单号生成成功,订单号: {}", vo.getOrderCode());
+                return vo.getOrderCode();
+            } else {
+                log.warn("订单号生成失败,响应码: {}, 响应内容: {}", vo.getCode(), responseBody);
+                return null;
+            }
+
+
+        } catch (Exception e) {
+            log.error("请求订单号生成接口异常,URL: {}", url, e);
+            return null;
+        }
+    }
 }

+ 3 - 3
fs-service/src/main/java/com/fs/his/service/impl/FsPrescribeServiceImpl.java

@@ -1,6 +1,7 @@
 package com.fs.his.service.impl;
 
 import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
@@ -1097,8 +1098,8 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
     @Override
     public R auditWithoutMsg(FsPrescribeAuditParam param) {
         FsPrescribe prescribe=this.selectFsPrescribeByPrescribeId(param.getPrescribeId());
-        if(prescribe.getStatus()!=0){
-            return R.error("非法操作");
+        if(ObjectUtil.notEqual(prescribe.getStatus(),0)){
+            throw new IllegalArgumentException(String.format("该处方单已经开过!参数: %s",JSON.toJSONString(prescribe)));
         }
         FsPrescribe map=new FsPrescribe();
         map.setPrescribeId(param.getPrescribeId());
@@ -1114,7 +1115,6 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
             this.updateFsPrescribe(map);
             //写入订单
             storeOrderService.createOrder(prescribe.getPrescribeId());
-
             return R.ok();
         }
         return R.ok("操作成功");

+ 1 - 1
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -500,7 +500,7 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
         List<FsStoreOrderItem> items = new ArrayList<>();
         String orderSn = OrderCodeUtils.getOrderSn();
         if (StringUtils.isEmpty(orderSn)) {
-            return R.error("订单生成失败,请重试");
+            throw new IllegalArgumentException("订单生成失败,获取订单ID失败!");
         }
         order.setOrderCode(orderSn);
         order.setCycle(prescribe.getCycle());