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
Beispiel #2
0
def modif_date(data):
    """
    初始化请求时修改时间
    :param data:
    :return:
    """
    data["order"][0]['inserttime'] = TimeFormat.getnow()
    start, end = get_data()
    data["order"][0]["dealtime"] = TimeFormat.random_time(start, end)
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
Beispiel #4
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