You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					79 lines
				
				2.6 KiB
			
		
		
			
		
	
	
					79 lines
				
				2.6 KiB
			| 
											3 years ago
										 | package com.ynxbd.bcm.config;
 | ||
|  | 
 | ||
|  | 
 | ||
|  | import com.bocom.api.DefaultBocomClient;
 | ||
|  | import com.ynxbd.common.helper.ProperHelper;
 | ||
|  | import com.ynxbd.common.helper.common.DateHelper;
 | ||
|  | import lombok.extern.slf4j.Slf4j;
 | ||
|  | 
 | ||
|  | import java.util.Date;
 | ||
|  | 
 | ||
|  | @Slf4j
 | ||
|  | public class BCMConfig {
 | ||
|  | 
 | ||
|  |     public static final String APP_ID;
 | ||
|  |     public static final String MER_PTC_ID;   // 商户编号
 | ||
|  |     public static final String PARTNER_ID;   // 服务商编号
 | ||
|  |     public static final String PRIVATE_KEY;  // 第三方私钥
 | ||
|  |     public static final String API_GW_PUBLIC_KEY;   // 公钥
 | ||
|  |     public static final String API_GW_URL_ADDRESS;  // 地址
 | ||
|  |     //
 | ||
|  |     private static boolean IS_DEV = false;
 | ||
|  | 
 | ||
|  |     static {
 | ||
|  |         ProperHelper config = new ProperHelper().read("bcm/bcm.properties");
 | ||
|  | 
 | ||
|  |         boolean isEnable = config.getBoolean("bcm.is_enable", false);
 | ||
|  |         if (isEnable) {
 | ||
|  |             IS_DEV = config.getBoolean("bcm.is_dev", false);
 | ||
|  |             if (IS_DEV) {
 | ||
|  |                 log.info("[交行]配置文件当前为测试环境-----------------------");
 | ||
|  |                 config = new ProperHelper().read("bcm/bcm-dev.properties");
 | ||
|  |             }
 | ||
|  | 
 | ||
|  |             APP_ID = config.getString("bcm.app_id");
 | ||
|  |             MER_PTC_ID = config.getString("bcm.mer_ptc_id");
 | ||
|  |             PARTNER_ID = config.getString("bcm.partner_id");
 | ||
|  |             PRIVATE_KEY = config.getString("bcm.private_key");
 | ||
|  |             API_GW_PUBLIC_KEY = config.getString("bcm.api_gw_public_key");
 | ||
|  |             API_GW_URL_ADDRESS = config.getString("bcm.api_gw_url_address");
 | ||
|  |         } else {
 | ||
|  |             APP_ID = null;
 | ||
|  |             MER_PTC_ID = null;
 | ||
|  |             PARTNER_ID = null;
 | ||
|  |             PRIVATE_KEY = null;
 | ||
|  |             API_GW_PUBLIC_KEY = null;
 | ||
|  |             API_GW_URL_ADDRESS = null;
 | ||
|  |         }
 | ||
|  | 
 | ||
|  |         if (APP_ID == null || MER_PTC_ID == null) {
 | ||
|  |             log.error("[交行]读取配置文件bcm.properties失败");
 | ||
|  |         }
 | ||
|  |     }
 | ||
|  | 
 | ||
|  | 
 | ||
|  |     public static DefaultBocomClient createClient() {
 | ||
|  |         DefaultBocomClient client = new DefaultBocomClient(APP_ID, PRIVATE_KEY, API_GW_PUBLIC_KEY);
 | ||
|  |         if (IS_DEV) {
 | ||
|  |             client.ignoreSSLHostnameVerifier();
 | ||
|  |         }
 | ||
|  |         return client;
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     // 交易时间
 | ||
|  |     public static String getTransTime() {
 | ||
|  |         return DateHelper.dateToStr(new Date(), DateHelper.DateEnum.yyyyMMddHHmmss);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     // 商户侧交易日期
 | ||
|  |     public static String getMerTradeDate() {
 | ||
|  |         return DateHelper.dateToStr(new Date(), DateHelper.DateEnum.yyyyMMdd);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     //  商户侧交易时间
 | ||
|  |     public static String getMerTradeTime() {
 | ||
|  |         return DateHelper.dateToStr(new Date(), DateHelper.DateEnum.HHmmss);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  | }
 |