Exemplo n.º 1
0
Arquivo: model.py Projeto: fcua/x8623
 def add_mail(self,
              title,
              content,
              addition=None,
              addtime=None,
              type=MailType.System,
              cd=0):
     from mail.model import Mail
     if not addition:
         addition = {}
     if not addtime:
         addtime = int(time.time())
     mail = Mail.create(playerID=self.entityID,
                        title=title,
                        content=content,
                        addition=addition,
                        addtime=addtime,
                        type=type,
                        cd=cd)
     mail.save()
     self.mails[mail.mailID] = mail
     # self.touch_mails()
     self.mailset.add(mail.mailID)
     self.save()
     self.sync()
     return mail
Exemplo n.º 2
0
 def load_mails(self):
     from mail.model import Mail
     mails = Mail.batch_load(self.mailset)
     for mail in mails:
         if not mail:
             continue
         self.mails[mail.mailID] = mail
Exemplo n.º 3
0
def give_offline():
    import time
    from mail.model import Mail
    from mail.constants import MailType
    slevel, elevel, fbID, title, content, reward, value = get_give_arguments(
        request.POST)
    reward = {reward: value}
    limit = {'slevel': slevel, 'elevel': elevel, 'fbID': fbID}
    atime = int(time.time())
    mail_message = {}
    mail_message['playerID'] = 0
    mail_message['title'] = title
    mail_message['content'] = content
    mail_message['addition'] = reward
    mail_message['addtime'] = atime
    mail_message['limitdata'] = limit
    mail_message['type'] = MailType.System

    Mail.add_offline_mail(**mail_message)
    return SUCCESS
Exemplo n.º 4
0
 def add_offline_mail(cls, **kwargs):
     from mail.model import Mail
     mail = Mail.create(playerID=kwargs['playerID'],
                        title=kwargs['title'],
                        content=kwargs['content'],
                        addition=kwargs['addition'],
                        addtime=kwargs['addtime'],
                        limitdata=kwargs['limitdata'],
                        type=kwargs['type'])
     mail.save()
     EmailByTimeIndexing.register(mail.mailID, kwargs['addtime'])
Exemplo n.º 5
0
def add_condition_mail():
    if request.method == "POST":
        title = request.POST.getone("title", "")
        content = request.POST.getone("content", "")
        petList = validate_list(request.POST.getone("petList", ""))
        matList = validate_list(request.POST.getone("matList", ""))
        equipList = validate_list(request.POST.getone("equipList", ""))
        specPacks = validate_list(request.POST.getone("specpackList", ""))
        specPacks = specPacks or validate_list(
            request.POST.getone("specPacks", ""))
        limitdata = json.loads(request.POST.getone("limitdata", "{}"))
        reward = {}
        from reward.base import get_reward_attr_list
        for attr in get_reward_attr_list():
            value = int(request.POST.getone(attr) or 0)
            if value:
                reward[attr] = value
        if petList:
            from config.configs import get_config, PetConfig
            for id, count in petList:
                if id not in get_config(PetConfig):
                    return json.dumps({
                        'status': 1,
                        'message': '精灵`%d`不存在' % id,
                    })
            reward['petList'] = petList
        if matList:
            from config.configs import get_config, MatConfig
            for id, count in matList:
                if id not in get_config(MatConfig):
                    return json.dumps({
                        'status': 1,
                        'message': '物品`%d`不存在' % id,
                    })
            reward['matList'] = matList
        if equipList:
            from config.configs import get_config, NewEquipConfig
            for id, count in equipList:
                if id not in get_config(NewEquipConfig):
                    return json.dumps({
                        'status': 1,
                        'message': '装备`%d`不存在' % id,
                    })
            reward['equipList'] = equipList
        if specPacks:
            from config.configs import get_config, SpecpackConfig
            for id, count in specPacks:
                if id not in get_config(SpecpackConfig):
                    return json.dumps({
                        'status': 1,
                        'message': '特殊掉落`%d`不存在' % id,
                    })
            reward['specPacks'] = specPacks
        from mail.model import Mail
        from mail.constants import MailType
        cd = 7 * 24 * 60 * 60
        params = {
            "title": title,
            "content": content,
            "addition": reward,
            "cd": cd,
            "limitdata": limitdata,
            "type": MailType.System,
        }
        Mail.add_condition_mail(**params)
        from gm.proxy import proxy
        from mail.manager import sync_condition_mail  # NOQA
        proxy.sync_condition_mail()
    return json.dumps({'status': 0, 'message': 'success', 'params': params})
Exemplo n.º 6
0
 def add_condition_mail(cls, **kwargs):
     kwargs["addtime"] = time.time()
     mail = Mail.create(**kwargs)
     mail.save()
     EmailByTimeIndexing.register(mail.mailID, kwargs['addtime'])
     return mail
Exemplo n.º 7
0
class Mail(c_MailBase, EntityStoreMixinRedis):
    pool = settings.REDISES['entity']

    @classmethod
    def add_offline_mail(cls, **kwargs):
        from mail.model import Mail
        mail = Mail.create(playerID=kwargs['playerID'],
                           title=kwargs['title'],
                           content=kwargs['content'],
                           addition=kwargs['addition'],
                           addtime=kwargs['addtime'],
                           limitdata=kwargs['limitdata'],
                           type=kwargs['type'])
        mail.save()
        EmailByTimeIndexing.register(mail.mailID, kwargs['addtime'])

    @classmethod
    def add_condition_mail(cls, **kwargs):
        kwargs["addtime"] = time.time()
        mail = Mail.create(**kwargs)
        mail.save()
        EmailByTimeIndexing.register(mail.mailID, kwargs['addtime'])
        return mail


Mail.set_identity_generator(
    RedisIdentityGenerator(pool=settings.REDISES['identity'],
                           key='identity_mail'))
EmailByTimeIndexing = SortedIndexing(
    'email_by_time{%d}' % settings.REGION['ID'], settings.REDISES['index'])