rpa_JD_searchOrderInfo
通过订单状态获取订单信息
1. 函数
rpa_JD_searchOrderInfo(page, orderStatus, startTime, endTime)
- page:int类型,页码,返回结果中的totalPage是总页数;
- orderStatus:字符串类型,订单状态,指定订单状态查询,多个状态使用逗号分隔;
- startTime:字符串类型,开始时间,格式:yyyy-mm-dd hh:mm:ss
- endTime:字符串类型,截止时间,格式:yyyy-mm-dd hh:mm:ss
2. 返回值
字符串类型,订单信息JSON串:不为空表示成功,为空表示失败或无订单信息,通过rpa_getLastErrorCode()获取错误码,rpa_getLastErrorMsg()获取错误信息。 可以使用rpa_JD_parseOrderInfo解析成RpaHelper.OrderResult,OrderResult类定义如下:
class OrderInfo:
def __init__(self, jsonInfo):
self.totalPage = jsonInfo['totalPage']
self.orderId = jsonInfo['orderId']
self.orderState = jsonInfo['orderState']
self.skuNames = jsonInfo['skuNames']
self.payType = jsonInfo['payType']
self.orderTotalPrice = jsonInfo['orderTotalPrice']
self.orderSellerPrice = jsonInfo['orderSellerPrice']
self.freightPrice = jsonInfo['freightPrice']
self.orderRemark = jsonInfo['orderRemark']
self.venderRemark = jsonInfo['venderRemark']
self.remarkFlag = jsonInfo['remarkFlag']
self.orderStartTime = jsonInfo['orderStartTime']
self.orderEndTime = jsonInfo['orderEndTime']
self.outBoundDate = jsonInfo['outBoundDate']
consigneeInfo = json.loads(jsonInfo['consigneeInfo'])
self.fullAddress = consigneeInfo['fullAddress']
self.fullname = consigneeInfo['fullname']
self.mobile = consigneeInfo['mobile']
self.telephone = consigneeInfo['telephone']
class OrderResult:
def __init__(self, totalPage, orderList):
self.totalPage = totalPage
self.orderList = orderList
3. 示例
def showResult(orderResult):
for orderInfo in orderResult.orderList:
if len(orderInfo.orderId) > 0:
print(orderInfo.orderId)
print(orderInfo.orderState)
print(orderInfo.venderRemark)
print(orderInfo.remarkFlag)
'''根据订单状态查询订单'''
#页码
page=1
"""
"WAIT_SELLER_STOCK_OUT", "等待出库"
"WAIT_SELLER_DELIVERY", "等待发货"
"WAIT_GOODS_RECEIVE_CONFIRM", "等待确认收货"
"FINISHED_L", "已完成"
"TRADE_CANCELED", "已取消"
"LOCKED", "锁定"
"RECEIPTS_CONFIRM", "收款确认"
"SEND_TO_DISTRIBUTION_CENER", "发往配送中心"
"DISTRIBUTION_CENTER_RECEIVED", "配送中心收到货"
"WAIT_CUSTOMER_REPLAY", "等待客户回复"
"""
#订单状态,可选值见上表
orderStatus = "WAIT_SELLER_STOCK_OUT,FINISHED_L"
#订单开始截止时间,不要超过1个月
startTime = "2019-06-01 00:00:00"
endTime = "2019-06-30 00:00:00"
#查询订单
orderJson = rpa_JD_searchOrderInfo(page, orderStatus, startTime, endTime)
#解析第一页结果
orderResult = rpa_JD_parseOrderInfo(orderJson)
#显示第一页结果
showResult(orderResult)
page = page + 1
totalPage=orderResult.totalPage
#多页时,循环获取每页订单
while page <= totalPage:
orderJson = rpa_JD_searchOrderInfo(page, orderStatus, startTime, endTime)
orderResult = rpa_JD_parseOrderInfo(orderJson)
showResult(orderResult)
page = page + 1