feat: 注册时检查促销码并绑定客户归属关系

- register.dspy: 用户名密码注册后检查promo_code_id
- sms_register.dspy: 短信注册后检查promo_code_id
- code_login.dspy: 验证码登录/自动注册后检查promo_code_id
- phone_login.dspy: 手机登录/自动注册后检查promo_code_id
- 绑定失败只记日志不影响注册成功(try/except)
This commit is contained in:
Hermes Agent 2026-06-24 00:56:33 +08:00
parent 600fddced3
commit 70a19238c1
4 changed files with 39 additions and 1 deletions

View File

@ -96,7 +96,17 @@ try:
await openCustomerAccounts(sor, ownerid, orgid)
except Exception as e:
exception(f'{e}')
# 检查是否有促销码,如果有则绑定客户归属关系
promo_code_id = params_kw.get('promo_code_id')
if promo_code_id:
try:
_new_orgid = d['data']['user'].orgid
await bind_customer(request, DictObject(promo_code_id=promo_code_id, customerid=_new_orgid))
debug(f'phone_login: customer {_new_orgid} bound via promo_code {promo_code_id}')
except Exception as e:
exception(f'phone_login: bind_customer failed: {e}')
r = d['data']['user']
await remember_user(r.id, username=r.username, userorgid=r.orgid)
debug(f'here')

View File

@ -209,6 +209,16 @@ try:
except Exception as e:
exception(f'{e}')
# 检查是否有促销码,如果有则绑定客户归属关系
promo_code_id = params_kw.get('promo_code_id')
if promo_code_id:
try:
_new_orgid = d['data']['user'].orgid
await bind_customer(request, DictObject(promo_code_id=promo_code_id, customerid=_new_orgid))
debug(f'code_login: customer {_new_orgid} bound via promo_code {promo_code_id}')
except Exception as e:
exception(f'code_login: bind_customer failed: {e}')
r = d['data']['user']
await remember_user(r.id, username=r.username, userorgid=r.orgid)
return {

View File

@ -22,6 +22,15 @@ async with db.sqlorContext(dbname) as sor:
except Exception as e:
exception(f'{e},{orgid=}')
# 检查是否有促销码,如果有则绑定客户归属关系
promo_code_id = params_kw.get('promo_code_id')
if promo_code_id:
try:
await bind_customer(request, DictObject(promo_code_id=promo_code_id, customerid=orgid))
debug(f'register: customer {orgid} bound via promo_code {promo_code_id}')
except Exception as e:
exception(f'register: bind_customer failed for {orgid} via {promo_code_id}: {e}')
# 注册成功后自动登录
await remember_user(user.id, username=user.username, userorgid=user.orgid)
return {

View File

@ -130,6 +130,15 @@ try:
except Exception as e:
exception(f'{e},{orgid=}')
# 检查是否有促销码,如果有则绑定客户归属关系
promo_code_id = params_kw.get('promo_code_id')
if promo_code_id:
try:
await bind_customer(request, DictObject(promo_code_id=promo_code_id, customerid=orgid))
debug(f'sms_register: customer {orgid} bound via promo_code {promo_code_id}')
except Exception as e:
exception(f'sms_register: bind_customer failed for {orgid} via {promo_code_id}: {e}')
# 注册成功后自动登录
await remember_user(user.id, username=user.username, userorgid=user.orgid)
return {