Exemplo n.º 1
0
    def get_award(self, uid):
        if not self.checkOperative():
            return 'acitivity expired!'

        actkey = ACTIVITY_KEY.format(HALL_GAMEID, uid, self.getid())
        weekcnt, daycnt = self._get_click_cnt(uid, actkey)
        if weekcnt >= self._clientConf['config'][
                'weeklimit'] or daycnt >= self._clientConf['config'][
                    'daylimit']:
            return 'awardcnt:({},{}) expand limitcnt!'.format(weekcnt, daycnt)

        shareid = self._serverConf["share"]
        share = hallshare.findShare(shareid)
        if not share:
            return 'share:{} not exist!'.format(shareid)

        daobase.executeUserCmd(uid, 'HINCRBY', actkey, self.FIELD_DAY_CNT, 1)
        daobase.executeUserCmd(uid, 'HINCRBY', actkey, self.FIELD_WEEK_CNT, 1)
        daobase.executeUserCmd(uid, 'HINCRBY', actkey, self.FIELD_TOTAL_CNT, 1)
        hallshare.sendReward(HALL_GAMEID, uid, share, 'share_click')
        # 分享BI日志汇报
        clientid = sessiondata.getClientId(uid)
        bireport.reportGameEvent('SHARE_CALLBACK', uid, HALL_GAMEID, shareid,
                                 0, 0, 0, 0, 0, [], clientid)
        if share.mail:
            message.send(HALL_GAMEID, message.MESSAGE_TYPE_SYSTEM, uid,
                         share.mail)
        return 'ok'
Exemplo n.º 2
0
 def handleRequest(self, msg):
     userid = msg.getParam('userId')
     gameid = msg.getParam('gameId')
     action = msg.getParam("action")
     actkey = ACTIVITY_KEY.format(HALL_GAMEID, userid, self.getid())
     if action == "credit_query":
         return self._query(userid, actkey)
     if action == "credit_exchange":
         exchangeid = msg.getParam('productId')
         return self._exchange(gameid, userid, actkey, exchangeid)
     return {'result': 'fail', 'tip': "unknown action"}
 def handleRequest(self, msg):
     userid = msg.getParam('userId')
     gameid = msg.getParam('gameId')
     action = msg.getParam("action")
     actkey = ACTIVITY_KEY.format(HALL_GAMEID, userid, self.getid())
     if action == "credit_query":
         return self._query(userid, actkey)
     if action == "credit_exchange":
         exchangeid = msg.getParam('productId')
         return self._exchange(gameid, userid, actkey, exchangeid)
     return {'result': 'fail', 'tip': "unknown action"}
Exemplo n.º 4
0
 def _add_credit(self, userid, credit, times):
     actkey = ACTIVITY_KEY.format(HALL_GAMEID, userid, self.act.getid())
     if self.limit > 0:
         field_time = self.act.FIELD_SOURCE_TIME.format(self.index)
         field_data = self.act.FIELD_SOURCE_NUM.format(self.index)
         used = self.act.check_reset('day', userid, actkey, field_data, field_time)
         if used >= self.limit:
             return
         times = min(times, self.limit - used)
         daobase.executeUserCmd(userid, 'HINCRBY', actkey, field_data, times)
     delta = int(credit * times)
     if delta <= 0:
         return
     self.act.alter_user_credit(userid, actkey, delta)
 def _add_credit(self, userid, credit, times):
     actkey = ACTIVITY_KEY.format(HALL_GAMEID, userid, self.act.getid())
     if self.limit > 0:
         field_time = self.act.FIELD_SOURCE_TIME.format(self.index)
         field_data = self.act.FIELD_SOURCE_NUM.format(self.index)
         used = self.act.check_reset('day', userid, actkey, field_data,
                                     field_time)
         if used >= self.limit:
             return
         times = min(times, self.limit - used)
         daobase.executeUserCmd(userid, 'HINCRBY', actkey, field_data,
                                times)
     delta = int(credit * times)
     if delta <= 0:
         return
     self.act.alter_user_credit(userid, actkey, delta)
Exemplo n.º 6
0
    def getConfigForClient(self, gameId, userId, clientId):
        client = copy.deepcopy(self._clientConf)
        shareid = self._serverConf['share']
        share = hallshare.findShare(shareid)
        if share:
            winrate = gamedata.getGameAttr(userId, 6, 'winrate')
            winrate = strutil.loads(winrate, ignoreException=True, execptionValue={})
            todotask = share.buildTodotask(HALL_GAMEID, userId, 'share_click',
                                           {'userId': userId, 'actName': client['id'],
                                            'dizhuPlayNum': winrate.get('pt', 0)})
            client['config']["share"] = todotask.toDict()

        actkey = ACTIVITY_KEY.format(HALL_GAMEID, userId, client['id'])
        total = daobase.executeUserCmd(userId, 'HGET', actkey, self.FIELD_TOTAL_CNT)
        client['config']['total'] = total if total else 0
        client['config']['today'] = self._get_click_cnt(userId, actkey)[1]
        return client
Exemplo n.º 7
0
    def getConfigForClient(self, gameId, userId, clientId):
        client = copy.deepcopy(self._clientConf)
        shareid = self._serverConf['share']
        share = hallshare.findShare(shareid)
        if share:
            winrate = gamedata.getGameAttr(userId, 6, 'winrate')
            winrate = strutil.loads(winrate,
                                    ignoreException=True,
                                    execptionValue={})
            todotask = share.buildTodotask(
                HALL_GAMEID, userId, 'share_click', {
                    'userId': userId,
                    'actName': client['id'],
                    'dizhuPlayNum': winrate.get('pt', 0)
                })
            client['config']["share"] = todotask.toDict()

        actkey = ACTIVITY_KEY.format(HALL_GAMEID, userId, client['id'])
        total = daobase.executeUserCmd(userId, 'HGET', actkey,
                                       self.FIELD_TOTAL_CNT)
        client['config']['total'] = total if total else 0
        client['config']['today'] = self._get_click_cnt(userId, actkey)[1]
        return client
Exemplo n.º 8
0
    def get_award(self, uid):
        if not self.checkOperative():
            return 'acitivity expired!'

        actkey = ACTIVITY_KEY.format(HALL_GAMEID, uid, self.getid())
        weekcnt, daycnt = self._get_click_cnt(uid, actkey)
        if weekcnt >= self._clientConf['config']['weeklimit'] or daycnt >= self._clientConf['config']['daylimit']:
            return 'awardcnt:({},{}) expand limitcnt!'.format(weekcnt, daycnt)

        shareid = self._serverConf["share"]
        share = hallshare.findShare(shareid)
        if not share:
            return 'share:{} not exist!'.format(shareid)

        daobase.executeUserCmd(uid, 'HINCRBY', actkey, self.FIELD_DAY_CNT, 1)
        daobase.executeUserCmd(uid, 'HINCRBY', actkey, self.FIELD_WEEK_CNT, 1)
        daobase.executeUserCmd(uid, 'HINCRBY', actkey, self.FIELD_TOTAL_CNT, 1)
        hallshare.sendReward(HALL_GAMEID, uid, share, 'share_click')
        # 分享BI日志汇报
        clientid = sessiondata.getClientId(uid)
        bireport.reportGameEvent('SHARE_CALLBACK', uid, HALL_GAMEID, shareid, 0, 0, 0, 0, 0, [], clientid)
        if share.mail:
            message.send(HALL_GAMEID, message.MESSAGE_TYPE_SYSTEM, uid, share.mail)
        return 'ok'