| @@ -20,6 +20,7 @@ import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| @@ -28,6 +29,10 @@ public class WxBankUtilServiceImpl implements WxBankUtilService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| private final List<String> bank17= Arrays.asList("工商银行","交通银行","招商银行","民生银行","中信银行","浦发银行","兴业银行","光大银行","广发银行","平安银行","北京银行","华夏银行","农业银行","建设银行","邮政储蓄银行","中国银行","宁波银行"); | |||
| private final String otherBank = "其他银行"; | |||
| @Autowired | |||
| WxPayAccountService wxPayAccountService; | |||
| @@ -55,6 +60,7 @@ public class WxBankUtilServiceImpl implements WxBankUtilService { | |||
| WxPayService wxPayService = wxPayAccountService.getWxPayService(tenantInfo.getTenantId()); | |||
| try { | |||
| BankingResult bankingResult = wxPayService.getBankService().personalBanking(offset,limit); | |||
| this.handlBankingResult(bankingResult.getData()); | |||
| return new ResultData(bankingResult.getData()); | |||
| } catch (WxPayException e) { | |||
| e.printStackTrace(); | |||
| @@ -70,6 +76,7 @@ public class WxBankUtilServiceImpl implements WxBankUtilService { | |||
| int offset = 0, limit = 200; | |||
| try { | |||
| BankingResult bankingResult = wxPayService.getBankService().personalBanking(offset,limit); | |||
| this.handlBankingResult(bankingResult.getData()); | |||
| bankInfoList.addAll(bankingResult.getData()); | |||
| String key = prev+offset+"_"+limit; | |||
| BankingResult cacheObject = RedisCacheUtils.getCacheObject(bankRedisTemplate, key, BankingResult.class); | |||
| @@ -88,6 +95,7 @@ public class WxBankUtilServiceImpl implements WxBankUtilService { | |||
| if(nextBankingResult == null){ | |||
| try{ | |||
| nextBankingResult = wxPayService.getBankService().personalBanking(offset,limit); | |||
| this.handlBankingResult(nextBankingResult.getData()); | |||
| if(nextBankingResult != null){ | |||
| RedisCacheUtils.cache(bankRedisTemplate,nextkey,nextBankingResult,0); | |||
| } | |||
| @@ -112,6 +120,7 @@ public class WxBankUtilServiceImpl implements WxBankUtilService { | |||
| WxPayService wxPayService = wxPayAccountService.getWxPayService(tenantInfo.getTenantId()); | |||
| try { | |||
| BankingResult bankingResult = wxPayService.getBankService().corporateBanking(offset,limit); | |||
| this.handlBankingResult(bankingResult.getData()); | |||
| return new ResultData(bankingResult.getData()); | |||
| } catch (WxPayException e) { | |||
| e.printStackTrace(); | |||
| @@ -127,6 +136,7 @@ public class WxBankUtilServiceImpl implements WxBankUtilService { | |||
| int offset = 0, limit = 200; | |||
| try { | |||
| BankingResult bankingResult = wxPayService.getBankService().corporateBanking(offset,limit); | |||
| this.handlBankingResult(bankingResult.getData()); | |||
| bankInfoList.addAll(bankingResult.getData()); | |||
| String key = prev+offset+"_"+limit; | |||
| BankingResult cacheObject = RedisCacheUtils.getCacheObject(bankRedisTemplate, key, BankingResult.class); | |||
| @@ -145,6 +155,7 @@ public class WxBankUtilServiceImpl implements WxBankUtilService { | |||
| if(nextBankingResult == null){ | |||
| try{ | |||
| nextBankingResult = wxPayService.getBankService().corporateBanking(offset,limit); | |||
| this.handlBankingResult(nextBankingResult.getData()); | |||
| if(nextBankingResult != null){ | |||
| RedisCacheUtils.cache(bankRedisTemplate,nextkey,nextBankingResult,0); | |||
| } | |||
| @@ -164,6 +175,24 @@ public class WxBankUtilServiceImpl implements WxBankUtilService { | |||
| return new ResultData(bankInfoList); | |||
| } | |||
| /** | |||
| * 处理银行数据 | |||
| * 开户银行,传参规则如下: | |||
| * 1、17家直连银行,请根据开户银行对照表直接填写银行名 ; | |||
| * 2、非17家直连银行,该参数请填写为“其他银行”。 | |||
| */ | |||
| private void handlBankingResult(List<BankInfo> list){ | |||
| if(list != null && !list.isEmpty()){ | |||
| for (BankInfo bank:list) { | |||
| if(!bank17.contains(bank.getBankAlias())){ | |||
| bank.setAccountBank(otherBank); | |||
| bank.setNeedBankBranch(true); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| public ResultData areasProvinces(TenantEntity tenantInfo) { | |||
| WxPayService wxPayService = wxPayAccountService.getWxPayService(tenantInfo.getTenantId()); | |||