コード例 #1
0
ファイル: route.py プロジェクト: qianyc1020/FishServer
    def query_summary(self, gid, mi, request):
        # 新增设备, 新增用户, 活跃用户, (新)付费玩家, (新)用户付费, 充值次数
        start = mi.get_param('start')
        end = mi.get_param('end')
        start_day = Time.str_to_datetime(start, '%Y-%m-%d')
        end_day = Time.str_to_datetime(end, '%Y-%m-%d')
        mo = MsgPack(0)
        while start_day <= end_day:
            fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
            kvs = Context.Stat.get_day_data(gid, fmt)
            channel_info = {}
            for k, v in kvs.iteritems():
                if (k.endswith('.new.device.count')
                        or k.endswith('.new.user.count')
                        or k.endswith('.login.user.count')
                        or k.endswith('.new.pay.user.count')
                        or k.endswith('.new.pay.user.pay_total')
                        or k.endswith('.pay.user.count')
                        or k.endswith('.pay.user.pay_total')
                        or k.endswith('.user.pay.times')):
                    channel, key = k.split('.', 1)
                    if channel not in channel_info:
                        channel_info[channel] = {}
                    channel_info[channel][key] = int(v)

            mo.set_param(fmt, channel_info)
            start_day = Time.next_days(start_day)
        return mo
コード例 #2
0
ファイル: shell.py プロジェクト: qianyc1020/FishServer
 def query_diamond_produce(self, gid, mi, request):
     start = mi.get_param('start')
     end = mi.get_param('end')
     start_day = Time.str_to_datetime(start, '%Y-%m-%d')
     end_day = Time.str_to_datetime(end, '%Y-%m-%d')
     mo = MsgPack(0)
     while start_day <= end_day:
         fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
         kvs = Context.Stat.get_day_data(gid, fmt)
         _kvs = {}
         total, task_total, fall_total = 0, 0, 0
         for k, v in kvs.iteritems():
             if k.startswith('in.diamond.'):
                 if k.startswith('in.diamond.task.reward.'):
                     task_total += int(v)
                 elif k.startswith('in.diamond.fish.fall.'):
                     fall_total += int(v)
                 else:
                     _kvs[k] = int(v)
                 total += int(v)
         _kvs['in.diamond.task.reward'] = task_total
         _kvs['in.diamond.fish.fall'] = fall_total
         _kvs['in.diamond.buy.product'] = int(kvs.get('in.diamond.buy.product', 0))
         _kvs['total'] = total
         mo.set_param(fmt, _kvs)
         start_day = Time.next_days(start_day)
     return mo
コード例 #3
0
ファイル: shell.py プロジェクト: qianyc1020/FishServer
 def query_pay_detail(self, gid, mi, request):
     conf = Context.Configure.get_game_item_json(gid, 'product.config')
     pids = []
     for pid in conf.iterkeys():
         pids.append('product_' + pid)
     start = mi.get_param('start')
     end = mi.get_param('end')
     start_day = Time.str_to_datetime(start, '%Y-%m-%d')
     end_day = Time.str_to_datetime(end, '%Y-%m-%d')
     mo = MsgPack(0)
     while start_day <= end_day:
         fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
         timess = Context.Stat.get_day_data(gid, fmt, *pids)
         kvs = {'product_100646': 0, 'product_100710': 0}
         for k, v in zip(pids, timess):
             pid = k.replace('product_', '')
             if pid in ('100646', '100647', '100648', '100649', '100650', '100651',
                        '100652', '100653', '100654', '100655'):
                 kvs['product_100646'] += Tool.to_int(v, 0)
             elif pid in ('100710', '100711', '100712', '100713', '100714', '100715', '100716'):
                 kvs['product_100710'] += Tool.to_int(v, 0)
             else:
                 kvs[k] = Tool.to_int(v, 0)
         mo.set_param(fmt, kvs)
         start_day = Time.next_days(start_day)
     return mo
コード例 #4
0
ファイル: shell.py プロジェクト: qianyc1020/FishServer
 def query_diamond_consume(self, gid, mi, request):
     start = mi.get_param('start')
     end = mi.get_param('end')
     start_day = Time.str_to_datetime(start, '%Y-%m-%d')
     end_day = Time.str_to_datetime(end, '%Y-%m-%d')
     mo = MsgPack(0)
     while start_day <= end_day:
         fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
         kvs = Context.Stat.get_day_data(gid, fmt)
         _kvs, total = {}, 0
         for k, v in kvs.iteritems():
             if k.startswith('out.diamond.'):
                 if k.startswith('out.diamond.inner.buy.'):
                     k = 'out.diamond.buy.' + k[-3:]
                 elif k.startswith('out.diamond.table.buy.'):
                     k = 'out.diamond.buy.' + k[-3:]
                 if k in _kvs:
                     _kvs[k] += int(v)
                 else:
                     _kvs[k] = int(v)
                 total += int(v)
         _kvs['total'] = total
         mo.set_param(fmt, _kvs)
         start_day = Time.next_days(start_day)
     return mo
コード例 #5
0
ファイル: shell.py プロジェクト: qianyc1020/FishServer
 def query_chip_produce(self, gid, mi, request):
     start = mi.get_param('start')
     end = mi.get_param('end')
     start_day = Time.str_to_datetime(start, '%Y-%m-%d')
     end_day = Time.str_to_datetime(end, '%Y-%m-%d')
     mo = MsgPack(0)
     while start_day <= end_day:
         fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
         kvs = Context.Stat.get_day_data(gid, fmt)
         task_total, catch_total = 0, 0
         _kvs = {}
         for k, v in kvs.iteritems():
             if k.startswith('in.chip.'):
                 if k.startswith('in.chip.task.reward.'):
                     task_total += int(v)
                 elif k.startswith('in.chip.catch.fish.'):
                     catch_total += int(v)
                 else:
                     _kvs[k] = int(v)
         _kvs['in.chip.task.reward'] = task_total
         _kvs['in.chip.catch.fish'] = catch_total
         _kvs['in.chip.buy.product'] = int(kvs.get('in.chip.buy.product', 0))
         mo.set_param(fmt, _kvs)
         start_day = Time.next_days(start_day)
     return mo
コード例 #6
0
ファイル: shell.py プロジェクト: qianyc1020/FishServer
 def query_chip_consume(self, gid, mi, request):
     room_types = (201, 202, 203)
     mini_games = (10002, 10003)
     fields = ['out.chip.attack']
     for room_type in room_types:
         fields.append('out.chip.game.shot.bullet.%d' % room_type)
     for game in mini_games:
         fields.append('out.chip.game.%d' % game)
     start = mi.get_param('start')
     end = mi.get_param('end')
     start_day = Time.str_to_datetime(start, '%Y-%m-%d')
     end_day = Time.str_to_datetime(end, '%Y-%m-%d')
     mo = MsgPack(0)
     while start_day <= end_day:
         fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
         chips = Context.Stat.get_day_data(gid, fmt, *fields)
         attack = Tool.to_int(chips[0], 0)
         info = []
         for chip in chips[1:]:
             if chip:
                 info.append(int(chip))
             else:
                 info.append(0)
         info[2] += attack
         mo.set_param(fmt, info)
         start_day = Time.next_days(start_day)
     return mo
コード例 #7
0
ファイル: shell.py プロジェクト: qianyc1020/FishServer
 def query_chip_pump(self, gid, mi, request):
     room_types = (201, 202, 203)
     fields = []
     for room_type in room_types:
         fields.append('out.chip.pump.%d' % room_type)
         fields.append('out.chip.buff.pump.%d' % room_type)
         fields.append('out.chip.red.pump.%d' % room_type)
     start = mi.get_param('start')
     end = mi.get_param('end')
     start_day = Time.str_to_datetime(start, '%Y-%m-%d')
     end_day = Time.str_to_datetime(end, '%Y-%m-%d')
     mo = MsgPack(0)
     while start_day <= end_day:
         fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
         chips = Context.Stat.get_day_data(gid, fmt, *fields)
         info = []
         for i in range(0, len(chips), 3):
             total = 0
             for j in range(3):
                 if chips[i + j]:
                     total += int(chips[i + j])
             info.append(total)
         mo.set_param(fmt, info)
         start_day = Time.next_days(start_day)
     return mo
コード例 #8
0
ファイル: shell.py プロジェクト: qianyc1020/FishServer
 def query_carrying(self, gid, mi, request):
     start = mi.get_param('start')
     end = mi.get_param('end')
     start_day = Time.str_to_datetime(start, '%Y-%m-%d')
     end_day = Time.str_to_datetime(end, '%Y-%m-%d')
     mo = MsgPack(0)
     while start_day <= end_day:
         fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
         _login, _total = Context.Stat.get_day_data(gid, fmt, 'login.carrying.volume.chip', 'carrying.volume.chip')
         _login = Tool.to_int(_login, 0)
         _total = Tool.to_int(_total, 0)
         mo.set_param(fmt, {'carrying': _login, 'total': _total})
         start_day = Time.next_days(start_day)
     return mo
コード例 #9
0
ファイル: shell.py プロジェクト: qianyc1020/FishServer
 def query_shot(self, gid, mi, request):
     room_types = (201, 202, 203)
     fields = []
     for room_type in room_types:
         fields.append('shot.times.%d' % room_type)
     start = mi.get_param('start')
     end = mi.get_param('end')
     start_day = Time.str_to_datetime(start, '%Y-%m-%d')
     end_day = Time.str_to_datetime(end, '%Y-%m-%d')
     mo = MsgPack(0)
     while start_day <= end_day:
         fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
         values = Context.Stat.get_day_data(gid, fmt, *fields)
         info = []
         for v in values:
             if v:
                 info.append(int(v))
             else:
                 info.append(0)
         mo.set_param(fmt, info)
         start_day = Time.next_days(start_day)
     return mo
コード例 #10
0
ファイル: shell.py プロジェクト: qianyc1020/FishServer
    def query_history_phone(self, gid, mi, request):
        start = mi.get_param('start')
        end = mi.get_param('end')
        start_day = Time.str_to_datetime(start, '%Y-%m-%d')
        end_day = Time.str_to_datetime(end, '%Y-%m-%d')
        uid_seq_map, all_seq_list = {}, []
        while start_day <= end_day:
            fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
            records = Context.RedisStat.hash_getall('history:%d:%s' % (gid, fmt))
            for seq, uid in records.iteritems():
                if uid not in uid_seq_map:
                    uid_seq_map[uid] = []
                uid_seq_map[uid].append(int(seq))
                all_seq_list.append(int(seq))
            start_day = Time.next_days(start_day)

        _list = []
        if all_seq_list:
            seq_record_map = Context.RedisMix.hash_mget_as_dict('game.%d.exchange.record' % gid, *all_seq_list)
            for uid, seq_list in uid_seq_map.iteritems():
                states = Context.RedisCluster.hash_mget(uid, 'history:%d:%s' % (gid, uid), *seq_list)
                for seq, state in zip(seq_list, states):
                    if state is not None and seq in seq_record_map:
                        record = Context.json_loads(seq_record_map[seq])
                        if record['type'] == 'exchange' and record['to'] == 'phone':
                            record = {
                                'uid': int(uid),
                                'ts': record['ts'],
                                'count': record['count'],
                                'phone': record['phone'],
                                'state': int(state),
                                'seq': seq,
                            }
                            _list.append(record)

        mo = MsgPack(0)
        mo.set_param('exchange', _list)
        return mo
コード例 #11
0
ファイル: shell.py プロジェクト: qianyc1020/FishServer
 def query_raffle(self, gid, mi, request):
     start = mi.get_param('start')
     end = mi.get_param('end')
     start_day = Time.str_to_datetime(start, '%Y-%m-%d')
     end_day = Time.str_to_datetime(end, '%Y-%m-%d')
     eggs = (211, 212, 213, 214)
     fileds = ['in.chip.bonus.raffle', 'in.diamond.bonus.raffle', 'in.coupon.bonus.raffle']
     for egg in eggs:
         fileds.append('in.props.%d.bonus.raffle' % egg)
     mo = MsgPack(0)
     while start_day <= end_day:
         kvs = {}
         fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
         values = Context.Stat.get_day_data(gid, fmt, *fileds)
         kvs['chip'] = Tool.to_int(values[0], 0)
         kvs['diamond'] = Tool.to_int(values[1], 0)
         kvs['coupon'] = Tool.to_int(values[2], 0)
         egg_list = []
         for egg in values[3:]:
             egg_list.append(Tool.to_int(egg, 0))
         kvs['egg'] = egg_list
         mo.set_param(fmt, kvs)
         start_day = Time.next_days(start_day)
     return mo
コード例 #12
0
ファイル: shell.py プロジェクト: qianyc1020/FishServer
    def query_egg_fall(self, gid, mi, request):
        room_types = (201, 202, 203)
        props_ids = (211, 212, 213)
        fields = []
        for pid in props_ids:
            for room_type in room_types:
                fields.append('in.props.%d.fish.fall.%d' % (pid, room_type))

        cnt_fields = []
        for pid in props_ids:
            cnt_fields.append('user.count.get.props.%d' % pid)

        start = mi.get_param('start')
        end = mi.get_param('end')
        start_day = Time.str_to_datetime(start, '%Y-%m-%d')
        end_day = Time.str_to_datetime(end, '%Y-%m-%d')
        mo = MsgPack(0)
        while start_day <= end_day:
            fmt = Time.datetime_to_str(start_day, '%Y-%m-%d')
            eggs = Context.Stat.get_day_data(gid, fmt, *fields)
            props_info = []
            for i in range(0, len(eggs), len(room_types)):
                fall = 0
                for j in range(len(room_types)):
                    if eggs[i+j]:
                        fall += int(eggs[i+j])
                props_info.append(fall)

            gets = Context.Stat.get_day_data(gid, fmt, *cnt_fields)
            get_total = 0
            for cnt in gets:
                if cnt:
                    get_total += int(cnt)
            mo.set_param(fmt, {'fall': props_info, 'get': get_total})
            start_day = Time.next_days(start_day)
        return mo