Ejemplo n.º 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
Ejemplo n.º 2
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