def sys_fly_user_auth(self, id, userdata): userdata['id'] = id request_url = api.API_URL['sysflyuserauth'] print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if "SUCCESS" in res['info']: print('Passed:sys flyuser auth successed.') flag_status = 1 return flag_status elif "此飞手已审核" in res['info']: print('Failed :sys flyuser auth failed.') flag_status = 2 return flag_status else: print('Failed:sys flyuser auth failed.') flag_status = 0 return flag_status
def mendian_addorder(self, token, userid, data): userdata = {} userdata = data request_url = api.API_MD_URL['wxaddorder'] print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if res['errno'] == 0 or res['errno'] != 13: prepayid = res['data']["prePayId"] groupmembercount = res['data']["groupMemberCount"] preferentialList = res['data']['preferentialList'] print('Get the prepayid is %s' % prepayid) print('Get the groupMemberCount is %s' % groupmembercount) print('Get the preferentialList is %s' % preferentialList) print('Passed: mendian addorder successed. ') flag_md = 1 return flag_md, prepayid, groupmembercount, preferentialList else: print('Failed:mendian addorder failed') flag_md = 0 return flag_md
def fsd_check_account(self, check_userdata): userdata = check_userdata request_url = api.API_URL['fsdcheckaccount'] print(userdata, '\n', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_errorinfo_from_FSD(res) print(ret) #将字典转换成字符 ret = json.dumps(ret) if 'user not exist' in ret: print(' flyuser account not exist') flag_fsd = 1 else: print('flyuser account exist') flag_fsd = 0 return flag_fsd
def fsd_create_flyuser_team(self, ids, token, flyuserteamdata): userdata = flyuserteamdata print(userdata) ids = str(ids) request_url = api.API_URL['createflyuserteam'].replace( "id", ids).replace("TOKEN", token) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) if res['info'] == '操作成功': print('Passed: FSD create flyuser team successed. ') flag_fsd = 1 elif "已经创建团队的老板不能再创建团队" in res['info']: flag_fsd = 2 print('Failed: 已经创建团队的老板不能再创建团队. ') else: print('Failed: FSD create flyuser team failed') flag_fsd = 0 return flag_fsd
def sysment_management_freeze_flyuser(self, userid, token): #只传入userid userdata = {} userdata["id"] = userid userdata["state"] = 3 headers = {} headers['FARMFRIEND_TOKEN'] = token request_url = api.API_URL['freezeflyaccount'] print(userdata, '\n', request_url, headers) # 发送post请求 my_request = MyRequest(request_url, userdata, headers) res = my_request.request_post() res = res.json() print("response: ", res) #转换成Str jsonres = json.dumps(res) # 解析response返回信息 if 'SUCCESS' in jsonres: print('Passed: freeze fly account successed') flag_freez_ret = 1 return flag_freez_ret else: print('Failed:freeze fly account failed') flag_freez_ret = 0 return flag_freez_ret
def add_fsd_tools(self, data, ids, token): userdata = data userdata['id'] = ids userdata['TOKEN'] = token request_url = api.API_URL['addtools'].replace("id", ids).replace( "TOKEN", token) print(userdata, '\n', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #jsonres=json.dumps(res) if res['info'] == '操作成功': print('Passed: flyuser add tools successed. ') flag_fsd_add_tools = 1 return flag_fsd_add_tools else: print('Failed: flyuser add tools failed') flag_fsd_add_tools = 0 return flag_fsd_add_tools
def mendian_getbalance(self, token, userid, data): userdata = {} userdata = data userdata['token'] = token userdata['userid'] = userid userdata['userId'] = userid request_url = api.API_MD_URL['getbalance'] print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if res['errno'] == 0 or res['errno'] != 13: amount = res['data']["amount"] print('Get the amount is %s' % amount) print('Passed: mendian getbalance successed. ') flag_md = 1 return flag_md, amount else: print('Failed:mendian getbalance failed') flag_md = 0 return flag_md
def fsd_update_Xy(self, ids, token, phone): userdata = {} x = "116.483189" y = "39.997527" ids = str(ids) phone = str(phone) request_url = api.API_URL['updatexy'].replace("XVALUE", x).replace( "YVALUE", y).replace("PHONE", phone).replace("id", ids).replace("TOKEN", token) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_errorinfo_from_FSD(res) print(ret) if '操作成功' in res['info']: print('Passed: update xy successed. ') flag_fsd = 1 return flag_fsd else: print('Failed: update xy failed') flag_fsd = 0 return flag_fsd
def fsd_get_reserve_calendar(self, ids, token, phone, carid): userdata = int(carid) print(type(carid)) ids = str(ids) phone = str(phone) request_url = api.API_URL['getreservecalendar'].replace( "PHONE", phone).replace("id", ids).replace("TOKEN", token) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_errorinfo_from_FSD(res) print(ret) if res['errno'] == 0: print('Passed: get reserve calendar successed. ') times = res['data'][0]['time'] print('Get the times %s' % times) flag_fsd = 1 return flag_fsd, times else: print('Failed: get reserve calendar failed') flag_fsd = 0 return flag_fsd
def fsd_get_plane_id(self, ids, token, phone): userdata = {} userdata['memberId'] = ids userdata['from'] = '3' userdata['reserveId'] = '' ids = str(ids) phone = str(phone) request_url = api.API_URL['getplaneid'].replace( "PHONE", phone).replace("id", ids).replace("TOKEN", token) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_errorinfo_from_FSD(res) print(ret) if '操作成功' in res['info']: print('Passed: fsd get plane id successed. ') planeid = res['datas']["toolList"][0]['toolId'] print('Get the planeid %s' % planeid) flag_fsd = 1 return flag_fsd, planeid else: print('Failed: fsd get plane id failed') flag_fsd = 0 return flag_fsd
def query_fly_auth(self, phone, userdata): userdata['phone'] = phone request_url = api.API_URL['queryflyuser'] print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_errorinfo_from_management(res) print(ret) if err_flag == True: print('Passed:query flyuser successed.') flag_status = 1 id = res['data']['data'][0]['id'] return flag_status, id else: print('Failed:query flyuser failed') flag_status = 0 return flag_status
def mendian_getwxuserinfo(self, data, openid): userdata = {} userdata = data userdata['openid'] = openid request_url = api.API_MD_URL['getwxuserinfo'] print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if res['errno'] == 0 or res['errno'] != 13: token = res['data']["token"] userid = res['data']["accountId"] print('Get the MD token is %s' % token) print('Get the MD userid is %s' % userid) print('Passed: mendian getuserinfo successed. ') flag_md = 1 return flag_md, token, userid else: print('Failed:mendian getuserinfo failed') flag_md = 0 return flag_md
def ywb_salesmanquery(self, ids, token, data, phone): userdata = {} userdata = data phone = str(phone) ids = str(ids) request_url = api.API_YWB_URL['salesmanquery'].replace( "id", ids).replace("TOKEN", token).replace("PHONE", phone) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if res['errorCode'] == 0 or res['errno'] != 13: print('Passed: ywb salesmanquery successed. ') flag_ywb = 1 return flag_ywb else: print('Failed:ywb salesmanquery failed') flag_ywb = 0 return flag_ywb
def ywb_login(self, data): userdata = {} userdata = data request_url = api.API_YWB_URL['ywblogin'] print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if res['errorCode'] == 0 or res['errno'] != 13: accountId = res['datas']["loginSuccess"]["accountId"] token = res['datas']["loginSuccess"]["token"] print('Get the token is %s' % token) print('Get the accountId is %s' % accountId) print('Passed: ywb login successed. ') flag_ywb = 1 return flag_ywb, accountId, token else: print('Failed:ywb login failed') flag_ywb = 0 return flag_ywb
def fsd_get_team_info(self, ids, token, phone, ordernumber): userdata = {} userdata['orderNumber'] = ordernumber phone = str(phone) ids = str(ids) request_url = api.API_URL['getteaminfo'].replace("id", ids).replace( "TOKEN", token).replace("PHONE", phone) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if res['errorCode'] == 0 or res['errno'] != 13: print('Passed: fsd getTeaminfo successed. ') flag_fsd = 1 return flag_fsd else: print('Failed:fsd getTeaminfo failed') flag_fsd = 0 return flag_fsd
def fsd_add_operate_car(self, ids, token, data): userdata = data userdata['memberId'] = ids ids = str(ids) request_url = api.API_URL['addoperatecar'].replace("id", ids).replace( "TOKEN", token) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_errorinfo_from_FSD(res) print(ret) if ret == 1: print('Passed: add operate car successed. ') flag_fsd = 1 else: print('Failed: add operate car failed') flag_fsd = 0 return flag_fsd
def fsd_get_car_id(self, ids, token, phone): userdata = {} ids = str(ids) phone = str(phone) request_url = api.API_URL['getcarid'].replace("PHONE", phone).replace( "id", ids).replace("TOKEN", token) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_errorinfo_from_FSD(res) print(ret) if res['errno'] == 0: print('Passed: fsd get car id successed. ') carid = res['data']['list'][0]['id'] print('Get the car id %s' % carid) flag_fsd = 1 return flag_fsd, carid else: print('Failed: fsd get car id failed') flag_fsd = 0 return flag_fsd
def fsd_add_plane(self, phone, ids, token, data): userdata = data userdata['memberId'] = ids userdata['phone'] = phone ids = str(ids) phone = str(phone) print(phone) request_url = api.API_URL['addplane'].replace("PHONE", phone).replace( "id", ids).replace("TOKEN", token) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_errorinfo_from_FSD(res) print(ret) if res['info'] == '操作成功': print('Passed: add plane successed. ') flag_fsd = 1 else: print('Failed: add plane failed') flag_fsd = 0 return flag_fsd
def flyuser_set_password(self, accesstoken, ids, phone, password): userdata = {} userdata['userId'] = ids userdata['password'] = password userdata['phone'] = phone userdata['token'] = accesstoken request_url = api.API_URL['fsdusersetpassword'] print(userdata, '\n', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_errorinfo_from_FSD(res) print(ret) if res['info'] == '操作成功': print('Passed: flyuser set password successed') flag_fsd_setpassword = 1 return flag_fsd_setpassword else: print('Failed:flyuser set password failed') flag_fsd_setpassword = 0 return flag_fsd_setpassword
def fsd_submitorder(self, ids, token, phone, msg_id, ordernumber, data, area): userdata = {} userdata = data userdata['userid'] = ids userdata['orderNumber'] = ordernumber userdata['actual_area'] = area userdata['fly_actual_area'] = area userdata['msgId'] = msg_id querystring = { "access_phone": "18301212965", "userId": "2187", "token": "bddd03f4a404463690a7fd6013d722f4" } json_data = "state=4&userid=" + str(ids) + "&orderNumber=" + str( ordernumber ) + "&fly_actual_area=" + str(area) + "&actual_area=" + str( area ) + "&msgId=" + str( msg_id ) + "&totalSprayedDays=1&actualWorkStartTime=1532964060&actualWorkEndTime=1533050460&serviceConfirmSheet=%5B%22http%3A%5C%2F%5C%2Ffarmlandbucketstest.oss-cn-beijing.aliyuncs.com%5C%2F07b6fd8d8aaf4008814e31a3894efc92%22%5D&medicalInformation=%5B%7B%22drugNumber%22%3A0.0%2C%22drugPositiveUrl%22%3A%22http%3A%2F%2Ffarmlandbucketstest.oss-cn-beijing.aliyuncs.com%2Fd6a45d9bdb9843f88fa865ef402c2182%22%2C%22drugReverseUrl%22%3A%22%22%2C%22unitMu%22%3A0.0%7D%5D" headers = { 'content-type': "application/x-www-form-urlencoded", } phone = str(phone) ids = str(ids) request_url = api.API_URL['updateorderreport'].replace( "id", ids).replace("TOKEN", token).replace("PHONE", phone) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata, headers) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if '操作成功' in res['info'] or res['errorCode'] == 0: print('Passed: fsd submitorder successed. ') flag_fsd = 1 return flag_fsd else: print('Failed:fsd submitorder failed') flag_fsd = 0 return flag_fsd
def mendian_orderprepay(self, token, userid, prepayid, pretotalprice, prepaypercent, chekcode, openid, data): userdata = {} userdata = data userdata['token'] = token userdata['userid'] = userid userdata['userId'] = userid userdata['prePayId'] = prepayid userdata['preTotalPrice'] = pretotalprice userdata['prePayPercent'] = prepaypercent userdata['openid'] = openid userdata['checkCode'] = chekcode request_url = api.API_MD_URL['orderprepay'] print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if res['errno'] == 0 or res['errno'] != 13: order_number = res['data']["orderNumber"] print('Get the order_number is %s' % order_number) print('Passed: mendian addorderpay successed. ') flag_md = 1 return flag_md, order_number else: print('Failed:mendian addorderpay failed') flag_md = 0 return flag_md
def ywb_addorder(self, ids, token, phone, values): userdata = {} userdata = values datas = MultipartEncoder(fields={'data': str(json.dumps(values))}) headers = {"content-type": datas.content_type} phone = str(phone) ids = str(ids) request_url = api.API_YWB_URL['addorder'].replace("id", ids).replace( "TOKEN", token).replace("PHONE", phone) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, datas, headers) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if res['errorCode'] == 0 or res['errorCode'] != 13: order_number = res['datas']["payment"]["order_number"] print('Get the ordernumber is %s' % order_number) print('Passed: ywb addorder successed. ') flag_ywb = 1 return flag_ywb, order_number else: print('Failed:ywb addorder failed') flag_ywb = 0 return flag_ywb
def mendian_getfullareamsg(self, token, userid, prepayid, data): userdata = {} userdata = data userdata['token'] = token userdata['userid'] = userid userdata['userId'] = userid userdata['prePayId'] = prepayid request_url = api.API_MD_URL['getfullareamsg'] print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if res['errno'] == 0 or res['errno'] != 13: fullareastate = res['data']["fullAreaState"] fullareamsg = res['data']["fullAreaMsg"] print('Get the fullareastate is %s' % fullareastate) print('Get the fullareamsg is %s' % fullareamsg) print('Passed: mendian getfullarea successed. ') flag_md = 1 return flag_md, fullareastate, fullareamsg else: print('Failed:mendian getfullarea failed') flag_md = 0 return flag_md
def mendian_getcanuservoucher(self, token, userid, prepayid, pretotalprice, prepaypercent, data): userdata = {} userdata = data userdata['token'] = token userdata['userid'] = userid userdata['userId'] = userid userdata['prePayId'] = prepayid userdata['preTotalPrice'] = pretotalprice userdata['prePayPercent'] = prepaypercent request_url = api.API_MD_URL['getcanuservoucherlist'] print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() #print("response: ",res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if res['errno'] == 0 or res['errno'] != 13: vouchlist = res['data']["voucherList"] print('Get the voucherList ') print('Passed: mendian getcanuservoucher successed. ') flag_md = 1 return flag_md, vouchlist else: print('Failed:mendian getcanuservoucher failed') flag_md = 0 return flag_md
def fsd_updateorderstate(self, ids, token, phone, msg_id, ordernumber, data, order_text): userdata = {} userdata = data userdata['state'] = 3 userdata['userid'] = ids userdata['orderNumber'] = ordernumber userdata['order_amount'] = order_text['total_money'] userdata['work_time'] = order_text['work_time'] userdata['msgId'] = msg_id phone = str(phone) ids = str(ids) request_url = api.API_URL['updateorderstate'].replace( "id", ids).replace("TOKEN", token).replace("PHONE", phone) print('Test data and api url |', userdata, '| ', request_url) # 发送post请求 my_request = MyRequest(request_url, userdata) res = my_request.request_post() res = res.json() print("response: ", res) #解析response返回信息 err_flag, ret = my_request.decode_res_info(res) #print(ret) if res['errorCode'] == 0: print('Passed: fsd updateorderstate successed. ') flag_fsd = 1 return flag_fsd else: print('Failed:fsd updateorderstate failed') flag_fsd = 0 return flag_fsd