Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
bailuntec-datacenter
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huluobin
bailuntec-datacenter
Commits
c1569b3e
Commit
c1569b3e
authored
Jan 18, 2021
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
# update
parent
0fc1257d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
123 additions
and
1 deletion
+123
-1
pom.xml
datacenter-job/datacenter-base/base-sync-ebay/pom.xml
+8
-0
EbayItemReader.java
...-ebay/src/main/java/com/bailuntec/job/EbayItemReader.java
+115
-0
pom.xml
datacenter-job/datacenter-base/base-sync-fee/pom.xml
+0
-1
No files found.
datacenter-job/datacenter-base/base-sync-ebay/pom.xml
View file @
c1569b3e
...
...
@@ -19,6 +19,14 @@
<maven.build.timestamp.format>
yyyyMMddHHmm
</maven.build.timestamp.format>
</properties>
<dependencies>
<dependency>
<groupId>
io.github.linus87
</groupId>
<artifactId>
ebaycalls
</artifactId>
<version>
1065
</version>
</dependency>
</dependencies>
<build>
<plugins>
...
...
datacenter-job/datacenter-base/base-sync-ebay/src/main/java/com/bailuntec/job/EbayItemReader.java
0 → 100644
View file @
c1569b3e
package
com
.
bailuntec
.
job
;
import
com.bailuntec.common.ListUtil
;
import
com.bailuntec.domain.DcBaseCompanyAccount
;
import
com.bailuntec.domain.DcJobConfig
;
import
com.ebay.sdk.ApiContext
;
import
com.ebay.sdk.ApiCredential
;
import
com.ebay.sdk.TimeFilter
;
import
com.ebay.sdk.call.GetAccountCall
;
import
com.ebay.soap.eBLBaseComponents.AccountEntryType
;
import
com.ebay.soap.eBLBaseComponents.AccountHistorySelectionCodeType
;
import
com.ebay.soap.eBLBaseComponents.DetailLevelCodeType
;
import
com.ebay.soap.eBLBaseComponents.PaginationType
;
import
com.google.common.collect.Lists
;
import
org.springframework.batch.item.ItemReader
;
import
org.springframework.batch.item.NonTransientResourceException
;
import
org.springframework.batch.item.ParseException
;
import
org.springframework.batch.item.UnexpectedInputException
;
import
java.time.ZoneId
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2021/1/18 5:23 下午
*/
public
class
EbayItemReader
implements
ItemReader
<
AccountEntryType
>
{
//剩余账户
private
List
<
DcBaseCompanyAccount
>
dcBaseCompanyAccountList
;
//剩余广告记录
private
List
<
AccountEntryType
>
accountEntryTypeList
;
//当前账户
private
DcBaseCompanyAccount
dcBaseCompanyAccount
;
private
GetAccountCall
getAccountCall
;
private
Integer
pageNum
;
private
Integer
pageSize
;
private
DcJobConfig
dcJobConfig
;
@Override
public
AccountEntryType
read
()
throws
Exception
,
UnexpectedInputException
,
ParseException
,
NonTransientResourceException
{
if
(
ListUtil
.
isNotEmpty
(
accountEntryTypeList
))
{
return
accountEntryTypeList
.
remove
(
0
);
}
else
{
nextPage
();
if
(
ListUtil
.
isNotEmpty
(
accountEntryTypeList
))
{
return
accountEntryTypeList
.
remove
(
0
);
}
else
{
nextAccount
();
if
(
ListUtil
.
isNotEmpty
(
accountEntryTypeList
))
{
return
accountEntryTypeList
.
remove
(
0
);
}
else
{
return
null
;
}
}
}
}
private
void
nextPage
()
throws
Exception
{
this
.
pageNum
++;
refreshPage
();
}
private
void
nextAccount
()
{
this
.
pageNum
=
1
;
if
(
ListUtil
.
isNotEmpty
(
dcBaseCompanyAccountList
))
{
dcBaseCompanyAccount
=
dcBaseCompanyAccountList
.
remove
(
0
);
this
.
refreshAccountCall
();
}
}
void
refreshAccountCall
()
{
ApiContext
apiContext
=
new
ApiContext
();
ApiCredential
cred
=
apiContext
.
getApiCredential
();
cred
.
seteBayToken
(
dcBaseCompanyAccount
.
getSoapAuthToken
());
apiContext
.
setApiServerUrl
(
"https://api.ebay.com/wsapi"
);
GetAccountCall
getAccountCall
=
new
GetAccountCall
(
apiContext
);
getAccountCall
.
setDetailLevel
(
new
DetailLevelCodeType
[]{
DetailLevelCodeType
.
RETURN_ALL
});
AccountHistorySelectionCodeType
accountHistorySelectionCodeType
=
AccountHistorySelectionCodeType
.
BETWEEN_SPECIFIED_DATES
;
getAccountCall
.
setViewType
(
accountHistorySelectionCodeType
);
//开始时间
Calendar
startCal
=
Calendar
.
getInstance
();
startCal
.
setTime
(
Date
.
from
(
dcJobConfig
.
getStartTime
().
atZone
(
ZoneId
.
systemDefault
()).
toInstant
()));
//结束时间
Calendar
endCal
=
Calendar
.
getInstance
();
endCal
.
setTime
(
Date
.
from
(
dcJobConfig
.
getEndTime
().
atZone
(
ZoneId
.
systemDefault
()).
toInstant
()));
TimeFilter
timeFilter
=
new
TimeFilter
(
startCal
,
endCal
);
getAccountCall
.
setViewPeriod
(
timeFilter
);
getAccountCall
.
setInvoiceDate
(
endCal
);
}
private
void
refreshPage
()
throws
Exception
{
PaginationType
paginationType
=
new
PaginationType
();
paginationType
.
setPageNumber
(
pageNum
);
getAccountCall
.
setPagination
(
new
PaginationType
());
accountEntryTypeList
=
Lists
.
newArrayList
(
getAccountCall
.
getAccount
());
}
}
datacenter-job/datacenter-base/base-sync-fee/pom.xml
View file @
c1569b3e
...
...
@@ -23,7 +23,6 @@
<build>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment