Esempio n. 1
0
def customer_page(request):
    global user
    global name
    status = customer_data.customer_show()
    if status == 0 :
        product = []
    else :
        product = status
    return render(request,"customer.html",{"user":user,"name":name,"product":product})
Esempio n. 2
0
def cart(request):
    global user
    global name
    global account
    customer,normal_product = cart_data.fetch_cart(account)
    status = customer_data.customer_show()
    if status == 0:
        product = []
    else:
        product = status
    return render(request,"cart.html",{"user":user,"name":name,"customer":customer,"product":product,"normal_product":normal_product})
Esempio n. 3
0
def make_order(account, order_time, name, order_name, phone, address,
               customer_status, normal_status):
    status = customer_data.customer_show()
    if status == 0:
        product_data = []
    else:
        product_data = status
    order_key = order_time + name
    final_customer, final_normal, money = product.fetch_product_order(
        account, customer_status, normal_status)
    real_data = {
        "取貨地址": address,
        "產品資訊": {
            "客製化": final_customer,
            "一般商品": final_normal
        },
        "總金額": money,
        "訂單成立人": order_name,
        "電話": phone
    }
    if final_customer != "":
        for index, data in final_customer.items():
            for data_name, data_count in data.items():
                if data_name in product_data:
                    print(data_count)
                    #print(fb.get('/蔬菜庫存/'+data_name+"/數量",None)[:-1])
                    final_count = int(
                        fb.get('/蔬菜庫存/' + data_name + "/數量",
                               None)) - int(data_count)
                    fb.put('/蔬菜庫存/' + data_name, data=final_count, name="數量")

    if final_normal != "":
        for index, data in final_normal.items():
            for data_name, data_count in data.items():
                if data_name == "數量":
                    count = data_count
                    inventory_count = int(
                        fb.get('/產品資訊/' + index + "/目前存貨", None)) - int(count)
                    fb.put('/產品資訊/' + index, data=inventory_count, name="目前存貨")
                if data_name == "產品資訊":
                    for name, quantity in data_count.items():
                        if name in product_data:
                            final_count = int(
                                fb.get('/蔬菜庫存/' + name + "/數量",
                                       None)) - int(count) * int(quantity[:-1])
                            fb.put('/蔬菜庫存/' + name,
                                   data=final_count,
                                   name="數量")
    print(final_normal)
    print(real_data)
    fb.put('/會員資料/' + account + "/購物紀錄", data=real_data, name=order_key)
    fb.put('/訂單記錄', data=real_data, name=order_key)
Esempio n. 4
0
def order(request):
    global name
    global customer_status
    global normal_status
    global phone
    global address
    global order_name
    global order_time
    global account
    global customer
    global normal
    status = customer_data.customer_show()
    if status == 0:
        product = []
    else:
        product = status
    return render(request,"order.html",{"user":user,"name":name,"number":order_time+name,"time":order_time,"name":order_name,"product":product,"phone":phone,"address":address,"customer":customer,"normal":normal})
Esempio n. 5
0
def delivery(request):
    global user
    global name
    global account
    global customer_status
    global normal_status
    global customer
    global normal
    customer = delivery_data.fetch_customer_product(account,customer_status)
    normal = delivery_data.fetch_normal_product(account,normal_status)
    status = customer_data.customer_show()
    if status == 0:
        product = []
    else:
        product = status
    phone,address = delivery_data.fetch_phone_address(account)
    return render(request,"delivery.html",{"user":user,"name":name,"phone":phone,"address":address,"product":product,"customer":customer,"normal":normal})