fix coupon bug.
This commit is contained in:
parent
bb28b7015f
commit
4f85408fd9
@ -149,6 +149,7 @@ async def receive_coupons(
|
||||
coupon_id=coupon.id,
|
||||
coupon_name=coupon.name,
|
||||
coupon_amount=coupon.amount,
|
||||
coupon_type=coupon.coupon_type,
|
||||
expire_time=expire_time,
|
||||
status=CouponStatus.UNUSED
|
||||
)
|
||||
|
||||
@ -22,6 +22,7 @@ from app.core.point_manager import PointManager
|
||||
from app.core.point_manager import PointRecordType
|
||||
from app.core.account import AccountManager
|
||||
import logging
|
||||
from app.core.security import get_password_hash
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@ -52,6 +53,7 @@ async def wechat_phone_login(
|
||||
|
||||
# 获取用户手机号
|
||||
phone_info = await wechat.get_phone_number(request.phone_code)
|
||||
|
||||
|
||||
if not phone_info:
|
||||
return error_response(code=400, message="获取手机号失败")
|
||||
@ -74,15 +76,13 @@ async def wechat_phone_login(
|
||||
phone=phone,
|
||||
user_code=user_code,
|
||||
referral_code=request.referral_code,
|
||||
password=get_password_hash("123456"),
|
||||
openid=openid, # 保存 openid
|
||||
unionid=unionid # 保存 unionid
|
||||
)
|
||||
db.add(user)
|
||||
db.flush()
|
||||
|
||||
# 发放优惠券
|
||||
# from app.api.endpoints.user import issue_register_coupons
|
||||
# issue_register_coupons(db, user.userid)
|
||||
|
||||
db.commit()
|
||||
db.refresh(user)
|
||||
|
||||
@ -76,7 +76,7 @@ class UserCouponInfo(BaseModel):
|
||||
coupon_amount: float
|
||||
coupon_type: CouponType
|
||||
expire_time: datetime
|
||||
used_time: datetime
|
||||
used_time: Optional[datetime] = None
|
||||
status: CouponStatus
|
||||
create_time: datetime
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user