Exemplo n.º 1
0
def cu_statistics():
    '''
    @note: 用户数量统计
    '''
    now = datetime.datetime.now()
    to_day = now.date()
    start_day = to_day.replace(day=1)
    db = Session()
    count = db.query(Customer).count()
    rec = db.query(Statistics).filter(Statistics.type == 1, Statistics.cur_day == start_day).first()
    if rec:
        rec.value = count
        db.add(rec)
        db.commit()
    else:
        rec = Statistics(type=1, cur_day=start_day, value=count)
        db.add(rec)
        db.commit()
Exemplo n.º 2
0
def su_statistics():
    '''
    @note: 成交金额
    '''
    now = datetime.datetime.now()
    to_day = now.date()
    start_day = to_day.replace(day=1)
    db = Session()
    datas = db.query(SuccessRequirment).all()
    count = 0
    for data in datas:
        count += data.succes_fee
    rec = db.query(Statistics).filter(Statistics.type == 2, Statistics.cur_day == start_day).first()
    if rec:
        rec.value = count
        db.add(rec)
        db.commit()
    else:
        rec = Statistics(type=2, cur_day=start_day, value=count)
        db.add(rec)
        db.commit()
Exemplo n.º 3
0
def init_product():
    from wannabuysth import Session
    session = Session()
    mc = Merchant(name='test2', password='******', mobile='15982150123', pre_payed=20,
             credit=10, success_count=10, faild_count=10
             )
    session.add(mc)
    session.commit()
    su = session.query(SubCatlog)
    j = 0
    for s in su :
        j += 1
        for i in xrange(random.randint(1, 10)):
                pr = Product(catalog_id=s.id, catalog=s, merchant_id=mc.id, merchant=mc,
                        descrip='content %s' % j, acept_fee=random.randint(100, 200),
                        show_fee=random.randint(200, 250), icon_smaill='/static/data/item_img.png',
                        icon_large='/static/data/item_img.png', view_count=0, success_count=0, title=u'测试标题 %s' % j
                        )
    session.add(pr)
    session.commit()