bugfix
This commit is contained in:
parent
4c5089edb8
commit
4f98a84635
BIN
models/pricing_item.xlsx
Normal file
BIN
models/pricing_item.xlsx
Normal file
Binary file not shown.
BIN
models/pricing_program.xlsx
Normal file
BIN
models/pricing_program.xlsx
Normal file
Binary file not shown.
BIN
models/pricing_spec.xlsx
Normal file
BIN
models/pricing_spec.xlsx
Normal file
Binary file not shown.
BIN
models/pricing_type.xlsx
Normal file
BIN
models/pricing_type.xlsx
Normal file
Binary file not shown.
0
pricing/__init__.py
Normal file
0
pricing/__init__.py
Normal file
0
pricing/init.py
Normal file
0
pricing/init.py
Normal file
63
pricing/pricing.py
Normal file
63
pricing/pricing.py
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
|
||||||
|
class PricingType:
|
||||||
|
|
||||||
|
|
||||||
|
class PricingProgram
|
||||||
|
def __init__(self, ppid, sor):
|
||||||
|
self.ppid = ppid
|
||||||
|
self.sor = sor
|
||||||
|
|
||||||
|
async def init(self):
|
||||||
|
await self.get_program()
|
||||||
|
await self.get_pricing_type(self.ptid)
|
||||||
|
|
||||||
|
async def get_program():
|
||||||
|
recs = await self.sor.R('pricing_program', {'id': self.ppid})
|
||||||
|
if len(recs):
|
||||||
|
self.__dict__.update(recs[0])
|
||||||
|
|
||||||
|
async def get_pricing_type(self, ptid):
|
||||||
|
self.pricing_type = await self.sor.R('pricing_type',
|
||||||
|
{'id': ptid})
|
||||||
|
|
||||||
|
async def get_items(self):
|
||||||
|
recs = await self.sor.R('program_item', {'ppid': self.id})
|
||||||
|
return recs
|
||||||
|
|
||||||
|
async def get_spec(self, psid):
|
||||||
|
recs = await self.sor.R('program_spec', {'id', psid})
|
||||||
|
return recs
|
||||||
|
|
||||||
|
pricing_program_charging(sor, pricing_program_id, data):
|
||||||
|
pp = PricingProgram(pricing_program_id)
|
||||||
|
await pp.init()
|
||||||
|
pp_items = pp.get_items()
|
||||||
|
specs = pt.get_spec()
|
||||||
|
charges = []
|
||||||
|
for item in pp_items:
|
||||||
|
charge = item.copy()
|
||||||
|
spec = await pp.get_spec(item.psid)
|
||||||
|
d = data.get(spec.spec_name)
|
||||||
|
if d is None:
|
||||||
|
continue
|
||||||
|
cnt = data.get(spec.count_name, 1)
|
||||||
|
if spec.pricing_spec_mode == 'spec_name':
|
||||||
|
if d == item.spec_value:
|
||||||
|
charge.amount = item.pricing_amount * cnt
|
||||||
|
charges.append(charge)
|
||||||
|
elif spec.pricing_spec_mode == 'spec_amount':
|
||||||
|
if charge.pricing_unit is None or charge.pricing_unit < 1:
|
||||||
|
charge.pricing_unit = 1
|
||||||
|
charge.amount = d * charge_amount / charge.pricing_unit
|
||||||
|
charges.append(charge)
|
||||||
|
elif spec.pricing_spec_mode == 'remote_pricing':
|
||||||
|
charge.amount = await get_remote_pricing(charge.uappid,
|
||||||
|
charge.apiname, params=d)
|
||||||
|
charges.append(charge)
|
||||||
|
elif spec.pricing_spec_mode == 'sub_pricing':
|
||||||
|
sub_charges = await pricing_program_chargeing(self.sor,
|
||||||
|
charge.subppid, d)
|
||||||
|
charges += sub_charges
|
||||||
|
|
||||||
|
return charges
|
||||||
|
|
||||||
4
pyproject.toml
Normal file
4
pyproject.toml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=61", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
15
setup.cfg
Normal file
15
setup.cfg
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[metadata]
|
||||||
|
name=pricing
|
||||||
|
version = 0.0.1
|
||||||
|
description = A pricing module for online store
|
||||||
|
author = "yu moqing"
|
||||||
|
author_email = "yumoqing@gmail.com"
|
||||||
|
readme = "README.md"
|
||||||
|
license = "MIT"
|
||||||
|
[options]
|
||||||
|
packages = find:
|
||||||
|
requires_python = ">=3.8"
|
||||||
|
install_requires =
|
||||||
|
apppublic
|
||||||
|
ahserver
|
||||||
|
sqlor
|
||||||
Loading…
x
Reference in New Issue
Block a user