def test_1(self,merchant_login_fix,test_input,expect): ms = merchant_login_fix DM = Drg_merchant(ms) sf = SF() channelOrderNumber = sf.channelOrderNumber() result = DM.merchant_recharge(test_input,channelOrderNumber) assert result["message"]["content"] == expect["message"]["content"]
def test_1(self, login_fix, merchant_login_fix): '''确认充值订单''' s = login_fix ms = merchant_login_fix sf = SF() channelOrderNumber = sf.channelOrderNumber() DM = Drg_merchant(ms) DF = DRG_func(s) paytime = time.strftime("%Y" + "-" + "%m" + "-" + "%d" + " " + "%H" + ":" + "%M" + ":" + "%S") #查询是否有未确认订单 r1 = DF.all_wait_order() #如果等于0 if r1 == 0: #商户端新增充值 DM.merchant_recharge(channelOrderNumber) #运营端确认订单 sysnb = DF.wait_order() sysnumber = sysnb["data"]["resultList"]["dataList"][0][ "systemOrderNumber"] result = DF.sucess_order(paytime, sysnumber) assert result["message"]["content"] == "确认成功" else: #不等于0查询系统单号,确认订单 sysnb = DF.wait_order() sysnumber = sysnb["data"]["resultList"]["dataList"][0][ "systemOrderNumber"] result = DF.sucess_order(paytime, sysnumber) assert result["message"]["content"] == "确认成功"
def test_8(self, login_fix, merchant_login_fix): '''单笔放款到银行卡''' s = login_fix ms = merchant_login_fix sj = SF() DF = DRG_func(s) DM = Drg_merchant(ms) #运营端修改商户出金方式为银行卡 licenceSerialNumber = time.strftime("%Y%m%d%H%M%S") smscode = licenceSerialNumber[2:8] DF.login_sucess(smscode) bankBranchCode = sj.phone() # 出金模式银行卡:BANK_CARD # 出金模式小程序钱包:APPLET_WALLET issuType = "BANK_CARD" result = DF.merchant_editDetail_bybankcard(issuType, bankBranchCode) #商户端单笔放款到银行卡 issuname = "郑国" issuidCard = "350181199006012155" issuamount = "2" accountNumber = '6232111820006508170' sql = 'select * FROM spman_center.task where merchant_name = "极限传媒" and status = 1 order by id desc limit 1;' r = select_taskid_number(sql) taskId = str(r[0]["id"]) result1 = DM.issu_by_bankcard(issuname, issuidCard, issuamount, accountNumber, taskId) batchNo = result1["data"]["batchNo"] result2 = DM.batchIssu_loan(batchNo) assert result2["message"]["content"] == "处理中, 请稍后..."
def test_1(self, merchant_login_fix, login_fix): '''开票申请''' sf = SF() channelOrderNumber = sf.channelOrderNumber() amount = sf.day() s = login_fix DF = DRG_func(s) paytime = time.strftime("%Y" + "-" + "%m" + "-" + "%d" + " " + "%H" + ":" + "%M" + ":" + "%S") ms = merchant_login_fix DM = Drg_merchant(ms) #查询是否有开票充值记录 r = DM.rechargeOrder_wait() rechargeCount = r["data"]["rechargeCount"] #判断充值记录为0的情况下 if rechargeCount == 0: #新增充值记录 print("新增充值") DM.merchant_recharge(amount, channelOrderNumber) #运营端确认 sysnumber1 = DF.wait_order() sysnumber = sysnumber1["data"]["resultList"]["dataList"][0][ "systemOrderNumber"] DF.sucess_order(paytime, sysnumber) print("运营端确认充值记录") # 查询开票充值几率不为0的情况下开票申请,先查询出开票充值记录里面的充值金额和系统单号 recharge_detail = DM.rechargeOrder_wait() totalAmount = recharge_detail["data"]["resultList"]["dataList"][0][ "amountStr"] s_totalAmount = recharge_detail["data"]["resultList"]["dataList"][ 0]["amountStr"] systemOrderNumbers = recharge_detail["data"]["resultList"][ "dataList"][0]["systemOrderNumber"] print("查询开票充值记录,返回税价合计金额、放款单号") # 提交开票申请 result = DM.invoice_apply(totalAmount, systemOrderNumbers, s_totalAmount) print("提交开票申请成功") assert result["message"]["content"] == "操作成功" else: #不为0的情况下开票申请,先查询出开票充值记录里面的充值金额和系统单号 print("查询开票充值记录,返回税价合计金额、放款单号") recharge_detail = DM.rechargeOrder_wait() totalAmount = recharge_detail["data"]["resultList"]["dataList"][0][ "amountStr"] s_totalAmount = recharge_detail["data"]["resultList"]["dataList"][ 0]["amountStr"] systemOrderNumbers = recharge_detail["data"]["resultList"][ "dataList"][0]["systemOrderNumber"] #提交开票申请 result = DM.invoice_apply(totalAmount, systemOrderNumbers, s_totalAmount) print("提交开票申请成功") assert result["message"]["content"] == "操作成功"
def test_10(self, login_fix): '''修改商户出金方式为小程序钱包''' s = login_fix DF = DRG_func(s) sj = SF() # 分行CODE前端随机生成 bankBranchCode = sj.phone() # 出金模式银行卡:BANK_CARD # 出金模式小程序钱包:APPLET_WALLET issuType = "APPLET_WALLET" result = DF.merchant_editDetail_bybankcard(issuType, bankBranchCode) assert result["message"]["content"] == "更新成功"
def test_10(self, login_fix, merchant_login_fix): '''保存订单至:未支付-待放款后,放款至银行卡''' s = login_fix ms = merchant_login_fix sj = SF() DF = DRG_func(s) DM = Drg_merchant(ms) # 运营端修改商户出金方式为银行卡 licenceSerialNumber = time.strftime("%Y%m%d%H%M%S") smscode = licenceSerialNumber[2:8] DF.login_sucess(smscode) bankBranchCode = sj.phone() # 出金模式银行卡:BANK_CARD # 出金模式小程序钱包:APPLET_WALLET issuType = "BANK_CARD" result = DF.merchant_editDetail_bybankcard(issuType, bankBranchCode) # 商户端单笔放款到银行卡 issuname = "郑国" issuidCard = "350181199006012155" issuamount = "2" accountNumber = '6232111820006508170' sql = 'select * FROM spman_center.task where merchant_name = "极限传媒" and status = 1 order by id desc limit 1;' r = select_taskid_number(sql) taskId = str(r[0]["id"]) result1 = DM.issu_by_bankcard(issuname, issuidCard, issuamount, accountNumber, taskId) batchNo = result1["data"]["batchNo"] #保存验证成功订单 result2 = DM.save_Verify_SuccessOrder(batchNo) #查询订单详情 result3 = DM.SuccessOrder_list(batchNo) #查询放款单号 systemOrderNumbers = result3["data"]["dataList"][0][ "systemOrderNumber"] #未支付-待放款后,放款至银行卡 result4 = DM.preSave_Loan(systemOrderNumbers) assert result4["message"]["content"] == "处理中, 请稍后..."
def test_4(self,login_fix): '''新增发包方''' s = login_fix sj = SF() accountName = sj.name() contactMail = sj.get_email() contactName = sj.name() licenceSerialNumber = time.strftime("%Y%m%d%H%M%S") shortName = sj.name() managerMobile = sj.phone() DF = DRG_func(s) result = DF.add_merchant(accountName,contactMail,contactName,licenceSerialNumber,shortName,managerMobile)#参数顺序要和方法一致 print(result)
def test_1(self, api_merchant_login, api_get_merchantPriKey, api_get_systemPubKey): '''api商户新增用户''' s = api_merchant_login # 获取商户私钥 merchantPriKey = api_get_merchantPriKey # 获取系统公钥 systemPubKey = api_get_systemPubKey api = API_merchant(s) sj = SF() requesterUserIdentity = "jx" + sj.phone() idCard = sj.idcard() mobile = sj.phone() name = sj.name() # 获取api商户密码 result1 = api.get_apimerchant_password(merchantPriKey, systemPubKey) password = result1["password"] # api商户新增用户 result2 = api.add_api_merchant(merchantPriKey, systemPubKey, password, requesterUserIdentity, idCard, mobile, name) assert result2[0]["message"] == "处理中"
@allure.step("商户信息") def account_merchantInfo(self): url_account_merchantInfo = "https://spman.shb02.net/merchant/account/merchantInfo" response = self.s.post(url=url_account_merchantInfo) return response.json() if __name__ == '__main__': ms = requests.session() sj = SF() username = "******" password = "******" DM = Drg_merchant(ms) DM.merchant_login(username,password) amout = '100' chanlnumber = '7976845646546' name = sj.name() idcard = sj.idcard() mobile = sj.phone() #充值金额参数化 amout = '-1' channelOrderNumber = sj.channelOrderNumber() result = DM.merchant_recharge(amout,channelOrderNumber) print(result)
import xlwt from common.common_func_SJ import SF sj = SF() wb = xlwt.Workbook() sheet = wb.add_sheet("批量新增用户") ''':type :xlwt.Worksheet''' class User_sj(): #批量新增 def sj_user(self): list = [] for i in range(0, 5): name = sj.name() id = sj.idcard() phone = sj.phone() user = {"name": name, "id": id, "phone": phone} list.append(user) title_row = 0 for i in range(len(list)): dic = list[i] sheet.write(title_row + i, 0, dic['name']) # 第0列放id的值 sheet.write(title_row + i, 1, dic['id']) # 第1列放name的值 sheet.write(title_row + i, 2, dic['phone']) # 第2列放age的值 #本地调试时的地址 #wb.save('E:\\pytest_api\\data\\user_info.xls') #代码再docker里面运行时的地址
def test_5(self, login_fix, merchant_login_fix): '''开票申请''' s = login_fix ms = merchant_login_fix sj = SF() DF = DRG_func(s) DM = Drg_merchant(ms) #运营端开票时间 invoiceDate = time.strftime("%Y" + "-" + "%m" + "-" + "%d" + " " + "%H" + ":" + "%M" + ":" + "%S") #发票代码 invoiceCode = sj.phone() #发票号码 invoiceNumber = sj.phone() #快递单号 emsOrderNumber = sj.phone() #商户端充值通道单号(随机生成) channelOrderNumber = sj.channelOrderNumber() #商户端充值金额 recharge_amount = sj.day() #---------运营端确认充值订单,查询放款单号------------------------------------------------- sysnumber1 = DF.wait_order() sysnumber = sysnumber1["data"]["resultList"]["dataList"][0][ "systemOrderNumber"] # ----------商户端,查询出开票充值记录里面的充值金额和系统单号--------------------------------- recharge_detail = DM.rechargeOrder_wait() m_totalAmount = recharge_detail["data"]["resultList"]["dataList"][0][ "amountStr"] s_totalAmount = recharge_detail["data"]["resultList"]["dataList"][0][ "amountStr"] #格式化输出,将字典里面的值参数化 systemOrderNumbers = recharge_detail["data"]["resultList"]["dataList"][ 0]["systemOrderNumber"] #-------查询是否有待处理开票订单------------------------------------------------------------------------------------- applyStatus = 'WAIT' apply = DF.invoice_apply_list(applyStatus) apply_result = apply["data"]["count"] if apply_result == 0: #新增开票申请 # ------查询是否有开票充值记录----- r = DM.rechargeOrder_wait() rechargeCount = r["data"]["rechargeCount"] # 判断充值记录为0的情况下 if rechargeCount == 0: # 新增充值记录 DM.merchant_recharge(recharge_amount, channelOrderNumber) # 运营端确认 DF.sucess_order(invoiceDate, sysnumber) # 商户端提交开票申请 DM.invoice_apply(m_totalAmount, systemOrderNumbers, s_totalAmount) # 运营端新增开票信息 # --------运营端查询,返回税价合计金额、批次号、用户编号、根据税价合计计算出 金额和 税额----------- applyStatus = 'WAIT' r2 = DF.invoice_apply_list(applyStatus) totalAmount1 = r2["data"]["resultList"]["dataList"][0][ "totalAmount"] # 获取税价合计金额,类型为 str batchNumber = r2["data"]["resultList"]["dataList"][0][ "batchNumber"] # 获取批次号 merchantNumber = r2["data"]["resultList"]["dataList"][0][ "merchantNumber"] # 获取用户编号 f_totalAmount = float(totalAmount1) # 类型为str的金额转化为 浮点型 y_totalAmount = round(f_totalAmount, 2) # 浮点型 税价合计金额 四舍五入 f_amount = y_totalAmount / (1 + 0.1) # 税率10% amount = round(f_amount, 2) # 金额 f_taxAmount = y_totalAmount - amount taxAmount = round(f_taxAmount, 2) # 税额 # 申请合并开票 r3 = DF.invoice_merger(batchNumber, merchantNumber) # 查询开票中订单 applyStatus = 'HANDLE' r4 = DF.invoice_apply_list(applyStatus) # 返回合并开票批次号 invoiceBatchNumber invoiceBatchNumber = r4["data"]["resultList"]["dataList"][0][ "invoiceBatchNumber"] DF.invoice_add(invoiceCode, invoiceDate, invoiceNumber, taxAmount, y_totalAmount, amount, invoiceBatchNumber, merchantNumber) # 填写快递单号,确认开票申请 result = DF.invoice_addEmsInfo(batchNumber, merchantNumber, invoiceBatchNumber, emsOrderNumber) assert result["message"]["content"] == "操作成功" else: # 商户端提交开票申请 DM.invoice_apply(m_totalAmount, systemOrderNumbers, s_totalAmount) # 运营端新增开票信息 # --------运营端查询,返回税价合计金额、批次号、用户编号、根据税价合计计算出 金额和 税额----------- applyStatus = 'WAIT' r2 = DF.invoice_apply_list(applyStatus) totalAmount1 = r2["data"]["resultList"]["dataList"][0][ "totalAmount"] # 获取税价合计金额,类型为 str batchNumber = r2["data"]["resultList"]["dataList"][0][ "batchNumber"] # 获取批次号 merchantNumber = r2["data"]["resultList"]["dataList"][0][ "merchantNumber"] # 获取用户编号 f_totalAmount = float(totalAmount1) # 类型为str的金额转化为 浮点型 y_totalAmount = round(f_totalAmount, 2) # 浮点型 税价合计金额 四舍五入 f_amount = y_totalAmount / (1 + 0.1) # 税率10% amount = round(f_amount, 2) # 金额 f_taxAmount = y_totalAmount - amount taxAmount = round(f_taxAmount, 2) # 税额 # 申请合并开票 r3 = DF.invoice_merger(batchNumber, merchantNumber) # 查询开票中订单 applyStatus = 'HANDLE' r4 = DF.invoice_apply_list(applyStatus) # 返回合并开票批次号 invoiceBatchNumber invoiceBatchNumber = r4["data"]["resultList"]["dataList"][0][ "invoiceBatchNumber"] DF.invoice_add(invoiceCode, invoiceDate, invoiceNumber, taxAmount, y_totalAmount, amount, invoiceBatchNumber, merchantNumber) # 填写快递单号,确认开票申请 result = DF.invoice_addEmsInfo(batchNumber, merchantNumber, invoiceBatchNumber, emsOrderNumber) assert result["message"]["content"] == "操作成功" else: # 运营端新增开票信息 # --------运营端查询,返回税价合计金额、批次号、用户编号、根据税价合计计算出 金额和 税额----------- applyStatus = 'WAIT' r2 = DF.invoice_apply_list(applyStatus) totalAmount1 = r2["data"]["resultList"]["dataList"][0][ "totalAmount"] # 获取税价合计金额,类型为 str batchNumber = r2["data"]["resultList"]["dataList"][0][ "batchNumber"] # 获取批次号 merchantNumber = r2["data"]["resultList"]["dataList"][0][ "merchantNumber"] # 获取用户编号 f_totalAmount = float(totalAmount1) # 类型为str的金额转化为 浮点型 y_totalAmount = round(f_totalAmount, 2) # 浮点型 税价合计金额 四舍五入 f_amount = y_totalAmount / (1 + 0.1) # 税率10% amount = round(f_amount, 2) # 金额 f_taxAmount = y_totalAmount - amount taxAmount = round(f_taxAmount, 2) # 税额 # 申请合并开票 r3 = DF.invoice_merger(batchNumber, merchantNumber) # 查询开票中订单 applyStatus = 'HANDLE' r4 = DF.invoice_apply_list(applyStatus) # 返回合并开票批次号 invoiceBatchNumber invoiceBatchNumber = r4["data"]["resultList"]["dataList"][0][ "invoiceBatchNumber"] DF.invoice_add(invoiceCode, invoiceDate, invoiceNumber, taxAmount, y_totalAmount, amount, invoiceBatchNumber, merchantNumber) # 填写快递单号,确认开票申请 result = DF.invoice_addEmsInfo(batchNumber, merchantNumber, invoiceBatchNumber, emsOrderNumber) assert result["message"]["content"] == "操作成功"
def test_6(self, login_fix, merchant_login_fix): '''驳回开票申请''' s = login_fix ms = merchant_login_fix sj = SF() DF = DRG_func(s) DM = Drg_merchant(ms) #--------------充值订单确认时间------------------------------------------------------- invoiceDate = time.strftime("%Y" + "-" + "%m" + "-" + "%d" + " " + "%H" + ":" + "%M" + ":" + "%S") # ---------运营端确认充值订单,查询放款单号------------------------------------------------- sysnumber1 = DF.wait_order() sysnumber = sysnumber1["data"]["resultList"]["dataList"][0][ "systemOrderNumber"] # 商户端充值通道单号(随机生成) channelOrderNumber = sj.channelOrderNumber() # 商户端充值金额 recharge_amount = sj.day() #------查询是否有待处理开票订单---------------- applyStatus = 'WAIT' apply = DF.invoice_apply_list(applyStatus) apply_result = apply["data"]["count"] if apply_result == 0: # 新增开票申请 # ------查询是否有开票充值记录----- r = DM.rechargeOrder_wait() rechargeCount = r["data"]["rechargeCount"] # 判断充值记录为0的情况下 if rechargeCount == 0: # 新增充值记录 DM.merchant_recharge(recharge_amount, channelOrderNumber) # 运营端确认 DF.sucess_order(invoiceDate, sysnumber) # ----------商户端,查询出开票充值记录里面的充值金额和系统单号 recharge_detail = DM.rechargeOrder_wait() m_totalAmount = recharge_detail["data"]["resultList"][ "dataList"][0]["amountStr"] s_totalAmount = recharge_detail["data"]["resultList"][ "dataList"][0]["amountStr"] # 格式化输出,将字典里面的值参数化 systemOrderNumbers = recharge_detail["data"]["resultList"][ "dataList"][0]["systemOrderNumber"] # 商户端提交开票申请 DM.invoice_apply(m_totalAmount, systemOrderNumbers, s_totalAmount) # --------查询待处理订单,返回批次号和用户编号--------------- applyStatus = 'WAIT' result = DF.invoice_apply_list(applyStatus) merchantNumber = result["data"]["resultList"]["dataList"][0][ "merchantNumber"] batchNumber = result["data"]["resultList"]["dataList"][0][ "batchNumber"] # 驳回开票申请 respnose = DF.unpass_invoice(batchNumber, merchantNumber) assert respnose["message"]["content"] == "操作成功" else: # ----------商户端,查询出开票充值记录里面的充值金额和系统单号 recharge_detail = DM.rechargeOrder_wait() m_totalAmount = recharge_detail["data"]["resultList"][ "dataList"][0]["amountStr"] s_totalAmount = recharge_detail["data"]["resultList"][ "dataList"][0]["amountStr"] # 格式化输出,将字典里面的值参数化 systemOrderNumbers = recharge_detail["data"]["resultList"][ "dataList"][0]["systemOrderNumber"] # 商户端提交开票申请 DM.invoice_apply(m_totalAmount, systemOrderNumbers, s_totalAmount) # --------查询待处理订单,返回批次号和用户编号--------------- applyStatus = 'WAIT' result = DF.invoice_apply_list(applyStatus) merchantNumber = result["data"]["resultList"]["dataList"][0][ "merchantNumber"] batchNumber = result["data"]["resultList"]["dataList"][0][ "batchNumber"] # 驳回开票申请 respnose = DF.unpass_invoice(batchNumber, merchantNumber) assert respnose["message"]["content"] == "操作成功" else: # --------查询待处理订单,返回批次号和用户编号--------------- applyStatus = 'WAIT' result = DF.invoice_apply_list(applyStatus) merchantNumber = result["data"]["resultList"]["dataList"][0][ "merchantNumber"] batchNumber = result["data"]["resultList"]["dataList"][0][ "batchNumber"] # 驳回开票申请 respnose = DF.unpass_invoice(batchNumber, merchantNumber) assert respnose["message"]["content"] == "操作成功"
url_modify_account = "https://spman.shb02.net/system/account/modify" data = { "id": "14644", "roleId": "119", "loginName": "OPERATION006359002930", "mobile": "18759888529", "userName": "******", "status": "1", } response = self.s.post(url=url_modify_account, data=data) return response.json() if __name__ == '__main__': s = requests.session() sj = SF() emsOrderNumber = sj.phone() invoiceCode = sj.phone() invoiceNumber = sj.phone() licenceSerialNumber = time.strftime("%Y%m%d%H%M%S") smscode = licenceSerialNumber[2:8] invoiceDate = time.strftime("%Y" + "-" + "%m" + "-" + "%d" + " " + "%H" + ":" + "%M" + ":" + "%S") accountName = sj.name() contactMail = sj.get_email() contactName = sj.name() licenceSerialNumber = time.strftime("%Y%m%d%H%M%S") shortName = sj.name() managerMobile = sj.phone()
"environment": "https://spman.shb02.net/api", "merchantNumber": "M002137", "merchantPriKey": merchantPriKey, "method": "/issu/detail", "password": password, "systemPubKey": systemPubKey, "type": "symmetry", } response = self.s.post(url, json=data) return response.json() if __name__ == '__main__': s = requests.session() api = API_merchant(s) sj = SF() requesterUserIdentity = "jx" + sj.phone() idCard = sj.idcard() mobile = sj.phone() name = sj.name() #商户端登录 h = api.merchant_login() #获取商户私钥和系统公钥 info = api.merchant_Info() merchantPriKey = info["data"]["merchantPriKey"] systemPubKey = info["data"]["systemPubKey"] #获取api商户密码 result1 = api.get_apimerchant_password(merchantPriKey, systemPubKey) password = result1["password"]