Commit 8b7dbf2f authored by 黎博's avatar 黎博

合并auto分支,并重构HttpClientUtils工具类

parent 6d70a0dc
...@@ -116,7 +116,7 @@ public class RuleEngineInterceptor implements HandlerInterceptor { ...@@ -116,7 +116,7 @@ public class RuleEngineInterceptor implements HandlerInterceptor {
// vcc // vcc
String callbackUrl = requestMap.get("callbackUrl").toString(); String callbackUrl = requestMap.get("callbackUrl").toString();
if (callbackUrl.contains("talos")) { if (callbackUrl.contains("talos")) {
vccRiskAuthAmountCompletion(callbackUrl, bizChannel, uuid, bizNo, (Integer) auditData.get("vccAuditAmount"), (Boolean) auditData.get("vccAuditResult")); vccRiskAuthAmountCompletion(callbackUrl, bizChannel, uuid, bizNo, auditData.get("vccAuditAmount").toString(), auditData.get("vccAuditResult").toString());
} }
// 一单一审现金贷 // 一单一审现金贷
if (bizType.equals("0")) { if (bizType.equals("0")) {
...@@ -135,7 +135,7 @@ public class RuleEngineInterceptor implements HandlerInterceptor { ...@@ -135,7 +135,7 @@ public class RuleEngineInterceptor implements HandlerInterceptor {
} }
// vcc账单分期审核, sceneId=11 // vcc账单分期审核, sceneId=11
if (bizType.equals("8") && sceneId.equals("11")) { if (bizType.equals("8") && sceneId.equals("11")) {
bodyMap.put("allowInstalment", 1); bodyMap.put("allowInstalment", "1");
bodyMap.put("allowInstalmentTerms", "3,6,9,12"); bodyMap.put("allowInstalmentTerms", "3,6,9,12");
} }
// vcc支付限额审核, sceneId=12 // vcc支付限额审核, sceneId=12
...@@ -174,41 +174,41 @@ public class RuleEngineInterceptor implements HandlerInterceptor { ...@@ -174,41 +174,41 @@ public class RuleEngineInterceptor implements HandlerInterceptor {
* @param amount 授信金额 * @param amount 授信金额
* @param auditResult 授信结果,true/false * @param auditResult 授信结果,true/false
*/ */
public static void vccRiskAuthAmountCompletion(String callbackUrl,String bizChannel, String uuid, String riskNo, Integer amount, boolean auditResult) { public static void vccRiskAuthAmountCompletion(String callbackUrl,String bizChannel, String uuid, String riskNo, String amount, String auditResult) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + 15); calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + 15);
long openingDeadLine = calendar.getTimeInMillis(); Long openingDeadLine = calendar.getTimeInMillis();
Calendar calendar2 = Calendar.getInstance(); Calendar calendar2 = Calendar.getInstance();
calendar2.add(Calendar.YEAR, 1); calendar2.add(Calendar.YEAR, 1);
Long deadLine = calendar2.getTimeInMillis(); Long deadLine = calendar2.getTimeInMillis();
Map<String, Object> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put("amount", amount); params.put("amount", amount);
params.put("auditResult", auditResult); params.put("auditResult", auditResult);
params.put("bizChannel", bizChannel); params.put("bizChannel", bizChannel);
params.put("bizNo", riskNo); params.put("bizNo", riskNo);
params.put("code", 0); params.put("code", "0");
params.put("deadLine", deadLine); params.put("deadLine", deadLine.toString());
params.put("openingDeadLine", openingDeadLine); // 开户失败有效期 params.put("openingDeadLine", String.valueOf(openingDeadLine)); // 开户失败有效期
params.put("success", true); params.put("success", "true");
params.put("uuid", uuid); params.put("uuid", uuid);
params.put("sceneId", 0); params.put("sceneId", "0");
params.put("allowInstalment", 1); // 1-允许分期,0-不允许分期 params.put("allowInstalment", "1"); // 1-允许分期,0-不允许分期
params.put("allowInstalmentTerms", "3,6,9,12"); // 允许分期的期数 params.put("allowInstalmentTerms", "3,6,9,12"); // 允许分期的期数
Map<String, Object> headers = new HashMap<>(); Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/x-www-form-urlencoded"); headers.put("Content-Type", "application/x-www-form-urlencoded");
JSONObject result = HttpClientUtils.doPost(callbackUrl, params, headers); String result = HttpClientUtils.doPost(callbackUrl, headers, params);
log.info("vcc风控授信回调参数:{}", params); log.info("vcc风控授信回调参数:{}", params);
log.info("vcc风控授信回调结果:{}", result); log.info("vcc风控授信回调结果:{}", result);
} }
public static void quotaAuthAmountAuditNotify(String callbackUrl, String uuid, Integer bizChannel, Integer fundId, String bizNo, Integer bizType, Integer creditAmount, Integer term, boolean auditResult) { public static void quotaAuthAmountAuditNotify(String callbackUrl, String uuid, String bizChannel, String fundId, String bizNo, String bizType, String creditAmount, String term, String auditResult) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + 30); calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + 30);
Long deadLine = calendar.getTimeInMillis(); Long deadLine = calendar.getTimeInMillis();
Map<String, Object> headers = new HashMap<>(); Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/x-www-form-urlencoded"); headers.put("Content-Type", "application/x-www-form-urlencoded");
Map<String, Object> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put("code", 0); params.put("code", "0");
params.put("msg", "success"); params.put("msg", "success");
params.put("bizChannel", bizChannel); // 渠道号 params.put("bizChannel", bizChannel); // 渠道号
params.put("uuid", uuid); params.put("uuid", uuid);
...@@ -216,16 +216,16 @@ public class RuleEngineInterceptor implements HandlerInterceptor { ...@@ -216,16 +216,16 @@ public class RuleEngineInterceptor implements HandlerInterceptor {
params.put("bizType", bizType); // 业务类型: 0-现金分期一单一审,…… params.put("bizType", bizType); // 业务类型: 0-现金分期一单一审,……
params.put("auditResult", auditResult); params.put("auditResult", auditResult);
params.put("amount", creditAmount); params.put("amount", creditAmount);
params.put("deadLine", deadLine); params.put("deadLine", String.valueOf(deadLine));
params.put("extData", ""); params.put("extData", "");
params.put("otherInformation", ""); params.put("otherInformation", "");
JSONArray financeProducts = createFinanceProducts(fundId, term); JSONArray financeProducts = createFinanceProducts(fundId, term);
params.put("financeProducts", financeProducts); params.put("financeProducts", JSONArray.toJSONString(financeProducts));
HttpClientUtils.doPost(callbackUrl, params, headers); HttpClientUtils.doPost(callbackUrl, headers, params);
log.info("现金分期风控授信回调:{}", params); log.info("现金分期风控授信回调:{}", params);
} }
public static JSONArray createFinanceProducts(Integer fundId, Integer term) { public static JSONArray createFinanceProducts(String fundId, String term) {
JSONArray financeProducts = new JSONArray(); JSONArray financeProducts = new JSONArray();
JSONObject financeProductsObject = new JSONObject(); JSONObject financeProductsObject = new JSONObject();
JSONArray terms = new JSONArray(); JSONArray terms = new JSONArray();
...@@ -241,11 +241,11 @@ public class RuleEngineInterceptor implements HandlerInterceptor { ...@@ -241,11 +241,11 @@ public class RuleEngineInterceptor implements HandlerInterceptor {
fundInfoObject.put("priority", 1); fundInfoObject.put("priority", 1);
fundInfoObject.put("feeType", 1); fundInfoObject.put("feeType", 1);
// 如果是云南信托,需要该参数 // 如果是云南信托,需要该参数
if (fundId == 1040) { if (fundId.equals("1040")) {
fundInfoObject.put("fundProductId", 1061); fundInfoObject.put("fundProductId", 1061);
} }
// 平顶山银行 // 平顶山银行
if (fundId == 1030) { if (fundId.equals("1030")) {
fundInfoObject.put("fundProductId", 1060); fundInfoObject.put("fundProductId", 1060);
} }
fundInfoList.add(fundInfoObject); fundInfoList.add(fundInfoObject);
......
package cn.qg.holmes.utils; package cn.qg.holmes.utils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.HashMap; import java.util.HashMap;
...@@ -11,11 +10,12 @@ import java.util.Map; ...@@ -11,11 +10,12 @@ import java.util.Map;
public class DingdingUtils { public class DingdingUtils {
public static boolean sendToDingding(String jsonString, String webhook) { public static boolean sendToDingding(String jsonString, String webhook) {
Map<String, Object> headers = new HashMap<>(); Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json; charset=utf-8"); headers.put("Content-Type", "application/json; charset=utf-8");
JSONObject result = HttpClientUtils.doPostJson(webhook, jsonString, headers); String result = HttpClientUtils.doPostJson(webhook, headers, jsonString);
log.info("发送给钉钉: {}, 内容:{}, 钉钉返回结果:{}", webhook, jsonString, result); log.info("发送给钉钉: {}, 内容:{}, 钉钉返回结果:{}", webhook, jsonString, result);
return result.get("errmsg").equals("ok"); Map<String, String> resultMap = JSON.parseObject(result, Map.class);
return resultMap.get("errmsg").equals("ok");
} }
public static String buildMarkdownMsg(String key, String summary, String creator, String assignee, String priority, String module) { public static String buildMarkdownMsg(String key, String summary, String creator, String assignee, String priority, String module) {
...@@ -33,4 +33,9 @@ public class DingdingUtils { ...@@ -33,4 +33,9 @@ public class DingdingUtils {
markdown.put("markdown", content); markdown.put("markdown", content);
return JSON.toJSONString(markdown); return JSON.toJSONString(markdown);
} }
public static void main(String[] args) {
String markdown = buildMarkdownMsg("YXM-1499", "【羊小咩v7.6.00】【VCC首次交易率提升专题】巴拉巴拉", "黎博", "于巧玲", "p1", "kddsp");
sendToDingding(markdown, "https://oapi.dingtalk.com/robot/send?access_token=835663338d638e40daaf3ab358af741ef0680a826a962c91bedc53b149d85ee1");
}
} }
...@@ -178,6 +178,10 @@ public class HttpClientUtils { ...@@ -178,6 +178,10 @@ public class HttpClientUtils {
// 创建请求内容 // 创建请求内容
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity); httpPost.setEntity(entity);
// 设置请求头
setHeader(headers, httpPost);
httpResponse = httpClient.execute(httpPost); httpResponse = httpClient.execute(httpPost);
resultString = EntityUtils.toString(httpResponse.getEntity(), ENCODING); resultString = EntityUtils.toString(httpResponse.getEntity(), ENCODING);
} catch (Exception e) { } catch (Exception e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment