Selaa lähdekoodia

feat(business): 添加经纬度字段并优化充电订单状态校验

- 在AppletStationDetailVO中新增longitude和latitude字段,支持站点地理位置描述
- 修改ThirdPartyStationInfoMapper.xml,映射充电站经纬度数据
- 优化ChargeOrderInfoServiceImpl中判断进行中订单逻辑,避免重复订单产生
- 调整异常处理,简化启动充电失败时的异常信息
- 注释ChargingJob中定时任务的@Scheduled注解,暂时关闭同步充电站信息和价格策略的定时执行
- 更新WFTOrderService退款测试用例中部分参数值
SheepHy 3 viikkoa sitten
vanhempi
commit
25b8ba3135

+ 6 - 0
src/main/java/com/zsElectric/boot/business/model/vo/AppletStationDetailVO.java

@@ -38,6 +38,12 @@ public class AppletStationDetailVO implements Serializable {
     @Schema(description = "详细地址")
     private String address;
 
+    @Schema(description = "经度")
+    private BigDecimal longitude;
+
+    @Schema(description = "纬度")
+    private BigDecimal latitude;
+
     @Schema(description = "站点图片列表(JSON数组)")
     private String pictures;
 

+ 4 - 4
src/main/java/com/zsElectric/boot/business/service/WFTOrderService.java

@@ -1073,11 +1073,11 @@ public class WFTOrderService {
     public static void main(String[] args) throws IOException {
         SortedMap<String, String> params = new TreeMap<>();
         SwiftpassConfig swiftpassConfig = new SwiftpassConfig();
-        params.put("out_trade_no", "ZSWL20250507000000551068");//商户订单号
-        params.put("out_refund_no", "TK20250507000000551068");//商户退款单号
+        params.put("transaction_id", "2301202601052012511795");//商户订单号
+        params.put("out_refund_no", "TK2301202601052012511795");//商户退款单号
         params.put("attach", "");//退款原因
-        params.put("total_fee", "2000");//原订单金额
-        params.put("refund_fee", "1953");//退款金额
+        params.put("total_fee", "3000");//原订单金额
+        params.put("refund_fee", "2970");//退款金额
         params.put("sign_type", "RSA_1_256");
         PayUtill payUtill = new PayUtill();
         swiftpassConfig.setKey("f5131b3f07acb965a59041b690a29911");

+ 4 - 13
src/main/java/com/zsElectric/boot/business/service/impl/ChargeOrderInfoServiceImpl.java

@@ -169,15 +169,9 @@ public class ChargeOrderInfoServiceImpl extends ServiceImpl<ChargeOrderInfoMappe
             Assert.isTrue(userInfo != null, "用户信息不存在");
 
             //判断有没有正在进行中的订单
-            ChargeOrderInfo selectOne = this.baseMapper.selectOne(Wrappers.lambdaQuery(ChargeOrderInfo.class)
-                    .eq(ChargeOrderInfo::getUserId, userId)
-                    .in(ChargeOrderInfo::getStatus, SystemConstants.STATUS_ZERO, SystemConstants.STATUS_ONE, SystemConstants.STATUS_TWO)
-                    .last("limit 1"));
-            if(null != selectOne){
-                appInvokeChargeVO.setChargeOrderId(selectOne.getId());
-                appInvokeChargeVO.setChargeOrderNo(selectOne.getChargeOrderNo());
-                appInvokeChargeVO.setStatus(selectOne.getStatus());
-                return appInvokeChargeVO;
+            Long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(ChargeOrderInfo.class).eq(ChargeOrderInfo::getUserId, userId).in(ChargeOrderInfo::getStatus, SystemConstants.STATUS_ZERO, SystemConstants.STATUS_ONE, SystemConstants.STATUS_TWO));
+            if (count > 0){
+                throw new BusinessException("您有正在进行中的订单,请先停止充电");
             }
             //生成系统充电订单号及互联互通充电订单号 startChargeSeq equipAuthSeq (格式"运营商ID+唯一编号")
             assert userId != null;
@@ -247,12 +241,9 @@ public class ChargeOrderInfoServiceImpl extends ServiceImpl<ChargeOrderInfoMappe
             appInvokeChargeVO.setChargeOrderNo(chargeOrderNo);
             appInvokeChargeVO.setChargeOrderId(chargeOrderInfo.getId());
             return appInvokeChargeVO;
-        } catch (BusinessException e) {
-            log.error("启动充电失败:{}", e.getMessage());
-            throw e;
         } catch (Exception e) {
             log.error("启动充电失败,系统错误", e);
-            throw new BusinessException("启动充电失败,系统错误,请联系客服处理!" + e.getMessage());
+            throw new BusinessException("启动充电失败 !" + e.getMessage());
         }
     }
 

+ 2 - 2
src/main/java/com/zsElectric/boot/charging/quartz/ChargingJob.java

@@ -45,7 +45,7 @@ public class ChargingJob {
      * 同步充电站信息
      * 每5分钟执行一次,从第三方接口获取充电站信息并存储到数据库
      */
-    @Scheduled(cron = "0 0/15 * * * ?")
+//    @Scheduled(cron = "0 0/15 * * * ?")
     public void syncStationsInfo() {
         log.info("开始执行充电站信息同步定时任务");
         
@@ -82,7 +82,7 @@ public class ChargingJob {
      * 每10分钟执行一次,查询所有充电桩的价格策略并存储到数据库
      * cron表达式: 0 10 * * * ? 表示每10分钟执行
      */
-    @Scheduled(cron = "0 */10 * * * ?")
+//    @Scheduled(cron = "0 */10 * * * ?")
     public void syncEquipmentPricePolicy() {
         // 检查任务是否正在执行,防止并发
         if (isPricePolicySyncRunning) {

+ 4 - 0
src/main/resources/mapper/business/ThirdPartyStationInfoMapper.xml

@@ -416,6 +416,8 @@
         <result property="tips" column="station_tips"/>
         <result property="distance" column="distance"/>
         <result property="address" column="address"/>
+        <result property="longitude" column="longitude"/>
+        <result property="latitude" column="latitude"/>
         <result property="pictures" column="pictures"/>
         <result property="currentPrice" column="current_price"/>
         <result property="currentPeriod" column="current_period"/>
@@ -434,6 +436,8 @@
             tpsi.station_name,
             tpsi.station_tips,
             tpsi.address,
+            tpsi.station_lng AS longitude,
+            tpsi.station_lat AS latitude,
             tpsi.banner_pictures AS pictures,
             tpsi.own_business_hours AS business_hours,
             tpsi.customer_service_hotline,