*** Settings *** Documentation 优惠券 Library urllib3 Library Collections Library RequestsLibrary Library DatabaseLibrary *** Test Cases *** 0-register #注册登录送券 Run Keyword UecLogin Run Keyword LoginToken Create Session factory ${uecClient} ${client_firstlogin_header} ${reps} GET On Session factory coupon-service/user/page/coupon params=checked=false ${records} Get From Dictionary ${reps.json()['data']} records #获取优惠券列表 Run Keyword DeleteLogin OrderCoupon #下首单送券 Run Keyword UecLogin Run Keyword LoginToken Run Keyword BaseInfo Run Keyword 完善用户信息 #获取spu列表 Create Session factory ${yytClient} ${client_firstlogin_header} ${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 ${Items} IN @{records} ${id} Get From Dictionary ${Items} id #获取spuid ${name} Get From Dictionary ${Items} name #盒子名称 ${orgId} Get From Dictionary ${Items} orgId #获取spuorgid ${factoryId} Get From Dictionary ${Items} factoryId #获取spufactoryId Exit For Loop If '${id}'=='820801091557003264' #下单内托 END #获取SPU报价 ${spuData} Set Variable {"spuId":"${id}","basic":true} ${reps} POST On Session factory printing-packaging-factory-service/user/render/spu-detail data=${spuData.encode('utf-8')} ${desc} Get From Dictionary ${reps.json()['data']['quote']} desc #盒型参数 ${count} Get From Dictionary ${reps.json()['data']['quote']} count #下单数量 ${price} Get From Dictionary ${reps.json()['data']['quote']} price #单价 ${quote} Get From Dictionary ${reps.json()['data']} quote #获取报价json ${amount} Get From Dictionary ${reps.json()['data']['quote']} amount #获取盒型价格 ${spuDetail} Get From Dictionary ${reps.json()['data']} spuDetail #获取盒型渲染 ${processDesc} Get From Dictionary ${reps.json()['data']['quote']} processDesc #盒型工艺 ${productArea} Get From Dictionary ${reps.json()['data']['quote']} productArea #初始化尺寸 ${materialDesc} Get From Dictionary ${reps.json()['data']['quote']} materialDesc #盒型材质 ${originalAmount} Get From Dictionary ${reps.json()['data']['quote']} originalAmount #低消 ${productMeasureDesc} Get From Dictionary ${reps.json()['data']['quote']} productMeasureDesc #下单尺寸 ${productProcessDesc} Get From Dictionary ${reps.json()['data']['quote']} productProcessDesc #下单工艺 ${productMaterialDesc} Get From Dictionary ${reps.json()['data']['quote']} productMaterialDesc #下单材质 ${data} Get From Dictionary ${reps.json()} data #${productSpecDetailJson} Set Variable {"quote":"${quote}"} #获取工厂税点信息(自提) #${reps} GET On Session factory printing-package-mall-service/user/page/invoice-title params=pageNum=factoryId=${factoryId}&orgId=${orgId}&deliveryAddressProvinceId=&deliveryAddressCityId=&deliveryAddressDistrictId= #${enterpriseInvoiceList} Get From Dictionary ${reps.json()['data']} enterpriseInvoiceList #FOR ${Freedata} IN @{enterpriseInvoiceList} #${tax} Get From Dictionary ${Freedata} tax #税点 #${type} Get From Dictionary ${Freedata} type #开票类型 #${logisticsCharges} Get From Dictionary ${Freedata} logisticsCharges #物流费用 #Exit For Loop If '${type}'==1 #普通发票:1,专用发票:2 #END #获取用户钱包账号 Create Session factory ${uecClient} ${client_firstlogin_header} ${reps} GET On Session factory wallet-service/user/get/wallet-account ${amountGift} Get From Dictionary ${reps.json()['data']} amountGift #赠送金额 ${totalBalance} Get From Dictionary ${reps.json()['data']} totalBalance #总金额 ${frozenBalance} Get From Dictionary ${reps.json()['data']} frozenBalance #可用金额 ${availableBalance} Get From Dictionary ${reps.json()['data']} availableBalance #冻结金额 #获取可用优惠券 #${reps} GET On Session factory coupon-service/user/calculate/discount-amount params=amount=${amount}&couponBusinessType=2&isUseCoupon=true #创建订单 Create Session factory ${yytClient} ${client_firstlogin_header} ${OrderData} Set Variable { \ \ \ \ "remark":"", \ \ \ \ "totalAmount":"${amount}", \ \ \ \ "taxFee":0, \ \ \ \ "taxRate":0, \ \ \ \ "logisticsFee":0, \ \ \ \ "supplierFactoryId":"${factoryId}", \ \ \ \ "supplierOrgId":"${orgId}", \ \ \ \ "customerContactsName":"26用户", \ \ \ \ "customerContactsPhone":"${mobile}", \ \ \ \ "packingMethod":2, \ \ \ \ "salesOrderInvoice":{ \ \ \ \ \ \ \ \ "type":0 \ \ \ \ }, \ \ \ \ "salesOrderItemProduct":{ \ \ \ \ \ \ \ \ "productName":"${name}", \ \ \ \ \ \ \ \ "productId":"${id}", \ \ \ \ \ \ \ \ "amount":"${amount}", \ \ \ \ \ \ \ \ "quantity":"${count}", \ \ \ \ \ \ \ \ "price":"${price}", \ \ \ \ \ \ \ \ "productImgUrl":"https://qncloudprintfiletest.oss-cn-shenzhen.aliyuncs.com/cloudprint/ee9ecad4-9535-42af-b92f-f7d5c804df1c.png", \ \ \ \ \ \ \ \ "factoryId":"${factoryId}", \ \ \ \ \ \ \ \ "orgId":"${orgId}", \ \ \ \ \ \ \ \ "orderSource":1, \ \ \ \ \ \ \ \ "desc":"${desc}", \ \ \ \ \ \ \ \ "productMeasureDesc":"${productMeasureDesc}", \ \ \ \ \ \ \ \ "productMaterialDesc":"${productMaterialDesc}", \ \ \ \ \ \ \ \ "productProcessDesc":"${productProcessDesc}", \ \ \ \ \ \ \ \ "copyFromId":null, \ \ \ \ \ \ \ \ "productSpecDetailJson":{"quote":"${data}"}, \ \ \ \ \ \ \ \ "productSpecDetail":"${desc}" \ \ \ \ }, \ \ \ \ "orderSource":1 } ${reps} POST On Session factory printing-package-mall-service/user/create/sales-order data=${OrderData.encode('utf-8')} ${OrderId} Get From Dictionary ${reps.json()} data #获取订单id *** Keywords *** DeleteLogin #新用户登录 #判断新用户 Connect To Database Using Custom Params pymysql host='8.135.8.221',user='root', password='qniaothreetwoonego', \ port=3306,database='ztb_recycle' #链接测试环境数据库 Execute Sql String UPDATE `uec`.`qn_account` SET `is_delete` = 1 WHERE `user_id` = ${userId}; Execute Sql String UPDATE `uec`.`qn_user` SET `is_delete` = 1 WHERE `id` = ${userId}; Execute Sql String UPDATE `coupon`.`qn_user_behavior` SET `is_delete` = 1 WHERE `user_id` = ${userId} Disconnect From Database Sleep 1 UecLogin #登录UEC Disable Warnings Create Session factory ${uecClient} ${Client-LoginHeader} ${LoginData} Set Variable {"account":"${New_account}","captcha":"${client_password}","accountType":2} ${resp} POST On Session factory uec/authorize/by-captcha data=${LoginData} ${token} Get From Dictionary ${resp.json()["data"]} token #获取UECtoken ${userId} Get From Dictionary ${resp.json()["data"]} userId #获取用户id Set Global Variable ${token} Set Global Variable ${userId} LoginToken #切换业务线token Create Session factory ${yytClient} ${Client-LoginHeader} #${Token} Create Dictionary loginToken=${token} ${Token} Set Variable {"loginToken":"${token}"} ${reps} POST On Session factory yyt-uec/authorize/get/product-line-token/by/login-token ${Token.encode('utf-8')} ${Token} Get From Dictionary ${reps.json()} data #获取业务线token #Set Global Variable ${Token} ${client_firstlogin_header} Set Variable {'Content-Type':'application/json','Authorization':'QNT ${Token}','X-APP-ID':'503258978847966422'} #移动端首次登录headerBaseInfo Set Global Variable ${client_firstlogin_header} BaseInfo #获取用户基础信息 Create Session factory ${yytClient} ${client_firstlogin_header} ${reps} GET On Session factory yyt-uec/get/base-info params=userId=${userId} ${mobile} Get From Dictionary ${reps.json()["data"]} mobile #获取用户手机号 Set Global Variable ${mobile} 完善用户信息 #完善用户信息 Create Session factoey ${uecClient} ${client_firstlogin_header} ${UserData} Set Variable {"avatar":"https://qncloudprintfiletest.oss-cn-shenzhen.aliyuncs.com/cloudprint/1697687519017.jpeg","nickname":"26用户"} ${reps} POST On Session factoey uec/user/update/user-info params=userId=${userId} data=${UserData.encode('utf-8')} ${message} Get From Dictionary ${reps.json()} message Should Be Equal ${message} successful