diff --git a/app/api/endpoints/order.py b/app/api/endpoints/order.py index bd3921c..dc46d32 100644 --- a/app/api/endpoints/order.py +++ b/app/api/endpoints/order.py @@ -1261,21 +1261,23 @@ async def deliveryman_complete_order( db.commit() - # 如果当前订单是首单,如果有邀请人,给邀请人发放优惠券 - if order.is_first_order and order_user.referral_code: + # 有邀请人,给邀请人积分奖励 + if order_user.referral_code: # 查询邀请人 invite_user = db.query(UserDB).filter( UserDB.user_code == order_user.referral_code ).first() if invite_user: - expire_time = datetime.now() + timedelta(days=settings.FIRST_ORDER_REFERRAL_COUPON_EXPIRE_DAYS) - manager = CouponManager(db) - manager.add_coupon( + points = settings.FIRST_ORDER_REFERRAL_POINT if order.is_first_order else settings.COMMON_ORDER_REFERRAL_POINT + desc = f"蜜友首单奖励" if order.is_first_order else f"蜜友下单奖励" + # 邀请人赠送积分 + point_manager = PointManager(db) + point_manager.add_points( user_id=invite_user.userid, - coupon_id=settings.FIRST_ORDER_REFERRAL_COUPON_ID, - expire_time=expire_time, - count=settings.FIRST_ORDER_REFERRAL_COUPON_COUNT + points=points, + description=desc, + order_id=order.orderid ) # 发送企业微信消息 diff --git a/app/core/config.py b/app/core/config.py index 7d4704e..0a69037 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -29,10 +29,11 @@ class Settings(BaseSettings): ORDER_EXTRA_PACKAGE_PRICE: float = 0.5 # 额外包裹费用 ORDER_EXTRA_PACKAGE_THRESHOLD: int = 5 # 额外收费阈值 - # 邀请新人赠送优惠券ID - FIRST_ORDER_REFERRAL_COUPON_ID: int = 1 - FIRST_ORDER_REFERRAL_COUPON_COUNT: int = 1 - FIRST_ORDER_REFERRAL_COUPON_EXPIRE_DAYS: int = 7 + # 邀请新人赠送积分 + FIRST_ORDER_REFERRAL_POINT: int = 5 + COMMON_ORDER_REFERRAL_POINT: int = 1 + + # JWT 配置 SECRET_KEY: str = "s10GmiRMmplfYWXYZLSsE3X36Ld4gVZxHgAcdqFGC20v3llv7UdOeWLBEEP3e40p" @@ -193,10 +194,6 @@ class ProdSettings(Settings): REDIS_PASSWORD: str = "redis_tjcZif" VERIFICATION_CODE_EXPIRE_SECONDS: int = 300 - FIRST_ORDER_REFERRAL_COUPON_ID: int = 2 - FIRST_ORDER_REFERRAL_COUPON_COUNT: int = 1 - FIRST_ORDER_REFERRAL_COUPON_EXPIRE_DAYS: int = 3 - class Config: env_file = ".env.prod" diff --git a/jobs.sqlite b/jobs.sqlite index 4070943..b6c79a2 100644 Binary files a/jobs.sqlite and b/jobs.sqlite differ