|
@@ -1,22 +1,61 @@
|
|
|
import { defHttp } from '/@/utils/http/axios';
|
|
|
+import md5 from 'md5';
|
|
|
+
|
|
|
+const API_UID = "Sw5bYYe7";
|
|
|
+const API_SECRET = "j4ThjI10jiV3L3y7";
|
|
|
|
|
|
enum Api {
|
|
|
- list = 'https://openapi.tradesparq.com/cds_v2/old_api/record',
|
|
|
+ list = 'http://localhost:3100/tradesparq/cds_v2/old_api/record',
|
|
|
+ listCompanies = 'http://localhost:3100/tradesparq/cds_v2/old_api/company',
|
|
|
}
|
|
|
|
|
|
|
|
|
export interface TradeRecordQueryParams {
|
|
|
- sortBy?: 'date' | 'weight';
|
|
|
- page?: number;
|
|
|
- pageSize?: number;
|
|
|
-
|
|
|
+ source_type?: number;
|
|
|
+ data_source?: string[];
|
|
|
+ date?: number[];
|
|
|
+ prod_desc?: string;
|
|
|
+ hs_code?: string;
|
|
|
+ supplier_t?: string;
|
|
|
+ supplier_addr?: string;
|
|
|
+ supplier_ex_nvl?: boolean;
|
|
|
+ supplier_ex_log?: boolean;
|
|
|
+ buyer_t?: string;
|
|
|
+ buyer_addr?: string;
|
|
|
+ buyer_ex_nvl?: boolean;
|
|
|
+ buyer_ex_log?: boolean;
|
|
|
+ quantity?: string[];
|
|
|
+ weight?: string[];
|
|
|
+ amount?: string[];
|
|
|
+ teu?: string[];
|
|
|
+ master_bill_no?: string;
|
|
|
+ sub_bill_no?: string;
|
|
|
+ container_no?: string[];
|
|
|
+ carrier_name?: string;
|
|
|
+ vessel_name?: string;
|
|
|
+ brand?: string;
|
|
|
+ others?: string;
|
|
|
+ log_shipper?: string;
|
|
|
+ log_consignee?: string;
|
|
|
+ f_orig_country?: string[];
|
|
|
+ f_orig_country_ex?: string[];
|
|
|
+ f_orig_port?: string[];
|
|
|
+ f_orig_port_ex?: string[];
|
|
|
+ f_dest_country?: string[];
|
|
|
+ f_dest_country_ex?: string[];
|
|
|
+ f_dest_port?: string[];
|
|
|
+ f_dest_port_ex?: string[];
|
|
|
+ orig_country_code?: string[];
|
|
|
+ orig_port_t?: string;
|
|
|
+ dest_country_code?: string[];
|
|
|
+ dest_port_t?: string;
|
|
|
+ [key: string]: any;
|
|
|
}
|
|
|
|
|
|
|
|
|
export interface TradeRecordResponse {
|
|
|
total: number;
|
|
|
records: Array<{
|
|
|
-
|
|
|
id: string;
|
|
|
date: string;
|
|
|
weight: number;
|
|
@@ -25,13 +64,42 @@ export interface TradeRecordResponse {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ * 生成请求签名
|
|
|
+ */
|
|
|
+function generateRequestSign(params: TradeRecordQueryParams): string {
|
|
|
+ const sortedValues = Object.keys(params)
|
|
|
+ .sort()
|
|
|
+ .map(k => JSON.stringify(params[k]))
|
|
|
+ .join('');
|
|
|
+
|
|
|
+
|
|
|
+ return md5(API_SECRET + sortedValues);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
* 获取交易详单列表及总数
|
|
|
- * @param params 查询参数
|
|
|
- * @returns Promise<TradeRecordResponse>
|
|
|
*/
|
|
|
-export const list = (params: TradeRecordQueryParams) => {
|
|
|
- return defHttp.post<TradeRecordResponse>({
|
|
|
- url: Api.list,
|
|
|
- params,
|
|
|
- });
|
|
|
+export const list = async (params: TradeRecordQueryParams) => {
|
|
|
+ const requestSign = generateRequestSign(params);
|
|
|
+
|
|
|
+ return defHttp.post<TradeRecordResponse>(
|
|
|
+ {
|
|
|
+ url: Api.list,
|
|
|
+ params,
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/json',
|
|
|
+ 'X-API-UID': API_UID,
|
|
|
+ 'X-API-REQUEST-SIGN': requestSign
|
|
|
+ },
|
|
|
+ withCredentials: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ errorMessageMode: 'message',
|
|
|
+ isTransformResponse: false,
|
|
|
+ }
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+export const listCompanies = (params) => {
|
|
|
+ return defHttp.post({ url: Api.listCompanies, params });
|
|
|
};
|