Commit 5c8b2561 by huluobin

账户信息

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