fix(pricing): 预种定价API常量同步 — 3566→1887, /5→/10, 正式认种15831不变
admin-service tree-pricing.service.ts: - BASE_PORTION_PRICE: 3566 → 1887 - supplement 除数: /5 → /PORTIONS_PER_TREE(10) - BASE_PRICE 保持 15831(正式认种价格不变) - 移除 updateSupplement 中重复声明的 BASE_PRICE 局部变量 planting-service tree-pricing-admin.client.ts: - fallback basePortionPrice/totalPortionPrice: 3566 → 1887 mobile-app tree_pricing_service.dart: - 修正上次commit误改的 basePrice/totalPrice fallback: 18870 → 15831 - basePortionPrice/totalPortionPrice 保持 1887 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1e31d6d863
commit
d7f7d7082d
|
|
@ -2,8 +2,9 @@ import { Injectable, Logger } from '@nestjs/common';
|
||||||
import { PrismaService } from '../infrastructure/persistence/prisma/prisma.service';
|
import { PrismaService } from '../infrastructure/persistence/prisma/prisma.service';
|
||||||
|
|
||||||
/** 基础价常量 */
|
/** 基础价常量 */
|
||||||
const BASE_PRICE = 15831;
|
const BASE_PRICE = 15831; // 正式认种基础价(不变)
|
||||||
const BASE_PORTION_PRICE = 3566; // 预种基础价:9项 floor(整棵树/5) 取整 + 余额归总部
|
const BASE_PORTION_PRICE = 1887; // 预种基础价 [2026-03-01 调整] 9项 floor(18870/10) 取整 + 总部吸收余额
|
||||||
|
const PORTIONS_PER_TREE = 10; // [2026-03-01 调整] 5 → 10 份/棵
|
||||||
|
|
||||||
export interface TreePricingConfigResponse {
|
export interface TreePricingConfigResponse {
|
||||||
basePrice: number;
|
basePrice: number;
|
||||||
|
|
@ -52,9 +53,8 @@ export class TreePricingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalPrice = BASE_PRICE + config.currentSupplement;
|
const totalPrice = BASE_PRICE + config.currentSupplement;
|
||||||
// 预种价格 = 基础预种价(3566) + floor(加价部分/5)
|
// 预种价格 = 基础预种价(1887) + floor(加价部分/10)
|
||||||
// 注意:3566 不是 15831/5,而是各权益项 floor(amount/5) 之和 + 总部吸收余额
|
const totalPortionPrice = BASE_PORTION_PRICE + Math.floor(config.currentSupplement / PORTIONS_PER_TREE);
|
||||||
const totalPortionPrice = BASE_PORTION_PRICE + Math.floor(config.currentSupplement / 5);
|
|
||||||
return {
|
return {
|
||||||
basePrice: BASE_PRICE,
|
basePrice: BASE_PRICE,
|
||||||
basePortionPrice: BASE_PORTION_PRICE,
|
basePortionPrice: BASE_PORTION_PRICE,
|
||||||
|
|
@ -80,7 +80,6 @@ export class TreePricingService {
|
||||||
operatorId: string,
|
operatorId: string,
|
||||||
): Promise<TreePricingConfigResponse> {
|
): Promise<TreePricingConfigResponse> {
|
||||||
// 允许负数(降价对冲),但总价不能低于 0
|
// 允许负数(降价对冲),但总价不能低于 0
|
||||||
const BASE_PRICE = 15831;
|
|
||||||
if (BASE_PRICE + newSupplement < 0) {
|
if (BASE_PRICE + newSupplement < 0) {
|
||||||
throw new Error(`调价金额不能低于 -${BASE_PRICE},否则总价为负`);
|
throw new Error(`调价金额不能低于 -${BASE_PRICE},否则总价为负`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,10 @@ export class TreePricingAdminClient {
|
||||||
// 安全降级:加价为 0,不影响现有业务
|
// 安全降级:加价为 0,不影响现有业务
|
||||||
return {
|
return {
|
||||||
basePrice: 15831,
|
basePrice: 15831,
|
||||||
basePortionPrice: 3566,
|
basePortionPrice: 1887,
|
||||||
currentSupplement: 0,
|
currentSupplement: 0,
|
||||||
totalPrice: 15831,
|
totalPrice: 15831,
|
||||||
totalPortionPrice: 3566,
|
totalPortionPrice: 1887,
|
||||||
autoIncreaseEnabled: false,
|
autoIncreaseEnabled: false,
|
||||||
autoIncreaseAmount: 0,
|
autoIncreaseAmount: 0,
|
||||||
autoIncreaseIntervalDays: 0,
|
autoIncreaseIntervalDays: 0,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import '../network/api_client.dart';
|
||||||
/// - 正式认种总价 = basePrice + currentSupplement
|
/// - 正式认种总价 = basePrice + currentSupplement
|
||||||
/// - 预种总价 = totalPrice / 10(取整)
|
/// - 预种总价 = totalPrice / 10(取整)
|
||||||
class TreePricingConfig {
|
class TreePricingConfig {
|
||||||
/// 正式认种基础价(固定 18870)
|
/// 正式认种基础价(固定 15831)
|
||||||
final int basePrice;
|
final int basePrice;
|
||||||
|
|
||||||
/// 预种基础价(固定 1887)
|
/// 预种基础价(固定 1887)
|
||||||
|
|
@ -48,10 +48,10 @@ class TreePricingConfig {
|
||||||
|
|
||||||
factory TreePricingConfig.fromJson(Map<String, dynamic> json) {
|
factory TreePricingConfig.fromJson(Map<String, dynamic> json) {
|
||||||
return TreePricingConfig(
|
return TreePricingConfig(
|
||||||
basePrice: json['basePrice'] ?? 18870,
|
basePrice: json['basePrice'] ?? 15831,
|
||||||
basePortionPrice: json['basePortionPrice'] ?? 1887,
|
basePortionPrice: json['basePortionPrice'] ?? 1887,
|
||||||
currentSupplement: json['currentSupplement'] ?? 0,
|
currentSupplement: json['currentSupplement'] ?? 0,
|
||||||
totalPrice: json['totalPrice'] ?? 18870,
|
totalPrice: json['totalPrice'] ?? 15831,
|
||||||
totalPortionPrice: json['totalPortionPrice'] ?? 1887,
|
totalPortionPrice: json['totalPortionPrice'] ?? 1887,
|
||||||
autoIncreaseEnabled: json['autoIncreaseEnabled'] ?? false,
|
autoIncreaseEnabled: json['autoIncreaseEnabled'] ?? false,
|
||||||
autoIncreaseAmount: json['autoIncreaseAmount'] ?? 0,
|
autoIncreaseAmount: json['autoIncreaseAmount'] ?? 0,
|
||||||
|
|
@ -65,10 +65,10 @@ class TreePricingConfig {
|
||||||
/// 默认配置(supplement=0,与原硬编码价格一致)
|
/// 默认配置(supplement=0,与原硬编码价格一致)
|
||||||
factory TreePricingConfig.defaultConfig() {
|
factory TreePricingConfig.defaultConfig() {
|
||||||
return TreePricingConfig(
|
return TreePricingConfig(
|
||||||
basePrice: 18870,
|
basePrice: 15831,
|
||||||
basePortionPrice: 1887,
|
basePortionPrice: 1887,
|
||||||
currentSupplement: 0,
|
currentSupplement: 0,
|
||||||
totalPrice: 18870,
|
totalPrice: 15831,
|
||||||
totalPortionPrice: 1887,
|
totalPortionPrice: 1887,
|
||||||
autoIncreaseEnabled: false,
|
autoIncreaseEnabled: false,
|
||||||
autoIncreaseAmount: 0,
|
autoIncreaseAmount: 0,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue