def add_order_service(data): """ 生成订单 :param data:[ { "product_id": 78, # 产品id "product_num": 2, # 产品数量 } ] :return: """ session = g.session user_id = get_user_info()["user_id"] for item in to_list(data): result = session.query(Product).filter( Product.id == item["product_id"]).one() order = Order() order.order_num = date_time(fmt="%Y%m%d%H%M%S") + str(user_id) + str( item["product_id"]) order.product_id = item["product_id"] order.buyer_id = user_id order.seller_id = result.publisher_id order.product_num = item["product_num"] order.product_amount = item["product_num"] * result.price order.logistics_amount = result.logistics_price session.add(order) session.commit() return True
def uploads_images(): if request.method == 'POST': date = date_time(fmt="%Y%m%d") files = request.files.getlist('file') file_urls = [] for each_file in files: if each_file and allowed_file(each_file.filename): filename = get_uuid() + '.png' files_path = check_file_path(app.config['UPLOAD_FOLDER'], date) each_file.save(os.path.join(files_path, filename)) file_url = web['pic_pix'] + "uploads/" + date + "/" + filename file_urls.append(file_url) result = {'file_url': file_urls} return build_ret(success=True, data=result) return html
def __init__(self): self.create_time = date_time() self.status = 0
def __init__(self): self.create_time = date_time()
def __init__(self, password, telephone, username=None): self.create_time = date_time() self.username = username self.password = password self.telephone = telephone