class friend(): def __init__(self): self.getapi = GetApi(host='c_test_host', filename='config3.ini') self.getapis = GetApi(host='web_test_host', filename='config3.ini') self.get_code = self.getapi.main(api='get_code') self.addwhitephone = self.getapis.main(api='addwhitephone') self.phone = str(15500000000 + randint(0, 1000000)) def add_whitephone(self): # r = requests.post(self.addwhitephone,json={'phone':self.phone, # "sign":"474ee58e4097c0e117de2d93a1088654", # "timestamp":1543571251400}) r = requests.get(self.addwhitephone + '?' + 'phone=' + self.phone) if r.status_code == 200: print('白名单添加成功') else: print('白名单添加失败') def get_codes(self): self.add_whitephone() print(self.phone) data = { 'phone': self.phone, 'channel': 2, "appCode": "29", "terminal": "xcx", "terminal_interface_type": "MiniProgram", "login_token": "", "login_merchant_id": 82927 } r = requests.post(self.get_code, data) print(r.json())
def setUp(self): #用例初始化,初始化整个用例需要用到的配置参数 import sys print(sys.argv[0]) self.url = GetApi() self.listurl = self.url.main('c_test_host', 'C_findproject', 'config3.ini') self.token = Get_Login().get_C_token()
def __init__(self): self.api = GetApi(host='web_test_host', filename='config3.ini') self.apis = GetApi(host='c_test_host',filename='config3.ini') self.token = Get_Login(workEnvironment=True).get_test_login_interface() self.create_project = self.apis.main(api='create_project')#创建订单 self.ajx_pay = self.api.main(api='ajx_pay')#现金支付 self.checkorder_Bouns = self.api.main(api='checkorder_Bouns')#查询分红比例 self.check_order = self.api.main(api='check_order')#财务结算查询 self.settingSalesperson = self.api.main(api='settingSalesperson')#设置销售员 self.orderlist = self.api.main(api='orderlist')#订单列表 self.create_pay_project = self.apis.main(api='create_pay_project') self.checkorder_Bouns = self.api.main(api='checkorder_Bouns') self.checkMrc = self.api.main(api='checkMrc') self.findMerchant = self.api.main(api='findMerchant') self.create_good = self.apis.main(api='create_good') self.good_pay = self.api.main(api='good_pay') self.create_ZJC_id = self.apis.main(api='create_ZJC_id') self.create_ZJC = self.apis.main(api='create_ZJC') self.seetingGW = self.api.main(api='settingGW') self.pay_ZJC = self.api.main(api='pay_ZJC') self.create_care_order = self.apis.main(api='create_care_order') self.pay_club = self.api.main(api='pay_club') self.create_club_order = self.apis.main(api='create_club_order') self.InterFace_json = InterFace_json() self.headers = {'Authorization':self.token} self.user_id = 344160 #下单用户 self.merchant_id = 84164 #下单门店 self.mer_admin_id = 82927 #下单管理中心 self.recommend_phone = 15818758705 #员工账号
def __init__(self): self.api = GetApi(host='web_test_host', filename='config3.ini') self.token = Get_Login(True).get_test_login_interface() self.interface = InterFace_json self.createorder = self.api.main(api='createorder') self.projectlist = self.api.main(api='projectlist') self.mrslist = self.api.main(api='mrslist')
class ManageStore(object): def __init__(self): self.api = GetApi(host='web_test_host', filename='config3.ini') self.token = Get_Login(True).get_test_login_interface() self.interface = InterFace_json self.createorder = self.api.main(api='createorder') self.projectlist = self.api.main(api='projectlist') self.mrslist = self.api.main(api='mrslist') # self.createorder = self.api.main(api='createorder') # self.createorder = self.api.main(api='createorder') # self.createorder = self.api.main(api='createorder') # self.createorder = self.api.main(api='createorder') # self.createorder = self.api.main(api='createorder') # self.createorder = self.api.main(api='createorder') # self.createorder = self.api.main(api='createorder') # self.createorder = self.api.main(api='createorder') # def request(self,url,data=None,headers=None,method='POST'): # if method == 'POSt': # try: # r = requests.post(url,data,headers) # return r # except Exception as e: # print (e) # r = requests.post(url,json=data,headers=headers) # return r def project_list(self): try: r = requests.post(self.projectlist, json=self.interface.projectlist, headers={'Authorization': self.token}) response = r.json() return response['data'][randint(0, len( response['data']))]['projectId'] except Exception as e: print('error--订单列表--', e) def mrs_list(self): self.interface.mrslist['projects'] = self.project_list() times = int(time.time()) * 1000 self.interface.mrslist['startDate'] = times self.interface.mrslist['endDate'] = times r = requests.post(self.mrslist, json=self.interface.mrslist, headers={'Authorization': self.token}) print(r.json()) def create_order(self): r = requests.post(self.createorder, data={})
def setUpClass(cls): cls.url = GetApi(host='c_test_host', filename='config3.ini') cls.token = Get_Login().get_C_token() cls.detailUrl = cls.url.main(api='c_detail') cls.hostList = cls.url.main(api='c_projectHostList') cls.activityDetailUrl = cls.url.main(api='C_activityDetail') cls.proCategoryUrl = cls.url.main(api='C_proCategory') #类别 cls.avtivityDatail = Test_HomePage().test_HomePage()
def setUpClass(cls): token = Get_Login() cls.token = token.get_test_token() cls.pic = token.get_picurl() if 'Bearer' in cls.token: mylog.info(u'token生成正确......') else: print('error', Exception) cls.clubcardadd = GetApi('test_host', 'ClubCardAdd').main() mylog.info(u'接口路径%s', cls.clubcardadd) global db db = fetchOracle()
def setUpClass(cls): cls.host = GetApi() cls.url = { 'homePageUrl': cls.host.main('c_test_host', 'C_homePage', 'config3.ini'), 'C_loginUrl': cls.host.main('c_test_host', 'phone_login', 'config3.ini'), 'accessCityUrl': cls.host.main('c_test_host', 'C_accessCity', 'config3.ini'), 'accessShopUrl': cls.host.main('c_test_host', 'C_accessShop', 'config3.ini') }
def __init__(self,workEnvironment): self.workEnvironment = workEnvironment if workEnvironment == False: self.api = GetApi(host='mp_test_host',filename='config3.ini') else: self.api = GetApi(host='mp_host', filename='config3.ini') try: #self.token = Get_Login(workEnvironment=False).get_mp_login_interface() mylog.info('token获取成功......') except Exception as e: mylog.error('token获取失败') raise ValueError(e) self.mini_url = self.api.main(api='mp_mini_list') self.Code_url = self.api.main(api='mp_Code') self.commit_url = self.api.main(api='mp_commit_code') self.cate_url = self.api.main(api='mp_wx_cate') self.commitSh = self.api.main(api='mp_commitSh') self.commitshenhe = self.api.main(api='commitshenhe') self.release = self.api.main(api='release') self.selectUrl = self.api.main(api='selectUrl') self.settingUrl = self.api.main(api='settingUrl') self.chehuishenhe = self.api.main(api='chehuishenhe')
def setUpClass(cls): import sys print(sys.argv[0]) global order_id get_login = Get_Login() cls.C_token = get_login.get_C_token() cls.url = GetApi() cls.Orderurl = cls.url.main('c_test_host', 'clubOrder', 'config3.ini') cls.ZJCpayurl = cls.url.main('web_test_host', 'mljpayclub', 'config3.ini') cls.xjPayUrl = cls.url.main('web_test_host', 'xjPayClub', 'config3.ini') cls.web_token = get_login.get_test_login_interface()
class test_goodssort(unittest.TestCase): #unittest单元测试框架固定格式 def setUp(self): #用例初始化,初始化整个用例需要用到的配置参数 import sys print(sys.argv[0]) self.url = GetApi() self.listurl = self.url.main('c_test_host', 'C_findproject', 'config3.ini') self.token = Get_Login().get_C_token() def tearDown(self): #用例执行完毕之后需要运行的代码 pass def test_goodSsort(self): #用例,必须以test_开头 data = { "appCode": "32", "keyContent": "", "login_merchant_id": "81136", "login_token": self.token, "merchantId": "81167", "pageIndex": "1", "type": "1", "userId": "183796" } r = requests.post(self.url, data=data) print(r.json()) headers = {} s = ['彩光', '快乐', '泰式', '丝白'] for i in s: data['keyContent'] = i r = requests.post(self.listurl, data=data, headers=headers) response = r.json() try: assert response['status'] == 100 mylog.info('{}项目搜索正确'.format(i)) except Exception as e: mylog.error('{}返回的status状态不等于100'.format(i), response) raise ValueError(e) try: if len(response['data']) != 0: assert i in response['data'][0]['projectName'] mylog.info('-------------pass---------------') except Exception as e: mylog.error('搜索到的项目不正确', response['data'][0]['projectName']) raise ValueError(e)
def __init__(self): self.getapi = GetApi(host='c_test_host', filename='config3.ini') self.getapis = GetApi(host='web_test_host', filename='config3.ini') self.get_code = self.getapi.main(api='get_code') self.addwhitephone = self.getapis.main(api='addwhitephone') self.phone = str(15500000000 + randint(0, 1000000))
class mp_ourmclist(): def __init__(self,workEnvironment): self.workEnvironment = workEnvironment if workEnvironment == False: self.api = GetApi(host='mp_test_host',filename='config3.ini') else: self.api = GetApi(host='mp_host', filename='config3.ini') try: #self.token = Get_Login(workEnvironment=False).get_mp_login_interface() mylog.info('token获取成功......') except Exception as e: mylog.error('token获取失败') raise ValueError(e) self.mini_url = self.api.main(api='mp_mini_list') self.Code_url = self.api.main(api='mp_Code') self.commit_url = self.api.main(api='mp_commit_code') self.cate_url = self.api.main(api='mp_wx_cate') self.commitSh = self.api.main(api='mp_commitSh') self.commitshenhe = self.api.main(api='commitshenhe') self.release = self.api.main(api='release') self.selectUrl = self.api.main(api='selectUrl') self.settingUrl = self.api.main(api='settingUrl') self.chehuishenhe = self.api.main(api='chehuishenhe') def get_request(self,work=False): data = { 'pageNumber': 1, 'pageSize': 300 } if work == True: data['auditstatus'] = 0 r = requests.post(self.mini_url,data) our_app = [] for i in r.json()['data']: one_app = [] one_app.append(i['appid']) one_app.append(i['name']) one_app.append(i['tradeRole']) one_app.append(i['merchantid_c']) our_app.append(one_app) mylog.info('获取所有小程序信息成功......') return our_app #根据小程序的appid获取所有模板,并取最新的一个 def get_code(self): get_request = self.get_request() r = '' data = { 'appid':get_request[0][0] } try: r = requests.post(self.Code_url,data) except Exception as e: mylog.error('获取模板失败') template_id = '' user_version = '' user_desc = '' template_id = 0 for i in r.json()['data']['template_list']: if i['template_id'] > template_id: template_id = i['template_id'] user_version = i['user_version'] user_desc = i['user_desc'] mylog.info('获取最新模板信息成功.......') return template_id,user_version,user_desc #提交模板 def commitCode(self,i,code): data = {} r = '' if i[2] == 1: i[2] = True else: i[2] = False data = { 'appid':i[0], 'merchant_name':i[1], 'tradeRole':i[2], 'merchantid_c':i[3], 'templateId':code[0], 'userDesc':code[2], 'userVersion':code[1] } try: r = requests.post(self.commit_url,json=data) except Exception as e: mylog.error('{}模板设置失败'.format(data['merchant_name'])) if r.json()['msg'] == '操作成功': mylog.info('{}模板操作成功,模板名称{}'.format(data['merchant_name'],data['userDesc'])) else: mylog.error('{}操作失败,失败原因{}'.format(data['merchant_name'],r.json())) def cateAndcommit(self,i,data): try: # headers = { # 'Authorization':self.token # } datas = { 'appid':i[0], 'itemList':[data] } # r = requests.post(self.commitSh,json=datas,headers=headers) r = requests.post(self.commitSh, json=datas) if r.json()['msg'] == '操作成功': mylog.info('{}提交成功'.format(i[1])) else: mylog.error('{}提交失败'.format(i[1])) except Exception as e: mylog.error('----到{}报错啦报错啦!!!!!!!!!!!!----'.format(i[1])) #多个线程进行模板设置 def commit(self): code = self.get_code() get_request = self.get_request() ourThread = [] for i in get_request: a = threading.Thread(target=self.commitCode,args=(i,code,)) a.setDaemon(True) ourThread.append(a) for i in ourThread: time.sleep(0.5) i.start() for i in ourThread: i.join() #启动多个线程进行提交 def commitour(self): get_request = self.get_request() ourThread = [] data = {} r = requests.post(self.cate_url, data={'appid': get_request[0][0]}) cate = r.json()['category_list'] for i in cate: if i['third_class']: if i['third_class'] == '美容': data['address'] = 'pages/index/index' data['first_class'] = i['first_class'] data['first_id'] = i['first_id'] data['second_class'] = i['second_class'] data['second_id'] = i['second_id'] data['third_class'] = i['third_class'] data['third_id'] = i['third_id'] data['title'] = '首页' continue elif i['third_class'] == '私立医疗机构': data['address'] = 'pages/index/index' data['first_class'] = i['first_class'] data['first_id'] = i['first_id'] data['second_class'] = i['second_class'] data['second_id'] = i['second_id'] data['third_class'] = i['third_class'] data['third_id'] = i['third_id'] data['title'] = '首页' continue for i in get_request: if i[3] != 81136: a = threading.Thread(target=self.cateAndcommit,args=(i,data)) a.setDaemon(True) ourThread.append(a) for i in ourThread: time.sleep(0.5) i.start() for i in ourThread: i.join() def commitsh(self,i,ourtitle,o): try: data = { 'appid':i[0] } r = requests.post(self.commitshenhe,data=data) res = r.json() if res['data']['status'] == 1: mylog.info('审核失败') s = [i[1],'审核失败',r.json()['data']['reason']] ourtitle.append(s) elif res['data']['status'] == 2: s = [i[1],'审核中',''] mylog.info('审核中') ourtitle.append(s) elif res['data']['status'] == 0: s = [i[1], '审核成功',''] mylog.info('已审核') ourtitle.append(s) else: mylog.info('没提交审核') # for i in self.get_request: # if res[] except Exception as e: raise ValueError(e) def commitSH(self): get_request = self.get_request() o = 0 ourtitle = [] our = [] for i in get_request: o += 1 a = threading.Thread(target=self.commitsh,args=(i,ourtitle,o,)) a.setDaemon(True) our.append(a) for i in our: time.sleep(0.3) i.start() for i in our: i.join() # import xlwt # file = xlwt.Workbook(encoding='utf-8') # table = file.add_sheet('xcx') # #table.write('序号','小程序名称','审核失败原因') # print(ourtitle) # for i,p in enumerate(ourtitle): # for j,q in enumerate(p): # table.write(i,j,q) # file.save('xcx.xls') # import pandas as pd # data = pd.read_excel('xcxs1.xls') # data['序号'] = [i for i in range(len(ourtitle))] # data['小程序名称'] = [i[0] for i in ourtitle] # data['审核状态'] = [i[1] for i in ourtitle] # data['审核失败原因'] = [i[2] for i in ourtitle] # data.to_excel('xcxs1.xls') def releasecode(self,i,ourname,s): try: time.sleep(1) data = { 'appid':i[0] } # headers = { # 'Authorization':self.token # } #r = requests.post(self.release,data=data,headers=headers) r = requests.post(self.release, data=data) res = r.json() if res['msg'] == '操作成功': print ('{}提交成功'.format(i[1])) ourname.append(i[1]) elif 'status not' in res['msg']: s.append(i[1]) else: print ('{}提交失败或已提交:{}'.format(i[1],res)) except Exception as e: print('{}提交失败或已提交'.format(i[1])) def releasecodeTh(self): get_request = self.get_request(work=True) s = [] ourname = [] our = [] for i in get_request: a = threading.Thread(target=self.releasecode,args=(i,ourname,s)) a.setDaemon(True) our.append(a) for i in our: time.sleep(0.8) i.start() for i in our: i.join() def selectUrls(self,i): try: r = requests.post(self.selectUrl,data={"appid":i[0]}) response = r.json() if response['status'] != 500: if response['data']['webviewdomain'].__len__() == 0: sr = requests.post(self.settingUrl,data={'appid':i[0]}) mylog.info('{}设置成功'.format(i[1])) else: pass except Exception as e: mylog.error(e) def settingUrls(self): get_request = self.get_request() our = [] for i in get_request: a = threading.Thread(target=self.selectUrls,args=(i,)) a.setDaemon(True) our.append(a) for i in our: time.sleep(0.5) i.start() for i in our: i.join() def chehuishenhes(self,i): try: r = requests.post(self.chehuishenhe,data={"appid":i[0]}) except Exception as e: mylog.error(e) def Thead_chehuishenhes(self): get_request = self.get_request() our = [] for i in get_request: a = threading.Thread(target=self.chehuishenhes, args=(i,)) a.setDaemon(True) our.append(a) for i in our: time.sleep(0.5) i.start() for i in our: i.join() def run(self,type=None): if type == 1: self.commitSH() # 查询所有小程序审核状态 elif type == 2: self.commit()#设置模板 elif type == 3: self.commitour()#提交审核 elif type == 4: self.releasecodeTh()#发布版本 elif type == 5: self.settingUrls() #设置所有小程序业务域名 elif type == 6: self.Thead_chehuishenhes()#撤销审核 else: self.get_request()#查看列表
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 14:21 # @Author : Carewn # @Software: PyCharm import requests from Public._get_excel import get_excel from Public.get_api import GetApi from Public.Get_login_token import Get_Login import threading import time url = GetApi('web_host', 'checkorder', 'config3.ini').main() token = Get_Login('ZS').get_test_token() aaa = [] x = get_excel('orderNo.xlsx', 'Sheet1').get_oneColum(1, 'values') def checkOrder(i): try: data = { 'bigClassId': "", 'branchID': [], 'endTime': "2018-08-08", 'orderType': "", 'pageData': 10, 'pageNumber': 1, 'payWay': [1, 2, 4, 7], 'searchParam': i, 'smallClassId': "",
class test_mchBonus_ten(): def __init__(self): self.api = GetApi(host='web_test_host', filename='config3.ini') self.apis = GetApi(host='c_test_host',filename='config3.ini') self.token = Get_Login(workEnvironment=True).get_test_login_interface() self.create_project = self.apis.main(api='create_project')#创建订单 self.ajx_pay = self.api.main(api='ajx_pay')#现金支付 self.checkorder_Bouns = self.api.main(api='checkorder_Bouns')#查询分红比例 self.check_order = self.api.main(api='check_order')#财务结算查询 self.settingSalesperson = self.api.main(api='settingSalesperson')#设置销售员 self.orderlist = self.api.main(api='orderlist')#订单列表 self.create_pay_project = self.apis.main(api='create_pay_project') self.checkorder_Bouns = self.api.main(api='checkorder_Bouns') self.checkMrc = self.api.main(api='checkMrc') self.findMerchant = self.api.main(api='findMerchant') self.create_good = self.apis.main(api='create_good') self.good_pay = self.api.main(api='good_pay') self.create_ZJC_id = self.apis.main(api='create_ZJC_id') self.create_ZJC = self.apis.main(api='create_ZJC') self.seetingGW = self.api.main(api='settingGW') self.pay_ZJC = self.api.main(api='pay_ZJC') self.create_care_order = self.apis.main(api='create_care_order') self.pay_club = self.api.main(api='pay_club') self.create_club_order = self.apis.main(api='create_club_order') self.InterFace_json = InterFace_json() self.headers = {'Authorization':self.token} self.user_id = 344160 #下单用户 self.merchant_id = 84164 #下单门店 self.mer_admin_id = 82927 #下单管理中心 self.recommend_phone = 15818758705 #员工账号 def create_orders(self): '''获取orderId''' r = requests.post(self.create_project, data=self.InterFace_json.create_project) response = r.json() print(self.create_project) print (response) orderid = response['orderId'][0] return orderid def create_goods(self): '''商品下单获取订单号、ID、价格''' orderNo = '' orderId = '' price = '' try: r =requests.post(self.create_good,data=self.InterFace_json.create_good) response = r.json() orderNo = response['orderNbr'] orderId = response['orderId'] price = response['pay_price'] / 100 print('订单编号:---------------{}----------------'.format(orderNo)) except Exception as e: print (e) return orderNo,orderId,price def create_pay_orders(self,orderid): '''获取订单编号''' self.InterFace_json.create_pay_project['order_ids'] = orderid self.InterFace_json.create_pay_project['order_list'][0] = orderid r =requests.post(self.create_pay_project,data=self.InterFace_json.create_pay_project) response = r.json() priceNum = response['project_list'][0]['price'] orderNo = response['project_list'][0]['order_no'] print ('订单编号:---------------{}----------------'.format(orderNo)) return orderNo,priceNum def settingBon(self,orderNo): self.InterFace_json.orderlist['searchParam'] = orderNo r = requests.post(self.orderlist,data=self.InterFace_json.orderlist,headers=self.headers) response = r.json() print (response) self.InterFace_json.settingSalesperson['orderID'] = response['data'][0]['orderId'] r = requests.post(self.settingSalesperson,data=self.InterFace_json.settingSalesperson,headers=self.headers) assert r.json()['msg'] == '操作成功' def checkOrder(self,orderNo,type): '''财务结算----收款订单,查询分红信息''' try: self.InterFace_json.check_order['searchParam'] = orderNo r = requests.post(self.check_order, data=self.InterFace_json.check_order, headers=self.headers) response = r.json() #print ('111111111111111',response,self.check_order,self.InterFace_json.check_order) share_total = response['data'][0]['share_div'] rec_div = response['data'][0]['rec_div'] if type == 1: print('查询出的项目一级分红:---------------{}----------------'.format(round(share_total))) print('查询出的项目收款分红:---------------{}----------------'.format(round(rec_div))) elif type == 2: print('查询出的商品一级分红:---------------{}----------------'.format(round(share_total))) print('查询出的商品收款分红:---------------{}----------------'.format(round(rec_div))) elif type == 3: print('查询出的美丽金一级分红:---------------{}----------------'.format(round(share_total))) print('查询出的美丽金收款分红:---------------{}----------------'.format(round(rec_div))) elif type == 4: print('查询出的会员卡一级分红:---------------{}----------------'.format(round(share_total))) print('查询出的会员卡收款分红:---------------{}----------------'.format(round(rec_div))) elif type == 5: print('查询出的疗程卡一级分红:---------------{}----------------'.format(round(share_total))) print('查询出的疗程卡收款分红:---------------{}----------------'.format(round(rec_div))) except Exception as e: print ('出错了',e) def create_care_orders(self): r = requests.post(self.create_care_order,data=self.InterFace_json.create_care_order) response =r.json() print (response) orderNo = response['pay_order_id'] orderprice = response['pay_amount'] print('订单编号:---------------{}----------------'.format(orderNo)) self.InterFace_json.pay_club['orderNo'] = orderNo r = requests.post(self.pay_club,data=self.InterFace_json.pay_club,headers=self.headers) return orderNo,orderprice def creaye_club_orders(self): r = requests.post(self.create_club_order,data=self.InterFace_json.create_club_order) response =r.json() orderprice = response['pay_amount'] orderNo = response['pay_order_id'] self.InterFace_json.pay_club['orderNo'] = orderNo r =requests.post(self.pay_club,data=self.InterFace_json.pay_club,headers = self.headers) print('订单编号:---------------{}----------------'.format(orderNo)) return orderNo,orderprice def getBl(self,i,price): '''项目0.商品1,美丽金2,会员卡3,项目4''' r = requests.post(self.checkorder_Bouns, json=self.InterFace_json.checkorder_Bouns, headers=self.headers) response = r.json() print(response) mrchanBoun = response['data'][i]['staffShareDis'] / 100 customerBoun = response['data'][i]['shareDis'] / 100 self.getBouns(price,mrchanBoun,customerBoun) def getBouns(self,price,mrchanBoun,customerBoun): '''查询分红配置并计算实际分红''' merchant_set = self.checkMrcs()#员工收益设置 findMerchant = self.findMerchants()#在离职状态 try: if merchant_set == 1 and findMerchant ==1: '''如果只拿分红且在职''' merchBouns = round(mrchanBoun * price * 1.2,2) print ('设置为只拿分红且在职') print ('应拿分享分红为{},应该收款分红为0'.format(merchBouns)) elif merchant_set == 1 and findMerchant == 2: '''如果只拿分红但已离职''' merchBouns = round(customerBoun * price * 1.2,2) print('设置为只拿分红但已离职') print ('应拿分享分红为{},应该收款分红为{}'.format(merchBouns,round(price * 1 * 0.06,2))) elif merchant_set == 2 and findMerchant == 1: '''如果只拿业绩且在职''' print('设置为只拿业绩且在职') print('应拿分享分红为0,应该收款分红为{}'.format(round(price * 1 * 0.06,2))) elif merchant_set == 2 and findMerchant == 2: '''如果只拿业绩但已离职''' merchBouns = round(price * customerBoun * 1.2,2) print('设置为只拿业绩但已离职') print('应拿分享分红为{},应该收款分红为{}'.format(merchBouns,round(price * 1 * 0.06,2))) elif merchant_set == 3 and findMerchant == 1: '''如果都拿且在职''' merchBouns = round(price * mrchanBoun * 1.2,2) print('设置为都拿且在职') print('应拿分享分红为{},应该收款分红为{}'.format(merchBouns, round(price * 1 * 0.06,2))) elif merchant_set == 3 and findMerchant == 2: '''如果都拿但离职''' merchBouns = round(price * customerBoun * 1.2, 2) print('设置为都拿但离职') print('应拿分享分红为{},应该收款分红为{}'.format(merchBouns, round(price * 1 * 0.06,2))) except Exception as e: print (111111111111111111111) # merchBouns = round(price * mrchanBoun * 1.2,2)#员工分红 # customerBouns = round(price * customerBoun * 1.2 /100,2)#客户分红 # print ('计算得出的员工分红:{},计算得出的客户分红:{},设置的员工比例:{},设置客户比例:{}' # .format(merchBouns,customerBouns,mrchanBoun,customerBoun)) return def checkMrcs(self): '''查询出下单门店的员工分红收益设置 1为只拿分红 2为只拿业绩 3为两者都拿 ''' self.InterFace_json.checkMrc['merchantId'] = '81167' #员工隶属门店的比例 r =requests.post(self.checkMrc,data=self.InterFace_json.checkMrc,headers=self.headers) response = r.json() merchant_set = response['data']['employeeIncome'] return merchant_set def findMerchants(self): '''查询该员工的在离职状态 1为在职 2为离职 ''' r =requests.post(self.findMerchant,data=self.InterFace_json.findMerchant,headers = self.headers) response = r.json() try: status = response['data'][0]['status'] except : status = 1 return status def create_ZJCs(self): '''生成美丽金订单''' orderNo = '' orderprice = '' try: r = requests.post(self.create_ZJC_id,data=self.InterFace_json.create_ZJC_id) response = r.json() print (response) orderID = response['orderId'] self.InterFace_json.create_ZJC['orderId'] = orderID rs = requests.post(self.create_ZJC,data=self.InterFace_json.create_ZJC) responses = rs.json() print(responses) orderNo = responses['data']['orderNo'] orderprice = responses['data']['cardPrice'] self.InterFace_json.settingGW['orderNumber'] = orderNo r =requests.post(self.seetingGW,data=self.InterFace_json.settingGW,headers = self.headers) self.InterFace_json.pay_ZJC['orderNo'] = orderNo r =requests.post(self.pay_ZJC,data=self.InterFace_json.pay_ZJC,headers =self.headers) print('订单编号:---------------{}----------------'.format(orderNo)) except Exception as e: print ('生成美丽金订单出错了') return orderNo,orderprice def pay_for_order(self): '''使用现金支付''' orderId = self.create_orders()#创建订单,获取订单Id orderNos = self.create_pay_orders(orderId) orderNo = orderNos[0]#获取订单编号 price = orderNos[1]#获取订单价格 self.settingBon(orderNo) self.InterFace_json.pay['orderId'] = orderId r =requests.post(self.ajx_pay,data=self.InterFace_json.pay,headers=self.headers)#支付 self.checkOrder(orderNo,type=1) self.getBl(0,price) ''''下面是商品的''' good = self.create_goods() good_orderNo =good[0] good_orderId = good[1] good_price = good[2] self.InterFace_json.good_pay['id'] = good_orderId time.sleep(1) r = requests.post(self.good_pay, data=self.InterFace_json.good_pay, headers=self.headers) # 支付 self.checkOrder(good_orderNo,type=2) self.getBl(1,good_price) # '''下面是美丽金的''' # ZJC = self.create_ZJCs() # self.checkOrder(ZJC[0],type=3) # self.getBl(2,ZJC[1]) '''下面是会员卡的''' club = self.create_care_orders() self.checkOrder(club[0], type=4) self.getBl(3, club[1]) '''下面是疗程卡的''' clubs = self.creaye_club_orders() self.checkOrder(clubs[0],type=5) self.getBl(4,clubs[1])
def setUp(self): self.detailUrl = GetApi('test_host', 'Detail', 'config3.ini').main() self.token = Get_Login().get_test_token()
def setUpClass(cls): token = Get_Login() cls.token = token.get_test_token() cls.Itemsurl = GetApi('test_host', 'get_Items', 'config3.ini').main()