Exemple #1
0
def get_data(times=None):
    if times == '1':
        start = TimeFormat.get_month_ago(1)
        end = TimeFormat.get_day_end_time(-7)
    elif times == '3':
        start = TimeFormat.get_month_ago(3)
        end = TimeFormat.get_month_ago(2)
    elif times == '6':
        start = TimeFormat.get_month_ago(6)
        end = TimeFormat.get_month_ago(5)
    elif times == '7':
        start, end = TimeFormat.get_day_start_time(-6), TimeFormat.getnow()
    else:
        start, end = TimeFormat.get_day_start_time(-6), TimeFormat.getnow()
    return start, end
Exemple #2
0
def get_data(times):
    start_time = tianxing_etl['json_data']['data']['report_time']
    start = start_time.split(' ')[0]
    if times == '1' or times == 1:
        end = TimeFormat.get_day_around(-27, start)
    elif times == '3' or times == 3:
        end = TimeFormat.get_month_ago(2, start_time)
    elif times == '6' or times == 6:
        end = TimeFormat.get_month_ago(5, start_time)
    elif times == '7' or times == 7:
        end = TimeFormat.get_day_around(-6, start)
    elif times == '12' or times == 12:
        end = TimeFormat.get_month_ago(11, start_time)
    else:
        end = TimeFormat.get_month_ago(8, start_time)
    return end
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)
def modif_date(data):
    """
    初始化请求时修改时间
    :param data:
    :return:
    """
    sev_time = TimeFormat.get_month_ago(1)
    sev_month = '-'.join(sev_time.split('-')[:2])
    sev_day = sev_time.split(' ')[0]
    sev_hms = data["calls"][0]['items'][0]['time'].split(' ')[-1]
    month_start_date, month_end_date = TimeFormat.get_FirstAndLastDay_month(
        sev_day)
    time_sec = sev_day + ' ' + sev_hms
    data["bills"][0]['bill_month'] = sev_month
    data["bills"][0]['bill_start_date'] = month_start_date
    data["bills"][0]['bill_end_date'] = month_end_date
    data["calls"][0]['bill_month'] = sev_month
    data["calls"][0]['items'][0]['time'] = time_sec
    data["smses"][0]['bill_month'] = sev_month
    data["smses"][0]['items'][0]['time'] = time_sec.replace(' ', '-')
Exemple #5
0
def modif(data, modif_key, modif_value):
    """
    修改京东请求数据
    :param data:
    :param modif_key:
    :param modif_value:
    :return:
    address: 收件人地址
    status:订单状态
    dealtime:下单时间
    name:收件人姓名
    telephone:收件人电话
    amount:订单总价
    goodsPrice:商品单价
    goodsNum:商品数量
    goodsName:商品名称
    amount_total: 总价格
    orderNum:订单数量,查询第一条订单后循环生成相同订单,配合其他条件使用
    """
    if modif_key == "address":
        data["order"][0]["address"] = modif_value
    elif modif_key == "status":
        data["order"][0]["status"] = modif_value
    elif modif_key == "dealtime":
        start, end = get_data(modif_value)
        data["order"][0]["dealtime"] = TimeFormat.random_time(start, end)
    elif modif_key == "first_deal_time":
        if modif_value == '7':
            data["first_deal_time"] = TimeFormat.get_day_end_time(-7)
        else:
            # num = int(modif_value) * 30
            data["first_deal_time"] = TimeFormat.get_month_ago(
                int(modif_value))
    elif modif_key == "name":
        data["order"][0]["name"] = modif_value
    elif modif_key == "telephone":
        data["order"][0]["telephone"] = modif_value
    elif modif_key == "amount":
        data["order"][0]["amount"] = modif_value
    elif modif_key == "goodsPrice":
        data["order"][0]["goods"][0]["goodsPrice"] = FileUtils.str_to_num(
            modif_value)
    elif modif_key == "goodsNum":
        data["order"][0]["goods"][0]["goodsNum"] = FileUtils.str_to_num(
            modif_value)
    elif modif_key == "goodsName":
        data["order"][0]["goods"][0]["goodsName"] = modif_value
    elif modif_key == "amount_total":
        data["order"][0]["amount_total"] = "商品总金额:¥{}".format(
            FileUtils.str_to_num(modif_value))
    elif modif_key == 'orderNum':
        order_info = data["order"][0]
        dealtime = order_info['dealtime'].split(' ')[0]
        orders_info = list()
        for _ in range(int(modif_value)):
            o = copy.deepcopy(order_info)
            o['orderid'] = MockData.strNumber(11)
            o['dealtime'] = TimeFormat.random_time(dealtime + ' 00:00:01',
                                                   dealtime + ' 23:59:59')
            orders_info.append(o)
        data["order"] = orders_info