This commit is contained in:
yumoqing 2025-04-12 19:59:51 +08:00
commit 26c78373a9
9 changed files with 102 additions and 100 deletions

View File

@ -1,6 +1,26 @@
{
"tblname":"agreement",
"params":{
"toolbar":{
"tools":[
{
"name":"prodauth",
"selected_row":true,
"label":"授权"
}
]
},
"binds":[
{
"wid":"self",
"event":"prodauth",
"actiontype":"urlwidget",
"target":"PopupWindow",
"options":{
"url":"{{entire_url('../agree_prodclone.dspy')}}"
}
}
],
"browserfields": {
"exclouded": ["id"],
"alters": {}

View File

@ -2,28 +2,6 @@
"tblname":"agreeproduct",
"params":{
"logined_userorgid":"orgid",
"toolbar":{
"tools":[
{
"name":"prodauth",
"label":"授权"
}
]
},
"binds":[
{
"wid":"self",
"event":"prodauth",
"actiontype":"urlwidget",
"target":"PopupWindow",
"options":{
"url":"{{entire_url('platformbiz/agreeproduct_auth.dspy')}}",
"params":{
"agreedetailid":"{{params_kw.agreedetailid}}"
}
}
}
],
"browserfields": {
"exclouded": ["id", "agreedetailid"],
"alters": {}

View File

@ -1,9 +1,32 @@
{
"treetype":"singlestruct",
"tblname":"prodtype",
"uitype":"tree",
"alias":"choose_prodtype",
"params":{
"toolbar":{
"bar_cwidth":2,
"tools":[
{
"name":"test",
"selected_data":true,
"label":"TEST"
}
]
},
"binds":[
{
"wid":"self",
"event":"prodauth",
"actiontype":"urlwidget",
"target":"PopupWindow",
"options":{
"url":"{{entire_url('platformbiz/ag.dspy')}}",
"params":{
"agreedetailid":"{{params_kw.agreedetailid}}"
}
}
}
],
"idField":"id",
"textField":"name",
"editable":true,
@ -11,12 +34,7 @@
"alters":{}
},
"edit_exclouded_fields":["del_flg", "create_at"],
"checkField":"dd",
"parentField":"parentid",
"toolbar":{
},
"binds":[
]
"parentField":"parentid"
}
}

View File

@ -6,39 +6,6 @@
"textField":"name",
"parentField":"parentid",
"editable":true,
"toolbar":{
"tools":[
{
"target":"PopupWindow",
"name":"spec",
"selected_data":true,
"label":"规格"
}
]
},
"binds":[
{
"wid":"self",
"event":"spec",
"actiontype":"urlwidget",
"target":"PopupWindow",
"popup_options":{
"width":"80%",
"height":"80%"
},
"params_mapping":{
"mapping":{
"id":"prodtypeid"
},
"need_others":false
},
"options":{
"params":{
},
"url":"/platformbiz/prodtypespec"
}
}
],
"browserfields": {
"exclouded": ["id", "parentid" ],
"alters": {}

8
platformbiz/getdbname.py Normal file
View File

@ -0,0 +1,8 @@
ifrom ahserver.serverenv import get_serverenv
def get_dbname():
f = get_serverenv('get_module_dbname')
if f is None:
raise Exception('get_module_dbname() not found')
return f('platformbiz')

View File

@ -5,15 +5,16 @@ from appPublic.registerfunction import rfexe
from sqlor.dbpools import DBPools
from ahserver.serverenv import get_serverenv
from accounting.accounting_config import Accounting
from accounting.bizaccount import BizAccounting
from accounting.bill import write_bill
from getdbname import get_dbname
async def get_owner_orgid(sor, orgid):
return '0'
async def get_balance(orgid):
db = DBPools()
dbname = await rfexe('get_module_dbname', 'platformbiz')
dbname = get_dbname()
async with db.sqlorContext(dbname) as sor:
f = get_serverenv('getCustomerBalance')
if f:
@ -23,43 +24,42 @@ async def get_balance(orgid):
class PlatformBizAcc:
"""
"""
async def accounting(self, sor, biz_orderid):
biz_order = await sor.R('biz_order', {'id':biz_orderid})
details = await sor.R('biz_orderdetail',{'orderid':biz_orderid})
self.customerid = biz_order.customerid
self.resellerid = biz_order.resellerid
self.orderid = biz_order.id
self.userid = biz_order.userid
self.business_op = biz_order.business_op
get_business_date = get_serverenv('get_business_date')
self.curdate = await get_business_date(sor)
self.transamt = biz_order.amount
async def build_accountset(self, sor, biz_order, biz_orderdetails):
acconuntset = DictObject()
accountset['action'] = biz_order.business_op
accountset['owner'] = get_owner_orgid(sor, '0')
accountset['reseller'] = biz_order.resellerid
accountset['customer'] = biz_order.customerid
accountset['交易金额'] = biz_order.amount
transfee = await get_transfee(sor, self.resellerid, biz_order.amount, self.curdate)
self.variable = {
"交易金额":biz_order.amount,
"交易费用":transfee
}
bill = await write_bill(sor, self.customerid, self.userid,
self.orderid,
self.business_op,
biz_order.amount)
self.billid = bill.id
self.bill = bill
self.providerid = None
self.resellerid = None
self.action = self.recharge.action
self.productid = None
self.timestamp = timestampstr()
a = Accounting(self)
r = await a.do_accounting(sor)
for detail in details:
detail.prod_config = json.loads(detail.prod_config)
accountset['交易费用'] = transfee
accountset.subsets = []
for od in biz_orderdetails:
price_infos = await get_price_infos(sor, self.resellerid,
self.customerid,
detail.productid,
detail.prod_config)
if len(price_infos) > 1:
for pi in price_infos[:-1]:
actions = biz_order.business_op.split('_')
actions[0] = actions[0] + '*'
aset = DictObject()
aset['action'] = '_'.join(actions)
aset['owner'] = get_owner_orgid(sor, '0')
aset['reseller'] = pi['buyerid']
aset['provider'] = pi['resellerid']
aset['采购成本'] = pi['sell_price']
accountset.subsets.append(aset)
return accountset
async def accounting(self, sor, biz_orderid):
biz_order = await sor.R('biz_order', {'id':biz_orderid})
details = await sor.R('biz_orderdetail',{'orderid':biz_orderid})
accountset = await self.build_accountset(biz_order, details)
self.curdate = await get_business_date(sor)
transfee = await get_transfee(sor, self.resellerid, biz_order.amount, self.curdate)
a = BizAccounting(self.curdate, biz_order, accountset)
r = await a.do_accounting(sor)
async def get_orgid_by_trans_role(self, sor, orgtype):
if orgtype== 'customer':
@ -109,5 +109,3 @@ class PlatformBizAccRecharge(PlatformBizAcc):
a = Accounting(self)
r = await a.do_accounting(sor)
async def PayAccounting(sor):
pass

View File

@ -18,6 +18,7 @@ a.description,
a.prod_state,
a.product_code,
a.spec_note,
b.id as apid,
d.id as agreeid,
d.providerid,
d.resellerid
@ -35,8 +36,9 @@ where a.id = b.providerpid
return
for rec in recs:
pid = getID()
d = {
"id":getID(),
"id":pid,
"name":rec.name,
"prodtypeid":rec.prodtypeid,
"orgid":rec.resellerid,
@ -49,6 +51,7 @@ where a.id = b.providerpid
"spec_note":rec.spec_note
}
await sor.C('product', d)
await sor.U('agreeproduct', {'id':rec.apid, 'resellerpid':pid})
async def open_agree_account(sor, providerid, sellerid):
accounting_orgid = await get_accounting_orgid(sor)

View File

@ -3,6 +3,7 @@ from appPublic.registerfunction import rfexe
from appPublic.log import exception, debug
from sqlor.dbpools import DBPools
from pf_pay.ali_pay import Zhifubao_Pay
from getdbname import get_dbname
from platformbiz.biz_order import add_recharge_log, add_recharge_order
class Recharge:
@ -23,7 +24,7 @@ class Recharge:
async def start_recharge_action(self, action):
db = DBPools()
dbname = await rfexe('get_module_dbname', 'platformbiz')
dbname = get_dbname()
async with db.sqlorContext(dbname) as sor:
order = await add_recharge_order(sor, self.customerid,
self.userid,

View File

@ -0,0 +1,9 @@
debug(f'{params_kw=}')
orgid = await get_userorgid()
db = DBPools()
dbname = get_module_dbname('platformbiz')
async with db.sqlorContext(dbname) as sor:
await agree_products_clone(sor, orgid, params_kw.id)
return UiMessage(title='product clone', message='product clone finished')
debug('product clone error')
return UiError(title='product clone', message='product clone error')