Browse Source

优化时间查询参数

18782137998 1 năm trước cách đây
mục cha
commit
4164d8e317

+ 4 - 0
src/main/java/com/sckw/freight/job/FreightTask.java

@@ -22,11 +22,15 @@ public class FreightTask implements Runnable {
 
     @Value("${job.sleep}")
     private Integer sleep;
+
+    @Value("${job.enable}")
+    private Boolean enable;
     @Autowired
     private JobService jobService;
 
     @Override
     public void run() {
+        if (!enable) return;
         new Thread(() -> {
             while (true) {
                 try {

+ 2 - 4
src/main/java/com/sckw/freight/model/vo/request/RequestLedgerLogisticsPageInfo.java

@@ -4,8 +4,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
-import java.time.LocalDateTime;
-
 /**
  * @BelongsProject: Freight-Settlement-Backend
  * @BelongsPackage: com.sckw.freight.model.vo.request
@@ -40,12 +38,12 @@ public class RequestLedgerLogisticsPageInfo extends RequestPageInfo {
      * 创建时间 ["2025-01-09","2025-01-09"]
      */
     @Schema(description = "创建时间", allowableValues = "[2025-01-09,2025-01-09]")
-    private LocalDateTime[] createTime;
+    private String[] createTime;
     /**
      * 更新时间 ["2025-01-09","2025-01-09"]
      */
     @Schema(description="更新时间",  allowableValues = "[2025-01-09,2025-01-09]")
-    private LocalDateTime[] updateTime;
+    private String[] updateTime;
     /**
      * 企业id
      */

+ 1 - 2
src/main/java/com/sckw/freight/model/vo/request/RequestQueryOrderPageInfo.java

@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
-import java.time.LocalDateTime;
 import java.util.List;
 
 /**
@@ -20,5 +19,5 @@ import java.util.List;
 @Schema( description = "待对账物流订单-分页查询参数")
 public class RequestQueryOrderPageInfo extends RequestPageInfo {
     private String name;
-    private List<LocalDateTime> createTime;
+    private List<String> createTime;
 }

+ 1 - 2
src/main/java/com/sckw/freight/model/vo/request/RequestSettlementLogisticsPageInfo.java

@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
-import java.time.LocalDateTime;
 import java.util.List;
 
 /**
@@ -24,5 +23,5 @@ public class RequestSettlementLogisticsPageInfo extends RequestPageInfo {
     @Schema(description = "收款单号")
     private String slOrderNo;
     @Schema(description = "收款时间", allowableValues = "[2025-01-09,2025-01-09]")
-    private List<LocalDateTime> payTime;
+    private List<String> payTime;
 }

+ 21 - 16
src/main/java/com/sckw/freight/service/PayCenterService.java

@@ -3,7 +3,6 @@ package com.sckw.freight.service;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.alibaba.fastjson2.TypeReference;
-
 import com.sckw.freight.exception.BusinessException;
 import com.sckw.freight.model.dto.*;
 import com.sckw.freight.model.enums.ChannelEnum;
@@ -143,6 +142,9 @@ public class PayCenterService {
     }
 
     private String changeRes(String sync) {
+        if (StringUtils.isEmpty(sync)) {
+            return sync;
+        }
         JSONObject jsonObject = JSONObject.parseObject(sync);
         //我的泛型是对象 返回值有可能 是对象或数组 {} []
         //data:[]->转换成 data:null 进入if
@@ -167,8 +169,7 @@ public class PayCenterService {
             put("channel", channelEnum);
             put("channels", "xinwang");
         }});
-        return JSONObject.parseObject(sync, new TypeReference<>() {
-        });
+        return JSONObject.parseObject(sync, new TypeReference<R<JSONObject>>(){});
     }
 
 
@@ -209,8 +210,7 @@ public class PayCenterService {
             put("uid", uid);
             put("order_no", orderNo);
         }});
-        return JSONObject.parseObject(sync, new TypeReference<>() {
-        });
+        return JSONObject.parseObject(sync, new TypeReference<R<Object>>(){});
     }
 
     /**
@@ -238,8 +238,7 @@ public class PayCenterService {
             put("money", money);
             put("remarks", remarks);
         }});
-        return JSONObject.parseObject(sync, new TypeReference<>() {
-        });
+        return JSONObject.parseObject(sync, new TypeReference<R<Order>>(){});
     }
 
 
@@ -271,8 +270,7 @@ public class PayCenterService {
             put("money", money);
             put("filter", filter);
         }});
-        return JSONObject.parseObject(sync, new TypeReference<>() {
-        });
+        return JSONObject.parseObject(sync, new TypeReference<R<Order>>(){});
     }
 
 
@@ -304,8 +302,8 @@ public class PayCenterService {
     public R<MemberRes> memberIndex(MemberCreate memberCreate) {
 
         String sync = jsonHttp(PayCenterEnum.MEMBER_INDEX, memberCreate);
-        return JSONObject.parseObject(sync, new TypeReference<>() {
-        });
+        //return JSONObject.parseObject(sync, new R<MemberRes>().getClass());
+      return   JSONObject.parseObject(sync, new TypeReference<R<MemberRes>>(){});
     }
 
     /**
@@ -324,9 +322,15 @@ public class PayCenterService {
             put("channel", channel);
             put("money", money);
         }});
-
-        return JSONObject.parseObject(sync, new TypeReference<>() {
-        });
+//        Object object = JSONObject.parseObject(sync);
+//        R<PayIndex> object1 = JSONObject.parseObject(sync,new R<PayIndex>().getClass());
+//        return JSONObject.parseObject(sync, new TypeReference<>() {
+//        });
+
+        TypeReference<R<PayIndex>> typeRef = new TypeReference<R<PayIndex>>() {};
+        return JSONObject.parseObject(sync, typeRef);
+        //return  JSONObject.parseObject(sync,new R<PayIndex>().getClass());
+       //return (R<PayIndex>) ((JSONObject) JSONObject.parseObject(sync)).values();
     }
 
 
@@ -351,8 +355,8 @@ public class PayCenterService {
             put("money", money);
             put("business_no", businessNo);
         }});
-        return JSONObject.parseObject(sync, new TypeReference<>() {
-        });
+        TypeReference<R<Freeze>> typeRef = new TypeReference<R<Freeze>>() {};
+        return JSONObject.parseObject(sync, typeRef);
     }
 
     /**
@@ -441,6 +445,7 @@ public class PayCenterService {
         return JSONObject.parseObject(sync, new TypeReference<>() {
         });
     }
+
     /**
      * @description: 根据单号,获取充值记录详情
      * @author: xj

+ 3 - 2
src/main/java/com/sckw/freight/service/freight/impl/KwpLedgerLogisticsServiceImpl.java

@@ -511,11 +511,12 @@ public class KwpLedgerLogisticsServiceImpl extends ServiceImpl<KwpLedgerLogistic
         //调用支付中台的【在线充值】接口
         R<PayIndex> payIndexR = payCenterService.payIndex(walletRelationP.getUid(), walletRelationS.getUid(), ChannelEnum.XW, money.multiply(BigDecimal.valueOf(100)).longValue());
         if (payIndexR == null || !payIndexR.getStatus() || payIndexR.getCode() != 200) {
-            return R.failed("支付中台的【在线充值】接口失败");
+            return R.failed("支付中台的【在线充值】接口失败,"+payIndexR.getMsg());
         }
         PayIndex payIndex = payIndexR.getData();
         //保存付款单信息
-        iKwpSettlementLogisticsService.addSettlementLogistics(ledgerLogisticsId, money, payIndex.getOrderNo(), null, ledgerLogistics.getCreateBy());
+        iKwpSettlementLogisticsService.saveSettlementLogistics(ledgerLogistics, money, payIndex.getOrderNo(), KwpSettlementLogisticsStatusEnum.Nopaid, null
+                , ledgerLogistics.getCreateBy());
         // 返回前端支付连接
         return R.ok(payIndex);
     }

+ 6 - 5
src/main/java/com/sckw/freight/service/freight/impl/KwpSettlementLogisticsServiceImpl.java

@@ -65,7 +65,7 @@ public class KwpSettlementLogisticsServiceImpl extends ServiceImpl<KwpSettlement
         //先进性数据验证
         KwpLedgerLogistics logistics = verifySettlementLogistics(lLedgerId, price, payTime, userid);
         //插入结算单信息(插入支付记录)
-        saveSettlementLogistics(logistics, price, slOrderNo,KwpSettlementLogisticsStatusEnum.Paid, payTime, userid);
+        saveSettlementLogistics(logistics, price, slOrderNo, KwpSettlementLogisticsStatusEnum.Paid, payTime, userid);
         //修改物流单对账单状态(如果支付总额已超过对账单)
         iKwpLedgerLogisticsService.updateLedgerLogisticsStatus(logistics, userid);
 
@@ -105,8 +105,8 @@ public class KwpSettlementLogisticsServiceImpl extends ServiceImpl<KwpSettlement
             responseSettlementLogistics.setLLedgerId(item.getLLedgerId());
             responseSettlementLogistics.setSlOrderNo(item.getSlOrderNo());
             responseSettlementLogistics.setTotalPrice(item.getTotalPrice());
-            responseSettlementLogistics.setReceiptTime(DateTimeUtil.format(item.getReceiptTime(), "YYYY-MM-dd HH:mm:ss"));
-            responseSettlementLogistics.setCreatedTime(DateTimeUtil.format(item.getCreateTime(), "YYYY-MM-dd HH:mm:ss"));
+            responseSettlementLogistics.setReceiptTime(item.getReceiptTime() == null ? null : DateTimeUtil.format(item.getReceiptTime(), "YYYY-MM-dd HH:mm:ss"));
+            responseSettlementLogistics.setCreatedTime(item.getCreateTime() == null ? null : DateTimeUtil.format(item.getCreateTime(), "YYYY-MM-dd HH:mm:ss"));
             responseSettlementLogistics.setRemark(item.getRemark());
             responseSettlementLogistics.setStatus(item.getStatus());
             responseSettlementLogistics.setStatusName(KwpSettlementLogisticsStatusEnum.getMsg(item.getStatus()));
@@ -148,7 +148,7 @@ public class KwpSettlementLogisticsServiceImpl extends ServiceImpl<KwpSettlement
      * @return: null
      **/
     @Override
-    public void saveSettlementLogistics(KwpLedgerLogistics logistics, BigDecimal price, String slOrderNo,KwpSettlementLogisticsStatusEnum status, LocalDateTime payTime, Long userid) {
+    public void saveSettlementLogistics(KwpLedgerLogistics logistics, BigDecimal price, String slOrderNo, KwpSettlementLogisticsStatusEnum status, LocalDateTime payTime, Long userid) {
         KwpSettlementLogistics settlementLogistics = new KwpSettlementLogistics();
         settlementLogistics.setId(SnowflakeIdUtil.getInstance().nextId());
         settlementLogistics.setEntId(logistics.getEntId());
@@ -169,6 +169,7 @@ public class KwpSettlementLogisticsServiceImpl extends ServiceImpl<KwpSettlement
         if (!save) throw new RuntimeException("保存结算单失败");
 
     }
+
     /**
      * @description: 更新结算单状态为已支付
      * @author: xj
@@ -183,7 +184,7 @@ public class KwpSettlementLogisticsServiceImpl extends ServiceImpl<KwpSettlement
         newSettlementLogistics.setStatus(KwpSettlementLogisticsStatusEnum.Paid.getCode());
         newSettlementLogistics.setUpdateTime(payOrderDetail.getPayTime());
         newSettlementLogistics.setActualPrice(payOrderDetail.getMoney());
-        newSettlementLogistics.setTotalPrice( payOrderDetail.getMoney());
+        newSettlementLogistics.setTotalPrice(payOrderDetail.getMoney());
         boolean update = updateById(newSettlementLogistics);
         if (!update) throw new RuntimeException("更新结算单状态为已支付失败");
     }

+ 24 - 0
src/main/java/com/sckw/freight/util/JsonUtil.java

@@ -0,0 +1,24 @@
+package com.sckw.freight.util;
+
+/**
+ * @BelongsProject: Freight-Settlement-Backend
+ * @BelongsPackage: com.sckw.freight.util
+ * @Author: xj
+ * @CreateTime: 2025-01-14  18:51
+ * @Description: TODO
+ * @Version: 1.0
+ */
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.TypeReference;
+
+public class JsonUtil {
+    // 不需要显式的ObjectMapper,因为fastjson2的JSON类提供了静态方法
+
+    public static <T> T fromJson(String jsonString, Class<T> clazz) {
+        return JSON.parseObject(jsonString, clazz);
+    }
+
+    public static <T> T fromJsonWithGenerics(String jsonString, TypeReference<T> typeReference) {
+        return JSON.parseObject(jsonString, typeReference);
+    }
+}

+ 12 - 0
src/main/java/com/sckw/freight/util/R.java

@@ -1,5 +1,6 @@
 package com.sckw.freight.util;
 
+import com.alibaba.fastjson.annotation.JSONField;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.*;
 import lombok.experimental.Accessors;
@@ -15,6 +16,7 @@ import java.io.Serializable;
 @NoArgsConstructor
 @AllArgsConstructor
 @Accessors(chain = true)
+@Data
 public class R<T> implements Serializable {
     @Serial
     private static final long serialVersionUID = 1L;
@@ -22,14 +24,23 @@ public class R<T> implements Serializable {
     @Getter
     @Setter
     @Schema(description = "返回信息")
+    @JSONField(name = "msg")
     private String msg;
     @Getter
     @Setter
+    @Schema(description = "警告性息")
+    @JSONField(name = "warning")
+    private String warning;
+    @Getter
+    @Setter
     @Schema(description = "返回状态")
+    @JSONField(name = "status")
     private Boolean status;
 
+
     @Setter
     @Schema(description = "状态码")
+    @JSONField(name = "code")
     private Integer code=200;
     public Integer getCode() {
         return status?200:500;
@@ -38,6 +49,7 @@ public class R<T> implements Serializable {
     @Getter
     @Setter
     @Schema(description = "返回数据")
+    @JSONField(name = "data")
     private T data;
 
     public static <T> R<T> ok() {

+ 2 - 1
src/main/resources/application-dev.yml

@@ -56,4 +56,5 @@ payCenter:
 
 #轮循任务 间隔时长(秒)
 job:
-  sleep: 5
+  sleep: 5
+  enable: false

+ 2 - 1
src/main/resources/application-test.yml

@@ -47,4 +47,5 @@ payCenter:
   address: http://10.10.10.223:9805
 #轮循任务 间隔时长(秒)
 job:
-  sleep: 5
+  sleep: 5
+  enable: false