async def testaddbz_order(ns={}): """ 立即下单 导入数据 """ db = DBPools() async with db.sqlorContext('kboss') as sor: if ns: """[{'name': 'xxx', 'money': 154800.0, 'stime': '2022-01-22'}...]""" data = ns.get('data') product = await sor.R('product',{"name":'线下数据'}) try: for i in data: user = await sor.R('users', {'username': i['name']}) orgid = await sor.R('organization', {'id': user[0]['orgid']}) amountadll = 0 bz_ns = {} bz_ns['id'] = uuid() bz_ns['order_status'] = '0' bz_ns['business_op'] = 'BUY' bz_ns['userid'] = user[0]['id'] bz_ns['customerid'] = orgid[0]['id'] bz_ns['order_date'] = i['stime'] await sor.C('bz_order', bz_ns) # 添加账户表 nss = {} nss['id'] = uuid() nss['orderid'] = bz_ns['id'] nss['productid'] = product[0]['id'] nss['providerid'] = product[0]['providerid'] nss['list_price'] = i['money'] nss['discount'] = ns.get('discount') nss['quantity'] = '1' nss['price'] = i['money'] nss['amount'] = i['money'] amountadll += float(nss['amount']) await sor.C('order_goods', nss) await sor.U('bz_order', {'id': bz_ns['id'], 'amount': amountadll}) return {'status': True, 'msg': '下单成功'} except Exception as error: raise error return {'status': False, 'msg': '下单失败'} ret = await testaddbz_order(params_kw) return ret