コード例 #1
0
    def POST(self):
        req = protocol.ReportYoumiPoint_Req(web.input())
        resp = protocol.ReportYoumiPoint_Resp()

        point = db_helper.query_offer_wall_point(req.device_id,
                                                 OfferWallType.T_YOUMI)
        if point > req.point:
            logger.error('invalid youmi point, %d => %d' % (point, req.point))
            resp.rtn = 1
        elif point < req.point:
            if point == 0:
                db_helper.insert_offer_wall_point(req.device_id,
                                                  OfferWallType.T_YOUMI,
                                                  req.point)
            else:
                db_helper.update_offer_wall_point(req.device_id,
                                                  OfferWallType.T_YOUMI,
                                                  req.point)

            inc = (req.point - point) * 10
            BillingClient.instance().recharge(req.device_id, req.userid, inc,
                                              '体验应用赚取%.1f元' % (inc / 100.0),
                                              inc)
            resp.increment = inc

            if req.inviter != 0:
                BillingClient.instance().share_income(req.inviter, req.userid,
                                                      int(inc / 10.0))

        return resp.dump_json()
コード例 #2
0
    def POST(self):
        req  = protocol.ReportComment_Req(web.input())
        resp = protocol.ReportComment_Resp()

        if req.userid == 0:
            task = TaskOfDevice()
            task.device_id = req.device_id
            task.task_id = Task.ID_COMMENT
            task.type = TaskType.T_COMMENT
            task.status = TaskStatus.S_DONE
            task.money = TASK_REWARD_COMMENT
            n = db_helper.insert_task_of_device(task)
        else:
            task = TaskOfUser()
            task.userid = req.userid
            task.device_id = req.device_id
            task.task_id = Task.ID_COMMENT
            task.type = TaskType.T_COMMENT
            task.status = TaskStatus.S_DONE
            task.money = TASK_REWARD_COMMENT
            n = db_helper.insert_task_of_user(task)

        if n > 0:
            #奖励0.1元
            BillingClient.instance().recharge(req.device_id, req.userid, TASK_REWARD_COMMENT, '好评旺财')

            resp.income = TASK_REWARD_COMMENT

        return resp.dump_json()
コード例 #3
0
    def POST(self):
        req = protocol.AppCallback_Req(web.input())
        resp = protocol.AppCallback_Resp()

        logger.debug('got app callback, device_id:%s, appid:%s' %
                     (req.device_id, req.appid))

        self.device_id = req.device_id
        self.appid = req.appid

        if not self.app_downloaded():
            logger.info('failed in task_app_download, device_id:%s, appid:%s' %
                        (req.device_id, req.appid))
            return resp.dump_json()

        task = self.query_task_info()
        if task is not None:
            t = TaskOfDevice()
            t.device_id = req.device_id
            t.userid = req.userid
            t.task_id = task.id
            t.type = TaskType.T_APP
            t.status = TaskStatus.S_DONE
            t.money = task.money
            n = db_helper.insert_task_of_device(t)
            if n == 0:
                logger.error('insert task_of_device failed')
            else:
                logger.info('task_app succeed! device_id:%s, appid:%s' %
                            (req.device_id, req.appid))
                BillingClient.instance().recharge(
                    req.device_id, req.userid, task.money,
                    'app: %s, %s' % (req.appid, task.app_name), task.money)

        return resp.dump_json()
コード例 #4
0
    def POST(self):
        req  = protocol.ReportComment_Req(web.input())
        resp = protocol.ReportComment_Resp()

        if req.userid == 0:
            task = TaskOfDevice()
            task.device_id = req.device_id
            task.task_id = Task.ID_COMMENT
            task.type = TaskType.T_COMMENT
            task.status = TaskStatus.S_DONE
            task.money = TASK_REWARD_COMMENT
            n = db_helper.insert_task_of_device(task)
        else:
            task = TaskOfUser()
            task.userid = req.userid
            task.device_id = req.device_id
            task.task_id = Task.ID_COMMENT
            task.type = TaskType.T_COMMENT
            task.status = TaskStatus.S_DONE
            task.money = TASK_REWARD_COMMENT
            n = db_helper.insert_task_of_user(task)

        if n > 0:
            #奖励0.1元
            BillingClient.instance().recharge(req.device_id, req.userid, TASK_REWARD_COMMENT, '好评小猪', 0)

            resp.income = TASK_REWARD_COMMENT

        return resp.dump_json()
コード例 #5
0
    def POST(self):
        req = protocol.CheckIn_Req(web.input())
        resp = protocol.CheckIn_Resp()

        self.userid = req.userid
        self.device_id = req.device_id

        #是否已经签过到
        if self.already_checked_in():
            resp.rtn = 1
            return resp.dump_json()
        else:
            award = self.roll()
            #roll到了,给账户充值
            if award.money > 0:
                BillingClient.instance().recharge(
                    req.device_id, req.userid, award.money,
                    '抽奖赢得%.1f元' % (award.money / 100.0), 0)
            task = TaskCheckIn()
            task.userid = req.userid
            task.device_id = req.device_id
            task.money = award.money
            task.extra = award.desc()
            db_helper.insert_task_checkin(task)
            resp.award = award.type
            return resp.dump_json()
コード例 #6
0
    def POST(self):
        req = protocol.ReportUserInfo_Req(web.input())
        resp = protocol.ReportUserInfo_Resp()

        if req.userid == 0:
            task = TaskOfDevice()
            task.device_id = req.device_id
            task.task_id = Task.ID_INFO
            task.type = TaskType.T_INFO
            task.status = TaskStatus.S_DONE
            task.money = TASK_REWARD_INFO
            n = db_helper.insert_task_of_device(task)
        else:
            task = TaskOfUser()
            task.userid = req.userid
            task.device_id = req.device_id
            task.task_id = Task.ID_INFO
            task.type = TaskType.T_INFO
            task.status = TaskStatus.S_DONE
            task.money = TASK_REWARD_INFO
            n = db_helper.insert_task_of_user(task)

        if n > 0:
            #奖励1元
            BillingClient.instance().recharge(req.device_id, req.userid, TASK_REWARD_INFO, '填写个人资料')

        return resp.dump_json()
コード例 #7
0
    def POST(self):
        req  = protocol.AppCallback_Req(web.input())
        resp = protocol.AppCallback_Resp()

        logger.debug('got app callback, device_id:%s, appid:%s' %(req.device_id, req.appid))

        self.device_id = req.device_id
        self.appid = req.appid

        if not self.app_downloaded():
            logger.info('failed in task_app_download, device_id:%s, appid:%s' %(req.device_id, req.appid))
            return resp.dump_json()

        task = self.query_task_info()
        if task is not None:
            t = TaskOfDevice()
            t.device_id = req.device_id
            t.userid = req.userid
            t.task_id = task.id
            t.type = TaskType.T_APP
            t.status = TaskStatus.S_DONE
            t.money = task.money
            n = db_helper.insert_task_of_device(t)
            if n == 0:
                logger.error('insert task_of_device failed')
            else:
                logger.info('task_app succeed! device_id:%s, appid:%s' %(req.device_id, req.appid))
                BillingClient.instance().recharge(req.device_id, req.userid, task.money, 'app: %s, %s' %(req.appid, task.app_name))

        return resp.dump_json()
コード例 #8
0
    def POST(self):
        req = protocol.ReportOfferWall_Req(web.input())
        resp = protocol.ReportOfferWall_Resp()

        is_task_finished = db_helper.check_offerwall_point_has_reported(
            req.unique_task_id)
        if is_task_finished:
            logger.error(
                "[OFFERWALL CALLBACK] task has finished, unique_task_id = %s",
                req.unique_task_id)
            resp.rtn = -1
            return resp.dump_json()

        total = db_helper.update_offerwall_point(req.device_id, req.type,
                                                 req.increment,
                                                 req.unique_task_id)

        income = req.increment * 10
        BillingClient.instance().recharge(req.device_id, req.userid, income,
                                          req.remark, income)

        if req.inviter != 0:
            BillingClient.instance().share_income(req.inviter, req.userid,
                                                  int(income / 10.0))

        resp.income = income
        return resp.dump_json()
コード例 #9
0
    def POST(self):
        req = protocol.ReportUserInfo_Req(web.input())
        resp = protocol.ReportUserInfo_Resp()

        if req.userid == 0:
            task = TaskOfDevice()
            task.device_id = req.device_id
            task.task_id = Task.ID_INFO
            task.type = TaskType.T_INFO
            task.status = TaskStatus.S_DONE
            task.money = TASK_REWARD_INFO
            n = db_helper.insert_task_of_device(task)
        else:
            task = TaskOfUser()
            task.userid = req.userid
            task.device_id = req.device_id
            task.task_id = Task.ID_INFO
            task.type = TaskType.T_INFO
            task.status = TaskStatus.S_DONE
            task.money = TASK_REWARD_INFO
            n = db_helper.insert_task_of_user(task)

        if n > 0:
            #奖励1元
            BillingClient.instance().recharge(req.device_id, req.userid,
                                              TASK_REWARD_INFO, '填写个人资料', 0)

        return resp.dump_json()
コード例 #10
0
    def POST(self):
        req  = protocol.ReportOfferWall_Req(web.input())
        resp = protocol.ReportOfferWall_Resp()

        total = db_helper.update_offerwall_point(req.device_id, req.type, req.increment)
        
        income = req.increment * 10
        BillingClient.instance().recharge(req.device_id, req.userid, income, '体验应用赚取%.1f元' %(income/100.0))

        if req.inviter != 0:
            BillingClient.instance().share_income(req.inviter, req.userid, int(income/10.0))

        resp.income = income
        return resp.dump_json()
コード例 #11
0
    def POST(self):
        req  = protocol.ReportYoumiPoint_Req(web.input())
        resp = protocol.ReportYoumiPoint_Resp()

        point = db_helper.query_offer_wall_point(req.device_id, OfferWallType.T_YOUMI)
        if point > req.point:
            logger.error('invalid youmi point, %d => %d' %(point, req.point))
            resp.rtn = 1
        elif point < req.point:
            if point == 0:
                db_helper.insert_offer_wall_point(req.device_id, OfferWallType.T_YOUMI, req.point)
            else:
                db_helper.update_offer_wall_point(req.device_id, OfferWallType.T_YOUMI, req.point)

            inc = (req.point - point)*10
            BillingClient.instance().recharge(req.device_id, req.userid, inc, '体验应用赚取%.1f元' %(inc/100.0))
            resp.increment = inc

            if req.inviter != 0:
                BillingClient.instance().share_income(req.inviter, req.userid, int(inc/10.0))

        return resp.dump_json()
コード例 #12
0
    def POST(self):
        req = protocol.ReportInvite_Req(web.input())
        resp = protocol.ReportInvite_Resp()

        task = TaskInvite()
        task.userid = req.userid
        task.invitee = req.invitee
        task.invite_code = req.invite_code

        n = db_helper.insert_task_invite(task)
        if n == 0:
            #已经邀请过
            return resp.dump_json()

        task = TaskOfUser()
        task.userid = req.invitee
        task.device_id = ''
        task.task_id = Task.ID_INVITE
        task.type = TaskType.T_INVITE
        task.status = TaskStatus.S_DONE
        task.money = TASK_REWARD_INVITEE
        n = db_helper.insert_task_of_user(task)

        if n == 0:
            return resp.dump_json()

        #被邀请者奖励2元
        BillingClient.instance().recharge('', req.invitee, TASK_REWARD_INVITEE,
                                          '被邀请奖励1元', 0)

        #        n = db_helper.count_task_invite(req.userid)
        #        if n <= TASK_INVITE_NUM_MAX:
        #            #邀请者奖励1元
        #            BillingClient.instance().recharge(req.device_id, req.userid, TASK_REWARD_INVITE, '邀请奖励1元')

        #        resp.total_invite = n
        return resp.dump_json()
コード例 #13
0
    def POST(self):
        req = protocol.ReportInvite_Req(web.input())
        resp = protocol.ReportInvite_Resp()

        task = TaskInvite()
        task.userid = req.userid
        task.invitee = req.invitee
        task.invite_code = req.invite_code

        n = db_helper.insert_task_invite(task)
        if n == 0:
            # 已经邀请过
            return resp.dump_json()

        task = TaskOfUser()
        task.userid = req.invitee
        task.device_id = ""
        task.task_id = Task.ID_INVITE
        task.type = TaskType.T_INVITE
        task.status = TaskStatus.S_DONE
        task.money = TASK_REWARD_INVITEE
        n = db_helper.insert_task_of_user(task)

        if n == 0:
            return resp.dump_json()

        # 被邀请者奖励2元
        BillingClient.instance().recharge("", req.invitee, TASK_REWARD_INVITEE, "被邀请奖励2元")

        #        n = db_helper.count_task_invite(req.userid)
        #        if n <= TASK_INVITE_NUM_MAX:
        #            #邀请者奖励1元
        #            BillingClient.instance().recharge(req.device_id, req.userid, TASK_REWARD_INVITE, '邀请奖励1元')

        #        resp.total_invite = n
        return resp.dump_json()
コード例 #14
0
    def POST(self):
        req  = protocol.CheckIn_Req(web.input())
        resp = protocol.CheckIn_Resp()

        self.userid = req.userid
        self.device_id = req.device_id

        #是否已经签过到
        if self.already_checked_in():
            resp.rtn = 1
            return resp.dump_json()
        else:
            award = self.roll()
            #roll到了,给账户充值
            if award.money > 0:
                BillingClient.instance().recharge(req.device_id, req.userid, award.money, '抽奖赢得%.1f元' %(award.money/100.0))
            task = TaskCheckIn()
            task.userid = req.userid
            task.device_id = req.device_id
            task.money = award.money
            task.extra = award.desc()
            db_helper.insert_task_checkin(task)
            resp.award = award.type
            return resp.dump_json()