def __init__(self, mobile): self.mobile = mobile self.waybill = CreateWayBill(self.mobile, totalAmt='1', preAmt='1', oilAmt='0', destAmt='0', lastAmt='0') self.logger = Log() self.config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() # URL ## self.url_pay_waybill = 'https://hfuapi.keking.cn:8887/api/tms/pay/single' self.head_dict = { 'YD_VERSION': str(self.config['wuliuyun_version']), 'YD_CLIENT': str(self.config['wuliuyun_client']), 'YD_OAUTH': str(self.config['wuliuyun_token']), 'token': str(self.config['wuliuyun_token']), 'User-Agent': str(self.config['User-Agent']) } self.shipper_wallet_pwd = self.config['wuliuyun_wallet_pwd']
class PayForDriver(object): def __init__(self, mobile): self.mobile = mobile self.waybill = CreateWayBill(self.mobile, totalAmt='1', preAmt='1', oilAmt='0', destAmt='0', lastAmt='0') self.logger = Log() self.config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() # URL ## self.url_pay_waybill = 'https://hfuapi.keking.cn:8887/api/tms/pay/single' self.head_dict = { 'YD_VERSION': str(self.config['wuliuyun_version']), 'YD_CLIENT': str(self.config['wuliuyun_client']), 'YD_OAUTH': str(self.config['wuliuyun_token']), 'token': str(self.config['wuliuyun_token']), 'User-Agent': str(self.config['User-Agent']) } self.shipper_wallet_pwd = self.config['wuliuyun_wallet_pwd'] def pay_for_driver(self): self.logger.info('### 获取用户钱包余额信息 ###') balance = self.get_wallet_info()['availBalance'] balance = float(balance) if balance != 0: self.logger.info('### 钱包余额为{}###'.format(str(balance))) return else: self.logger.info('### 用户余额为零,创建运单并进行余额支付 ###') waybillId = self.waybill.confirmWayBill() body_dict = {"wayBillId": waybillId, # 运单ID,String,必填 "paymentMethod": "2", # 支付方式,int【贷款付商户=1】、【余额付司机=2】、【白条付司机=3】、【线下支付=4】 "amountType": "1", # 预付款1,油卡2,到付款3,尾款4,9总运费 "amount": "1.00", # 实际支付金额,double "password": self.shipper_wallet_pwd, # 使用线下支付时必填,其他不填; "verifiCode": "", # 可能会有,非必填 "actualPayee": "" # 实际收款人loginId } response = HttpClient().post_json(url=self.url_pay_waybill, header_dict=self.head_dict, body_dict=body_dict) DbOperation().delete_waybill_driver(self.mobile) return response def get_wallet_info(self): # 获取司机钱包信息 'cardBindFlag' 是否绑卡 'availBalance' 余额信息 url_get_wallet = 'https://hfuapi.keking.cn:8015/app/mybank/myWallet' head_dict = { 'YD_VERSION': str(self.config['chezhu_version']), 'YD_CLIENT': str(self.config['chezhu_client']), 'YD_OAUTH': str(self.config['driver_token_regiseter']), 'User-Agent': str(self.config['User-Agent']) } response = HttpClient().get(url=url_get_wallet, header_dict=head_dict).json()['content'] return response
def setUp(self): """前置条件准备""" self.logger = Log() self.logger.info('########################### TestCancelWaybill START ###########################') config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() app_package = config['appPackage_wuliuyun'] app_activity = config['appActivity_wuliuyun'] # AppUiDriver(appPackage=app_package, appActivity=app_activity).app_ui_driver() # 单例调试 self.driver_mobile = config['employ_driver_mobile'] self.driver = AppUiDriver(appPackage=app_package, appActivity=app_activity).get_driver() self.driver_tool = DriverOperation(self.driver) CreateWayBill(self.driver_mobile).saveWayBill() self.driver.start_activity(app_activity=app_activity, app_package=app_package) pass
def setUp(self): """前置条件准备""" self.logger = Log() self.logger.info('########################### TestWaybillConfirm START ###########################') config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() # 获取配置文件 app_package = config['appPackage_chezhu'] app_activity = config['appActivity_chezhu'] # AppUiDriver(appPackage=app_package, appActivity=app_activity).app_ui_driver() self.mobile = config['mobile_register'] self.driver = AppUiDriver(app_package, app_activity).get_driver() # 获取appium driver DbOperation().delete_waybill_driver(self.mobile) # 删除已有运单 CreateWayBill(self.mobile).saveWayBill() # 创建运单 self.driver_tools = DriverOperation(self.driver) self.driver.start_activity(app_activity=app_activity, app_package=app_package) # 重启应用 pass
def setUp(self): """前置条件准备""" self.logger = Log() self.logger.info( '########################### TestWaybillReceiptUpload START ###########################' ) config = ReadYaml(FileUtil.getProjectObsPath() + '/config/config.yaml').getValue() # 读取配置文件 app_package = config['appPackage_chezhu'] # APP 包名 app_activity = config['appActivity_chezhu'] # APP 启动activity # AppUiDriver(appPackage=app_package, appActivity=app_activity).app_ui_driver() self.mobile = config['mobile_register'] # 认证司机手机号 self.driver = AppUiDriver(app_package, app_activity).get_driver() # 获取appium driver CreateWayBill(self.mobile).arrive_confirm() # 创建运单并确认发车及到达确认 self.driver_tools = DriverOperation(self.driver) self.driver.start_activity( app_activity=app_activity, app_package=app_package) # 重启APP 保证case从主页面开始执行 pass