feat(store): v4.0.18 门店多收款账户与子账号继承二维码
C 端门店列表拼接省市区县地址;门店多银行账户与默认打款账户;子账号独立 sa_ 关联码及统计维度;同步 v4.0.18 开发文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
-- v4.0.18:门店多收款银行账户(列表 + 默认账户)
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `store_bank_account` (
|
||||
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`store_id` BIGINT UNSIGNED NOT NULL,
|
||||
`bank_account_name` VARCHAR(64) NOT NULL,
|
||||
`bank_account_no` VARCHAR(32) NOT NULL,
|
||||
`bank_branch` VARCHAR(128) NULL,
|
||||
`is_default` TINYINT NOT NULL DEFAULT 0,
|
||||
`status` ENUM('ACTIVE','DISABLED') NOT NULL DEFAULT 'ACTIVE',
|
||||
`sort_order` INT NOT NULL DEFAULT 0,
|
||||
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_store_bank_account_store_status` (`store_id`, `status`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='门店收款银行账户';
|
||||
|
||||
-- 回填:按门店主账号(is_primary=1,缺失则取最早绑定账号)的收款字段,为每店生成一条默认账户
|
||||
INSERT INTO `store_bank_account`
|
||||
(`store_id`, `bank_account_name`, `bank_account_no`, `bank_branch`, `is_default`, `status`, `sort_order`)
|
||||
SELECT
|
||||
b.`store_id`,
|
||||
a.`bank_account_name`,
|
||||
a.`bank_account_no`,
|
||||
a.`bank_branch`,
|
||||
1,
|
||||
'ACTIVE',
|
||||
0
|
||||
FROM `store_account_store` b
|
||||
JOIN `store_account` a ON a.`id` = b.`store_account_id`
|
||||
WHERE a.`bank_account_name` IS NOT NULL
|
||||
AND TRIM(a.`bank_account_name`) <> ''
|
||||
AND a.`bank_account_no` IS NOT NULL
|
||||
AND TRIM(a.`bank_account_no`) <> ''
|
||||
AND b.`store_account_id` = (
|
||||
SELECT b2.`store_account_id`
|
||||
FROM `store_account_store` b2
|
||||
JOIN `store_account` a2 ON a2.`id` = b2.`store_account_id`
|
||||
WHERE b2.`store_id` = b.`store_id`
|
||||
ORDER BY (a2.`is_primary` = 1) DESC, a2.`id` ASC
|
||||
LIMIT 1
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE `updated_at` = `updated_at`;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- v4.0.18:子账号独立继承二维码 —— 记录带来用户的子账号归属
|
||||
|
||||
ALTER TABLE `user_user`
|
||||
ADD COLUMN `assoc_sub_account_id` BIGINT UNSIGNED NULL AFTER `assoc_partner_account_id`,
|
||||
ADD KEY `idx_user_user_assoc_sub_account_id` (`assoc_sub_account_id`);
|
||||
@@ -1278,6 +1278,7 @@ model PartnerAccount {
|
||||
stores Store[]
|
||||
bills PartnerBill[]
|
||||
assocUsers User[] @relation("UserPartnerAssoc")
|
||||
assocSubUsers User[] @relation("UserSubAccountAssoc")
|
||||
userNotes PartnerUserNote[]
|
||||
assocQrcodeResource CommonResource? @relation("PartnerAssocQrcode", fields: [assocQrcodeResourceId], references: [id], onDelete: SetNull)
|
||||
activityPoster ActivityPoster? @relation(fields: [activityPosterId], references: [id], onDelete: SetNull)
|
||||
@@ -1457,6 +1458,7 @@ model User {
|
||||
sourceLabel String? @map("source_label") @db.VarChar(128)
|
||||
referrerUserId BigInt? @map("referrer_user_id") @db.UnsignedBigInt
|
||||
assocPartnerAccountId BigInt? @map("assoc_partner_account_id") @db.UnsignedBigInt
|
||||
assocSubAccountId BigInt? @map("assoc_sub_account_id") @db.UnsignedBigInt
|
||||
assocBoundAt DateTime? @map("assoc_bound_at") @db.DateTime(3)
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
@@ -1466,6 +1468,7 @@ model User {
|
||||
referrer User? @relation("UserReferrer", fields: [referrerUserId], references: [id], onDelete: SetNull)
|
||||
referrers User[] @relation("UserReferrer")
|
||||
assocPartner PartnerAccount? @relation("UserPartnerAssoc", fields: [assocPartnerAccountId], references: [id], onDelete: SetNull)
|
||||
assocSubAccount PartnerAccount? @relation("UserSubAccountAssoc", fields: [assocSubAccountId], references: [id], onDelete: SetNull)
|
||||
partnerNotes PartnerUserNote[]
|
||||
avatar CommonResource? @relation("UserAvatar", fields: [avatarResourceId], references: [id], onDelete: SetNull)
|
||||
addresses UserAddress[]
|
||||
@@ -1482,6 +1485,7 @@ model User {
|
||||
@@index([sourceType, sourceRefId])
|
||||
@@index([referrerUserId])
|
||||
@@index([assocPartnerAccountId])
|
||||
@@index([assocSubAccountId])
|
||||
@@index([mergedIntoUserId])
|
||||
@@index([wxOpenId])
|
||||
@@index([isTest])
|
||||
@@ -1598,6 +1602,7 @@ model Store {
|
||||
packageChangeRequests StorePackageChangeRequest[]
|
||||
infoChangeRequests StoreInfoChangeRequest[]
|
||||
categoryLinks StoreCategoryLink[]
|
||||
bankAccounts StoreBankAccount[]
|
||||
|
||||
@@index([cityId, status])
|
||||
@@index([partnerAccountId])
|
||||
@@ -1607,6 +1612,25 @@ model Store {
|
||||
@@map("store_store")
|
||||
}
|
||||
|
||||
/// 门店收款银行账户(一个门店可维护多个,is_default 为打款默认账户)
|
||||
model StoreBankAccount {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
storeId BigInt @map("store_id") @db.UnsignedBigInt
|
||||
bankAccountName String @map("bank_account_name") @db.VarChar(64)
|
||||
bankAccountNo String @map("bank_account_no") @db.VarChar(32)
|
||||
bankBranch String? @map("bank_branch") @db.VarChar(128)
|
||||
isDefault Int @default(0) @map("is_default") @db.TinyInt
|
||||
status AccountStatus @default(ACTIVE)
|
||||
sortOrder Int @default(0) @map("sort_order")
|
||||
createdAt DateTime @default(now()) @map("created_at") @db.DateTime(3)
|
||||
updatedAt DateTime @updatedAt @map("updated_at") @db.DateTime(3)
|
||||
|
||||
store Store @relation(fields: [storeId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([storeId, status])
|
||||
@@map("store_bank_account")
|
||||
}
|
||||
|
||||
/// Store visibility whitelist phones (match by bound user phone)
|
||||
model StoreVisibilityPhone {
|
||||
id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
|
||||
|
||||
Reference in New Issue
Block a user