Beispiel #1
0
def get_rate_reports(redis, selfUid, startDate, endDate, agent_type):
    """
    获取抽成的列表
    """
    date_list = convert_util.to_week_list(startDate, endDate)
    if agent_type == 0:
        my_downline_agents = redis.smembers(AGENT_CHILD_TABLE % (selfUid))
    elif agent_type > 0:
        my_downline_agents = getAllChildAgentId(redis, selfUid)
    else:
        my_downline_agents = []

    log_util.debug('my_downline_agents[%s]' % (my_downline_agents))
    RateReportList = []
    for date in date_list:
        downline_reports = get_downline_rate(redis, date, my_downline_agents)
        log_util.debug(
            '[get_rate_reports] date[%s] selfId[%s] downline_reports[%s]' %
            (date, selfUid, downline_reports))
        if not downline_reports:
            continue
        RateReportList.extend(downline_reports)

    log_util.debug('[agentRateTable1111] selfUid[%s] RateReportList[%s]' %
                   (selfUid, RateReportList))
    return {'date': RateReportList}
Beispiel #2
0
def get_wechat_order_records(redis, groupId, condition, action="HALL"):
    """
    获取微信支付订单记录
    :params redis Redis实例
    :params groupId 公会ID
    :params condition 查询条件
    :params action 查询 捕鱼FISH 或 棋牌HALL的订单
    """
    deltaTime = timedelta(1)
    orderList = []

    roomCardCount, pendingMoney, successMoney, moneyCount = 0, 0, 0, 0
    date_lists = convert_util.to_week_list(condition['startDate'],
                                           condition['endDate'])

    if action == "HALL":
        date_table = DAY_ORDER
        order_table = ORDER_TABLE
    else:
        date_table = DAY_ORDER4FISH
        order_table = ORDER_TABLE4FISH

    pipe = redis.pipeline()
    for date in date_lists:
        orders = redis.lrange(date_table % (date), 0, -1)
        #roomCardCount+=len(orders)
        for order in orders:
            orderInfo = {}
            if not order_table % (order):
                pipe.lrem(ORDER_NUM_LIST, orders)
                pipe.lrem(date_table % (date), order)
                continue
            orderDetail = redis.hgetall(order_table % (order))
            if not orderDetail:
                pipe.lrem(ORDER_NUM_LIST, orders)
                pipe.lrem(date_table % (date), order)
                continue

            dateStr1 = time.strftime(
                '%Y-%m-%d %H:%M:%S',
                time.localtime(float(orderDetail['time'])))
            log_util.debug('time[%s]' % (dateStr1))
            moneyCount += round(float(orderDetail['money']), 2)
            if orderDetail['type'] == 'pending':
                pendingMoney += round(float(orderDetail['money']), 2)
            else:
                successMoney += round(float(orderDetail['money']), 2)

            user_table = redis.get(FORMAT_ACCOUNT2USER_TABLE %
                                   (orderDetail['account']))
            group_id = redis.hget(user_table, 'parentAg')
            orderInfo['orderNo'] = order
            orderInfo['good_name'] = orderDetail['name']
            orderInfo['good_money'] = round(
                float(orderDetail['money']) * 0.01, 2)
            orderInfo['order_paytime'] = dateStr1
            orderInfo['good_count'] = orderDetail['roomCards']
            orderInfo['order_type'] = orderDetail['type']
            orderInfo['group_id'] = group_id if group_id else '-'
            orderInfo['memberId'] = user_table.split(':')[1]
            orderList.append(orderInfo)
    pipe.execute()
    return {
        'data': orderList,
        'orderCount': len(orderList),
        'moneyCount': moneyCount * 0.01,
        'pendingMoney': pendingMoney * 0.01,
        'successMoney': successMoney * 0.01
    }