feat(points): 新增积分赠送
This commit is contained in:
39
core/routers/card/actions.py
Normal file
39
core/routers/card/actions.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Project : X25020501_card_book
|
||||
# @File : actions.py.py
|
||||
# @Date : 2025/5/7 20:38
|
||||
# @Software : PyCharm
|
||||
# @Author : xingc
|
||||
# @Desc :
|
||||
import logging
|
||||
|
||||
from core.base.schema import ProductCategory
|
||||
from core.db.crud import CRUD
|
||||
from core.db.models import User, Product
|
||||
from core.routers.auth.schema import LoginUser
|
||||
from core.routers.pay.actions import actions_handler
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def reward_points_after_uploading_pictures(
|
||||
db_crud: CRUD,
|
||||
gift_product_id: int,
|
||||
login_user: LoginUser
|
||||
):
|
||||
product: Product = await db_crud.get(
|
||||
model=Product, filters={
|
||||
'id': gift_product_id,
|
||||
'category': ProductCategory.GIFT
|
||||
}
|
||||
)
|
||||
if not product:
|
||||
logger.warning(f'Product not found -> {gift_product_id}')
|
||||
return
|
||||
|
||||
user: User = await db_crud.get(model=User, filters={'user_id': login_user.user_id})
|
||||
|
||||
try:
|
||||
await actions_handler(db_crud, product, user)
|
||||
except Exception as e:
|
||||
logger.error(f'Reward Points After Uploading Pictures -> {e}')
|
||||
Reference in New Issue
Block a user