修复合同到期时间与终止恢复规则
- 合同动作中文化并将到期时间设为必填\n- 隐藏修订记录无业务意义的删除时间\n- 禁止已终止合同直接启用,统一三端状态规则\n- 补充回归测试、模拟数据回填和中文文档
This commit is contained in:
@@ -544,6 +544,8 @@ func MockData(database *gorm.DB) error {
|
||||
// seedAdditionalCoreScenarios 补齐十组可独立检索的核心主数据。
|
||||
// 每组记录都使用本组父表的数据库 ID 建立关联,避免仅有展示字段而无真实关系。
|
||||
func seedAdditionalCoreScenarios(database *gorm.DB, passwordHash string, now time.Time) error {
|
||||
// 联调合同统一设置一年有效期,保证合同详情具有明确到期时间。
|
||||
nextYear := now.AddDate(1, 0, 0)
|
||||
for scenario := 2; scenario <= 10; scenario++ {
|
||||
sequence := 1000 + scenario*100
|
||||
suffix := fmt.Sprintf("%03d", scenario)
|
||||
@@ -635,11 +637,17 @@ func seedAdditionalCoreScenarios(database *gorm.DB, passwordHash string, now tim
|
||||
ContractNo: "MOCK-CONTRACT-" + suffix, UserAccountID: user.ID, GasBasicID: gas.ID,
|
||||
DeliveryBasicID: delivery.ID, Title: fmt.Sprintf("示例供气合同 %d", scenario),
|
||||
Terms: "仅用于开发联调。", DefaultDeliveryFee: 500,
|
||||
SignedAt: now, EffectiveAt: now,
|
||||
SignedAt: now, EffectiveAt: now, ExpiredAt: &nextYear,
|
||||
}
|
||||
if err := put(database, &contract); err != nil {
|
||||
return err
|
||||
}
|
||||
// 仅回填本函数生成的联调合同,修复旧种子执行后已存在的空到期时间。
|
||||
if err := database.Model(&models.GasorderContract{}).
|
||||
Where("identity = ? AND contract_no = ? AND expired_at IS NULL", contract.Identity, contract.ContractNo).
|
||||
Update("expired_at", nextYear).Error; err != nil {
|
||||
return fmt.Errorf("backfill mock contract expiry: %w", err)
|
||||
}
|
||||
|
||||
contractProduct := models.GasorderContractProduct{
|
||||
Entity: entity(sequence+11, common.StatusEnable), GasorderContractID: contract.ID,
|
||||
|
||||
Reference in New Issue
Block a user