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'
def testLoad(self): shareList = hallshare.getAllShare() for share in shareList: timestamp = self.timestamp if share.rewardTimeCycle.isTimestampIn(timestamp): ok, rewardCount = hallshare.incrRewardCount(10001, share, timestamp) self.assertEqual((ok, rewardCount), (True, 1)) hallshare.sendReward(self.gameId, self.userId, share, 'test') self.assertFalse(hallshare.canReward(10001, share, timestamp)) daobase.executeUserCmd(10001, 'del', 'share.status:9999:10001') self.assertTrue(hallshare.canReward(10001, share, timestamp)) timestamp += 86400 self.assertFalse(hallshare.canReward(10001, share, timestamp))
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'
def testLoad(self): shareList = hallshare.getAllShare() for share in shareList: ftlog.debug('>>> sendReward %s' % (share.shareId)) hallshare.sendReward(self.gameId, self.userId, share, 'test') ftlog.debug('<<< sendReward %s' % (share.shareId))
def testRewardCountN(self): share_conf = { "shares": [ { "desc": [ { "conditions": [], "value": "来玩途游斗地主,输入我的推荐码\\${promoteCode},一起拿红包,赢话费!" } ], "mail": "恭喜您获得1000金币的分享奖励!", "maxRewardCount": 10, "rewardTimeCycle":{ "typeId":"timeCycle.perDay" }, "rewardContent": { "items": [ { "count": 1000, "itemId": "user:chip" } ], "typeId": "FixedContent" }, "shareIcon": [ { "conditions": [], "value": "" } ], "shareId": 10086, "smsDesc": "来玩途游斗地主,输入我的推荐码\\${promoteCode},一起拿红包,赢话费!下载地址:\\${url}", "title": [ { "conditions": [], "value": "亲爱的小伙伴" } ], "typeId": "hall.share.promote", "url": [ { "conditions": [], "value": "http://001.wx.fx.tuyoo.com/gamesites.html" } ] } ] } self.testContext.configure.setJson('game:9999:share', share_conf, 0) hallshare._reloadConf() shareList = hallshare.getAllShare() for share in shareList: timestamp = self.timestamp for i in xrange(share.maxRewardCount): ok, rewardCount = hallshare.incrRewardCount(10001, share, timestamp) self.assertEqual((ok, rewardCount), (True, i + 1)) hallshare.sendReward(self.gameId, self.userId, share, 'test') self.assertFalse(hallshare.canReward(10001, share, timestamp)) timestamp += 86400 self.assertTrue(hallshare.canReward(10001, share, timestamp)) for i in xrange(share.maxRewardCount): ok, rewardCount = hallshare.incrRewardCount(10001, share, timestamp) self.assertEqual((ok, rewardCount), (True, i + 1)) hallshare.sendReward(self.gameId, self.userId, share, 'test') self.assertFalse(hallshare.canReward(10001, share, timestamp))