示例#1
0
def mine():
    u = current_user()
    pus = ProductUser.find(nickname='mccmccmcc')
    ps = []
    for pu in pus:
        p = Product.find_one(plan_code=pu.plan_code)
        p.my_in = pu.investor_capital_total_init
        p.my_out = pu.investor_capital_total
        p.my_profit = p.my_out - p.my_in
        ps.append(p)
    for p in ps:
        if p.phase == 1:
            continue
        a = float(p.EQUITY)
        b = p.launch_money
        t = 1
        if p.phase == 2:
            start = datetime.strptime(p.operation_start, '%Y-%m-%d %H:%M:%S')
            now = datetime.now()
            t = (now - start).days
        elif p.phase == 3:
            t = int(p.actual_operation)
        if t == 0:
            t = 1
        profit = (a - b) / b * 100
        profit_year = profit / int(p.operation_time) * 360
        # profit = '{:.2f}%'.format(profit)
        # profit_year = '{:.2f}%'.format(profit_year)
        p.profit = round(profit, 2)
        p.profit_year = round(profit_year, 2)
        p.t = t
        p.lt = int(p.operation_time) - t
    if u is None:
        u = User.find_one(nickname='mccmccmcc')
    u.all_profit = sum([p.my_profit for p in ps])
    return render_template('product/mine.html', u=u, ps=ps)
示例#2
0
def detail(code):
    p = Product.find_one(plan_code=code)
    pu = ProductUser.find(plan_code=code)
    return render_template('product_user.html', p=p, pu=pu)
示例#3
0
文件: product.py 项目: NickYxy/eMall
def detail(uuid):
    u = current_user()
    p = Product.find_one(uuid=uuid)

    return render_template('product/detail.html', p=p, u=u)