
    Bi;                         d dl mZmZmZmZmZmZmZ d dlm	Z	 d dl
mZ d dlmZ d dlZ G d dej                  Z G d d	ej                  Z G d
 dej                  Z G d dej                  ZdS )    )ColumnIntegerStringDateTimeTextEnumDate)relationship)func)dbNc                   6    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdS )
CreditTypeu   크레딧 타입eventfreedaily_renewalexpiresubscription_basicsubscription_plussubscription_proadd_onusageN)__name__
__module____qualname____doc__EVENTFREEDAILY_RENEWALEXPIRESUBSCRIPTION_BASICSUBSCRIPTION_PLUSSUBSCRIPTION_PROADD_ONUSAGE     J/var/www/html/web/mlink/mlink_AI_Server/mlink-backend/src/models/credit.pyr   r      sD        ED#MF-+)FEEEr&   r   c                      e Zd ZdZdZ eed          Z e ed          d          Z	 e e
e          d          Z eed          Z eed          Z ee          Z e ed                    Z e ed	                    Z ee          Z ee ej                    
          Z ee          Z edddd          Zd ZdS )CreditTransactionu!   크레딧 거래 내역 테이블credit_transactionsTprimary_key   Fnullabled   2   defaultUserz'CreditTransaction.user_id==User.user_idzCreditTransaction.user_idback_populatesprimaryjoinforeign_keysc                    | j         | j        | j        r| j        j        nd | j        | j        | j        | j        | j        | j	        r| j	        
                                nd | j        | j        r| j        
                                nd dS )N)iduser_idcredit_typeamountbalance_afterdescriptionreference_idreference_type
created_at	meta_dataevent_expiry_date)r:   r;   r<   valuer=   r>   r?   r@   rA   rB   	isoformatrC   rD   selfs    r'   to_dictzCreditTransaction.to_dict3   s    '|595EO4+114k!/+ -"19=R$/33555dGKG]!g!7!A!A!C!C!Ccg
 
 	
r&   N)r   r   r   r   __tablename__r   r   r:   r   r;   r   r   r<   r=   r>   r   r?   r@   rA   rC   r   r   nowrB   rD   r
   userrI   r%   r&   r'   r)   r)      sD       ++)M	T	*	*	*BfVVBZZ%000G &j))E:::KVGe,,,FF7U333M &,,K6&&++&&LVFF2JJ''N tI($(**555J x(( <4=0  D
 
 
 
 
r&   r)   c                      e Zd ZdZdZ eed          Z e ed          dd          Z	 eed	          Z
 eed	          Z eed	          Z eed	          Z eed	          Z eed	          Z ee          Z ee ej                     ej                    
          Z edddd          Zd ZdS )CreditBalanceu'   사용자별 크레딧 잔액 테이블credit_balancesTr+   r-   F)r/   uniquer   r2   r3   onupdater4   credit_balancez#CreditBalance.user_id==User.user_idzCreditBalance.user_idr5   c                     | j         | j        | j        | j        | j        | j        | j        | j        | j        r| j        	                                nd | j
        r| j
        	                                nd d
S )N)
r:   r;   total_creditfree_creditevent_creditdaily_renewal_creditsubscription_creditadd_on_creditlast_daily_renewal
updated_at)r:   r;   rU   rV   rW   rX   rY   rZ   r[   rF   r\   rG   s    r'   rI   zCreditBalance.to_dict\   s|    '| -+ -$($=#'#;!/IMI`"j$"9"C"C"E"E"Efj9=R$/33555d
 
 	
r&   N)r   r   r   r   rJ   r   r   r:   r   r;   rU   rV   rW   rX   rY   rZ   r   r[   r   rK   r\   r
   rL   rI   r%   r&   r'   rN   rN   B   s8       11%M	T	*	*	*BfVVBZZ%===G 6'1---L&!,,,K6'1---L!6'1555 &!444F7A...M  ))($(**xtxzzJJJJ </9,  D
 
 
 
 
r&   rN   c                   f   e Zd ZdZdZ eed          Z e ed          d          Z	 e ed          d          Z
 eedd	
          Z eed          Z ee ej                              Z ee ej                     ej                              Z edddd          Zd ZdS )EventCreditLotu7   이벤트 크레딧 로트 테이블 (만료일 관리)event_credit_lotsTr+   r-   Fr.   r0   r   )r/   r3   r2   rQ   r4   z$EventCreditLot.user_id==User.user_idzEventCreditLot.user_idr5   c                     | j         | j        | j        | j        | j        r| j                                        nd | j        r| j                                        nd | j        r| j                                        nd dS )N)r:   r;   event_idamount_remaining
expires_atrB   r\   )r:   r;   ra   rb   rc   rF   rB   r\   rG   s    r'   rI   zEventCreditLot.to_dict}   s}    '| $ 59=R$/33555d9=R$/33555d9=R$/33555d
 
 	
r&   N)r   r   r   r   rJ   r   r   r:   r   r;   ra   rb   r	   rc   r   r   rK   rB   r\   r
   rL   rI   r%   r&   r'   r^   r^   j   s       AA'M	T	*	*	*BfVVBZZ%000GvffSkkE222HvgqAAAu---J($(**555J($(**xtxzzJJJJ <2:-  D	
 	
 	
 	
 	
r&   r^   )
sqlalchemyr   r   r   r   r   r   r	   sqlalchemy.ormr
   sqlalchemy.sqlr   src.models.dbr   enumr   Modelr)   rN   r^   r%   r&   r'   <module>rj      s6   J J J J J J J J J J J J J J J J J J ' ' ' ' ' '             
 
 
 
 
 
 
 
,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
\&
 &
 &
 &
 &
BH &
 &
 &
P
 
 
 
 
RX 
 
 
 
 
r&   