Browse Source

refactor(property): 优化收据生成逻辑和用户权限查询接口- 在 AContractInfoServiceImpl 中添加操作员和入住日期信息
- 更新 ReceiptDto 结构,增加 rzrq 和 operator 字段
-重构 UserPermissionsController 中的 queryUserPermissions 方法,使用查询参数替代请求体

nahida 8 tháng trước cách đây
mục cha
commit
256a21c261

+ 11 - 16
src/main/java/com/zksy/controller/common/UserPermissionsController.java

@@ -1,9 +1,7 @@
 package com.zksy.controller.common;
 
-import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.zksy.common.domain.dto.UserPermissions;
 import com.zksy.utils.AjaxResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -12,6 +10,7 @@ import okhttp3.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.io.IOException;
@@ -33,22 +32,17 @@ public class UserPermissionsController {
     private OkHttpClient httpClient;
     @ApiOperation(value = "用户权限查询")
     @PostMapping("/queryUserPermissions")
-    public AjaxResult queryUserPermissions(UserPermissions request){
-        ObjectMapper objectMapper = new ObjectMapper();
-        String jsonParams = null;
-        try {
-            jsonParams = objectMapper.writeValueAsString(request);
-        } catch (JsonProcessingException e) {
-            log.error("JSON序列化失败: {}", e);
-            return AjaxResult.error("请求失败");
-        }
-        // 创建请求体
-        RequestBody body = RequestBody.create(jsonParams, JSON);
-        // 构建请求
+    public AjaxResult queryUserPermissions(@RequestParam String appToken, @RequestParam String appId){
+
+        // 拼接URL参数
+        String url = "http://183.215.203.75:9010/minto/extTask/findUsers?appToken=" + appToken + "&appId=" + appId;
+
+        // 构建POST请求(空body)
         Request requestHttp = new Request.Builder()
-                .url("http://172.168.80.14:8082/minto/extTask/findUsers")
-                .post(body)
+                .url(url)
+                .post(RequestBody.create("", null)) // 空body
                 .build();
+
         // 发送请求
         try (Response response = httpClient.newCall(requestHttp).execute()) {
             if (!response.isSuccessful()) {
@@ -57,6 +51,7 @@ public class UserPermissionsController {
             ResponseBody responseBody = response.body();
             if (responseBody != null) {
                 String responseString = responseBody.string();
+                ObjectMapper objectMapper = new ObjectMapper();
                 JsonNode rootNode = objectMapper.readTree(responseString);
                 JsonNode success = rootNode.path("success");
                 if("true".equals(success.asText())) {

+ 2 - 0
src/main/java/com/zksy/property/domain/dto/ReceiptDto.java

@@ -19,5 +19,7 @@ public class ReceiptDto {
     private BigDecimal wyf;
     private BigDecimal sf;
     private String paymentReason;
+    private String rzrq;
+    private String operator;
 
 }

+ 2 - 1
src/main/java/com/zksy/property/service/impl/AContractInfoServiceImpl.java

@@ -119,7 +119,7 @@ public class AContractInfoServiceImpl extends ServiceImpl<AContractInfoMapper, A
         bo.setD8(String.valueOf(dto.getSf()));
         bo.setD9(dto.getPaymentReason());
         bo.setD10(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy年M月d日")));
-        bo.setD11("");
+        bo.setD11(dto.getOperator());
         bo.setD12(receiptNumber);
 
         String attachmentUrl = aRentalContractService.generatorRental("4", bo, true);
@@ -133,6 +133,7 @@ public class AContractInfoServiceImpl extends ServiceImpl<AContractInfoMapper, A
         receiptInfo.setPropertyFee(dto.getWyf());
         receiptInfo.setDeposit(dto.getYj());
         receiptInfo.setWaterFee(dto.getSf());
+        receiptInfo.setAccountingDate(LocalDate.parse(dto.getRzrq()));
         receiptInfo.setReceiptReason(dto.getPaymentReason());
         receiptInfo.setAttachmentUrl(attachmentUrl);
         receiptInfo.setGenerationDate(LocalDate.now());

+ 1 - 0
src/test/java/com/zksy/property/service/impl/AContractInfoServiceImplTest.java

@@ -140,6 +140,7 @@ class AContractInfoServiceImplTest {
                 new BigDecimal(1),
                 new BigDecimal(1),
                 new BigDecimal(1),
+                "1",
                 "1"
         );
         String receipt = aContractInfoService.getReceipt("31c7f3fdfc236328bce3307645d566dd",dto);