diff --git a/003-CreateOrder/Order.robot b/003-CreateOrder/Order.robot index 954e9d1..c32f07e 100644 --- a/003-CreateOrder/Order.robot +++ b/003-CreateOrder/Order.robot @@ -96,6 +96,7 @@ Quotation ${TotalPrice} Evaluate round(${Material}+${Technology},2) #总价 ${Price} Set Variable If '${TotalPrice}'<='125' 125 ${TotalPrice} #比较价格 Should Be Equal As Numbers ${Amount} ${Price} + Set Global Variable ${Price} Normal #选择盒型参数-正常计算 @@ -113,6 +114,7 @@ Normal ${Price} Set Variable If '${TotalPrice}'<='125' 125 ${TotalPrice} #比较价格 Log ${Price} Should Be Equal As Numbers ${Amount} ${Price} + Set Global Variable ${Price} ConfirmOrder #确认下单页面 @@ -127,6 +129,14 @@ ConfirmOrder Set Global Variable ${totalBalance} Set Global Variable ${frozenBalance} Set Global Variable ${availableBalance} + #获取抬头数据 + Create Session factory ${yytClient} ${ClientHeader} + ${reps} Get On Session factory printing-package-mall-service/user/page/invoice-title params=pageNum=1&pageSize=100 + ${Title} Get From Dictionary ${reps.json()['data']} records #获取发票抬头列表 + ${InvoiceTitle} Evaluate random.choice(${Title}) random + Set Global Variable ${InvoiceTitle} + +DeliveryOrder #获取送货地址列表 Create Session factory ${yytClient} ${ClientHeader} ${reps} GET On Session factory printing-package-mall-service/user/page/user-shipping-address params=pageNum=1&pageSize=100 @@ -138,6 +148,35 @@ ConfirmOrder Set Global Variable ${CityId} Set Global Variable ${DistrictId} Set Global Variable ${ProvinceId} + #送货-获取税点 + ${reps} GET On Session factory printing-package-mall-service/user/get/sale-order/other-fees-config params=factoryId=${Fid}&orgId=${organizationId}&deliveryAddressProvinceId=${ProvinceId}&deliveryAddressCityId=${CityId}&deliveryAddressDistrictId=${DistrictId} + ${Charges} Get From Dictionary ${reps.json()['data']} logisticsCharges #物流费用 + ${InvoiceList} Get From Dictionary ${reps.json()['data']} enterpriseInvoiceList #获取税点信息 + FOR ${Invoice} IN @{InvoiceList} + ${tax} Get From Dictionary ${Invoice} tax #税点 + ${type} Get From Dictionary ${Invoice} type #开票类型 + END + ${InvoiceData} Set Variable If '${type}'=='1' or '${type}'=='2' ${tax} 0 + ${Charges} Set Variable If '${Charges}'=='${None}' 0 ${Charges} + Set Global Variable ${Charges} + Set Global Variable ${InvoiceData} + #计算合计金额 + ${Amount} Evaluate 125 #商品金额 + ${InvoicePrice} Evaluate round((${Price}+${Charges})*${InvoiceData},2) #开票费用 + ${TotalAmount} Evaluate round(${Price}+${InvoicePrice},2) #合计金额 + Set Global Variable ${Amount} + Set Global Variable ${InvoicePrice} + Set Global Variable ${TotalAmount} + #获取优惠券列表 + Create Session factory ${uecClient} ${ClientHeader} + ${reps} Get On Session factory coupon-service/user/list/coupon/current-order-usable params=businessType=2&amount=${TotalAmount} + ${CouponList} Get From Dictionary ${reps.json()['data']} currentOrderUsableCouponList #可用优惠券信息 + Log ${CouponList} + ${CouponPrice} Run Keyword If '${CouponList}'=='[]' Evaluate 0 + ... ELSE Run Keyword Coupon + ${TotalPrice} Evaluate round(${Price}+${InvoicePrice}-${CouponPrice}+${Charges},2) #下单金额=商品金额+开票费用+物流-优惠券 + +PickupOrder #自提 ${LocationCityId} Set Variable 120100 ${LocationDistrictId} Set Variable 120102 @@ -145,5 +184,44 @@ ConfirmOrder Set Global Variable ${LocationCityId} Set Global Variable ${LocationDistrictId} Set Global Variable ${LocationProvinceId} - #送货-获取税点 - ${reps} GET On Session factory printing-package-mall-service/user/get/sale-order/other-fees-config params=factoryId=${Fid}&orgId=${organizationId}&deliveryAddressProvinceId=${ProvinceId}&deliveryAddressCityId=${CityId}&deliveryAddressDistrictId=${DistrictId} + #自提-获取税点 + Create Session factory ${yytClient} ${ClientHeader} + ${reps} GET On Session factory printing-package-mall-service/user/get/sale-order/other-fees-config params=factoryId=${Fid}&orgId=${organizationId}&deliveryAddressProvinceId=${LocationProvinceId}&deliveryAddressCityId=${LocationCityId}&deliveryAddressDistrictId=${LocationDistrictId} + ${Charges} Get From Dictionary ${reps.json()['data']} logisticsCharges #物流费用 + ${InvoiceList} Get From Dictionary ${reps.json()['data']} enterpriseInvoiceList #获取税点信息 + FOR ${Invoice} IN @{InvoiceList} + ${tax} Get From Dictionary ${Invoice} tax #税点 + ${type} Get From Dictionary ${Invoice} type #开票类型 + END + ${LocationInvoiceData} Set Variable If '${type}'=='1' ${tax} '${type}'=='2' ${tax} 0 + Set Global Variable ${Charges} + Set Global Variable ${LocationInvoiceData} + #计算合计金额 + ${Amount} Evaluate 125 #商品金额 + ${InvoicePrice} Evaluate (${Amount}+${Charges})*${LocationInvoiceData} #开票费用 + ${TotalAmount} Evaluate ${Amount}+${InvoicePrice} #合计金额 + Set Global Variable ${Amount} + Set Global Variable ${InvoicePrice} + Set Global Variable ${TotalAmount} + #获取优惠券列表 + Create Session factory ${uecClient} ${ClientHeader} + ${reps} Get On Session factory coupon-service/user/list/coupon/current-order-usable params=businessType=2&amount=${TotalAmount} + ${CouponList} Get From Dictionary ${reps.json()['data']} currentOrderUsableCouponList #可用优惠券信息 + ${CouponData} Run Keyword If '${CouponList}'=='[]' Evaluate 0 + ... ElSE Run Keyword Coupon + +*** Keywords *** +Coupon + #获取优惠券列表 + Create Session factory ${uecClient} ${ClientHeader} + ${reps} Get On Session factory coupon-service/user/list/coupon/current-order-usable params=businessType=2&amount=${TotalAmount} + ${CouponList} Get From Dictionary ${reps.json()['data']} currentOrderUsableCouponList #可用优惠券信息 + ${CouponData} Evaluate random.choice(${CouponList}) random + ${couponType} Get From Dictionary ${CouponData} couponType #优惠类型,3:折扣,2:满减 + ${discountAmount} Get From Dictionary ${CouponData} discountAmount #优惠金额/折扣 + ${orderAmountLowerLimit} Get From Dictionary ${CouponData} orderAmountLowerLimit #优惠条件金额 + ${discountAmountUpperLimit} Get From Dictionary ${CouponData} discountAmountUpperLimit #优惠封顶金额 + ${CouponPrice} Run Keyword If '${couponType}'==3 Evaluate ${orderAmountLowerLimit}*(1-${discountAmount}) + ... ELSE Set Variable ${discountAmount} + ${Coupon} Set Variable If '${CouponPrice}'>'${discountAmountUpperLimit}' ${discountAmountUpperLimit} ${CouponPrice} + Set Global Variable ${Coupon}