Commit 5c8b2561 by huluobin

账户信息

parent 484fbd3e
...@@ -31,57 +31,60 @@ public class CompanyAccountSyncJob extends PointJob { ...@@ -31,57 +31,60 @@ public class CompanyAccountSyncJob extends PointJob {
@Override @Override
public void executeJob(ShardingContext shardingContext, JobPointLog jobPointLog) { public void executeJob(ShardingContext shardingContext, JobPointLog jobPointLog) {
Request request = new Request.Builder() Request request = new Request.Builder()
.url(propertiesUtil.getPropertyAsString("COMPANY_ACCOUNT_URL")) .url(propertiesUtil.getPropertyAsString("COMPANY_ACCOUNT_URL"))
.get() .get()
.addHeader("Content-Type", "application/json") .addHeader("Content-Type", "application/json")
.build(); .build();
Response response = null; Response response = null;
String resultStr = null; String resultStr = null;
try { try {
response = client.newCall(request).execute(); response = client.newCall(request).execute();
resultStr = response.body().string(); resultStr = response.body().string();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("调用公司账户授权信息接口失败", e); throw new RuntimeException("调用公司账户授权信息接口失败", e);
} finally { } finally {
if (response != null) { if (response != null) {
response.close(); response.close();
}
} }
if (StringUtils.isNotBlank(resultStr)) { }
AccountResult<CompanyAccountInfo> companyAccountInfoResult = JSONObject.parseObject(resultStr, new TypeReference<AccountResult<CompanyAccountInfo>>(){}); if (StringUtils.isNotBlank(resultStr)) {
if (companyAccountInfoResult.getSuccess()!= null && companyAccountInfoResult.getSuccess()) { AccountResult<CompanyAccountInfo> companyAccountInfoResult = JSONObject.parseObject(resultStr, new TypeReference<AccountResult<CompanyAccountInfo>>() {
List<CompanyAccountInfo> result = companyAccountInfoResult.getData(); });
if (result != null && result.size() > 0) { if (companyAccountInfoResult.getSuccess() != null && companyAccountInfoResult.getSuccess()) {
DcBaseCompanyAccountMapper mapper = SessionUtil.getSession().getMapper(DcBaseCompanyAccountMapper.class); List<CompanyAccountInfo> result = companyAccountInfoResult.getData();
DcBaseCompanyAccount dcBaseCompanyAccount = new DcBaseCompanyAccount(); if (result != null && result.size() > 0) {
DcBaseCompanyAccountMapper mapper = SessionUtil.getSession().getMapper(DcBaseCompanyAccountMapper.class);
DcBaseCompanyAccount dcBaseCompanyAccount = new DcBaseCompanyAccount();
try { try {
// Add by Allan at 20200718 // Add by Allan at 20200718
mapper.updatesetstatusoff(); mapper.updatesetstatusoff();
for (CompanyAccountInfo companyAccountInfo : result) { for (CompanyAccountInfo companyAccountInfo : result) {
BeanUtils.copyProperties(dcBaseCompanyAccount, companyAccountInfo); BeanUtils.copyProperties(dcBaseCompanyAccount, companyAccountInfo);
dcBaseCompanyAccount.setBjModified(LocalDateTime.now()); dcBaseCompanyAccount.setBjModified(LocalDateTime.now());
int i = mapper.updateByExampleSelective(dcBaseCompanyAccount, DcBaseCompanyAccountExample.newAndCreateCriteria() int i = mapper.updateByExampleSelective(dcBaseCompanyAccount, DcBaseCompanyAccountExample.newAndCreateCriteria()
.andCompanyIdEqualTo(companyAccountInfo.getCompanyId()) .andCompanyIdEqualTo(companyAccountInfo.getCompanyId())
.andAccountIdEqualTo(companyAccountInfo.getAccountId()).example()); .andAccountIdEqualTo(companyAccountInfo.getAccountId()).example());
if (i == 0) { if (i == 0) {
mapper.insertSelective(dcBaseCompanyAccount); mapper.insertSelective(dcBaseCompanyAccount);
}
} }
} catch (Exception e) {
throw new RuntimeException("Mybatis操作DB失败",e);
} finally {
SessionUtil.closeSession();
} }
} catch (Exception e) {
throw new RuntimeException("Mybatis操作DB失败", e);
} finally {
SessionUtil.closeSession();
} }
} else {
throw new RuntimeException("调用公司账户授权信息接口返回错误");
} }
log.info("授权账户信息完成");
} else { } else {
throw new RuntimeException("调用公司账户授权信息接口返回null"); throw new RuntimeException("调用公司账户授权信息接口返回错误");
} }
} else {
throw new RuntimeException("调用公司账户授权信息接口返回null");
}
} }
} }
#COMPANY_INFO_URL=http://sso.bailuntec.com/GetCompanys #COMPANY_INFO_URL=http://sso.bailuntec.com/GetCompanys
#COMPANY_STAFF_URL=http://sso.bailuntec.com/GetUserByCompany #COMPANY_STAFF_URL=http://sso.bailuntec.com/GetUserByCompany
#COMPANY_ACCOUNT_URL=http://pams.bailuntec.com/Api/GetAccountToken COMPANY_ACCOUNT_URL=http://pams.bailuntec.com/Api/GetAccountToken
COMPANY_INFO_URL=http://172.31.255.10/GetCompanys COMPANY_INFO_URL=http://172.31.255.10/GetCompanys
COMPANY_STAFF_URL=http://172.31.255.10/GetUserByCompany COMPANY_STAFF_URL=http://172.31.255.10/GetUserByCompany
COMPANY_ACCOUNT_URL=http://10.0.6.17:8090/Api/GetAccountToken #COMPANY_ACCOUNT_URL=http://10.0.6.17:8090/Api/GetAccountToken
PAYPAL_ACCOUNT_URL=http://pams.bailuntec.com/Api/GetPayPalAccounts PAYPAL_ACCOUNT_URL=http://pams.bailuntec.com/Api/GetPayPalAccounts
...@@ -124,7 +124,8 @@ public class SyncCostFirstJob extends PointJob { ...@@ -124,7 +124,8 @@ public class SyncCostFirstJob extends PointJob {
DcBaseCostFirstExample.newAndCreateCriteria() DcBaseCostFirstExample.newAndCreateCriteria()
.andBailunSkuEqualTo(dcBaseCostFirst.getBailunSku()) .andBailunSkuEqualTo(dcBaseCostFirst.getBailunSku())
.andChannelOrderIdEqualTo(dcBaseCostFirst.getChannelOrderId()) .andChannelOrderIdEqualTo(dcBaseCostFirst.getChannelOrderId())
.andBoxIdEqualTo(dcBaseCostFirst.getBoxId()).andTransferOrderIdEqualTo(dcBaseCostFirst.getTransferOrderId()) .andBoxIdEqualTo(dcBaseCostFirst.getBoxId())
.andTransferOrderIdEqualTo(dcBaseCostFirst.getTransferOrderId())
.andWarehouseCodeEqualTo(dcBaseCostFirst.getWarehouseCode()) .andWarehouseCodeEqualTo(dcBaseCostFirst.getWarehouseCode())
.example()); .example());
if (i == 0) { if (i == 0) {
......
...@@ -10,8 +10,8 @@ public class SyncCostFirstTest { ...@@ -10,8 +10,8 @@ public class SyncCostFirstTest {
public void test() { public void test() {
SyncCostFirstJob syncCostFirstJob = new SyncCostFirstJob(); SyncCostFirstJob syncCostFirstJob = new SyncCostFirstJob();
JobPointLog jobPointLog = new JobPointLog("base-sync-cost-first", 1, 1, 1, 1, JobPointLog jobPointLog = new JobPointLog("base-sync-cost-first", 1, 1, 1, 1,
LocalDateTime.of(2020,8,14,9,0,0), LocalDateTime.of(2020,1,1,9,0,0),
LocalDateTime.of(2020,8,17,13,0,0)); LocalDateTime.of(2020,8,20,0,0,0));
syncCostFirstJob.executeJob(null, jobPointLog); syncCostFirstJob.executeJob(null, jobPointLog);
} }
} }
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