Exemplo n.º 1
0
def recharge_heart_apple():
    '''
    애플 영수증을 검증하고 하트를 충전합니다.
    '''
    heart_recharge = afr(HeartRecharge(**request.json.get('recharge_info')))
    afr(UserPointTx(user_id=g.user_session.user.id, hp=heart_recharge.amount))
    UserPoint.heart_point(user_id=g.user_session.user.id,
                          hp=heart_recharge.amount)
    Session().commit()
    return {'okay': True}, Status.HTTP_200_OK
Exemplo n.º 2
0
    def accept(self):
        '''
        하트 받기는 기본적으로 3천원~
        '''
        from libs.database.engine import Session
        from api.models.item import Item

        if not self.double:
            accept = Session().query((Item.symbol == 'accept')).one_or_none()
            UserPoint.heart_point(self.to_user_id, accept.price if accept else -30)

        self.accpeted = True
        for match in self.matches:
            match.match()
Exemplo n.º 3
0
def stay():
    '''
    회원탈퇴 하시려구요? 가지마세요
    100 포인트 드립니다.
    '''
    stay = Session().query(Stay).filter(
        (Stay.user_id == g.user_session.user.id)).one_or_none()
    if stay:
        raise ClientError('duplicate')
    stay = Stay(user_id=g.user_session.user.id)
    UserPoint.heart_point(g.user_session.user.id, 100)
    Session().add(stay)
    Session().commit()
    return {'okay': True}, Status.HTTP_200_OK
Exemplo n.º 4
0
def login_kakao():
    oauth = Session().query(OauthKakao).filter(
        OauthKakao.party_id == g.info.get('id')).first()
    is_new = True if oauth is None else False

    if is_new:
        user = afr(User(email=g.info['kakao_account'].get('email')))
        oauth = afr(OauthKakao(user, g.info))
        afr(UserPoint(user_id=user.id))

    user_session = UserSession(oauth.user,
                               third_party_token=request.json.get('token'))
    Session(changed=True).add(user_session)

    return {
        'user_id': oauth.user.id,
        'token': user_session.token,
        'is_new': is_new,
        'expiry': DateTimeHelper.full_datetime(user_session.expiry)
    }, Status.HTTP_200_OK
Exemplo n.º 5
0
 def redeem(self, user_id):
     from api.models.user_point import UserPoint
     self.redeemed = True
     self.redeemed_at = datetime.now()
     UserPoint.heart_point(user_id, self.hp)
     UserPoint.manner_point(user_id, self.mp)