diff --git a/wwwroot/phone_login.dspy b/wwwroot/phone_login.dspy index 8445ab6..c615668 100644 --- a/wwwroot/phone_login.dspy +++ b/wwwroot/phone_login.dspy @@ -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') diff --git a/wwwroot/user/code_login.dspy b/wwwroot/user/code_login.dspy index 4da92e7..49c9f5b 100644 --- a/wwwroot/user/code_login.dspy +++ b/wwwroot/user/code_login.dspy @@ -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 { diff --git a/wwwroot/user/register.dspy b/wwwroot/user/register.dspy index d0be462..0c03da4 100644 --- a/wwwroot/user/register.dspy +++ b/wwwroot/user/register.dspy @@ -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 { diff --git a/wwwroot/user/sms_register.dspy b/wwwroot/user/sms_register.dspy index d6adaf5..762a1cf 100644 --- a/wwwroot/user/sms_register.dspy +++ b/wwwroot/user/sms_register.dspy @@ -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 {