salescrm/b/user/user_productadd.dspy
2025-10-27 15:50:44 +08:00

64 lines
2.6 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

async def user_productadd(ns):
"""
渠道上传产品
:param ns:
user_id : 用户id = varchar
name :产品名 = varchar
description :产品描述 = varchar
price :产品价格 = int
effect_date :设备可用日期 = dete
expire_date :失效日期 = dete
spec_note :规格说明 = varchar(数组)
server_username :服务器用户名 = varchar
server_passwrod :服务器密码 = varchar
ip 服务器ip地址 = varchar
:return:
"""
db = DBPools()
async with db.sqlorContext('kboss') as sor:
user = await sor.R('users', {'id':ns.get('user_id')})
user_provider = await sor.R('provider', {'user_orgid':user[0]['orgid']})
#产品表
ns_product = {}
# ns_product['id'] = UUID()
ns_product['id'] = uuid()
ns_product['providerid'] = user_provider[0]['id']
ns_product['name'] = ns.get('name')
ns_product['description'] = ns.get('description')
ns_product['ptype'] = '17'
ns_product['state'] = '0'
ns_product['effect_date'] = ns.get('effect_date')
ns_product['expire_date'] = ns.get('expire_date')
ns_product['salemode'] = '0'
ns_product['spec_note'] = ns.get('spec_note')
ns_product['reseller_orgid'] = 'mIWUHBeeDM8mwAFPIQ8pS'
#协议折扣表
saleprotocol = await sor.R('saleprotocol',{'offer_orgid':user_provider[0]['orgid']})
params = await sor.R('params',{'id':'p16'})
ns_product_salemode = {}
ns_product_salemode['id'] = uuid()
# ns_product_salemode['id'] = UUID()
ns_product_salemode['protocolid'] = saleprotocol[0]['id']
ns_product_salemode['providerid'] = user_provider[0]['user_orgid']
ns_product_salemode['productid'] = ns_product['id']
ns_product_salemode['discount'] = params[0]['pvalue']
#产品配置表
ns_product_config = {}
ns_product_config['id'] = uuid()
# ns_product_config['id'] = UUID()
ns_product_config['price'] = ns.get('price')
ns_product_config['server_username'] = ns.get('server_username')
ns_product_config['server_password'] = ns.get('server_password')
ns_product_config['ip'] = ns.get('ip')
try:
await sor.C('product',ns_product)
await sor.C('product_salemode', ns_product_salemode)
await sor.C('product_config', ns_product_config)
return {'status': True, 'msg': '产品添加成功'}
except Exception as e:
raise e
return {'status': False, 'msg': '失败'}
ret = await user_productadd(params_kw)
return ret