feat(geo): add tenant/merchant/store geocode fallback and retry workflow
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 43s

This commit is contained in:
2026-02-19 17:13:00 +08:00
parent ad245078a2
commit 53f7c54c82
33 changed files with 9514 additions and 11 deletions

View File

@@ -0,0 +1,262 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TakeoutSaaS.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class AddGeoLocationRetryMetadata : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "GeoFailReason",
table: "tenants",
type: "character varying(500)",
maxLength: 500,
nullable: true,
comment: "地理定位失败原因。");
migrationBuilder.AddColumn<DateTime>(
name: "GeoNextRetryAt",
table: "tenants",
type: "timestamp with time zone",
nullable: true,
comment: "下次地理定位重试时间UTC。");
migrationBuilder.AddColumn<int>(
name: "GeoRetryCount",
table: "tenants",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "地理定位重试次数。");
migrationBuilder.AddColumn<int>(
name: "GeoStatus",
table: "tenants",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "地理定位状态。");
migrationBuilder.AddColumn<DateTime>(
name: "GeoUpdatedAt",
table: "tenants",
type: "timestamp with time zone",
nullable: true,
comment: "地理定位最近成功时间UTC。");
migrationBuilder.AddColumn<double>(
name: "Latitude",
table: "tenants",
type: "double precision",
nullable: true,
comment: "纬度信息。");
migrationBuilder.AddColumn<double>(
name: "Longitude",
table: "tenants",
type: "double precision",
nullable: true,
comment: "经度信息。");
migrationBuilder.AddColumn<string>(
name: "GeoFailReason",
table: "stores",
type: "character varying(500)",
maxLength: 500,
nullable: true,
comment: "地理定位失败原因。");
migrationBuilder.AddColumn<DateTime>(
name: "GeoNextRetryAt",
table: "stores",
type: "timestamp with time zone",
nullable: true,
comment: "下次地理定位重试时间UTC。");
migrationBuilder.AddColumn<int>(
name: "GeoRetryCount",
table: "stores",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "地理定位重试次数。");
migrationBuilder.AddColumn<int>(
name: "GeoStatus",
table: "stores",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "地理定位状态。");
migrationBuilder.AddColumn<DateTime>(
name: "GeoUpdatedAt",
table: "stores",
type: "timestamp with time zone",
nullable: true,
comment: "地理定位最近成功时间UTC。");
migrationBuilder.AddColumn<string>(
name: "GeoFailReason",
table: "merchants",
type: "character varying(500)",
maxLength: 500,
nullable: true,
comment: "地理定位失败原因。");
migrationBuilder.AddColumn<DateTime>(
name: "GeoNextRetryAt",
table: "merchants",
type: "timestamp with time zone",
nullable: true,
comment: "下次地理定位重试时间UTC。");
migrationBuilder.AddColumn<int>(
name: "GeoRetryCount",
table: "merchants",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "地理定位重试次数。");
migrationBuilder.AddColumn<int>(
name: "GeoStatus",
table: "merchants",
type: "integer",
nullable: false,
defaultValue: 0,
comment: "地理定位状态。");
migrationBuilder.AddColumn<DateTime>(
name: "GeoUpdatedAt",
table: "merchants",
type: "timestamp with time zone",
nullable: true,
comment: "地理定位最近成功时间UTC。");
migrationBuilder.CreateIndex(
name: "IX_tenants_GeoStatus_GeoNextRetryAt",
table: "tenants",
columns: new[] { "GeoStatus", "GeoNextRetryAt" });
migrationBuilder.CreateIndex(
name: "IX_tenants_Longitude_Latitude",
table: "tenants",
columns: new[] { "Longitude", "Latitude" },
filter: "\"Longitude\" IS NOT NULL AND \"Latitude\" IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_stores_TenantId_MerchantId_GeoStatus_GeoNextRetryAt",
table: "stores",
columns: new[] { "TenantId", "MerchantId", "GeoStatus", "GeoNextRetryAt" });
migrationBuilder.CreateIndex(
name: "IX_merchants_Longitude_Latitude",
table: "merchants",
columns: new[] { "Longitude", "Latitude" },
filter: "\"Longitude\" IS NOT NULL AND \"Latitude\" IS NOT NULL");
migrationBuilder.CreateIndex(
name: "IX_merchants_TenantId_GeoStatus_GeoNextRetryAt",
table: "merchants",
columns: new[] { "TenantId", "GeoStatus", "GeoNextRetryAt" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_tenants_GeoStatus_GeoNextRetryAt",
table: "tenants");
migrationBuilder.DropIndex(
name: "IX_tenants_Longitude_Latitude",
table: "tenants");
migrationBuilder.DropIndex(
name: "IX_stores_TenantId_MerchantId_GeoStatus_GeoNextRetryAt",
table: "stores");
migrationBuilder.DropIndex(
name: "IX_merchants_Longitude_Latitude",
table: "merchants");
migrationBuilder.DropIndex(
name: "IX_merchants_TenantId_GeoStatus_GeoNextRetryAt",
table: "merchants");
migrationBuilder.DropColumn(
name: "GeoFailReason",
table: "tenants");
migrationBuilder.DropColumn(
name: "GeoNextRetryAt",
table: "tenants");
migrationBuilder.DropColumn(
name: "GeoRetryCount",
table: "tenants");
migrationBuilder.DropColumn(
name: "GeoStatus",
table: "tenants");
migrationBuilder.DropColumn(
name: "GeoUpdatedAt",
table: "tenants");
migrationBuilder.DropColumn(
name: "Latitude",
table: "tenants");
migrationBuilder.DropColumn(
name: "Longitude",
table: "tenants");
migrationBuilder.DropColumn(
name: "GeoFailReason",
table: "stores");
migrationBuilder.DropColumn(
name: "GeoNextRetryAt",
table: "stores");
migrationBuilder.DropColumn(
name: "GeoRetryCount",
table: "stores");
migrationBuilder.DropColumn(
name: "GeoStatus",
table: "stores");
migrationBuilder.DropColumn(
name: "GeoUpdatedAt",
table: "stores");
migrationBuilder.DropColumn(
name: "GeoFailReason",
table: "merchants");
migrationBuilder.DropColumn(
name: "GeoNextRetryAt",
table: "merchants");
migrationBuilder.DropColumn(
name: "GeoRetryCount",
table: "merchants");
migrationBuilder.DropColumn(
name: "GeoStatus",
table: "merchants");
migrationBuilder.DropColumn(
name: "GeoUpdatedAt",
table: "merchants");
}
}
}

View File

@@ -2468,6 +2468,31 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("character varying(500)")
.HasComment("冻结原因。");
b.Property<string>("GeoFailReason")
.HasMaxLength(500)
.HasColumnType("character varying(500)")
.HasComment("地理定位失败原因。");
b.Property<DateTime?>("GeoNextRetryAt")
.HasColumnType("timestamp with time zone")
.HasComment("下次地理定位重试时间UTC。");
b.Property<int>("GeoRetryCount")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0)
.HasComment("地理定位重试次数。");
b.Property<int>("GeoStatus")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0)
.HasComment("地理定位状态。");
b.Property<DateTime?>("GeoUpdatedAt")
.HasColumnType("timestamp with time zone")
.HasComment("地理定位最近成功时间UTC。");
b.Property<bool>("IsFrozen")
.ValueGeneratedOnAdd()
.HasColumnType("boolean")
@@ -2557,8 +2582,13 @@ namespace TakeoutSaaS.Infrastructure.Migrations
b.HasIndex("TenantId");
b.HasIndex("Longitude", "Latitude")
.HasFilter("\"Longitude\" IS NOT NULL AND \"Latitude\" IS NOT NULL");
b.HasIndex("TenantId", "Status");
b.HasIndex("TenantId", "GeoStatus", "GeoNextRetryAt");
b.ToTable("merchants", null, t =>
{
t.HasComment("商户主体信息,承载入驻和资质审核结果。");
@@ -4935,6 +4965,31 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("timestamp with time zone")
.HasComment("强制关闭时间。");
b.Property<string>("GeoFailReason")
.HasMaxLength(500)
.HasColumnType("character varying(500)")
.HasComment("地理定位失败原因。");
b.Property<DateTime?>("GeoNextRetryAt")
.HasColumnType("timestamp with time zone")
.HasComment("下次地理定位重试时间UTC。");
b.Property<int>("GeoRetryCount")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0)
.HasComment("地理定位重试次数。");
b.Property<int>("GeoStatus")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0)
.HasComment("地理定位状态。");
b.Property<DateTime?>("GeoUpdatedAt")
.HasColumnType("timestamp with time zone")
.HasComment("地理定位最近成功时间UTC。");
b.Property<double?>("Latitude")
.HasColumnType("double precision")
.HasComment("纬度。");
@@ -5056,6 +5111,8 @@ namespace TakeoutSaaS.Infrastructure.Migrations
b.HasIndex("TenantId", "OwnershipType");
b.HasIndex("TenantId", "MerchantId", "GeoStatus", "GeoNextRetryAt");
b.ToTable("stores", null, t =>
{
t.HasComment("门店信息,承载营业配置与能力。");
@@ -6460,11 +6517,40 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("timestamp with time zone")
.HasComment("服务到期时间UTC。");
b.Property<string>("GeoFailReason")
.HasMaxLength(500)
.HasColumnType("character varying(500)")
.HasComment("地理定位失败原因。");
b.Property<DateTime?>("GeoNextRetryAt")
.HasColumnType("timestamp with time zone")
.HasComment("下次地理定位重试时间UTC。");
b.Property<int>("GeoRetryCount")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0)
.HasComment("地理定位重试次数。");
b.Property<int>("GeoStatus")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasDefaultValue(0)
.HasComment("地理定位状态。");
b.Property<DateTime?>("GeoUpdatedAt")
.HasColumnType("timestamp with time zone")
.HasComment("地理定位最近成功时间UTC。");
b.Property<string>("Industry")
.HasMaxLength(64)
.HasColumnType("character varying(64)")
.HasComment("所属行业,如餐饮、零售等。");
b.Property<double?>("Latitude")
.HasColumnType("double precision")
.HasComment("纬度信息。");
b.Property<string>("LegalEntityName")
.HasColumnType("text")
.HasComment("法人或公司主体名称。");
@@ -6473,6 +6559,10 @@ namespace TakeoutSaaS.Infrastructure.Migrations
.HasColumnType("text")
.HasComment("LOGO 图片地址。");
b.Property<double?>("Longitude")
.HasColumnType("double precision")
.HasComment("经度信息。");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128)
@@ -6537,6 +6627,11 @@ namespace TakeoutSaaS.Infrastructure.Migrations
b.HasIndex("ContactPhone")
.IsUnique();
b.HasIndex("GeoStatus", "GeoNextRetryAt");
b.HasIndex("Longitude", "Latitude")
.HasFilter("\"Longitude\" IS NOT NULL AND \"Latitude\" IS NOT NULL");
b.ToTable("tenants", null, t =>
{
t.HasComment("租户信息,描述租户的生命周期与基础资料。");