|
@@ -437,16 +437,35 @@ public class accountController extends BaseController {
|
|
|
@Mapping(value = "com.awspaas.user.apps.donenow_crm.getProductInfoByContractServiceId")
|
|
@Mapping(value = "com.awspaas.user.apps.donenow_crm.getProductInfoByContractServiceId")
|
|
|
public ResponseObject getProductInfoByContractServiceId(UserContext uc, String id) {
|
|
public ResponseObject getProductInfoByContractServiceId(UserContext uc, String id) {
|
|
|
try {
|
|
try {
|
|
|
- // 1. 根据传入的id查询BO_EU_DNCTT_CONTRACT_SERVICE表获取OBJECT_ID
|
|
|
|
|
- String contractServiceSql = "SELECT OBJECT_ID " +
|
|
|
|
|
- "FROM BO_EU_DNCTT_CONTRACT_SERVICE " +
|
|
|
|
|
- "WHERE id = ?";
|
|
|
|
|
- Map<String, Object> contractServiceInfo = DBSql.getMap(contractServiceSql, new Object[]{id});
|
|
|
|
|
|
|
+ // 1. 原有:查询订单产品关联表获取order_id,再查订单表获取VENDOR_ACCOUNT_ID
|
|
|
|
|
+ String orderProductSql = "SELECT order_id FROM BO_EU_DNIVT_ORDER_PRODUCT WHERE CONTRACT_SERVICE_ID = ?";
|
|
|
|
|
+ Map<String, Object> orderProductInfo = DBSql.getMap(orderProductSql, new Object[]{id});
|
|
|
|
|
+ String vendorAccountId = null;
|
|
|
|
|
+ if (orderProductInfo != null && orderProductInfo.get("order_id") != null) {
|
|
|
|
|
+ String orderId = orderProductInfo.get("order_id").toString();
|
|
|
|
|
+ String orderSql = "SELECT VENDOR_ACCOUNT_ID FROM BO_EU_DNIVT_ORDER WHERE id = ?";
|
|
|
|
|
+ Map<String, Object> orderInfo = DBSql.getMap(orderSql, new Object[]{orderId});
|
|
|
|
|
+ if (orderInfo != null && orderInfo.get("VENDOR_ACCOUNT_ID") != null) {
|
|
|
|
|
+ vendorAccountId = orderInfo.get("VENDOR_ACCOUNT_ID").toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 新增:根据VENDOR_ACCOUNT_ID查询bo_eu_dncrm_account表获取name
|
|
|
|
|
+ String vendorAccountName = null;
|
|
|
|
|
+ if (vendorAccountId != null) { // 仅当有vendorAccountId时才查询
|
|
|
|
|
+ String accountSql = "SELECT NAME FROM bo_eu_dncrm_account WHERE id = ?";
|
|
|
|
|
+ Map<String, Object> accountInfo = DBSql.getMap(accountSql, new Object[]{vendorAccountId});
|
|
|
|
|
+ if (accountInfo != null && accountInfo.get("NAME") != null) {
|
|
|
|
|
+ vendorAccountName = accountInfo.get("NAME").toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ // 3. 原有:查询合同服务、服务、产品信息(保持不变)
|
|
|
|
|
+ String contractServiceSql = "SELECT OBJECT_ID FROM BO_EU_DNCTT_CONTRACT_SERVICE WHERE id = ?";
|
|
|
|
|
+ Map<String, Object> contractServiceInfo = DBSql.getMap(contractServiceSql, new Object[]{id});
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
|
|
if (contractServiceInfo == null || contractServiceInfo.get("OBJECT_ID") == null) {
|
|
if (contractServiceInfo == null || contractServiceInfo.get("OBJECT_ID") == null) {
|
|
|
- // 未查询到合同服务记录
|
|
|
|
|
result.put("contractServiceExists", false);
|
|
result.put("contractServiceExists", false);
|
|
|
result.put("serviceExists", false);
|
|
result.put("serviceExists", false);
|
|
|
result.put("productExists", false);
|
|
result.put("productExists", false);
|
|
@@ -455,15 +474,10 @@ public class accountController extends BaseController {
|
|
|
} else {
|
|
} else {
|
|
|
result.put("contractServiceExists", true);
|
|
result.put("contractServiceExists", true);
|
|
|
String objectId = contractServiceInfo.get("OBJECT_ID").toString();
|
|
String objectId = contractServiceInfo.get("OBJECT_ID").toString();
|
|
|
-
|
|
|
|
|
- // 2. 根据OBJECT_ID查询BO_EU_DNIVT_SERVICE表获取PRODUCT_ID
|
|
|
|
|
- String serviceSql = "SELECT PRODUCT_ID " +
|
|
|
|
|
- "FROM BO_EU_DNIVT_SERVICE " +
|
|
|
|
|
- "WHERE id = ?";
|
|
|
|
|
|
|
+ String serviceSql = "SELECT PRODUCT_ID FROM BO_EU_DNIVT_SERVICE WHERE id = ?";
|
|
|
Map<String, Object> serviceInfo = DBSql.getMap(serviceSql, new Object[]{objectId});
|
|
Map<String, Object> serviceInfo = DBSql.getMap(serviceSql, new Object[]{objectId});
|
|
|
|
|
|
|
|
if (serviceInfo == null || serviceInfo.get("PRODUCT_ID") == null) {
|
|
if (serviceInfo == null || serviceInfo.get("PRODUCT_ID") == null) {
|
|
|
- // 未查询到服务记录
|
|
|
|
|
result.put("serviceExists", false);
|
|
result.put("serviceExists", false);
|
|
|
result.put("productExists", false);
|
|
result.put("productExists", false);
|
|
|
result.put("productId", null);
|
|
result.put("productId", null);
|
|
@@ -471,27 +485,19 @@ public class accountController extends BaseController {
|
|
|
} else {
|
|
} else {
|
|
|
result.put("serviceExists", true);
|
|
result.put("serviceExists", true);
|
|
|
String productId = serviceInfo.get("PRODUCT_ID").toString();
|
|
String productId = serviceInfo.get("PRODUCT_ID").toString();
|
|
|
-
|
|
|
|
|
- // 3. 根据PRODUCT_ID查询bo_eu_dnivt_product表获取id和NAME
|
|
|
|
|
- String productSql = "SELECT id, NAME " +
|
|
|
|
|
- "FROM bo_eu_dnivt_product " +
|
|
|
|
|
- "WHERE id = ?";
|
|
|
|
|
|
|
+ String productSql = "SELECT id, NAME FROM bo_eu_dnivt_product WHERE id = ?";
|
|
|
Map<String, Object> productInfo = DBSql.getMap(productSql, new Object[]{productId});
|
|
Map<String, Object> productInfo = DBSql.getMap(productSql, new Object[]{productId});
|
|
|
|
|
|
|
|
- if (productInfo == null) {
|
|
|
|
|
- // 未查询到产品记录
|
|
|
|
|
- result.put("productExists", false);
|
|
|
|
|
- result.put("productId", null);
|
|
|
|
|
- result.put("productName", null);
|
|
|
|
|
- } else {
|
|
|
|
|
- // 成功查询到产品信息
|
|
|
|
|
- result.put("productExists", true);
|
|
|
|
|
- result.put("productId", productInfo.get("id"));
|
|
|
|
|
- result.put("productName", productInfo.get("NAME"));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ result.put("productExists", productInfo != null);
|
|
|
|
|
+ result.put("productId", productInfo != null ? productInfo.get("id") : null);
|
|
|
|
|
+ result.put("productName", productInfo != null ? productInfo.get("NAME") : null);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 4. 新增返回字段:vendorAccountId(原有)和 vendorAccountName(新增)
|
|
|
|
|
+ result.put("vendorAccountId", vendorAccountId);
|
|
|
|
|
+ result.put("vendorAccountName", vendorAccountName); // 账户名称
|
|
|
|
|
+
|
|
|
ResponseObject responseObject = ResponseObject.newOkResponse();
|
|
ResponseObject responseObject = ResponseObject.newOkResponse();
|
|
|
responseObject.setData(result);
|
|
responseObject.setData(result);
|
|
|
return responseObject;
|
|
return responseObject;
|