예제 #1
0
def get_time_step2(time_day, time_step):
    # 前开后闭
    if time_step == '早晨':
        start_time, end_time = time_day + " " + "5:30:00", time_day + " " + "11:30:00"
    elif time_step == '中午':
        start_time, end_time = time_day + " " + "11:30:00", time_day + " " + "13:30:00"
    elif time_step == '下午':
        start_time, end_time = time_day + " " + "13:30:00", time_day + " " + "17:30:00"
    elif time_step == '晚上':
        start_time, end_time = time_day + " " + "17:30:00", time_day + " " + "23:30:00"
    elif time_step == '凌晨':
        start_time1, end_time1 = time_day + " " + "23:30:00", time_day + " " + "23:59:59"
        start_time2, end_time2 = time_day + " " + "00:00:00", time_day + " " + "05:30:00"
        start_time, end_time = random.choice(
            ((start_time1, end_time1), (start_time2, end_time2)))
    else:
        start_time, end_time = time_day + " " + "13:30:00", time_day + " " + "17:30:00"
    e_time = TimeFormat.random_time(start_time, end_time)
    e_day, e_hms = e_time.split(' ')
    now = TimeFormat.getnow()
    n_hms = now.split(' ')[-1]
    e_time_num = int(TimeFormat.string_toTimestamp_13(e_time))
    n_time_num = int(TimeFormat.string_toTimestamp_13(e_day + ' ' + n_hms))
    if e_time_num <= n_time_num:
        e_time = TimeFormat.get_day_around(1, e_day) + ' ' + e_hms
    return e_time
예제 #2
0
def get_time_step07(time_day):
    # 前开后闭
    start_time, end_time = time_day + " " + "00:00:00", time_day + " " + "07:00:00"
    e_time = TimeFormat.random_time(start_time, end_time)
    e_day, e_hms = e_time.split(' ')
    now = TimeFormat.getnow()
    n_hms = now.split(' ')[-1]
    e_time_num = int(TimeFormat.string_toTimestamp_13(e_time))
    n_time_num = int(TimeFormat.string_toTimestamp_13(e_day + ' ' + n_hms))
    if e_time_num <= n_time_num:
        e_time = TimeFormat.get_day_around(1, e_day) + ' ' + e_hms
    return e_time
예제 #3
0
 def test_028_api_78dk_platform_om_trans_findTransLogList_now(self):
     """
     交易流水列表  今天
     :return:
     """
     res = json.loads(WebAction.test_api_78dk_platform_om_trans_findTransLogList(
         pagesize=10, pagecurrent=1, enddate=TimeFormat.get_now_time_13(), transstate='',
         begindate=TimeFormat.string_toTimestamp_13(TimeFormat.get_day_start_time(0)), searchwhere='', transtype=''))
     Assertion.verity(res['code'], '10000')
     Assertion.verity(res['msg'], '成功')
예제 #4
0
def get_days(month, premise, params):
    """
    几月距离今天的天数
    :param month:  几月
    :param premise:  请求参数
    :param params:  请求参数
    :return:
    """
    calls_items = list()
    for items in params['calls']:
        calls_items.extend(items['items'])
    calls_days = list()
    if premise == 'no_dial_day':
        dial_calls_days = list(
            filter(lambda x: x['dial_type'] == 'dial', calls_items))
        calls_days = [t['time'] for t in dial_calls_days]
    elif premise == 'no_call_day':
        calls_days = [t['time'] for t in calls_items]
    elif premise in ('power_off_day', 'continue_power_off_days'):
        calls_days = [t['time'] for t in calls_items]
        smses_items = list()
        for items in params['smses']:
            smses_items.extend(items['items'])
        smses_days = [
            '-'.join(t['time'].split('-')[:3]) + ' ' + t['time'].split('-')[-1]
            for t in smses_items
        ]
        calls_days.extend(smses_days)
    on_days = list(set(calls_days))
    now, times = TimeFormat.getnow().split(' ')
    now_time = TimeFormat.get_now_time_13()
    if month == '7':
        day = TimeFormat.get_day_around(-7)
    else:
        time_day = TimeFormat.get_month_ago(int(month))
        day = time_day.split(' ')[0]
    day_time = TimeFormat.string_toTimestamp_13(day + ' ' + times)
    days_num = len(
        list(
            filter(
                lambda x: day_time < int(TimeFormat.string_toTimestamp_13(x))
                <= now_time, on_days)))
    return str(TimeFormat.time_between_day(day, now) - days_num)
예제 #5
0
 def test_005_api_78dk_platform_sys_user_saveSystemUser_now_days(self):
     """
     合同列表查询(申请列表) 最近30天
     :return:
     """
     res = json.loads(
         WebAction.test_api_78dk_platform_om_contract_viewContracts(
             pagecurrent=1, orderstate='', enddate=TimeFormat.get_now_time_13(),
             begindate=TimeFormat.string_toTimestamp_13(TimeFormat.get_day_start_time(0)), pagesize=10, name=''))
     Assertion.verity(res['code'], '10000')
     Assertion.verity(res['msg'], '成功')
예제 #6
0
 def test_006_api_78dk_clientapp_tools_carEva_vinEva(self):
     """
       Time       :2019-04-25
       author     : 罗林
       desc       : VIN估价
     """
     rs = ea_app.test_api_78dk_clientapp_tools_carEva_vinEva(
         citycode=510100,
         miles=10000,
         oncardate=tf.string_toTimestamp_13('2015-04-25 00:00:00'),
         vincode=vincode)
     ass.verity(json.loads(rs)['code'], "10000")
예제 #7
0
 def test_002_api_78dk_clientapp_auth_messAuth_addCarInfo(self):
     """
       Time       :2019-04-25
       author     : 罗林
       desc       : 车辆认证
     """
     vehicleauthuuid, brandname, city, modelid, modelname, registertime, seriesid, seriesname = eq.get_info(
         'vehicle_auth', 'vehicle_auth_uuid,brand_name,city,model_id,model_name,register_time,series_id,series_name')
     registertime = tf.string_toTimestamp_13(tf.datetime_toString(registertime, tf.FORMART1))
     rs = ea_app.test_api_78dk_clientapp_auth_messAuth_addCarInfo(
         brandid='', seriesid=seriesid, city=city, registertime=registertime, modelid=modelid,
         vehicleauthuuid=vehicleauthuuid, seriesname=seriesname, brandname=brandname, modelname=modelname)
     ass.verity(json.loads(rs)['code'], "10000")
예제 #8
0
def test_sht_login():
    """
    商户通 获取 token
    :return:
    """
    redis_keys = redisDB.get_keys()
    for redis_key in redis_keys:
        if wx_name in redisDB.redis_get(redis_key):
            redisDB.del_name(redis_key)
    uuid_str = str(uuid.uuid4()).replace("-", "")
    wx_name_prefix = 'wxuser_' + wx_open_id
    wx_token = hashlib.md5(
        (wx_name_prefix + uuid_str).encode("utf-8")).hexdigest()
    wx_user_name = wx_name_prefix + wx_token
    wx_phone = 'https://wx.qlogo.cn/mmopen/vi_32' \
               '/Q0j4TwGTfTJInkWfFr8ftFB8TYjb78xiamRc9bqRDkJKZHliaeHLdldQjeGdtqIzl659XHEcBxicBeRHQq5wBOvpw/132'
    c_time = TimeFormat.getnow()
    state = 'enabled'
    created = TimeFormat.string_toTimestamp_13(c_time)
    rows = ms.select_rows(DB, 'Tbl_WX_User', 'id',
                          'name="{}" AND state="enabled"'.format(wx_name))
    if rows == 0:
        insert_dict = {
            "wx_user_uuid": wxUserUuid,
            "merchant_uuid": "",
            "name": wx_name,
            "phone": wx_phone,
            "open_id": wx_open_id,
            "is_master": wx_isMaster,
            "created": c_time,
            "updated": c_time,
            "state": state
        }
        ms.insert(DB, 'Tbl_WX_User', insert_dict)
    m_id = ms.select_one(DB, 'Tbl_WX_User', 'id',
                         'name="{}" AND state="enabled"'.format(wx_name))
    wx_user_info = {
        'created': created,
        'id': m_id,
        'isMaster': wx_isMaster,
        'merchantUuid': '',
        'name': wx_name,
        'openId': wx_open_id,
        'phone': wx_phone,
        'state': state,
        'token': wx_token,
        'updated': created,
        'wxUserUuid': wxUserUuid
    }
    redisDB.redis_set(wx_user_name, json.dumps(json.dumps(wx_user_info)))
    return wx_token
예제 #9
0
 def test_005_api_78dk_clientapp_tools_carEva_carTypeEva(self):
     """
       Time       :2019-04-25
       author     : 罗林
       desc       : 车型估价
     """
     rs = ea_app.test_api_78dk_clientapp_tools_carEva_carTypeEva(
         carcode=car_code,
         citycode=510100,
         miles=10000,
         oncardate=tf.string_toTimestamp_13('2015-04-25 00:00:00'),
         brandid=1,
         modelname='奥迪A3')
     ass.verity(json.loads(rs)['code'], "10000")
예제 #10
0
def modif(data, modif_key, modif_value):
    """
    修改请求数据
    :param data: 请求数据
    :param modif_key:  修改请求数据参数
    :param modif_value: 修改值
    :return:
    carrier: 运营商类型 (联通、移动、电信)
    open_time: 开户时长 (天)
    sex:男,女
    age: 年龄
    total_fee:账期内所有费用
    web_fee:网络流量消费金额(分)
    voice_fee:通话消费金额(分)
    sms_fee:短信消费金额(分)
    extra_service_fee:增值业务消费金额(分)
    extra_fee:其它消费金额(分)
    base_fee:基础消费金额
    sms_cnt:短信次数 (数字)
    sms_fees:短信费用
    location:朋友圈中心城市
    peer_number:朋友联系数量
    location_type:号码类型;国内通话
    dial_type:主叫,被叫 DAIL,DAILED
    duration: 通话时长(秒)
    fee: 通话费用
    time: 通话时段 (早晨,上午,中午,下午,傍晚,晚上,凌晨,深夜)
        早晨(5:30:00-9:00:00)
        上午(9:00:00-11:30:00)
        中午(11:30:00-13:30:00)
        下午(13:30:00-17:30:00)
        傍晚(17:30:00-19:30:00)
        晚上(19:30:00-23:30:00)
        凌晨(23:30:00-01:30:00)
        深夜(01:30:00-05:30:00)
    time2: 通话时段
        早晨(5:30-11:30)
        中午(11:30-13:30)
        下午(13:30-17:30)
        晚上(17:30-23:30)
        凌晨(23:30-5:30)
    time3: 通话时段 0-7点,不用输入参数修改值
    total_size:通话次数
    bill_month:通话月份 (7,1,3,6)
    calls: 通话信息条数 (数字)
    """
    if re.sub('\s+', '', modif_value) == '':
        modif_value = 'null'
    if modif_key == 'carrier':
        # modif_value 输入 联通、移动、电信
        if modif_value in carriers.keys():
            modif_value = carriers[modif_value]
        data["carrier"] = modif_value
    elif modif_key == 'open_time':
        # 输入数字,距离当前时间的天数
        if modif_value.isdigit():
            modif_value = TimeFormat.get_day_around(-int(modif_value))
        data["open_time"] = modif_value
    elif modif_key == 'sex':
        # 输入男、女,自动生成 idcard
        idcard = list(data["idcard"])
        if modif_value == '女':
            v = random.choice('02468')
            idcard[16] = str(v)
            data["idcard"] = ''.join(idcard)
        elif modif_value == '男':
            v = random.choice('13579')
            idcard[16] = str(v)
            data["idcard"] = ''.join(idcard)
        else:
            data["idcard"] = modif_value
    elif modif_key == 'age':
        # 输入年龄,自动生成 idcard
        if modif_value.isdigit():
            idcard = list(data["idcard"])
            time_now = TimeFormat.getnow_day()
            year, month, day = time_now.split('-')
            y = int(year) - int(modif_value)
            idcard[6:14] = ''.join([str(y), month, day])
            data["idcard"] = ''.join(idcard)
        else:
            data["idcard"] = modif_value
    elif modif_key == 'city':
        data["city"] = modif_value
    elif modif_key == 'total_fee':
        data["bills"][0]["total_fee"] = modif_value
    elif modif_key == 'web_fee':
        data["bills"][0]["web_fee"] = modif_value
    elif modif_key == 'voice_fee':
        data["bills"][0]["voice_fee"] = modif_value
    elif modif_key == 'sms_fee':
        data["bills"][0]["sms_fee"] = modif_value
    elif modif_key == 'extra_service_fee':
        data["bills"][0]["extra_service_fee"] = modif_value
    elif modif_key == 'extra_fee':
        data["bills"][0]["extra_fee"] = modif_value
    elif modif_key == 'base_fee':
        data["bills"][0]["base_fee"] = modif_value
    elif modif_key == 'sms_cnt':
        # 输入数字, 自动生成对应数字的短信条数
        if modif_value.isdigit():
            sms = data['smses'][0]
            data['smses'] = [sms for _ in range(int(modif_value))]
        else:
            data['smses'] = []
    elif modif_key == 'sms_fees':
        data['smses'][0]['items'][0]['fee'] = modif_value
    elif modif_key == 'location':
        data["calls"][0]['items'][0]['location'] = modif_value
    elif modif_key == 'peer_number':
        data["calls"][0]['items'][0]['peer_number'] = modif_value
    elif modif_key == 'location_type':
        data["calls"][0]['items'][0]['location_type'] = modif_value
    elif modif_key == 'dial_type':
        # 输入 DAIL 或者 DAILED
        calls = data["calls"][0]
        call = copy.deepcopy(calls)
        call['items'][0]['dial_type'] = modif_value
        data["calls"][0] = call
    elif modif_key == 'duration':
        if modif_value.isdigit():
            modif_value = int(modif_value)
        data["calls"][0]['items'][0]['duration'] = modif_value
    elif modif_key == 'fee':
        data["calls"][0]['items'][0]['fee'] = modif_value
    elif modif_key == 'time':
        # 输入时间段
        #         早晨(5:30:00-9:00:00)
        #         上午(9:00:00-11:30:00)
        #         中午(11:30:00-13:30:00)
        #         下午(13:30:00-17:30:00)
        #         傍晚(17:30:00-19:30:00)
        #         晚上(19:30:00-23:30:00)
        #         凌晨(23:30:00-01:30:00)
        #         深夜(01:30:00-05:30:00)
        if modif_value in ('早晨', '上午', '中午', '下午', '傍晚', '晚上', '凌晨', '深夜'):
            sev_time = data["calls"][0]['items'][0]['time']
            sev_day = sev_time.split(' ')[0]
            data["calls"][0]['items'][0]['time'] = get_time_step(
                sev_day, modif_value)
        else:
            data["calls"][0]['items'][0]['time'] = modif_value
    elif modif_key == 'time2':
        # 输入时间段
        #         早晨(5:30-11:30)
        #         中午(11:30-13:30)
        #         下午(13:30-17:30)
        #         晚上(17:30-23:30)
        #         凌晨(23:30-5:30)
        if modif_value in ('早晨', '中午', '下午', '晚上', '凌晨'):
            sev_time = data["calls"][0]['items'][0]['time']
            sev_day = sev_time.split(' ')[0]
            data["calls"][0]['items'][0]['time'] = get_time_step2(
                sev_day, modif_value)
        else:
            data["calls"][0]['items'][0]['time'] = modif_value
    elif modif_key == 'time3':
        # 输入时间段, 不用输入修改参数值, 直接获取 0-7点
        sev_time = data["calls"][0]['items'][0]['time']
        sev_day = sev_time.split(' ')[0]
        data["calls"][0]['items'][0]['time'] = get_time_step07(sev_day)
    elif modif_key == 'total_size':
        if modif_value.isdigit():
            modif_value = int(modif_value)
        data["calls"][0]['total_size'] = modif_value
    elif modif_key == 'bill_month':
        # 输入修改的月份 7,1,3,6; 7代表7天,其余的都是月份
        times = data["calls"][0]['items'][0]['time']
        time_hmc = times.split(' ')[-1]
        if modif_value == '7':
            start_day = TimeFormat.get_day_around(-7)
            bill_month = '-'.join(start_day.split('-')[:2])
            month_start_date, month_end_date = TimeFormat.get_FirstAndLastDay_month(
                bill_month)
            e_time = start_day + ' ' + time_hmc
            e_time_num = int(TimeFormat.string_toTimestamp_13(e_time))
            n_hms = TimeFormat.getnow().split(' ')[-1]
            n_time_num = int(
                TimeFormat.string_toTimestamp_13(start_day + ' ' + n_hms))
            if e_time_num <= n_time_num:
                e_time = TimeFormat.get_day_around(1,
                                                   start_day) + ' ' + time_hmc
            data["calls"][0]['bill_month'] = bill_month
            data["calls"][0]['items'][0]['time'] = e_time
            data["smses"][0]['bill_month'] = bill_month
            data["smses"][0]['items'][0]['time'] = e_time.replace(' ', '-')
            data["bills"][0]['bill_month'] = bill_month
            data["bills"][0]['bill_start_date'] = month_start_date
            data["bills"][0]['bill_end_date'] = month_end_date
        elif modif_value in ('1', '3', '6'):
            month_day = TimeFormat.get_month_day_ago(int(modif_value))
            year, month, day = month_day.split('-')
            bill_month = year + '-' + month
            month_start_date, month_end_date = TimeFormat.get_FirstAndLastDay_month(
                bill_month)
            data["calls"][0]['bill_month'] = bill_month
            e_time = month_day + ' ' + time_hmc
            e_time_num = int(TimeFormat.string_toTimestamp_13(e_time))
            n_hms = TimeFormat.getnow().split(' ')[-1]
            n_time_num = int(
                TimeFormat.string_toTimestamp_13(month_day + ' ' + n_hms))
            if e_time_num <= n_time_num:
                e_time = TimeFormat.get_day_around(1,
                                                   month_day) + ' ' + time_hmc
            data["calls"][0]['items'][0]['time'] = e_time
            data["smses"][0]['bill_month'] = bill_month
            data["smses"][0]['items'][0]['time'] = e_time.replace(' ', '-')
            data["bills"][0]['bill_month'] = bill_month
            data["bills"][0]['bill_start_date'] = month_start_date
            data["bills"][0]['bill_end_date'] = month_end_date
        else:
            data["calls"][0]['bill_month'] = modif_value
            data["smses"][0]['bill_month'] = modif_value
            data["bills"][0]['bill_month'] = modif_value
    elif modif_key == 'calls':
        # 输入数字,自动生成通话条数
        if modif_value.isdigit():
            calls = data["calls"][0]
            call = copy.deepcopy(calls)
            data["calls"] = [call for _ in range(int(modif_value))]
        else:
            data["calls"] = []