コード例 #1
0
 def createCityCoupon(self, parkName, cityCouponName):
     """创建城市劵"""
     parkCodeSql = "select parkCode from tbl_device_parking where name ='" + parkName + "'"
     parkCode = db().select(parkCodeSql)
     self.url = "/openydt/api/v2/createCityOperationCouponTemplate"
     json_data = {
         "parkCodeList": [parkCode],
         "couponTemplate": {
             "wxAppid": "wxbc0f049b70707054",
             "name": cityCouponName,
             "totalNum": 10,
             "couponType": 1,
             "faceValue": 1.00,
             "useRuleFrom": 0,
             "useRuleTo": 1000,
             "couponRule": "",
             "useParkingFee": "",
             "isCover": 1,
             "maxCoverNum": 3,
             "validFrom": SA().get_today_data() + " 00:00:00",
             "validTo":
             SA().cal_get_day(strType="%Y-%m-%d", days=365) + " 23:59:59",
             "validTime": 360,
             "billUseType": 0,
             "remark": "创建城市运营模板劵--金额扣减券_正常"
         }
     }
     re = self.post(self.openYDT_api, json=json_data)
     return re
コード例 #2
0
 def _getCenterMonitorHandleCarMsg(self, carNum):
     """远程值班 -获取车场进出场处理车辆信息"""
     data = {
         "message_id": SA().get_uuid(),
         "timestamp": SA().get_time(),
         "biz_content": {}
     }
     self.url = "/get_center_monitor_msg"
     re = self.post(self.mock_api, json=data, headers=self.api_headers)
     result = re.json()['biz_content']['center_monitor_msg']
     if result == "null": raise Exception("远程值班获取车场进出场处理车辆信息为null")
     if result['msgType'] == "CORRECT_CAR_NO_ALERT":
         if result['data']['carNo'] == carNum:
             return result['data']
     else:
         result = result['data']
         if result['msg_type'] == '进车':
             if result['carInMsg']['carNo'] == carNum:
                 return result
             else:
                 # print('该进车信息不是车辆【{}】'.format(carNum))
                 result = self.setValueByDict(result, ['carInMsg', 'carNo'],
                                              carNum)
                 return result
         elif result['msg_type'] == '出车':
             if result['carOutMsg']['leaveCarNo'] == carNum:
                 return result
             else:
                 # print('该出车信息不是车辆【{}】'.format(carNum))
                 result = self.setValueByDict(result,
                                              ['carOutMsg', 'leaveCarNo'],
                                              carNum)
                 return result
         else:
             print('接口返回值错误!!')
コード例 #3
0
 def mockCarInOut(self,
                  carNum,
                  mockType,
                  ytj_id,
                  confidence=91,
                  carType='蓝牌车'):
     self.url = "/mock_car_in_out"
     json_data = {
         "message_id": SA().get_uuid(),
         "timestamp": SA().get_time(),
         "biz_content": {
             "car_plate": carNum,
             "mock_type": mockType,  # 取消进出类型
             "ytj_id": ytj_id,
             "confidence": confidence,
             "job_id": SA().get_uuid(),
             "car_size": self.carTypeDict[carType]
         }
     }
     re = self.post(self.mock_api, json=json_data, headers=self.api_headers)
     try:
         if str(mockType) == '1':
             self.save('carOut_jobId', re.json()['biz_content']['job_id'])
         elif str(mockType) == '0':
             self.save('carIn_jobId', re.json()['biz_content']['job_id'])
     except KeyError:
         raise KeyError("【{}】一体机状态异常,无法进出车!".format(ytj_id))
     return re.json()['biz_content']['result']
コード例 #4
0
 def __editBatchRenewBillFile(self, file, ticketCode, carNum):
     """修改批量续费excel文件"""
     excel = ExcelUnitl(file)
     excel.editCell(1, 0, ticketCode)
     excel.editCell(1, 3, carNum)
     excel.editCell(1, 4, "{} 00:00:00".format(SA().get_today_data()))
     excel.editCell(1, 5, "{} 23:59:59".format(SA().cal_get_day(strType="%Y-%m-%d", days=15)))
     excel.editCell(1, 7, 30)
コード例 #5
0
 def checkYtjOnlineList(self):
     """查看在线一体机"""
     self.url = "/check_ytj_list"
     data = {
         "message_id": SA().get_uuid(),
         "timestamp": SA().get_time(),
         "biz_content": {}
     }
     re = self.post(self.mock_api, json=data, headers=self.api_headers)
     return re
コード例 #6
0
 def __editOpenBillFile(self,file,ticketCode,carNum):
     """修改批量开通月票excel文件"""
     excel = ExcelUnitl(file)
     excel.editCell(1, 0, ticketCode)
     excel.editCell(1, 1, SA.create_name())
     excel.editCell(1, 2, "135{}".format(SA().create_randomNum(val=8)))
     excel.editCell(1, 3, carNum)
     excel.editCell(1, 4, "{} 00:00:00".format(SA().get_today_data()))
     excel.editCell(1, 5, "{} 23:59:59".format(SA().cal_get_day(strType ="%Y-%m-%d", days=15)))
     excel.editCell(1, 7, 30)
コード例 #7
0
 def getCenterMonitorMsgList(self):
     """获取远程值班-接收信息列表"""
     data = {
         "message_id": SA().get_uuid(),
         "timestamp": SA().get_time(),
         "biz_content": {}
     }
     self.url = "/get_center_monitor_msg_list"
     re = self.post(self.mock_api, json=data, headers=self.api_headers)
     return re.json()
コード例 #8
0
 def __createUserSocket(self, ip, token):
     """请求创建用户的socket"""
     data = {
         "message_id": SA().get_uuid(),
         "timestamp": SA().get_time(),
         "biz_content": {
             "login_url": ip,
             "login_token": token
         }
     }
     url = self.mock_host + "/mock_login_center_monitor"
     re = self.S.post(url, json=data, headers=json_headers)
     return re
コード例 #9
0
 def getCarMsgYtj(self, job_id):
     """
     获取车场进出场一体机的返回的信息
     :param job_id:
     :return:
     """
     self.url = "/get_ytj_msg"
     json_data = {
         "message_id": SA().get_uuid(),
         "timestamp": SA().get_time(),
         "biz_content": {
             "job_id": job_id
         }
     }
     re = self.post(self.mock_api, json=json_data, headers=self.api_headers)
     return re.json()['biz_content']['result']
コード例 #10
0
 def login(self):
     """校验图片验证码-登陆中央值守"""
     sessionId = SA().get_time()
     url = self.host + "/zbcloud/user-service/cenduty/seat/getVerificationCode?sessionId={}".format(
         sessionId)
     self.S.get(url=url)
     url = self.host + "/zbcloud/user-service/cenduty/seat/login"
     data = {
         "userid": "{}".format(self.user),
         "password": self.__setPwd(self.password),
         "validateCode": "9999",
         "sessionId": "{}".format(sessionId)
     }
     log.info("登录名:【" + data['userid'] + "】")
     r = self.S.post(url=url, json=data, headers=json_headers)
     LoginReponse.loginRe = r
     if r.json()['status'] == 0:
         token = r.json()['message'].split(";")[0]
         topOperatorId = r.json()['message'].split(";")[-1]
         self.S.headers.update({"token": token})
         websocketUrl = "wss://monitor.k8s.yidianting.com.cn/zbcloud/center-monitor/websocket"
         print((self.__createUserSocket(websocketUrl, token)).json())
         executeUrl = self.host + '/zbcloud/center-monitor-service/zbcloud-grey/api/execute?topOperatorId={}'.format(
             topOperatorId)
         re = self.S.get(executeUrl, headers=form_headers)
         if re.text == 'ok':
             return self.S
     else:
         return self.S
コード例 #11
0
 def addTrader(self, name, parkName, account, couponName, pwd='123456'):
     """
     新增商家
     :return:
     """
     parkNameDict = self.getDictBykey(self.__queryAllPark().json(), 'name',
                                      parkName)
     couponDict = self.getDictBykey(
         self.__getCoupon2Buy(parkNameDict['id']).json(), 'name',
         couponName)
     json_data = {
         "name": name,
         "parkName": parkNameDict['name'],
         "parkId": parkNameDict['pkGlobalid'],
         "type": "美食",
         "defaultType": "美食",
         "contact": "auto-zbyun",
         "account": account,
         "tel": "135{}".format(SA().create_randomNum(val=8)),
         "password": pwd,
         "confirmPassword": pwd,
         "isLimitBuy": 0,
         "userCount": 2,
         "couponIdListStr": couponDict['id'],
         "telIsEdit": "true"
     }
     if self.__isUniqueName(
             json_data['name']) and self.__isExistOtherTrader(
                 json_data['account']):
         self.url = "/mgr/trader/addTrader.do"
         re = self.post(self.api, data=json_data, headers=form_headers)
         return re.json()
     else:
         logger.error('商家名或电话已被注册')
コード例 #12
0
 def getVipType(self,parkCode,customVipName):
     """通过开放平台-查询vems月票类型信息"""
     self.url = "/openydt/api/v2/getVipType"
     data = {
         "parkCode": parkCode,
         "customVipName":customVipName,
         "operateTime": SA().get_time(strType='%Y-%m-%d %H:%M:%S')
     }
     re = self.post(self.openYDT_api,json=data, headers = json_headers)
     return re.json()['data']['vipTypeList']
コード例 #13
0
 def renewMonthTicketBill(self, parkName, carNum, status , date = None):
     """
     月票续费,默认续费10天
     :param parkName:
     :param carNum:
     :param refundValue: 续费折扣价格
     :param status: 月票有效状态:
     :paramdate 续费的时间点,'2020-02-02'
     :return:
     """
     monthTicketBillDict = self.getDictBykey(self.getMonthTicketBillList(parkName, carNum, status), 'carCode', carNum)
     self.url = "/mgr/monthTicketBill/renew.do"
     if monthTicketBillDict['renewMethod'] == 'NATURAL_MONTH':
         openMonthNum = 2
         timeperiodListStr = SA().cal_getTheMonth(date = date, n = openMonthNum - 1)
     else:
         openMonthNum = 10
         if date == None:
             date = SA().get_today_data()
         else:
             if not isinstance(date, str):
                 # dateType = datetime.datetime.strptime(date, '%Y-%m-%d')
                 date = date.strftime("%Y-%m-%d")
         timeperiodListStr = date + " 00:00:00 - " + SA().cal_get_day(strType='%Y-%m-%d', days=int(openMonthNum), date=date) + " 23:59:59"
     price = self.__operationPrice(monthTicketBillDict['price'])
     data = {
         "monthTicketId": monthTicketBillDict['monthTicketId'],
         "monthTicketName": monthTicketBillDict['ticketName'],
         "monthTicketBillId": monthTicketBillDict['id'],
         "timeperiodListStr": timeperiodListStr,
         "userName": monthTicketBillDict['userName'],
         "userPhone": monthTicketBillDict['userPhone'],
         "price": price,
         "totalValue": monthTicketBillDict['totalValue'],
         "openMonthNum": openMonthNum,
         "realValue": 19,
         "remark1": 'pytest续费',
         "dynamicCarportNumber": monthTicketBillDict['dynamicCarportNumber'],
     }
     re = self.post(self.api, data= data, headers = form_headers)
     return re.json()
コード例 #14
0
 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()
コード例 #15
0
 def addVisitor(self, visitorType, carNum):
     """新建访客车辆"""
     visitorTypeDict = self.getDictBykey(
         self.__getVisitorConfigList().json(), 'name', visitorType)
     self.url = "/mgr/park/parkVisitorlist/save.do"
     data = {
         "specialCarTypeConfigId": visitorTypeDict['id'],
         "carLicenseNumber": carNum,
         "owner": 'apipytest',
         "ownerPhone": '135' + SA().create_randomNum(val=8),
         "visitReason": 'apipytest',
         "remark1": "apipytest",
         "visitFrom": today + ' 00:00:00',
         "visitTo": endDate + ' 23:59:59'
     }
     re = self.post(self.api, data=data, headers=form_headers)
     return re.json()
コード例 #16
0
 def payParkFee(self ,parkCode, carNum):
     """缴费"""
     parkFeeDict = self.getParkFee(parkCode, carNum)
     # couponList = parkFeeDict.get('otherAttr').get('traderCouponList') if parkFeeDict.get('otherAttr').get('traderCouponList') else []
     data = {
         "parkingCode": parkFeeDict.get("parkingCode"),
         "chargeDate": parkFeeDict.get("chargeDate"),
         "payDate": SA().get_time(),
         "actPayCharge": parkFeeDict.get("shouldPayValue"),
         "reliefCharge": "1.2",
         "payOrigin": "3",
         "payOriginRemark": "微信",
         "paymentMode": "0",
         "paymentModeRemark": "00",
         "billCode": SA.getTimeStamp(),
         "couponList": []
     }
     self.url = "/openydt/api/v2/payParkFee"
     re = self.post(self.openYDT_api, json=data, headers = json_headers)
     return re.json()
コード例 #17
0
 def __postLogFormat(self, url, data, json, result):
     """
     日志打印格式
     :param url:
     :param data:
     :param json:
     :param result:
     :return:
     """
     logger.info("===请求方式:{}".format('POST'))
     logger.info("===请求路径:{}".format(url))
     if json == None:
         logger.info("===请求参数:{}".format(data))
     else:
         logger.info("===请求参数:{}".format(json))
     logger.info("===返回状态码:{}".format(result.status_code))
     if "mock" in url:
         logger.info("===返回结果:{}".format(SA().changeDate(eval(
             result.text))))
     else:
         logger.info("===返回结果:{}".format(result.text))
コード例 #18
0
 def __updateDiciStatus(self, parkingState, cmcId, pmdId):
     """
     上报地磁状态
     :param parkingState: 无车or有车
     :param cmcId: 控制器编号
     :param pmdId: 地磁编号
     :return:
     """
     parkingStateDict = {"无车": 0, "有车": 1}
     obj = SA().execjs("encrypt.js", "encrypt",
                       parkingStateDict.get(parkingState), cmcId, pmdId)
     data = {
         "parkingState": parkingStateDict.get(parkingState),
         "cmcId": cmcId,
         "pmdId": pmdId,
         "key": obj.get("account"),
         "timestamp": obj.get("timestamp"),
         "sign": obj.get("sign"),
         "data": obj.get("data")
     }
     self.url = "/parking/dici/status/update.do"
     re = self.post(self.roadSide_api, data=data, headers=form_headers)
     return re
コード例 #19
0
    def openMonthTicketBill(self, carNum, ticketName, timeperiodListStr):
        """
        开通月票
        :param carNum:
        :param ticketName:
        :param timeperiodListStr: ‘2020-02-01 00:00:00 - 2020-02-29 23:59:59’
        :return:
        """
        if ',' in carNum:
            carNumList = carNum.split(',')
        else:
            carNumList = list()
            carNumList.append(carNum)
        ticketNameDict = self.getDictBykey(self.getValidCofigList(), 'ticketName', ticketName)
        if ticketNameDict['renewMethod'] == 'NATURAL_MONTH':
            openMonthNum = self.__getMonthCount(timeperiodListStr)
        elif ticketNameDict['renewMethod'] == 'CUSTOM':
            openMonthNum = self.__getDayCount(timeperiodListStr)
        price = self.__operationPrice(ticketNameDict['price'])

        json_data = {
            "monthTicketId": ticketNameDict['id'],
            "monthTicketName": ticketNameDict['ticketName'],
            "timeperiodListStr": timeperiodListStr,
            "userName": "******",
            "userPhone": "135{}".format(SA().create_randomNum(val=8)),
            "price": price,
            "totalValue": int(float(price) * openMonthNum * len(carNumList)),
            "openMonthNum": openMonthNum,
            "realValue": 10,
            "inviteCarTotal": len(carNumList),
            "dynamicCarportNumber": 1,
            "carCode": carNumList,
        }
        self.url = "mgr/monthTicketBill/open.do"
        re = self.post(self.api, data=json_data, headers=form_headers)
        return re.json()
コード例 #20
0
    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()
コード例 #21
0
# -*- coding: utf-8 -*-
# @Time    : 2020/3/9 17:27
# @Author  : 叶永彬
# @File    : carTypeConfig.py

from common.Req import Req
from urllib.parse import urlencode
from common.superAction import SuperAction as SA
from common import const
import json

form_headers = {"content-type": "application/x-www-form-urlencoded"}
json_headers = {"content-type": "application/json;charset=UTF-8"}

specialCarTypeDict = {"黑名单": 2, "访客": 1, "预定": 3}
today = SA().get_today_data()
endDate = SA().cal_get_day('%Y-%m-%d', days=1)


class CarType(Req):
    """车辆分类"""
    aList = []

    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,
コード例 #22
0
class Coupon(Req):
    """优惠配置"""
    today = SA().get_today_data()
    endDate = SA().cal_get_day('%Y-%m-%d', days=1)

    def addCoupon(self,
                  couponName,
                  parkName,
                  traderName,
                  couponType='免费劵',
                  couponRule=0,
                  faceValue=0,
                  chargeGroupName=None,
                  isCover=0):
        """
        创建优惠劵
        :param couponName:
        :param parkName:
        :param traderName:
        :param couponType:优惠劵类型
        :param faceValue: 各个优惠劵的优惠值(‘免费劵’和‘不同计价劵’不用填写)
        :param chargeGroupName: 不同计价劵填写收费组名
        :param couponRule:扣减类型,时间劵才要填写
        :param isCover: 是否叠加(‘金额扣减劵’‘时间劵’才可填写)
        :return:
        """
        # parkDict = self.getDictBykey(self.__getParkingBaseDataTree().json(),'name',parkName)
        parkDict = self.getDictBykey(self.__getParkingBaseDataTree().json(),
                                     'name', parkName)
        traderDict = self.getDictBykey(
            self.__getTrader2Sell(parkDict['value']).json(), 'name',
            traderName)
        if str(couponType) == '不同计价券':
            if parkDict.get('parkSysType') == 1:
                chargeGroupDict = self.getDictBykey(
                    self.__selectChargeGroupList(parkDict['parkId']).json(),
                    'typeName', chargeGroupName)
                faceValue = chargeGroupDict['chargeTypeSeq']
            else:
                faceValue = chargeGroupName
        if str(couponType) == '金额折扣券':
            faceValue = int(faceValue) / 10
        json_data = {
            "name": couponName,
            "parkList[0]": parkDict['value'],
            "inputParks[0]": parkDict['name'],
            "balanceType": "0",
            "validDay": "1440",
            "couponType": couponTypeDict[couponType],  # 优惠劵类型
            "faceValue":
            faceValue,  # 各个优惠劵的优惠值(‘免费劵’默认0,不同计价劵会自动获取计费组的typeSeq)
            "originalPrice": "11",  #券原价
            "realPrice": "11",  # 折扣价
            "useRuleMin": "0",
            "useRuleMax": "9999",
            "totalNum": "0",
            "isLimitTotal": "1",
            "couponRule": couponRule,
            "useParkingFee": "0",
            "maxCoverNum": "2",
            "expireRefund": "0",
            "financialParkId": parkDict['value'],
            "isCover": isCover,  # 是否叠加
            "datePrivilegeType": 0,
            "priDateArrStr": None,
            "datePrivilege": 0,
            "useRule": "0~9999",
            "sellFrom": SA().get_today_data() + " 00:00:00",
            "sellTo":
            SA().cal_get_day(strType="%Y-%m-%d", days=365) + " 23:59:59",
            "validFrom": SA().get_today_data() + " 00:00:00",
            "validTo":
            SA().cal_get_day(strType="%Y-%m-%d", days=365) + " 23:59:59",
            "traderIdListStr": traderDict['id']
        }
        self.url = "/mgr/coupon/add.do"
        re = self.post(self.api, data=json_data, headers=form_headers)
        return re.json()

    def __getParkingBaseDataTree(self):
        """获取当前用户停车场权限列表树"""
        # self.url = "/mgr/coupon/getParkingBaseDataTree.do"
        self.url = "/mgr/parkingBaseData/getParkingBaseDataTree.do"
        re = self.get(self.api, headers=form_headers)
        return re

    def __selectChargeGroupList(self, parkUUid):
        """列取车场计费组"""
        data = {"parkIdList": parkUUid}
        self.url = "/mgr/coupon/selectChargeGroupList2?" + urlencode(data)
        re = self.get(self.api, headers=form_headers)
        return re

    def __getTrader2Sell(self, parkId):
        """获取商家列表"""
        form_data = {
            "parkIds": parkId,
            "sort": True  # 是否排序
        }
        self.url = "/mgr/coupon/getTrader2Sell.do?" + urlencode(form_data)
        re = self.get(self.api, headers=form_headers)
        return re

    def addSell(self,
                couponName,
                parkName,
                traderName,
                sellNum=1,
                sellMoney=None):
        """
        售卖商家劵
        :param traderName: 商家名
        :param parkName: 停车场名
        :param couponName: 优惠劵名
        :param sellNum: 数量(默认1张)
        :param sellMoney:商家折扣价 (不填自动取总数)
        :return:
        """
        couponDict = self.getDictBykey(self.getCouponListByPage(parkName),
                                       'name', couponName)
        couponParkDict = self.getDictBykey(
            self.__getCouponParkList(couponDict['tmpId']).json(), 'name',
            parkName)
        traderDict = self.getDictBykey(
            self.__getTraderList(couponParkDict['id'], traderName), 'name',
            traderName)
        totalMoney = int(couponDict['originalPrice']) * int(sellNum)
        if sellMoney == None:
            sellMoney = totalMoney
        json_data = {
            "coupon": "0",
            "realPrice": couponDict['originalPrice'],
            "originalPrice": couponDict['originalPrice'],
            "traderName": traderName,
            "traderId": traderDict.get("id"),
            "totalAvilableToBuy": 0,
            "maxBuyNum": 0,
            "sellNum": sellNum,
            "totalMoney": totalMoney,
            "sellMoney": sellMoney,
            "couponTmpId": couponDict['tmpId']
        }
        self.url = "/mgr/coupon/sell/add.do"
        sleep(3)
        re = self.post(self.api, data=json_data, headers=form_headers)
        return re.json()

    def __getCouponParkList(self, couponTmpId):
        """查看当前劵的使用停车场列表"""

        data = {"couponTmpId": couponTmpId}
        self.url = "/mgr/coupon/couponParkList.do?" + urlencode(data)
        re = self.get(self.api, headers=form_headers)
        return re

    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 __getTraderList(self, parkId, traderName):
        """
        在优惠配置,销售劵,获取商家信息列表
        :return:
        """
        form_data = {
            "query_parkId": parkId,
            "name": traderName,
            "page": 1,
            "rp": 10
        }
        self.url = '/mgr/coupon/sell/getTraderListByPage.do?' + urlencode(
            form_data)
        re = self.get(self.api, headers=json_headers)
        return re.json()['data']['rows']

    def getCouponGrantList(self, parkName, carNum):
        """
        优惠劵发放记录
        :param parkName:
        :param carNum: 发放车牌
        :return:
        """
        parkDict = self.getDictBykey(self.__getParkingBaseDataTree().json(),
                                     'name', parkName)
        self.url = "/mgr/coupon/getCouponGrantList.do?page=1&rp=20&query_parkId=" + str(
            parkDict['value']
        ) + "&parkSysType=1&beginTime=" + self.today + "+00:00:00&endTime=" + self.today + "+23:59:59&carCode=" + carNum
        re = self.get(self.api, headers=json_headers)
        return re.json()['data']['rows']

    def getCouponSerialList(self, parkName, carNum):
        """
        优惠劵使用记录
        :param parkName:
        :param carNum: 使用车牌
        :return:
        """
        parkDict = self.getDictBykey(self.__getParkingBaseDataTree().json(),
                                     'name', parkName)
        self.url = "/mgr/coupon/getCouponSerialList.do?page=1&rp=20&query_parkId=" + str(
            parkDict['value']
        ) + "&beginTime=" + self.today + "+00:00:00&endTime=" + self.endDate + "+23:59:59&carCode=" + carNum
        sleep(3)
        re = self.get(self.api, headers=json_headers)
        return re.json()['data']['rows']

    def getCityCouponUseRecord(self, parkName, carNum):
        """查看城市劵使用记录"""
        parkDict = self.getDictBykey(self.__getParkingBaseDataTree().json(),
                                     "name", parkName)
        data = {
            "page": 1,
            "rp": 20,
            "query_useTimeFrom": self.today + " 00:00:00",
            "query_useTimeTo": self.endDate + " 23:59:59",
            "query_carCode": carNum,
            "parkIds": parkDict['value'],
            "parkSysType": 1
        }
        self.url = "/mgr/cityCoupon/useRecord/list.do?" + urlencode(data)
        re = self.get(self.api, headers=json_headers)
        return re.json()
コード例 #23
0
 def addCoupon(self,
               couponName,
               parkName,
               traderName,
               couponType='免费劵',
               couponRule=0,
               faceValue=0,
               chargeGroupName=None,
               isCover=0):
     """
     创建优惠劵
     :param couponName:
     :param parkName:
     :param traderName:
     :param couponType:优惠劵类型
     :param faceValue: 各个优惠劵的优惠值(‘免费劵’和‘不同计价劵’不用填写)
     :param chargeGroupName: 不同计价劵填写收费组名
     :param couponRule:扣减类型,时间劵才要填写
     :param isCover: 是否叠加(‘金额扣减劵’‘时间劵’才可填写)
     :return:
     """
     # parkDict = self.getDictBykey(self.__getParkingBaseDataTree().json(),'name',parkName)
     parkDict = self.getDictBykey(self.__getParkingBaseDataTree().json(),
                                  'name', parkName)
     traderDict = self.getDictBykey(
         self.__getTrader2Sell(parkDict['value']).json(), 'name',
         traderName)
     if str(couponType) == '不同计价券':
         if parkDict.get('parkSysType') == 1:
             chargeGroupDict = self.getDictBykey(
                 self.__selectChargeGroupList(parkDict['parkId']).json(),
                 'typeName', chargeGroupName)
             faceValue = chargeGroupDict['chargeTypeSeq']
         else:
             faceValue = chargeGroupName
     if str(couponType) == '金额折扣券':
         faceValue = int(faceValue) / 10
     json_data = {
         "name": couponName,
         "parkList[0]": parkDict['value'],
         "inputParks[0]": parkDict['name'],
         "balanceType": "0",
         "validDay": "1440",
         "couponType": couponTypeDict[couponType],  # 优惠劵类型
         "faceValue":
         faceValue,  # 各个优惠劵的优惠值(‘免费劵’默认0,不同计价劵会自动获取计费组的typeSeq)
         "originalPrice": "11",  #券原价
         "realPrice": "11",  # 折扣价
         "useRuleMin": "0",
         "useRuleMax": "9999",
         "totalNum": "0",
         "isLimitTotal": "1",
         "couponRule": couponRule,
         "useParkingFee": "0",
         "maxCoverNum": "2",
         "expireRefund": "0",
         "financialParkId": parkDict['value'],
         "isCover": isCover,  # 是否叠加
         "datePrivilegeType": 0,
         "priDateArrStr": None,
         "datePrivilege": 0,
         "useRule": "0~9999",
         "sellFrom": SA().get_today_data() + " 00:00:00",
         "sellTo":
         SA().cal_get_day(strType="%Y-%m-%d", days=365) + " 23:59:59",
         "validFrom": SA().get_today_data() + " 00:00:00",
         "validTo":
         SA().cal_get_day(strType="%Y-%m-%d", days=365) + " 23:59:59",
         "traderIdListStr": traderDict['id']
     }
     self.url = "/mgr/coupon/add.do"
     re = self.post(self.api, data=json_data, headers=form_headers)
     return re.json()
コード例 #24
0
 def addOperatorPark(self, activationCode, parkName, picName='pic.jpg'):
     """增加停车场配置信息"""
     picPath = os.path.join(root_path, 'upload', picName)
     data = {
         "parkBaseInfo": {
             "address": "佛山市南海区桂城街道万科广场",
             "areaFullPath": "110000000.110100000.110101000",
             "areaID": "110101000",
             "areaName": "北京市-市辖区-东城区",
             "chargePicChangeFlag": False,
             "chargeRulePicStr": "{}".format(SA().getPicBase64(picPath)),
             "chargeRulePicType": "jpeg",
             "chargeRulePicUrl": "",
             "customParkCode": "",
             "flagTag": "",
             "freeTime": "",
             "fullPath": "",
             "gpsX": "116.416443",
             "gpsY": "39.927711",
             "id": None,
             "isTemplatePay": False,
             "isTradecouponOnlinesettle": False,
             "name": parkName,
             "parkCode": "",
             "parkType": 0,
             "parkingSupervisor": SA.create_name(),
             "parkingSupervisorPhone": 13800137999,
             "partWay": 0,
             "picChangeFlag": False,
             "picPath": "",
             "picStr": "{}".format(SA().getPicBase64(picPath)),
             "picType": "jpeg",
             "pkGlobalid": "",
             "slotsNumber": 100,
             "tempCarports": 10,
             "timeoutLength": "10",
             "parkSysType": 0,
             "fixNumber": 90
         },
         "operatorInitInfo": {
             "activationCode": activationCode,
             "protocolKey": ""
         },
         "parkChargeBaseVoList": [{
             "typeName":
             "计费组1",
             "actionType":
             0,
             "carType":
             False,
             "chargeTypeSeq":
             0,
             "isDefault":
             True,
             "isFree":
             "收费车场",
             "uiOpt": {
                 "isShow":
                 True,
                 "carTypeOpt": [{
                     "name": "蓝牌车",
                     "value": 1,
                     "disabled": False
                 }, {
                     "name": "黄牌车",
                     "value": 2,
                     "disabled": False
                 }, {
                     "name": "新能源小车",
                     "value": 4,
                     "disabled": False
                 }, {
                     "name": "新能源大车",
                     "value": 3,
                     "disabled": False
                 }, {
                     "name": "不区分",
                     "value": 0,
                     "disabled": False
                 }]
             },
             "parkChargeStandardVoList": [{
                 "uiOpt": {
                     "splitTimeOpt": ["不分时段", "分时段"],
                     "curSplitTime": "不分时段",
                     "splitTimeCount": 2,
                     "isMaxCharge": False,
                     "customIsMaxCharge": False,
                     "curTimeType": "分钟",
                     "isShowRuleDetail": True
                 },
                 "actionType":
                 0,
                 "carType":
                 0,
                 "chargeTypeSeq":
                 0,
                 "chargeUnit":
                 "",
                 "cmxSettleType":
                 0,
                 "customMaxCharge":
                 "",
                 "customMaxUnit":
                 "",
                 "freeTime":
                 9,
                 "freeTimeAcc":
                 False,
                 "loopType":
                 1,
                 "maxCharge":
                 "",
                 "minCharge":
                 0,
                 "mxSettleType":
                 0,
                 "natureDay":
                 0,
                 "natureFreeTime":
                 0,
                 "parkChargeStandardPeriodVoList": [{
                     "uiOpt": {
                         "ruleTypeOpt": ["按次定额收费", "按单价收费", "递增收费"],
                         "curRuleType": "按次定额收费"
                     },
                     "maxCharge":
                     0,
                     "mxSettleType":
                     0,
                     "parkChargeStandardPeriodDetailVoList": [{
                         "chargeAmount":
                         5,
                         "chargeType":
                         3,
                         "chargeUnit":
                         1,
                         "periodDetailSeq":
                         "",
                         "standardPeriodSeq":
                         "",
                         "stepType":
                         None
                     }],
                     "standardPeriodSeq":
                     "",
                     "standardSeq":
                     "",
                     "timeArray": ["00:00:00", "23:59:59"]
                 }],
                 "remark":
                 "",
                 "standardName":
                 "默认规则",
                 "standardSeq":
                 0,
                 "startTime":
                 "00:00:00",
                 "type":
                 0
             }]
         }],
         "parkSpecialChargeVoList": [],
         "channelVoList": [{
             "uiOpt": {
                 "isShow":
                 False,
                 "curTab":
                 "语音播报",
                 "tabData": ["语音播报", "更多设置"],
                 "voiceOpenPeriod": ["00:00", "23:59"],
                 "displayContentArray": [[{
                     "key": "%CN",
                     "text": "通道名称",
                     "previewText": ""
                 }], [{
                     "key": "%T",
                     "text": "时间",
                     "previewText": ""
                 }], [], []],
                 "screenSettingType":
                 "1"
             },
             "qrcodePicUrl":
             "",
             "actionType":
             0,
             "areaID":
             0,
             "blacklistPassMode":
             1,
             "boxId":
             0,
             "boxStatus":
             0,
             "customCode":
             "",
             "deviceNetModel":
             0,
             "deviceVolume":
             50,
             "displayContent":
             "{\"displayContentArray\":[[\"%CN\"],[\"%T\"],[],[]]}",
             "displayViewModel":
             0,
             "dynamicVipToNormalMode":
             2,
             "enable":
             True,
             "entranceName":
             "入口{}".format(SA().create_randomNum(val=2)),
             "entranceType":
             1,
             "id":
             0,
             "isRootChannel":
             False,
             "isSelfOpenGate":
             0,
             "localVipCarPassMode":
             2,
             "noChannelMode":
             2,
             "noPlatePassMode":
             3,
             "normalCarPassMode":
             2,
             "parkCode":
             "",
             "parkGlobalID":
             "",
             "parkName":
             "",
             "qrCodeStr":
             "",
             "qrCodeValue":
             "",
             "redListPassMode":
             2,
             "settlementType":
             0,
             "shareListPassMode":
             0,
             "thirdPartyVipCarPassMode":
             0,
             "timeArray": ["00:00", "23:59"],
             "vipNotInPassMode":
             2,
             "visitorListPassMode":
             1,
             "voiceOpenPeriod":
             "00:00-23:59",
             "ytjSeq":
             0,
             "ytjStatus":
             0
         }, {
             "uiOpt": {
                 "isShow":
                 False,
                 "curTab":
                 "语音播报",
                 "tabData": ["语音播报", "更多设置"],
                 "voiceOpenPeriod": ["00:00", "23:59"],
                 "displayContentArray": [[{
                     "key": "%CN",
                     "text": "通道名称",
                     "previewText": ""
                 }], [{
                     "key": "%T",
                     "text": "时间",
                     "previewText": ""
                 }], [], []],
                 "screenSettingType":
                 "1"
             },
             "qrcodePicUrl":
             "",
             "actionType":
             0,
             "areaID":
             0,
             "blacklistPassMode":
             1,
             "boxId":
             0,
             "boxStatus":
             0,
             "customCode":
             "",
             "deviceNetModel":
             0,
             "deviceVolume":
             50,
             "displayContent":
             "{\"displayContentArray\":[[\"%CN\"],[\"%T\"],[],[]]}",
             "displayViewModel":
             0,
             "dynamicVipToNormalMode":
             2,
             "enable":
             True,
             "entranceName":
             "出口{}".format(SA().create_randomNum(val=2)),
             "entranceType":
             2,
             "id":
             0,
             "isRootChannel":
             False,
             "isSelfOpenGate":
             0,
             "localVipCarPassMode":
             2,
             "noChannelMode":
             2,
             "noPlatePassMode":
             3,
             "normalCarPassMode":
             2,
             "parkCode":
             "",
             "parkGlobalID":
             "",
             "parkName":
             "",
             "qrCodeStr":
             "",
             "qrCodeValue":
             "",
             "redListPassMode":
             2,
             "settlementType":
             0,
             "shareListPassMode":
             0,
             "thirdPartyVipCarPassMode":
             0,
             "timeArray": ["00:00", "23:59"],
             "vipNotInPassMode":
             2,
             "visitorListPassMode":
             1,
             "voiceOpenPeriod":
             "00:00-23:59",
             "ytjSeq":
             0,
             "ytjStatus":
             0
         }],
         "parkCloudDetailVo": {
             "defaultProvince": "京"
         }
     }
     re = self.__isExistParkName(parkName)
     if re.json()['status'] == 1:
         re = self.__checkValidateCode(activationCode)
         if re.json()['status'] == 1:
             self.url = "/mgr/operatorPark/addOperatorPark"
             re = self.post(self.api, json=data, headers=json_headers)
     return re.json()
コード例 #25
0
class Information(Req):
    """
    信息查询
    """
    api_headers = {"Content-Type": "application/json;charset=UTF-8"}
    form_headers = {"content-type": "application/x-www-form-urlencoded"}
    data = SA().get_today_data()
    endDate = SA().cal_get_day('%Y-%m-%d',days=1)

    def getPresentCar(self,parkName,carNum = ""):
        """
        获取在场车场
        :param parkId:
        :return:
        """
        parkDict = self.getDictBykey(self.__getParkingBaseTree().json(),'name',parkName)
        data = {
            "page":1,
            "rp":5,
            "approchTimeFrom":self.data +" 00:00:00",
            "approchTimeTo":self.endDate +" 23:59:59",
            "parkIds":parkDict['value'],
            "parkSysType":parkDict['parkSysType'],
            "plate":carNum
        }
        self.url = "/mgr/park/presentCar/getPresentCar.do?" + urlencode(data)
        re = self.get(self.api,headers= self.api_headers)
        return re.json()["data"]["rows"]

    def getCarLeaveHistory(self,parkName,carNum):
        """
        获取进出场记录
        :param parkId:
        :return:
        """
        parkDict = self.getDictBykey(self.__getParkingBaseTree().json(), 'name', parkName)
        data = {
            "page":1,
            "rp":1,
            "fromLeaveTime":self.data + " 00:00:00",
            "toLeaveTime":self.endDate +" 23:59:59",
            "query_carNo":carNum,
            "parkIds":parkDict['value'],
            "parkSysType":parkDict['parkSysType']
        }
        self.url = "/mgr/park/carLeaveHistory/pageListParkingRecord.do?" + urlencode(data)
        re = self.get(self.api,headers= self.api_headers)
        return re.json()["data"]["rows"]

    def getParkingBillDetail(self,parkName,carNum):
        """
        获取收费记录
        :param parkId:
        :return:
        """
        parkDict = self.getDictBykey(self.__getParkingBaseTree().json(), 'name', parkName)
        data = {
            "page":1,
            "rp":1,
            "query_payTimeFrom":self.data + " 00:00:00",
            "query_payTimeTo":self.endDate + " 23:59:59",
            "query_carCode":carNum,
            "parkIds":parkDict['value']
        }
        self.url = "/mgr/park/parkingBillDetail/list.do?" + urlencode(data)
        time.sleep(3)
        re = self.get(self.api, headers=self.api_headers)
        return re.json()['data']['rows']

    def getAdjustCarWaterNum(self,newCarCode,parkName):
        """
        获取校正流水
        :return:
        """
        parkDict = self.getDictBykey(self.__getParkingBaseTree().json(), 'name', parkName)
        data = {
            "page":1,
            "rp":20,
            "newCarCode":newCarCode,
            "modifyDateFrom": self.data + " 00:00:00",
            "modifyDateTo":self.endDate +" 23:59:59",
            "parkIds":parkDict['value']
        }
        self.url = "/mgr/park/adjustCarRecord/getAdjustCarRecord.do?" + urlencode(data)
        re = self.get(self.api, headers=self.api_headers)
        return re.json()["data"]["rows"]


    def getAbnormalInCar(self, parkName, carCode):
        """
        获取异常进场记录
        :return:
        """
        parkDict = self.getDictBykey(self.__getParkingBaseTree().json(), 'name', parkName)
        data = {
            "page":1,
            "rp":20,
            "carCode": carCode,
            "modifyDateFrom": self.data + " 00:00:00",
            "modifyDateTo":self.endDate +" 23:59:59",
            "parkIds":parkDict['value'],
            "parkSysType": parkDict['parkSysType']
        }
        self.url = "mgr/park/abnormalInCar/getAbnormalInCar.do?" + urlencode(data)
        re = self.get(self.api, headers=self.api_headers)
        return re.json()['data']['rows']

    def getAbnormalPicCar(self, parkName, carCode):
        """
        获取异常拍照记录
        :return:
        """
        parkDict = self.getDictBykey(self.__getParkingBaseTree().json(), 'name', parkName)
        data = {
            "page":1,
            "rp":20,
            "carCode": carCode,
            "modifyDateFrom": self.data + " 00:00:00",
            "modifyDateTo":self.endDate +" 23:59:59",
            "parkIds":parkDict['value'],
            "parkSysType": parkDict['parkSysType']
        }
        self.url = "mgr/park/parkAbnormalPicCar/getParkAbnormalPicCar.do?" + urlencode(data)
        re = self.get(self.api, headers=self.api_headers)
        return re.json()['data']['rows']

    def __getParkingBaseTree(self):
        """获取当前用户车场树信息"""
        self.url = "/mgr/parkingBaseData/getParkingBaseDataTree.do"
        re = self.get(self.api,headers=self.api_headers)
        return re

    def getEmergencyCarRecord(self, parkName, carType, carNum):
        """查询指定车牌告警记录"""
        carTypeDict = {"指定车辆": 0, "黑名单": 4, "白名单": 8}
        parkDict = self.getDictBykey(self.__getParkingBaseTree().json(), 'name', parkName)
        data = {
            "page":1,
            "pageSize": 1,
            "carType": carTypeDict[carType],
            "carCode": carNum,
            "createTimeFrom": self.data + " 00:00:00",
            "createTimeTo": self.endDate +" 23:59:59",
            "parkIds": parkDict['value'],
            "parkSysType": parkDict['parkSysType'],
        }
        self.url = "/mgr/park/emergency/record/list.do?" + urlencode(data)
        re = self.get(self.api, headers = self.api_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 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 __autoClearCarByTime(self, clearTime, parkUUID, operatorName):
        """智能盘点-按时间盘点方式"""
        data = {
            "clearTime": clearTime,
            "parkUUID": parkUUID,
            "comment": 'pytest智能盘点',
            "operatorName": operatorName
        }
        if self.__getPresentCarByTime(clearTime, parkUUID).json()['message'] == "OK":
            self.url = "/mgr/park/presentCar/clearByTime?" + urlencode(data)
            re = self.post(self.api, headers=self.api_headers)
            return re


    def __getPresentCarByTime(self, clearTime, parkUUID):
        """按时间获取在场车辆数量"""
        data = {
            "clearTime": clearTime,
            "parkUUID": parkUUID
        }
        self.url = "/mgr/park/presentCar/clearByTimeCheck?" + urlencode(data)
        re = self.post(self.api, headers=self.api_headers)
        return re

    def __autoClearCarCheck(self, clearTime, operatorName, parkUUID, file):
        """按模板获取在场车场信息记录"""
        files = {
            "autoClearFile": open(file, 'rb')
        }

        data = {
            "clearTime": clearTime,
            "operatorName": operatorName,
            "parkUUID": parkUUID
        }
        self.url = "/mgr/park/presentCar/autoClearCarCheck?" + urlencode(data)
        re = self.post(self.api, files=files, headers={'User-Agent':'Chrome/71.0.3578.98 Safari/537.36'})
        return re

    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 __setCarNumInClearCarFile(self, file, presentCarNum):
        """往盘点车辆文件设置在场车牌"""
        import xlrd
        from xlutils.copy import copy
        old_excel = xlrd.open_workbook(file, formatting_info=True)
        new_excel = copy(old_excel)
        ws = new_excel.get_sheet(0)
        presentCarNum = presentCarNum.replace(',',',')
        if ',' in presentCarNum:
            carNum = presentCarNum.split(',')
            for index, v in enumerate(carNum):
                ws.write(2 + index, 0, v)
        else:
            ws.write(2, 0, presentCarNum)
        new_excel.save(file)

    def getSystemLog(self, menuLevel = None, operationObject = None):
        """查看系统日志"""
        data = {
            "page": 1,
            "rp": 1,
            "query_startTime": self.data + " 00:00:00",
            "query_endTime": self.endDate +" 23:59:59",
            "query_menuLevel": menuLevel,
            "query_operationObject": operationObject
        }
        self.url = "/mgr/pomplog/list.do"
        re = self.post(self.api, data = data, headers = self.form_headers)
        return re.json()['data']['rows']
コード例 #26
0
    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()