rpa_JD_parseOrderInfo

解析订单信息

1. 函数

rpa_JD_parseOrderInfo(orderJson)

  • orderJson:字符串类型,rpa_JD_searchOrderInfo和rpa_JD_searchOrderByIds返回的数据;

2. 返回值

数组类型,OrderResult对象:不为空表示成功,为空表示失败或无订单信息,通过rpa_getLastErrorCode()获取错误码,rpa_getLastErrorMsg()获取错误信息。 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. 示例

from RpaHelper import OrderInfo
from RpaHelper import OrderResult

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)

#订单id
orderIds="94954811140,83181606077"

#查询订单
orderJson = rpa_JD_searchOrderByIds(orderIds)

#解析订单信息,返回OrderResult对象
orderResult = rpa_JD_parseOrderInfo(orderJson)

#解析订单查询结果
showResult(orderResult)
powered by Gitbook修订时间: 2021-04-15 15:56:54

找到相关内容

    未找到""相关内容

    找到相关内容

      未找到""相关内容