-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
36 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
import { FincodeService } from "../../src/server"; | ||
import { FincodeNs } from "../../src/types"; | ||
|
||
export const getSaleList = async () => { | ||
const service = FincodeService.createInstance(); | ||
console.log(service.configData); | ||
await service.getSaleList( | ||
{}, | ||
{ | ||
onSuccess: console.log, | ||
onError: console.error, | ||
}, | ||
); | ||
await service.getSaleItem("sales_s_22082100904_231130_00001", { | ||
onSuccess: console.log, | ||
onError: console.error, | ||
}); | ||
await service.getSaleDetail( | ||
"sales_s_22082100904_231130_00001", | ||
{ trade_type: [1, 2] }, | ||
{ | ||
onSuccess: console.log, | ||
onError: console.error, | ||
}, | ||
const getFincodeSalesList = async (nextPage = 1): Promise<FincodeNs.Sale.SaleItem[]> => { | ||
const fincode = FincodeService.createInstance(); | ||
const { current_page, last_page, list } = await fincode.getSaleList({ limit: 100, page: nextPage }, { onError: console.error }); | ||
let result: FincodeNs.Sale.SaleItem[] = list; | ||
for (let page = current_page; page < last_page; page++) { | ||
const res = await fincode.getSaleList({ limit: 100, page }, { onError: console.error }); | ||
result = [...res.list, ...result]; | ||
} | ||
return result; | ||
}; | ||
|
||
const getSaleDetailItems = async (saleId: string, nextPage = 1): Promise<FincodeNs.Sale.SaleDetailItem[]> => { | ||
const fincode = FincodeService.createInstance(); | ||
const { current_page, last_page, list } = await fincode.getSaleDetail( | ||
saleId, | ||
{ limit: 100, page: nextPage, trade_type: [1, 2, 3, 4, 5] }, | ||
{ onError: console.error }, | ||
); | ||
let result: FincodeNs.Sale.SaleDetailItem[] = list; | ||
for (let page = current_page; page < last_page; page++) { | ||
const res = await fincode.getSaleDetail(saleId, { limit: 100, page, trade_type: [1, 2, 3, 4, 5] }, { onError: console.error }); | ||
result = [...res.list, ...result]; | ||
} | ||
return result; | ||
}; | ||
|
||
export const getSaleList = async () => { | ||
const saleList = await getFincodeSalesList(); | ||
let saleDetailList: FincodeNs.Sale.SaleDetailItem[] = []; | ||
for (const saleItem of saleList) { | ||
const saleDetail = await getSaleDetailItems(saleItem.id); | ||
saleDetailList = [...saleDetailList, ...saleDetail]; | ||
} | ||
console.log(saleDetailList); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters