Browse Source

计划付款功能调整

HULEI 3 tháng trước cách đây
mục cha
commit
298a25ddef

BIN
com.awspaas.user.apps.donenow_ivt/lib/com.awspaas.user.apps.donenow_ivt.jar


+ 165 - 12
com.awspaas.user.apps.donenow_ivt/src/com/awspaas/user/apps/donenow_ivt/controller/caiController.java

@@ -70,21 +70,69 @@ public class caiController {
             return ResponseObject.newErrResponse("订单ID不能为空");
         }
 
-        String sql = "select a.order_id 采购订单id ,b.PERIOD_END_DATE 计划付款时间, b.PERIOD_COST 计划付款金额 " +
-                "from `BO_EU_DNIVT_ORDER_PRODUCT` a " +
-                "join `BO_EU_DNCTT_CONTRACT_SERVICE_PERIOD` b " +
-                "on a.CONTRACT_SERVICE_ID = b.CONTRACT_SERVICE_ID " +
-                "where a.ORDER_ID = ?";
-        List<RowMap> rowMaps = DBSql.getMaps(sql, new Object[]{orderId});
+        String mainSql = "SELECT " +
+                "a.order_id 采购订单id, " +
+                "a.CONTRACT_SERVICE_ID 合同服务ID, " +
+                "b.PERIOD_END_DATE 计划付款时间, " +
+                "b.PERIOD_COST 计划付款金额 " +
+                "FROM `BO_EU_DNIVT_ORDER_PRODUCT` a " +
+                "JOIN `BO_EU_DNCTT_CONTRACT_SERVICE_PERIOD` b " +
+                "ON a.CONTRACT_SERVICE_ID = b.CONTRACT_SERVICE_ID " +
+                "WHERE a.ORDER_ID = ?";
+        List<RowMap> mainRowMaps = DBSql.getMaps(mainSql, new Object[]{orderId});
+        System.out.println("主表查询结果数量:" + (mainRowMaps != null ? mainRowMaps.size() : 0));
 
         List<Map<String, Object>> resultList = new ArrayList<>();
-        if (rowMaps != null && !rowMaps.isEmpty()) {
-            for (RowMap row : rowMaps) {
+        Set<String> processedServiceIds = new HashSet<>();
+
+        if (mainRowMaps != null && !mainRowMaps.isEmpty()) {
+
+            for (RowMap mainRow : mainRowMaps) {
                 Map<String, Object> plan = new HashMap<>();
-                plan.put("order_id", orderId);
-                plan.put("计划付款时间", row.getString("计划付款时间"));
-                plan.put("计划付款金额", row.getDouble("计划付款金额"));
+                plan.put("order_id", mainRow.getString("采购订单id"));
+                plan.put("计划付款时间", mainRow.getString("计划付款时间"));
+                plan.put("计划付款金额", mainRow.getDouble("计划付款金额"));
                 resultList.add(plan);
+
+                Object contractServiceObj = mainRow.get("合同服务ID");
+                String contractServiceId = contractServiceObj != null ? contractServiceObj.toString() : null;
+                System.out.println("当前行CONTRACT_SERVICE_ID:" + contractServiceId +
+                        "(类型:" + (contractServiceObj != null ? contractServiceObj.getClass().getSimpleName() : "null") + ")");
+
+                if (StringUtils.isNotBlank(contractServiceId) && !processedServiceIds.contains(contractServiceId)) {
+                    processedServiceIds.add(contractServiceId);
+
+                    String adjustSql = "SELECT " +
+                            "effective_date 计划付款时间, " +
+                            "prorated_cost_change 计划付款金额 " +
+                            "FROM `BO_EU_DNCTT_CONTRACT_SERVICE_ADJUST` " +
+                            "WHERE CAST(CONTRACT_SERVICE_ID AS CHAR) = ?";
+
+                    System.out.println("执行服务调整表查询SQL:" + adjustSql + ",参数:" + contractServiceId);
+                    List<RowMap> adjustRowMaps = DBSql.getMaps(adjustSql, new Object[]{contractServiceId});
+                    System.out.println("服务调整表查询结果数量:" + (adjustRowMaps != null ? adjustRowMaps.size() : 0));
+
+
+                    if (adjustRowMaps != null && !adjustRowMaps.isEmpty()) {
+
+                        for (RowMap adjustRow : adjustRowMaps) {
+                            Map<String, Object> adjustPlan = new HashMap<>();
+                            adjustPlan.put("order_id", orderId);
+                            adjustPlan.put("计划付款时间", adjustRow.getString("计划付款时间"));
+                            adjustPlan.put("计划付款金额", adjustRow.getDouble("计划付款金额"));
+                            resultList.add(adjustPlan);
+                            System.out.println("已添加服务调整数据:" + adjustPlan);
+                        }
+                    } else {
+                        System.out.println("服务调整表无数据,CONTRACT_SERVICE_ID:" + contractServiceId);
+
+                        String checkSql = "SELECT COUNT(1) AS cnt FROM `BO_EU_DNCTT_CONTRACT_SERVICE_ADJUST` WHERE CAST(CONTRACT_SERVICE_ID AS CHAR) = ?";
+                        List<RowMap> checkMaps = DBSql.getMaps(checkSql, new Object[]{contractServiceId});
+                        if (checkMaps != null && !checkMaps.isEmpty()) {
+                            System.out.println("数据库中实际存在的记录数:" + checkMaps.get(0).getInt("cnt"));
+                        }
+                    }
+                }
             }
         } else {
             ResponseObject responseObject = ResponseObject.newOkResponse();
@@ -93,11 +141,14 @@ public class caiController {
             return responseObject;
         }
 
+        System.out.println("最终结果总数:" + resultList.size() + "(主表" + mainRowMaps.size() + "条 + 服务调整" + (resultList.size() - mainRowMaps.size()) + "条)");
         ResponseObject responseObject = ResponseObject.newOkResponse();
         responseObject.setData(resultList);
         return responseObject;
     }
 
+
+
     @Mapping(value = "com.awspaas.user.apps.donenow_ivt.queryPayAmount")
     public ResponseObject queryPayAmount(UserContext uc, String orderId) {
         if (StringUtils.isBlank(orderId)) {
@@ -136,7 +187,7 @@ public class caiController {
         if (StringUtils.isBlank(orderId)) {
             return ResponseObject.newErrResponse("订单ID不能为空");
         }
-
+        System.out.println("代码中接收到的 orderId:" + orderId);
         String sql = "delete from `BO_EU_DNIVT_ORDER_PAYMENT_PLAN` " +
                 "where ORDER_ID = ? " +
                 "and (PAY_AMOUNT is null or PAY_AMOUNT = 0)";
@@ -206,7 +257,109 @@ public class caiController {
         }
     }
 
+    @Mapping(value = "com.awspaas.user.apps.donenow_ivt.queryNonServiceOrderDate")
+    public ResponseObject queryNonServiceOrderDate(UserContext uc, String orderId) {
+
+        if (StringUtils.isBlank(orderId)) {
+            return ResponseObject.newErrResponse("订单ID不能为空");
+        }
+
+        // 2. 查询BO_EU_DNIVT_ORDER表的EXPECTED_SHIP_DATE字段(条件:id=order_id)
+        String sql = "select EXPECTED_SHIP_DATE " +
+                "from `BO_EU_DNIVT_ORDER` " +
+                "where id = ? ";
+        String expectedShipDate = DBSql.getString(sql, new Object[]{orderId});
+
+        if (StringUtils.isBlank(expectedShipDate)) {
+            ResponseObject responseObject = ResponseObject.newOkResponse();
+            responseObject.put("message", "未找到ORDER_ID为【" + orderId + "】的预期发货日期(EXPECTED_SHIP_DATE)");
+            responseObject.setData(Collections.emptyList());
+            return responseObject;
+        }
+
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        Map<String, Object> dateInfo = new HashMap<>();
+        dateInfo.put("order_id", orderId);
+        dateInfo.put("EXPECTED_SHIP_DATE", expectedShipDate);
+        resultList.add(dateInfo);
+
+        ResponseObject responseObject = ResponseObject.newOkResponse();
+        responseObject.setData(resultList);
+        return responseObject;
+    }
+
+    @Mapping(value = "com.awspaas.user.apps.donenow_ivt.queryNonServiceOrderPrice")
+    public ResponseObject queryNonServiceOrderPrice(UserContext uc, String orderId) {
+        // 1. 订单ID非空校验(完全复制日期接口的校验逻辑)
+        if (StringUtils.isBlank(orderId)) {
+            return ResponseObject.newErrResponse("订单ID不能为空");
+        }
+
+        String sql = "select UNIT_COST_ADD_TAX " +
+                "from `BO_EU_DNIVT_ORDER_PRODUCT` " +
+                "where order_id = ? ";
+
+        String priceStr = DBSql.getString(sql, new Object[]{orderId});
+
+        if (StringUtils.isBlank(priceStr)) {
+            ResponseObject responseObject = ResponseObject.newOkResponse();
+            responseObject.put("message", "未找到ORDER_ID为【" + orderId + "】的含税单价(UNIT_COST_ADD_TAX)");
+            responseObject.setData(Collections.emptyList());
+            return responseObject;
+        }
+
+        Double unitCostAddTax = null;
+        try {
+            unitCostAddTax = Double.parseDouble(priceStr);
+        } catch (NumberFormatException e) {
+            return ResponseObject.newErrResponse("含税单价格式错误:" + priceStr);
+        }
+
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        Map<String, Object> priceInfo = new HashMap<>();
+        priceInfo.put("order_id", orderId);
+        priceInfo.put("UNIT_COST_ADD_TAX", unitCostAddTax);
+        resultList.add(priceInfo);
+
+        ResponseObject responseObject = ResponseObject.newOkResponse();
+        responseObject.setData(resultList);
+        return responseObject;
+    }
+
+    @Mapping(value = "com.awspaas.user.apps.donenow_ivt.queryNonServicePaymentPlan")
+    public ResponseObject queryNonServicePaymentPlan(UserContext uc, String orderId) {
 
+        if (StringUtils.isBlank(orderId)) {
+            return ResponseObject.newErrResponse("订单ID不能为空");
+        }
+
+        String sql = "select * from bo_eu_dnivt_order_payment_plan where ORDER_ID = ?";
+
+        try {
+            List<RowMap> rowMapList = DBSql.getMaps(sql, new Object[]{orderId});
+
+//            if (rowMapList == null || rowMapList.isEmpty()) {
+//                return ResponseObject.newErrResponse("未找到ORDER_ID为【" + orderId + "】的付款计划数据");
+//            }
+
+            List<Map<String, Object>> resultList = new ArrayList<>();
+            for (RowMap map : rowMapList) {
+                Map<String, Object> result = new HashMap<>();
+                result.put("ORDER_ID", map.getString("ORDER_ID"));
+                result.put("PLAN_DATE", map.getString("PLAN_DATE"));
+                result.put("PLAN_AMOUNT", map.getDouble("PLAN_AMOUNT"));
+                resultList.add(result);
+            }
+
+            ResponseObject responseObject = ResponseObject.newOkResponse();
+            responseObject.setData(resultList);
+
+            return responseObject;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return ResponseObject.newErrResponse("查询失败:" + e.getMessage());
+        }
+    }