kboss/b/zj/customer_sync_note.dspy
2025-07-16 14:27:17 +08:00

65 lines
2.2 KiB
Plaintext

async def customer_sync_note(ns={}):
"""
:param ns:
:return:
"""
if not ns:
return {
'code': 1,
'status': False,
'msg': 'Unable to obtain parameters'
}
if not (ns.get('orig_cid') and ns.get('thirdid')):
return {
'code': 1,
'status': False,
'msg': 'Unable to obtain parameters, orig_cid or thirdid is empty'
}
db = DBPools()
async with db.sqlorContext('kboss') as sor:
try:
if not ns.get('orig_cid').startswith('kboss_'):
return {
'code': 1,
'status': False,
'msg': 'orig_cid String format should start with kboss_'
}
orgid = ns.get('orig_cid').split("kboss_")[1]
ns['orig_cid'] = orgid
if ns.get('err_message'):
sql_up = """update zj_users set sf_msg = ${err_message}$, sync_status = 3 where thirdId = ${thirdid}$ and orgid = ${orig_cid}$;"""
await sor.sqlExe(sql_up, ns)
return {
'code': 200,
'status': True,
'msg': 'Success'
}
else:
sql_up = """update zj_users set zjcid = ${zjcid}$, sync_status = 2 where thirdId = ${thirdid}$ and orgid = ${orig_cid}$;"""
await sor.sqlExe(sql_up, ns)
res = await sor.R('zj_users', ns)
result = res[0] if res else {}
if result.get('zjcid') and result.get('sync_status'):
return {
'code': 200,
'status': True,
'msg': 'Success'
}
else:
return {
'code': 1,
'status': False,
'msg': 'failed, please contact sales personnel for processing'
}
except Exception as e:
raise e
return {
'status': False,
'msg': 'failed, please contact sales personnel for processing',
}
ret = await customer_sync_note(params_kw)
return ret