-
Notifications
You must be signed in to change notification settings - Fork 5
refactor(render3d): 报价只留积分,删掉供应商单价与人民币换算 #547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
johnnyzhang-eng
wants to merge
1
commit into
1024XEngineer:main
Choose a base branch
from
johnnyzhang-eng:fix/render3d-drop-remaining-cny
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,7 @@ | |
|
|
||
| __all__ = [ | ||
| "TencentModel3DProvider", "TencentAutoRigProvider", "TencentCosModelUploader", | ||
| "SpendNotAuthorizedError", "CREDITS", "CREDIT_PRICE_CNY", "PRESET_MOTIONS", | ||
| "SpendNotAuthorizedError", "CREDITS", "PRESET_MOTIONS", | ||
| "RIG_CREDITS", "MAX_IMAGE_BYTES", "VIEW_TYPES", | ||
| ] | ||
|
|
||
|
|
@@ -54,7 +54,6 @@ | |
|
|
||
| CREDITS = {"Normal": 20, "LowPoly": 25, "Geometry": 15, "Sketch": 25} | ||
| RIG_CREDITS = 10 | ||
| CREDIT_PRICE_CNY = 0.12 # 后付费单价;预付费 0.09–0.1 | ||
| MAX_IMAGE_BYTES = 6 * 10**6 # ImageBase64 上限 | ||
| VIEW_TYPES = ("back", "left", "right") # 正面走主参数,不在这里 | ||
|
|
||
|
|
@@ -266,10 +265,10 @@ def __init__( | |
| self._poll = poll_interval | ||
| self._max_min = max_min | ||
|
|
||
| def quote(self, n_views: int = 1) -> tuple[int, float]: | ||
| def quote(self, n_views: int = 1) -> int: | ||
| """返回 (积分, 预估元)。PBR、多视图各 +10 积分。纯计算,可在提交前随便调。""" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] 将 quote 文档同步为单个积分返回值 这里的签名和实现已改为返回 |
||
| credits = CREDITS[self._type] + (10 if self._pbr else 0) + (10 if n_views > 1 else 0) | ||
| return credits, round(credits * CREDIT_PRICE_CNY, 2) | ||
| return credits | ||
|
|
||
| def build_params(self, master: bytes, | ||
| extra_views: Mapping[str, bytes] | None = None) -> dict: | ||
|
|
@@ -305,10 +304,10 @@ def image_to_3d(self, master: bytes, *, want: str = "GLB", | |
| if want not in MODEL_FORMATS: | ||
| raise ArtifactFormatError(f"want 只能是 {MODEL_FORMATS},收到 {want!r}") | ||
| params = self.build_params(master, extra_views) | ||
| credits, cny = self.quote(1 + len(extra_views or {})) | ||
| credits = self.quote(1 + len(extra_views or {})) | ||
| if not self._allow_spend: | ||
| raise SpendNotAuthorizedError( | ||
| f"图生 3D 会消耗 {credits} 积分(后付费约 ¥{cny})。" | ||
| f"图生 3D 会消耗 {credits} 积分。" | ||
| "确认要花这笔钱后,用 TencentModel3DProvider(..., allow_spend=True) 构造。") | ||
|
|
||
| if self._ask_format: | ||
|
|
@@ -392,8 +391,8 @@ def __init__( | |
| def preset_motions(self) -> Mapping[str, PresetMotion]: | ||
| return PRESET_MOTIONS | ||
|
|
||
| def quote(self) -> tuple[int, float]: | ||
| return RIG_CREDITS, round(RIG_CREDITS * CREDIT_PRICE_CNY, 2) | ||
| def quote(self) -> int: | ||
| return RIG_CREDITS | ||
|
|
||
| def resolve_motion(self, motion: str | int | None) -> PresetMotion | None: | ||
| """动作名 / 编号 → :class:`PresetMotion`。名字不认识就抛,不猜编号。""" | ||
|
|
@@ -424,10 +423,10 @@ def rig(self, model: bytes, *, want: str = "GLB", | |
| # 入口预检在**上传与提交之前**:三条硬约束违反了接口不报错,只默默出错结果。 | ||
| check_model(model) | ||
|
|
||
| credits, cny = self.quote() | ||
| credits = self.quote() | ||
| if not self._allow_spend: | ||
| raise SpendNotAuthorizedError( | ||
| f"绑骨会消耗 {credits} 积分(后付费约 ¥{cny})。" | ||
| f"绑骨会消耗 {credits} 积分。" | ||
| "确认要花这笔钱后,用 TencentAutoRigProvider(..., allow_spend=True) 构造。") | ||
|
|
||
| url = self._upload(model, src_fmt) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这块我觉得可以统一走配置?
你看看是否可以将这些东西放在.env中?而不是在代码中写死?