|
|
@@ -1,7 +1,9 @@
|
|
|
package nckd.base.common.utils;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import kd.bos.exception.ErrorCode;
|
|
|
import kd.bos.exception.KDBizException;
|
|
|
+import kd.bos.exception.KDException;
|
|
|
import kd.bos.logging.Log;
|
|
|
import kd.bos.logging.LogFactory;
|
|
|
|
|
|
@@ -24,14 +26,6 @@ public class TripSyncUtils {
|
|
|
*/
|
|
|
private final static String PATH = "/fcopen/fcoutapi";
|
|
|
|
|
|
- /**
|
|
|
- * SIT.胜意接口.KEY
|
|
|
- */
|
|
|
- public final static String SIT_FWS_KEY = "011f42937f4049209b5c9fac611020a3";
|
|
|
- /**
|
|
|
- * SIT.胜意接口.账号
|
|
|
- */
|
|
|
- public final static String ACCOUNT = "JXWL";
|
|
|
|
|
|
/**
|
|
|
* @param service 接口名称
|
|
|
@@ -109,144 +103,6 @@ public class TripSyncUtils {
|
|
|
return getMD5Sign(account + dateStr + key).toLowerCase(Locale.ROOT);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- String sign = createTripSyncSign();
|
|
|
-// String sign = createSYSign();
|
|
|
- System.out.println(sign);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * @return 生成胜意接口签名,通过main方法生成签名postman调试
|
|
|
- */
|
|
|
- private static String createSYSign() {
|
|
|
- String dateStr = DateUtil.date2str(new Date(), DateUtil.DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI_SS);
|
|
|
- //账号+当前时间+KEY
|
|
|
- return String.format("timestamp:%s\nsign:%s", dateStr, getMD5Sign(ACCOUNT + dateStr + SIT_FWS_KEY).toLowerCase(Locale.ROOT));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return 生成商旅标准订单接口签名,通过main方法生成签名postman调试
|
|
|
- */
|
|
|
- private static String createTripSyncSign() {
|
|
|
- //商旅订单标准接口报文,此处报文和实际接口入参报文存在差异,key值tripSync需要剔除,只需要传value值,且sign参数需要剔除
|
|
|
- String str = "{\n" +
|
|
|
- " \"method\": \"er_planebill\",\n" +
|
|
|
- " \"service\": \"SY_SL\",\n" +
|
|
|
- " \"data\": [\n" +
|
|
|
- " {\n" +
|
|
|
- " \"billstatus\": \"A\",\n" +
|
|
|
- " \"ordernum\": \"DF210121121212212\",\n" +
|
|
|
- " \"pnr\": \"Zr3LF\",\n" +
|
|
|
- " \"ticketnum\": \"999-9000999000\",\n" +
|
|
|
- " \"parentordernum\": \"\",\n" +
|
|
|
- " \"oriordernum\": \"\",\n" +
|
|
|
- " \"overdesc\": \"\",\n" +
|
|
|
- " \"refundreason\": \"\",\n" +
|
|
|
- " \"changereason\": \"\",\n" +
|
|
|
- " \"changetype\": \"\",\n" +
|
|
|
- " \"fromcityname\": \"上海\",\n" +
|
|
|
- " \"takeoffportname\": \"SHA\",\n" +
|
|
|
- " \"tocityname\": \"广州\",\n" +
|
|
|
- " \"landingportname\": \"CAN\",\n" +
|
|
|
- " \"airlinename\": \"川航\",\n" +
|
|
|
- " \"flightno\": \"3U9911\",\n" +
|
|
|
- " \"cabin\": \"Q\",\n" +
|
|
|
- " \"tripid\": \"SHm4t\",\n" +
|
|
|
- " \"overflag\": \"\",\n" +
|
|
|
- " \"orderdate\": \"2024-01-31\",\n" +
|
|
|
- " \"totalamount\": \"858.62\",\n" +
|
|
|
- " \"ordertype\": \"O\",\n" +
|
|
|
- " \"isbusiness\": \"1\",\n" +
|
|
|
- " \"producttype\": \"1\",\n" +
|
|
|
- " \"orderstatus\": \"40000\",\n" +
|
|
|
- " \"ticketstatus\": \"UNUSED\",\n" +
|
|
|
- " \"ticketprice\": \"178.71\",\n" +
|
|
|
- " \"discount\": \"558.68\",\n" +
|
|
|
- " \"airportprice\": \"94.78\",\n" +
|
|
|
- " \"fuelprice\": \"318.53\",\n" +
|
|
|
- " \"tax\": \"233.28\",\n" +
|
|
|
- " \"refundamount\": \"\",\n" +
|
|
|
- " \"endorsementamount\": \"\",\n" +
|
|
|
- " \"assuranceamount\": \"\",\n" +
|
|
|
- " \"servicefee\": \"\",\n" +
|
|
|
- " \"standprice\": \"\",\n" +
|
|
|
- " \"ordersort\": \"1\",\n" +
|
|
|
- " \"orderstatusname\": \"\",\n" +
|
|
|
- " \"bookedname\": \"IatNP\",\n" +
|
|
|
- " \"travelername\": \"Nfwd9\",\n" +
|
|
|
- " \"operationtype\": \"1\",\n" +
|
|
|
- " \"choosenotminreason\": \"sDH6T\",\n" +
|
|
|
- " \"isapprove\": false,\n" +
|
|
|
- " \"cabinclass\": \"BDPLk\",\n" +
|
|
|
- " \"takeofftime\": \"2024-01-3109:45:05\",\n" +
|
|
|
- " \"landingtime\": \"2024-01-3109:45:05\",\n" +
|
|
|
- " \"isaddintegral\": false,\n" +
|
|
|
- " \"isdeductible\": true,\n" +
|
|
|
- " \"itinerarynum\": \"XoPV8\",\n" +
|
|
|
- " \"itinerarydate\": \"2024-01-31\",\n" +
|
|
|
- " \"downloadlink\": \"6aouW\",\n" +
|
|
|
- " \"happenddate\": \"2024-01-3109:45:05\",\n" +
|
|
|
- " \"lowestpirce\": \"524.76\",\n" +
|
|
|
- " \"islowestpirce\": false,\n" +
|
|
|
- " \"otheramount\": \"828.17\",\n" +
|
|
|
- " \"bookeddate\": \"2024-01-31\",\n" +
|
|
|
- " \"servicefeepaytype\": \"1\",\n" +
|
|
|
- " \"personalfee\": \"231.29\",\n" +
|
|
|
- " \"oabillformid\": \"er_tripreqbill\",\n" +
|
|
|
- " \"sourcebookedid\": \"qwe\",\n" +
|
|
|
- " \"expcommitcomnum\": 123,\n" +
|
|
|
- " \"expcommitdepnum\": 123,\n" +
|
|
|
- " \"sourcetravelerid\": \"qwe\",\n" +
|
|
|
- " \"travelerdept\": 123,\n" +
|
|
|
- " \"bookeddept\": 123,\n" +
|
|
|
- " \"company\": 123,\n" +
|
|
|
- " \"std_costcenter\": 123,\n" +
|
|
|
- " \"currency\": 123\n" +
|
|
|
- " }\n" +
|
|
|
- " ]\n" +
|
|
|
- " }";
|
|
|
- Map map = JSONObject.parseObject(str, Map.class);
|
|
|
- String result = genSign(map);
|
|
|
- return String.format("sign:%s", getMD5Sign(result + SIT_FWS_KEY).toLowerCase(Locale.ROOT));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public static String genSign(Map<String, Object> params) {
|
|
|
- params.remove("sign");
|
|
|
- StringBuilder buf = new StringBuilder();
|
|
|
-
|
|
|
- try {
|
|
|
- List<Map.Entry<String, Object>> infoIds = new ArrayList(params.entrySet());
|
|
|
- infoIds.sort(new Comparator<Map.Entry<String, Object>>() {
|
|
|
- public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) {
|
|
|
- return ((String) o1.getKey()).compareTo((String) o2.getKey());
|
|
|
- }
|
|
|
- });
|
|
|
- Iterator var3 = infoIds.iterator();
|
|
|
-
|
|
|
- while (var3.hasNext()) {
|
|
|
- Map.Entry<String, Object> item = (Map.Entry) var3.next();
|
|
|
- if (item.getKey() != null && !((String) item.getKey()).isEmpty()) {
|
|
|
- String key = (String) item.getKey();
|
|
|
- String val = item.getValue() == null ? "" : item.getValue().toString();
|
|
|
- if (buf.toString().isEmpty()) {
|
|
|
- buf.append(key).append("=").append(val);
|
|
|
- } else {
|
|
|
- buf.append("&").append(key).append("=").append(val);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-// logger.info("商旅推送:生成签名前字符串:{}", buf.toString());
|
|
|
- } catch (Exception e) {
|
|
|
-// throw new KDBizException(String.format(ResManager.loadKDString("商旅集成,获取签名失败:%s", "TripCommonUtil_03", "fi-er-business", new Object[0]), var7));
|
|
|
- }
|
|
|
- return buf.toString();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
public static String getMD5Sign(String input) {
|
|
|
StringBuilder sb = new StringBuilder(32);
|
|
|
|
|
|
@@ -266,9 +122,9 @@ public class TripSyncUtils {
|
|
|
sb.append(hex(d));
|
|
|
}
|
|
|
} catch (NoSuchAlgorithmException var8) {
|
|
|
-// throw new KDException(var8, new ErrorCode("md5 error", "not exist md5 instance"), new Object[0]);
|
|
|
+ throw new KDException(var8, new ErrorCode("md5 error", "not exist md5 instance"), new Object[0]);
|
|
|
} catch (UnsupportedEncodingException var9) {
|
|
|
-// throw new RuntimeException(var9);
|
|
|
+ throw new RuntimeException(var9);
|
|
|
}
|
|
|
|
|
|
return sb.toString();
|
|
|
@@ -283,5 +139,4 @@ public class TripSyncUtils {
|
|
|
|
|
|
private static final char[] base = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
|
|
|
|
|
-
|
|
|
}
|