def __getOperatorParkConfigListView(self): """获取当前用户车场列表""" re = Index(self.Session).getNewMeun() operatorID = re.json()["user"]["operatorID"] json_data = {"pageNumber": 1, "pageSize": 6, "sortType": "ASC"} data = {"operatorId": operatorID, "parkName": ""} self.url = '/mgr/operatorPark/getOperatorParkConfigListView?' + urlencode( data) re = self.post(self.api, json=json_data, headers=json_headers) return re
def getMonthTicketBillList(self, parkName, carNum = "", combinedStatus=""): """ 获取已开通月票记录列表 :param parkName: :param carNum: :param combinedStatus: 状态‘不在有效期,生效中,已退款’ :return: """ parkDict = self.getDictBykey(Index(self.Session).getParkingBaseDataTree().json(), 'name', parkName) statusDict = { "不在有效期":0, "生效中":1, "已退款":2, "":"" } data = { "page":1, "rp":20, "query_parkId":parkDict['value'], "parkSysType":parkDict['parkSysType'], "query_carCode":carNum, "combinedStatus":statusDict[combinedStatus] } self.url = "/mgr/monthTicketBill/list.do?" + urlencode(data) re = self.get(self.api, headers=form_headers) return re.json()
def addWhitelist(self, parkName, carNum): """录入白名单""" parkDict = self.getDictBykey( Index(self.Session).getParkingBaseDataTree().json(), 'name', parkName) self.url = "/mgr/park/park_redlist/add.do" data = {"redlistParam": carNum, "parkIds": parkDict['value']} re = self.post(self.api, data=data, headers=form_headers) return re.json()
def cleanCarCheckOut(self, parkName, carNum): """批量盘点""" carNumDict = self.getDictBykey(self.getPresentCar(parkName, carNum), 'carNo', carNum) userDict = Index(self.Session).getNewMeun().json()['user'] data = { "topBillCodeList": carNumDict['topBillCode'], "operatorName": userDict['nickname'], "comment": 'pytest' } self.url = '/mgr/park/presentCar/clearByTopBillCodeList?' + urlencode(data) re = self.post(self.api, headers = self.api_headers) return re.json()
def __getMonthTicketListChoose(self, parkName, typeName): """"选择性获取月票类型""" parkInfoDict = self.getDictBykey( Index(self.Session).getUnsignedParkList().json(), 'name', parkName) data = { "page": 1, "rp": 20, "query_parkId": parkInfoDict['id'], "parkSysType": 1, "query_ticketName": typeName } self.url = "/mgr/monthTicketConfig/list.do?" + urlencode(data) re = self.get(self.api, headers=form_headers) return re.json()
def getCouponListByPage(self, parkName): """优惠配置-获取优惠劵列表""" parkDict = self.getDictBykey( Index(self.Session).getParkingBaseDataTree().json(), 'name', parkName) data = { "page": 1, "rp": 20, "query_parkId": parkDict.get("value"), "parkSysType": parkDict.get('parkSysType') } self.url = "/mgr/coupon/getListByPage.do?" + urlencode(data) re = self.get(self.api, headers=form_headers) return re.json()
def batchRenewMonthTicketBill(self, parkName, carNum, fileName = "批量续费月票.xls"): """批量续费月票""" file = root_path + '/upload/' + fileName Index(self.Session).downloadExcelTmp("renew_month_ticket_bill.xls", file) ticketBillDict = self.getDictBykey(self.getMonthTicketBillList(parkName, carNum, '不在有效期'),'carCode',carNum) self.__editBatchRenewBillFile(file, ticketBillDict['ticketCode'], carNum) file = { "renewFile": open(file,'rb') } self.url = "/mgr/monthTicketBill/renewBills.do" re = self.post(self.api, files = file, headers = {'User-Agent':'Chrome/71.0.3578.98'}) if re.json()['status'] == 1: re = self.__getRenewBillResult() return re.json()['data']
def batchOpenMonthTicketBill(self,parkName, typeName, carNum, fileName = '批量开通月票.xls'): """批量开通月票""" file = root_path + '/upload/' + fileName Index(self.Session).downloadExcelTmp("month_ticket_bill.xls", file) ticketConfigDict = self.getDictBykey(MonthTicketConfig(self.Session).getMonthTicketList(parkName,typeName),'ticketName',typeName) self.__editOpenBillFile(file, ticketConfigDict['ticketCode'], carNum) file = { "importFile": open(file, 'rb'), "im12portFile": "self.importFile.importFile" } self.url = "/mgr/monthTicketBill/importBills.do" re = self.post(self.api, files = file, headers = {'User-Agent':'Chrome/71.0.3578.98'}) if re.json()['status'] == 1: re = self.__getImportBillResut() return re.json()['data']
def getTraderListData(self, parkName, name=''): """获取商户列表""" parkDict = self.getDictBykey( Index(self.Session).getParkingBaseDataTree().json(), 'name', parkName) data = { "page": 1, "rp": 20, "query_parkId": parkDict['value'], "parkSysType": 1, "name": name } self.url = '/mgr/trader/getTraderListData.do?' + urlencode(data) re = self.get(self.api, headers=form_headers) return re.json()['data']['rows']
def intelligenceCheckCarOut(self, parkName, cleanType = '按时间条件',carNum = None ): """ 智能盘点 :param parkName: :param cleanType: '按时间条件','按在场车辆' :param file: 按上传模板 :return: """ nowTime = SA().get_time('%Y-%m-%d %H:%M:%S') parkDict = self.getDictBykey(self.__getParkingBaseTree().json(), 'name', parkName) userDict = Index(self.Session).getNewMeun().json()['user'] if cleanType == '按时间条件': re = self.__autoClearCarByTime(nowTime, parkDict['parkId'], userDict['nickname']) else: re = self.__autoClearCarByFile(nowTime, parkDict['parkId'], userDict['nickname'], carNum) return re.json()
def getParkVisitorList(self, parkName): """获取访客录入车辆""" parkDict = self.getDictBykey( Index(self.Session).getParkingBaseDataTree().json(), 'name', parkName) data = { "page": 1, "rp": 20, "startDate": today + ' 00:00:00', "endDate": endDate + ' 23:59:59', "parkIds": parkDict['value'], "parkSysType": 1, } self.url = "/mgr/park/parkVisitorlist/getParkVisitorlist.do?" + urlencode( data) re = self.get(self.api, headers=form_headers) return re.json()
def getBlacklist(self, parkName): """获取黑名单列表""" parkDict = self.getDictBykey( Index(self.Session).getParkingBaseDataTree().json(), 'name', parkName) data = { "page": 1, "rp": 20, "startDate": today + ' 00:00:00', "endDate": endDate + ' 23:59:59', "parkIds": parkDict['value'], "parkSysType": 1, } self.url = '/mgr/park/parkBlacklist/getParkBlacklist.do?' + urlencode( data) re = self.get(self.api) return re.json()
def batchRefundMonthTicketBill(self, parkName, carNum, fileName = '批量退费月票.xls'): """批量退费月票""" file = root_path + '/upload/' + fileName Index(self.Session).downloadExcelTmp("refund_month_ticket_bill.xls", file) billDict = self.getDictBykey(self.getMonthTicketBillList(parkName, carNum, '生效中'), 'carCode',carNum) excel = ExcelUnitl(file) excel.editCell(1, 0, billDict['ticketCode']) excel.editCell(1, 3, carNum) excel.editCell(1, 7, '1') file = { "refundFile": open(file,'rb'), "im12portFile": "self.importFile.importFile" } self.url = "/mgr/monthTicketBill/batchRefund.do" re =self.post(self.api, files = file, headers = {'User-Agent':'Chrome/71.0.3578.98'}) if re.json()['status'] == 1 : re = self.__getBatchRefundResult() return re.json()['data']
def __autoClearCarByFile(self,clearTime, parkUUID, operatorName, carNum, fileName = "智能盘点.xls"): """ 智能盘点-按在场车场,按模板盘点在场车场信息记录 :param clearTime: :param parkUUID: :param operatorName: :param carNum: 可以输入多个车牌,用','隔开 :param fileName: :return: """ file = root_path + '/upload/' + str(fileName) Index(self.Session).downloadExcelTmp("auto_clear_car.xls", file) self.__setCarNumInClearCarFile(file, carNum) clearCarCheck = self.__autoClearCarCheck(clearTime, operatorName, parkUUID, file).json() data = { "clearCode":clearCarCheck['data']['clearCode'], "comment":'pytest智能盘点按模板', "additionRecord": 1, "operatorName":operatorName } self.url = "/mgr/park/presentCar/autoClearCar?" + urlencode(data) re = self.post(self.api, headers=self.api_headers) return re
def createSpecialType(self, parkName, specialCarType, typeName): """创建特殊类型""" parkInfoDict = self.getDictBykey( Index(self.Session).getUnsignedParkList().json(), 'name', parkName) optionArrList = self.__selectChargeGroupList( parkInfoDict['parkUUID']).json()['data'][parkInfoDict['parkUUID']] parkJson = [{ "parkSysType": 1, "parkVipTypeId": "", "parkLongId": parkInfoDict['id'], "parkId": parkInfoDict['parkUUID'], "parkName": parkName, "chargeGroupCode": "0", "optionArr": optionArrList }] channelAuthTree = self.getDictBykey( self.__getChannelAuthTreeMultiPark().json(), 'name', parkName) self.__getDictChildList(channelAuthTree, 'childrenList') newChannelAuthTree = json.dumps( self.setValueByDict(self.aList, ['checked'], True)) parkVipTypeJson = { "customVipName": "", "settlementType": 0, "isDynamicMode": 0, "isDatePrivilege": 0, "isTimePrivilege": 0, "privilegeTimePeriod": "", "isChargeGroupRelated": 0, "vipGroupType": 0, "dynamicFullLimit": 0, "vipNearExpiredDayThreshold": 10, "vipDeleteExpiredDayThreshold": 0, "openVipFullLimit": 0, "vipFullLimitValue": "", "vipFullOpenModel": 0, "priTimeArrFrom": "", "priTimeArrTo": "", "priDateArrStr": "", "parkId": "", "parkName": "", "channelAuthTree": str(newChannelAuthTree), "channelSeqList": [], "autoSwitchVip": 0, "offLine": 1 } data = { "parkSysType": 1, "vipGroupType": specialCarTypeDict[specialCarType], "name": typeName, "description": "pytest", "parkJson": str(parkJson), "renewFormerDays": 1, "inviteCarTotal": 3, "parkVipTypeJson": str(parkVipTypeJson), "showMessage": const.showMessage } self.url = "/mgr/park/specialCarTypeConfig/add.do" # print(data['parkVipTypeJson']) re = self.post(self.api, data=data, headers=form_headers) return re.json()
def test_checkParkingOnLine(self, userLogin, send_data, expect): """查看车场是否上线""" re = Index(userLogin).getOperatorParkConfigListView( send_data['parkName']) result = re[0] Assertions().assert_text(result['online'], expect['parkingOnLineMsg'])
def editMonthTicketConfig(self, parkName, oldTypeName, newTypeName): """ 修改月票类型- 条件sellNum > 0强制编辑,等于0,编辑, parkSysType==0 并且 ticketStatus==='VALID'是不可以编辑和强制编辑 :param parkName: :param oldTypeName: :param newTypeName: :return: """ parkDict = self.getDictBykey( Index(self.Session).getParkingBaseDataTree().json(), 'name', parkName) typeConfigDict = self.getDictBykey( self.getMonthTicketList(parkName, oldTypeName), 'ticketName', oldTypeName) typeConfigDetailDict = self.__getMonthTicketCofigDetail( typeConfigDict['id']).json()['data'] optionArrList = self.__selectChargeGroupList( parkDict['parkId']).json()['data'][parkDict['parkId']] optionArrDict = {'optionArr': optionArrList} parkJsonList = [] configDict = typeConfigDetailDict['parkList'][0] configDict.update(optionArrDict) parkJsonList.append(configDict) channelAuthTree = typeConfigDetailDict['channelArr'] parkVipTypeDict = typeConfigDetailDict['parkVipType'] parkVipTypeJson = { "id": parkVipTypeDict['id'], "customVipName": parkVipTypeDict['customVipName'], "settlementType": parkVipTypeDict['settlementType'], "settlementAmount": parkVipTypeDict['settlementAmount'], "isDynamicMode": parkVipTypeDict['isDynamicMode'], "dynamicCarportNumber": parkVipTypeDict['dynamicCarportNumber'], "isDatePrivilege": parkVipTypeDict['isDatePrivilege'], "isTimePrivilege": parkVipTypeDict['isTimePrivilege'], "privilegeTimePeriod": parkVipTypeDict['privilegeTimePeriod'], "isChargeGroupRelated": parkVipTypeDict['isChargeGroupRelated'], "chargeGroupCode": parkVipTypeDict['chargeGroupCode'], "vipGroupType": parkVipTypeDict['vipGroupType'], "dynamicFullLimit": parkVipTypeDict['dynamicFullLimit'], "dynamicCarNumber": parkVipTypeDict['dynamicCarNumber'], "vipNearExpiredDayThreshold": parkVipTypeDict['vipNearExpiredDayThreshold'], "vipDeleteExpiredDayThreshold": parkVipTypeDict['vipDeleteExpiredDayThreshold'], "openVipFullLimit": parkVipTypeDict['openVipFullLimit'], "vipFullLimitValue": parkVipTypeDict['vipFullLimitValue'], "vipFullOpenModel": parkVipTypeDict['vipFullOpenModel'], "vipRecoverTime": parkVipTypeDict['vipRecoverTime'], "priDateArrStr": parkVipTypeDict['priDateArrStr'], "parkId": parkVipTypeDict['parkId'], "parkName": parkVipTypeDict['parkName'], "channelAuthTree": channelAuthTree, "channelSeqList": parkVipTypeDict['channelSeqList'], "autoSwitchVip": parkVipTypeDict['autoSwitchVip'], "offLine": parkVipTypeDict['offLine'] } data = { "id": typeConfigDetailDict['id'], "settlementType": 0, "parkSysType": typeConfigDetailDict['parkSysType'], "price": typeConfigDetailDict['price'], "ticketName": newTypeName, "ticketType": typeConfigDetailDict['ticketType'], "renewMethod": typeConfigDetailDict['renewMethod'], "maxSellLimit": typeConfigDetailDict['maxSellLimit'], "maxSellNum": typeConfigDetailDict['maxSellNum'], "sellNum": typeConfigDetailDict['sellNum'], "remark": typeConfigDetailDict['remark'], "renewFormerDays": typeConfigDetailDict['renewFormerDays'], "renew": typeConfigDetailDict['renew'], "inviteCarTotal": typeConfigDetailDict['inviteCarTotal'], "financialParkId": typeConfigDetailDict['financialParkId'], "continueBuyFlag": 1, "supportVirtualCarcode": typeConfigDetailDict['supportVirtualCarcode'], "validTo": SA().timestamp_to_format(typeConfigDetailDict['validTo']), "parkJson": json.dumps(parkJsonList), "sellFrom": SA().timestamp_to_format(typeConfigDetailDict['sellFrom']), "sellTo": '4020-03-19 00:00:00', "parkVipTypeJson": json.dumps(parkVipTypeJson), "inviteCarSwitcher": 0, "showMessage": typeConfigDetailDict['showMessage'] } if typeConfigDetailDict['sellNum'] == 0: self.url = "/mgr/monthTicketConfig/save.do" else: self.url = "/mgr/monthTicketConfig/forceSave.do" re = self.post(self.api, data=data, headers=form_headers) return re.json()
def createMonthTicketConfig(self, parkName, ticketTypeName, renewMethod, validTo, isChargeGroupRelated=0, vipGroupName=None, isDynamicMode=0, autoSwitchVip=0, openVipFullLimit=0, vipFullLimitValue=1, vipFullOpenModel=0): """ 创建月票类型 :param parkName: :param ticketName: :param renewMethod: '自然月','自定义' :param validTo: '2020-5-19' :param isDynamicMode=0 开启多车多车,autoSwitchVip=0 开启场内转vip :param isChargeGroupRelated 是否支持收费 ,vipGroupName 月票组名 :param openVipFullLimit 开启满位控制,vipFullLimitValue 最多可进车辆,vipFullOpenModel 满位放行模式 :return: """ renewMethodDict = {"自然月": "NATURAL_MONTH", "自定义": "CUSTOM"} parkInfoDict = self.getDictBykey( Index(self.Session).getParkingBaseDataTree().json(), 'name', parkName) parkSysType = parkInfoDict['parkSysType'] if parkSysType == 1: optionArrListDict = self.__selectChargeGroupList( parkInfoDict['parkId']).json() optionArrList = optionArrListDict['data'][parkInfoDict['parkId']] else: optionArrList = [] vipGroupType = 0 if str(isChargeGroupRelated) == '1': vipGroupType = self.getDictBykey(optionArrListDict, 'typeName', vipGroupName)['chargeTypeSeq'] parkJson = [{ "parkSysType": parkInfoDict['parkSysType'], "parkVipTypeId": "", "parkId": parkInfoDict['value'], "parkUuid": parkInfoDict['parkId'], "parkName": parkName, "chargeGroupCode": vipGroupType, "optionArr": optionArrList }] channelAuthTree = self.getDictBykey( self.__getChannelAuthTreeMultiPark(parkSysType).json(), 'name', parkName) self.__getDictChildList(channelAuthTree, 'childrenList') newChannelAuthTree = json.dumps( self.setValueByDict(self.aList, ['checked'], True)) parkVipTypeJson = { "customVipName": "", "settlementType": 0, "isDynamicMode": isDynamicMode, "isDatePrivilege": 0, "isTimePrivilege": 0, "privilegeTimePeriod": "", "isChargeGroupRelated": isChargeGroupRelated, "vipGroupType": vipGroupType, "dynamicFullLimit": 0, "vipNearExpiredDayThreshold": 10, "vipDeleteExpiredDayThreshold": 0, "openVipFullLimit": openVipFullLimit, "vipFullLimitValue": vipFullLimitValue, "vipFullOpenModel": vipFullOpenModel, "priTimeArrFrom": "", "priTimeArrTo": "", "priDateArrStr": "", "parkId": "", "parkName": "", "channelAuthTree": str(newChannelAuthTree), "channelSeqList": [], "autoSwitchVip": autoSwitchVip, "offLine": 1 } data = { "ticketName": ticketTypeName, "settlementType": 0, "ticketType": 'OUTTER', "renew": 1, "price": 35, "renewMethod": renewMethodDict[renewMethod], "maxSellLimit": 'NO', "financialParkId": parkInfoDict['value'], "parkJson": str(parkJson), "remark": 'pytest', "renewFormerDays": 60, # 允许向前续费天数 "inviteCarTotal": 0, "continueBuyFlag": 1, "supportVirtualCarcode": 0, "parkVipTypeJson": str(parkVipTypeJson), "inviteCarSwitcher": 0, "validTo": "{} 23:59:59".format(validTo), "sellFrom": SA().get_time(strType='%Y-%m-%d %H:%M:%S'), "sellTo": SA().get_time(strType='%Y-%m-%d %H:%M:%S'), "showMessage": const.showMessage } self.url = "/mgr/monthTicketConfig/save.do" re = self.post(self.api, data=data, headers=form_headers) return re.json()