fix(trading): 区分买方支付和卖方收款金额

问题:executeBuy使用含销毁倍数的tradeAmount,但买方冻结的是原始金额
原因:买方支付=原始数量×价格,卖方收款=有效数量×价格(含销毁)
修复:
- buyerPayAmount = tradeQuantity × price(买方实际支付)
- sellerReceiveAmount = effectiveQuantity × price(卖方实际收款)
- executeBuy 使用 buyerPayAmount
- executeSell 使用 sellerReceiveAmount

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-18 08:08:58 -08:00
parent 64b9dcb6c7
commit 096d87e2a8
3 changed files with 13 additions and 181 deletions

View File

@ -181,8 +181,11 @@ export class OrderService {
}
}
// 计算交易额 = 有效数量 × 价格
const tradeAmount = new Money(effectiveQuantity.value.times(match.trade.price.value));
// 计算交易额
// 买方支付:原始数量 × 价格(买方冻结的是这个金额)
const buyerPayAmount = new Money(tradeQuantity.value.times(match.trade.price.value));
// 卖方收到:有效数量 × 价格(含销毁倍数的收益)
const sellerReceiveAmount = new Money(effectiveQuantity.value.times(match.trade.price.value));
// 保存成交记录(包含销毁信息和来源标识)
await this.prisma.trade.create({
@ -196,7 +199,7 @@ export class OrderService {
quantity: tradeQuantity.value,
burnQuantity: burnQuantity.value,
effectiveQty: effectiveQuantity.value,
amount: tradeAmount.value,
amount: sellerReceiveAmount.value,
buyerSource: match.buyOrder.source,
sellerSource: match.sellOrder.source,
},
@ -218,23 +221,24 @@ export class OrderService {
await this.orderRepository.save(match.buyOrder);
await this.orderRepository.saveWithBurnInfo(match.sellOrder, burnQuantity, effectiveQuantity);
// 更新买方账户
// 更新买方账户(支付原始交易额)
const buyerAccount = await this.accountRepository.findByAccountSequence(match.buyOrder.accountSequence);
if (buyerAccount) {
buyerAccount.executeBuy(tradeQuantity, tradeAmount, match.trade.tradeNo);
buyerAccount.executeBuy(tradeQuantity, buyerPayAmount, match.trade.tradeNo);
await this.accountRepository.save(buyerAccount);
}
// 更新卖方账户(获得的是有效交易额)
// 更新卖方账户(收到含销毁倍数的有效交易额)
const sellerAccount = await this.accountRepository.findByAccountSequence(match.sellOrder.accountSequence);
if (sellerAccount) {
sellerAccount.executeSell(tradeQuantity, tradeAmount, match.trade.tradeNo);
sellerAccount.executeSell(tradeQuantity, sellerReceiveAmount, match.trade.tradeNo);
await this.accountRepository.save(sellerAccount);
}
this.logger.log(
`Trade executed: ${match.trade.tradeNo}, price=${match.trade.price.toFixed(8)}, ` +
`qty=${tradeQuantity.toFixed(8)}, burn=${burnQuantity.toFixed(8)}, amount=${tradeAmount.toFixed(8)}`,
`qty=${tradeQuantity.toFixed(8)}, burn=${burnQuantity.toFixed(8)}, ` +
`buyerPay=${buyerPayAmount.toFixed(8)}, sellerReceive=${sellerReceiveAmount.toFixed(8)}`,
);
// 发布成交事件
@ -244,7 +248,7 @@ export class OrderService {
match.sellOrder,
match.trade.price,
tradeQuantity,
tradeAmount,
sellerReceiveAmount,
burnQuantity,
effectiveQuantity,
);

View File

@ -1,172 +0,0 @@
# 阴道瘙痒病例综合分析报告
## 患者基本情况
| 项目 | 内容 |
|------|------|
| **主诉** | 反复尿路感染8+月,强调阴道瘙痒 |
| **婚育史** | 已婚已育产2 |
| **LMP** | 2025-12-14 |
---
## 已确认诊断
1. **压力性尿失禁** (Stress Urinary Incontinence)
2. **阴道前壁脱垂** (Anterior Vaginal Wall Prolapse / Cystocele)
3. **宫颈ASCUS**
4. **子宫内膜息肉**
---
## 检查报告关键发现
| 检查项目 | 结果 | 临床意义 |
|---------|------|---------|
| 白带常规 | 阴性 | 排除念珠菌、滴虫、BV |
| HPV | 阴性 | 排除HPV感染 |
| 衣原体 | 阴性 | 排除衣原体感染 |
| TCT | ASCUS | 需随访建议2026-6复查TCT+HPV |
| 尿常规隐血 | ± (0.3 mg/L) | 轻度异常 |
| B超 | 宫腔内稀高回声团14×8mm | 内膜息肉可能 |
| 左侧卵巢 | 囊性占位灶21×14mm | O-RADS 2类随访 |
---
## 阴道瘙痒可能原因分析
### 1. 泌尿生殖综合征 (GSM) / 萎缩性阴道炎 ⭐ **最可能**
**依据:**
- 检查显示HPV阴性、衣原体阴性、白带常规阴性排除感染
- 患者同时存在反复UTI + 压力性尿失禁 + 阴道前壁脱垂
- 这三者常共同出现于**雌激素下降**的情况
**机制:**
- 雌激素下降导致阴道黏膜变薄、干燥
- 阴道pH值改变易发生瘙痒、灼热感
- 同时增加UTI风险和盆底功能障碍
> Mayo Clinic指出GSM可导致阴道瘙痒、灼热感、反复UTI、尿失禁这些症状常同时出现。
### 2. 尿液刺激导致的外阴皮炎
**依据:**
- 患者有压力性尿失禁(咳嗽漏尿)
- 尿液长期刺激外阴皮肤可导致瘙痒
- 属于刺激性外阴皮炎 (Irritant Vulvar Dermatitis)
### 3. 阴道菌群失调
**依据:**
- 虽然白带常规阴性,但菌群失调仍可能存在
- 反复UTI治疗中使用抗生素可能破坏阴道正常菌群
- 菌群失调可导致轻度瘙痒不适
### 4. 阴道前壁脱垂相关
**依据:**
- 脱垂导致阴道黏膜部分暴露、干燥
- 可引起瘙痒和不适感
- 体检已确认:前壁轻度脱垂
---
## 核心病理机制
```
雌激素相对不足
┌─────┴─────┐
↓ ↓
阴道黏膜萎缩 盆底支持减弱
↓ ↓
瘙痒/干燥 脱垂/尿失禁
反复UTI
```
患者的阴道瘙痒、压力性尿失禁、阴道前壁脱垂、反复UTI形成一个**相互关联的综合征**,核心机制可能是**雌激素相对不足**。
---
## 应对思路
### 一、针对阴道瘙痒
#### 1. 评估雌激素水平
- 建议检测FSH、E2雌二醇
- 若确认雌激素低下 → **阴道局部雌激素治疗**
- 雌激素乳膏(如普罗雌烯)
- 雌激素栓剂
- 雌激素阴道环
> Mayo Clinic推荐阴道局部雌激素是GSM的首选治疗剂量低、全身吸收少、安全性好。
#### 2. 排除刺激因素
- ❌ 避免使用香皂、护理液清洗外阴
- ❌ 避免使用含香料的卫生巾/护垫
- ✅ 仅用温水清洗外阴
- ✅ 穿棉质透气内裤
- ✅ 及时更换尿垫(若在使用)
#### 3. 阴道保湿
- 可使用无香料的阴道保湿剂
- 如Replens、K-Y Liquibeads等
### 二、针对压力性尿失禁和脱垂
#### 保守治疗(已在执行)
- ✅ 盆底肌锻炼Kegel运动
- 快缩收缩后放松20次
- 慢缩收缩5秒放松5秒20次
- 早中晚各一次
- ✅ 避免提重物、抱小孩
- ✅ 防止便秘、咳嗽
- ✅ 控制体重
#### 进一步治疗选项
- 子宫托 (Pessary)
- 手术修复(根据脱垂程度)
### 三、针对子宫内膜息肉
- 患者选择暂观察
- 建议月经干净后复查B超
- 若持续存在 → 宫腔镜检查 + 手术切除
### 四、随访计划
| 时间 | 项目 |
|------|------|
| 月经干净后 | 复查B超内膜息肉 |
| 2026年6月 | 复查TCT + HPV |
| 定期 | 盆底功能评估 |
---
## 小结
患者的阴道瘙痒很可能与**泌尿生殖综合征(GSM)**或**尿液刺激性外阴炎**相关,而非感染性原因(感染指标均阴性)。
**建议:**
1. 进一步检查激素水平FSH、E2
2. 考虑阴道局部雌激素治疗
3. 继续盆底康复训练
4. 避免外阴刺激因素
---
## 参考来源
- [Mayo Clinic - Vaginitis](https://www.mayoclinic.org/diseases-conditions/vaginitis/symptoms-causes/syc-20354707)
- [Cleveland Clinic - Vaginitis](https://my.clevelandclinic.org/health/diseases/9131-vaginitis)
- [Mayo Clinic - Vaginal Atrophy/GSM](https://www.mayoclinic.org/diseases-conditions/vaginal-atrophy/symptoms-causes/syc-20352288)
- [Cleveland Clinic - Vaginal Atrophy](https://my.clevelandclinic.org/health/diseases/15500-vaginal-atrophy)
- [Mayo Clinic - Anterior Vaginal Prolapse](https://www.mayoclinic.org/diseases-conditions/cystocele/diagnosis-treatment/drc-20369457)
- [Cleveland Clinic - Vulvar Dermatitis](https://my.clevelandclinic.org/health/diseases/24336-vulvar-dermatitis)
- [Mayo Clinic - Stress Urinary Incontinence](https://www.mayoclinicproceedings.org/article/S0025-6196(24)00324-0/fulltext)
---
*报告生成时间2026-01-18*

Binary file not shown.