From 1d30ffc93499cc8072eb3cbd903a9d00389aa483 Mon Sep 17 00:00:00 2001 From: luojian <1327479187@qq.com> Date: Fri, 28 Feb 2025 16:31:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=90=E5=8D=95=E7=94=9F=E6=88=90=E6=97=B6?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=BC=82=E6=AD=A5=E8=B0=83=E7=94=A8=E9=82=AE?= =?UTF-8?q?=E6=94=BF=E7=B3=BB=E7=BB=9F=EF=BC=8C=E9=81=BF=E5=85=8D=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E5=93=8D=E5=BA=94=E8=B6=85=E6=97=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-druid.yml | 5 ++- cpxt-admin/src/main/resources/application.yml | 5 +-- .../biz/service/impl/BizOrderServiceImpl.java | 33 +++++++++++++++---- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/cpxt-admin/src/main/resources/application-druid.yml b/cpxt-admin/src/main/resources/application-druid.yml index f340093..821efa0 100644 --- a/cpxt-admin/src/main/resources/application-druid.yml +++ b/cpxt-admin/src/main/resources/application-druid.yml @@ -6,9 +6,8 @@ spring: druid: # 主库数据源 master: -# url: jdbc:mysql://localhost:3306/cpxtdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 -# url: jdbc:mysql://192.168.0.49:3306/cpxtdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - url: jdbc:mysql://localhost:3506/cpxtdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://192.168.0.49:3306/cpxtdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# url: jdbc:mysql://localhost:3506/cpxtdb?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root # password: 1234 password: root diff --git a/cpxt-admin/src/main/resources/application.yml b/cpxt-admin/src/main/resources/application.yml index 747171d..ec1733c 100644 --- a/cpxt-admin/src/main/resources/application.yml +++ b/cpxt-admin/src/main/resources/application.yml @@ -7,7 +7,8 @@ ruoyi: # 版权年份 copyrightYear: 2024 # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) - profile: D:/ruoyi/cpxt/uploadPath +# profile: D:/ruoyi/cpxt/uploadPath + profile: D:/ruoyi/uploadPath # 获取ip地址开关 addressEnabled: false # 验证码类型 math 数字计算 char 字符验证 @@ -16,7 +17,7 @@ ruoyi: # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 - port: 8888 + port: 8007 servlet: # 应用的访问路径 context-path: / diff --git a/cpxt-system/src/main/java/com/cpxt/biz/service/impl/BizOrderServiceImpl.java b/cpxt-system/src/main/java/com/cpxt/biz/service/impl/BizOrderServiceImpl.java index 0d94aba..493eae7 100644 --- a/cpxt-system/src/main/java/com/cpxt/biz/service/impl/BizOrderServiceImpl.java +++ b/cpxt-system/src/main/java/com/cpxt/biz/service/impl/BizOrderServiceImpl.java @@ -404,10 +404,16 @@ public class BizOrderServiceImpl implements IBizOrderService { bizOrderSub.setOrderFee(BigDecimal.valueOf(Helper.FDouble(subList.get(0).get("orderFee")))); bizOrderSub.setRemark((String) subList.get(0).get("remark")); bizOrderSubMapper.insert(bizOrderSub); - - // 同步调用同城急送平台入口 - callThirdPartyInterface(bizOrder, bizOrderSub); } + // 异步调用,避免出现响应时间过长的问题 + Runnable runnable = () -> { + for (int i = 1; i <= totalQuantity; i++) { + BizOrderSub bizOrderSub = bizOrderSubMapper.selectBySubOrderSn(orderSn + "-" + i); + // 调用同城急送平台入口 + callThirdPartyInterface(bizOrder, bizOrderSub); + } + }; + new Thread(runnable).start(); } } else { for (Map map1 : subList) { @@ -432,11 +438,19 @@ public class BizOrderServiceImpl implements IBizOrderService { bizOrderSub.setOrderFee(BigDecimal.valueOf(Helper.FDouble(map1.get("orderFee")))); bizOrderSub.setRemark((String) map1.get("remark")); bizOrderSubMapper.insert(bizOrderSub); - - // 同步调用同城急送平台入口 - callThirdPartyInterface(bizOrder, bizOrderSub); } } + // 异步调用,避免出现响应时间过长的问题 + Runnable runnable = () -> { + for (Map map1 : subList) { + if (map1.get("orderSn").equals(orderSn)) { + BizOrderSub bizOrderSub = bizOrderSubMapper.selectBySubOrderSn((String) map1.get("subOrderSn")); + // 调用同城急送平台入口 + callThirdPartyInterface(bizOrder, bizOrderSub); + } + } + }; + new Thread(runnable).start(); } } @@ -473,6 +487,13 @@ public class BizOrderServiceImpl implements IBizOrderService { orderSub.setTotalFee(String.valueOf(totalFee)); orderSub.setPostageFee(String.valueOf(postageFee)); bizOrderSubMapper.updateById(orderSub); + }else { + // 如果订单创建失败,则记录失败原因 + Object message = jsonObject.get("message"); + if (ObjectUtil.isNotEmpty(message)){ + bizOrderSub.setRemark(message.toString()); + bizOrderSubMapper.updateById(bizOrderSub); + } } }