*** Settings *** Documentation 拼版下单 Library urllib3 Library Collections Library RequestsLibrary Library DatabaseLibrary Library JSONLibrary Library demjson Library HttpLibrary *** Test Cases *** spuDetail #拼版订单 #获取spu列表 Create Session factory ${yytClient} ${ClientHeader} ${reps} GET On Session factory printing-packaging-factory-service/user/get/all-spu-list params=printingType=2&status=1 ${records} Get From Dictionary ${reps.json()['data']} records #盒型列表 FOR ${SPUData} IN @{records} ${url} Get From Dictionary ${SPUData['imageUrlList'][0]} url #盒型图片 ${name} Get From Dictionary ${SPUData} name #盒型名称 ${spuId} Get From Dictionary ${SPUData} id #盒型id ${orgId} Get From Dictionary ${SPUData} orgId #盒子归属组织id ${factoryId} Get From Dictionary ${SPUData} factoryId #盒子归属工厂id Exit For Loop If '${name}'=='内托' END Set Global Variable ${url} Set Global Variable ${name} Set Global Variable ${spuId} Set Global Variable ${orgId} Set Global Variable ${factoryId} #盒型详情 ${SPUDetail} Set Variable {"spuId":"${spuId}","basic":true} ${reps} POST On Session factory printing-packaging-factory-service/user/render/spu-detail ${SPUDetail.encode('utf-8')} ${quote} Get From Dictionary ${reps.json()['data']} quote #获取报价基础信息 ${amount} Get From Dictionary ${quote} amount #获取盒型报价 ${quantity} Get From Dictionary ${quote} count #${quantity} evaluate random.choice(['1000','2000','3000','4000','5000']) random #数量随机数:1000~5000 ${spuDetail} Get From Dictionary ${reps.json()['data']} spuDetail #获取盒型参数信息 ${spuDetail} Update Value To Json ${spuDetail} $..value null #修改value字段key为null ${spuDetail} Update Value To Json ${spuDetail} $..remark null #修改remark字段key为null ${spuDetail} Update Value To Json ${spuDetail} $..partNum null #修改partNum字段key为null ${spuDetail} Update Value To Json ${spuDetail} $..displayName null #修改displayName字段key为null ${spuDetail} Update Value To Json ${spuDetail} $..spuCategoryName null #修改spuCategoryName字段key为null ${spuDetail} Update Value To Json ${spuDetail} $..measureFormulaId null #修改measureFormulaId字段key为null ${spuCategoryId} Get From Dictionary ${spuDetail} spuCategoryId ${SpuSize} Get From List ${spuDetail["spuSpecItemList"]} 1 #SPU尺寸参数 ${SpuMaterial} Get From List ${spuDetail["spuSpecItemList"]} 0 #SPU材质参数 ${SpuTechnology} Get From List ${spuDetail["spuSpecItemList"]} 2 #SPU工艺参数 ${spuSpecItemList} Create List Append To List ${spuSpecItemList} ${SpuMaterial} ${SpuSize} ${SpuTechnology} ${productMeasureDesc} Get From Dictionary ${quote} productMeasureDesc #计价尺寸 ${Long} Set Variable ${productMeasureDesc[0:3]} #截取长 ${Weight} Set Variable ${productMeasureDesc[4:7]} #截取宽 ${Material} Evaluate ${Long}*${Weight}/1000000*1.85*${quantity} #材料费 ${Technology} Evaluate round(${Long}*${Weight}/100*0.00003*${quantity},2) #工艺费 ${TotalPrice} Evaluate round(${Material}+${Technology},2) #总价 ${Price} Set Variable If '${TotalPrice}'<='125' 125 ${TotalPrice} #判断是否小于等于低消 ${SpuSizeNormal} Update Value To Json ${SpuSize} $.value 1-250*300 #spu正常计价 ${SpuSizeQuotation} Update Value To Json ${SpuSize} $.value 1-166*350 #spu低消计价 ${Data} Evaluate 3 #修改 ${SpuSizeNormal} Add Object To Json ${SpuSizeNormal} $.operateType ${Data} ${SpuSizeQuotation} Add Object To Json ${SpuSizeQuotation} $.operateType ${Data} #将对象data加入到json中 ${Operate} Get Value From Json ${SpuSizeQuotation} $.operateType ${Value} Get Value From Json ${spuDetail} $..value ${remark} Get Value From Json ${spuDetail} $..remark ${partNum} Get Value From Json ${spuDetail} $..partNum ${displayName} Get Value From Json ${spuDetail} $..displayName ${spuCategoryName} Get Value From Json ${spuDetail} $..spuCategoryName ${measureFormulaId} Get Value From Json ${spuDetail} $..measureFormulaId ${spuDetail} Evaluate demjson.encode(${spuDetail}) demjson ${SpuSizeNormal} Evaluate demjson.encode(${SpuSizeNormal}) demjson ${SpuSizeQuotation} Evaluate demjson.encode(${SpuSizeQuotation}) demjson Should Be Equal ${amount} ${TotalPrice} Set Global Variable ${quote} Set Global Variable ${SpuSize} Set Global Variable ${spuDetail} Set Global Variable ${SpuMaterial} Set Global Variable ${spuCategoryId} Set Global Variable ${SpuTechnology} Set Global Variable ${SpuSizeNormal} Set Global Variable ${spuSpecItemList} Set Global Variable ${SpuSizeQuotation} Quotation #选择盒型参数-低消 Create Session factory ${yytClient} ${ClientHeader} ${spuQotation} Set Variable { \ \ \ \ "spuId":"${spuId}", \ \ \ \ "basic":false, \ \ \ \ "spuDetail":${spuDetail}, \ \ \ \ "operateRenderSpuItemList":[${SpuSizeQuotation}] } ${reps} POST On Session factory printing-packaging-factory-service/user/render/spu-detail ${spuQotation.encode('utf-8')} ${Amount} Get From Dictionary ${reps.json()['data']['quote']} amount #获取合计金额 ${quantity} Get From Dictionary ${reps.json()['data']['quote']} count #获取几家数量 ${productMeasureDesc} Get From Dictionary ${reps.json()['data']['quote']} productMeasureDesc #计价尺寸 ${Long} Set Variable ${productMeasureDesc[0:3]} #截取长 ${Weight} Set Variable ${productMeasureDesc[4:7]} #截取宽 ${Material} Evaluate ${Long}*${Weight}/1000000*1.85*${quantity} #材料费 ${Technology} Evaluate round(${Long}*${Weight}/100*0.00003*${quantity},2) #工艺费 ${TotalPrice} Evaluate round(${Material}+${Technology},2) #总价 ${Price} Set Variable If '${TotalPrice}'<='125' 125 ${TotalPrice} #比较价格 Should Be Equal As Numbers ${Amount} ${Price} Normal #选择盒型参数-正常计算 Create Session factory ${yytClient} ${ClientHeader} ${spuNormal} Set Variable { \ \ \ \ "spuId":"${spuId}", \ \ \ \ "basic":false, \ \ \ \ "spuDetail":${spuDetail}, \ \ \ \ "operateRenderSpuItemList":[${SpuSizeNormal}] } ${reps} POST On Session factory printing-packaging-factory-service/user/render/spu-detail ${spuNormal.encode('utf-8')} ${Amount} Get From Dictionary ${reps.json()['data']['quote']} amount #获取合计金额 ${quantity} Get From Dictionary ${reps.json()['data']['quote']} count #获取几家数量 ${productMeasureDesc} Get From Dictionary ${reps.json()['data']['quote']} productMeasureDesc #计价尺寸 ${Long} Set Variable ${productMeasureDesc[0:3]} #截取长 ${Weight} Set Variable ${productMeasureDesc[4:7]} #截取宽 ${Material} Evaluate ${Long}*${Weight}/1000000*1.85*${quantity} #材料费 ${Technology} Evaluate round(${Long}*${Weight}/100*0.00003*${quantity},2) #工艺费 ${TotalPrice} Evaluate round(${Material}+${Technology},2) #总价 ${Price} Set Variable If '${TotalPrice}'<='125' 125 ${TotalPrice} #比较价格 Should Be Equal As Numbers ${Amount} ${Price}