已完成用户APP首期功能开发

交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
This commit is contained in:
czl231
2026-09-13 00:57:32 +08:00
parent a0a4bb1218
commit 3ef33b531d
793 changed files with 40959 additions and 1204 deletions

View File

@@ -0,0 +1,41 @@
// 功能描述供气订单支付完成后原子生成正式押金事实版本1.0.0。
package payment
import (
"fmt"
"time"
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
// CompleteGasDeposits 将下单时锁定的押金快照转为用户押金记录,重复回调不会重复入账。
func CompleteGasDeposits(tx *gorm.DB, orderIdentity string, paidAt time.Time) error {
var order models.GasorderBasic
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).Where("identity = ?", orderIdentity).First(&order).Error; err != nil {
return err
}
var snapshots []models.GasorderDeposit
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).Where("gasorder_basic_id = ? AND deposit_status = ?", order.ID, 10).Find(&snapshots).Error; err != nil {
return err
}
for _, snapshot := range snapshots {
var existing int64
if err := tx.Model(&models.DepositRecord{}).Where("gasorder_id = ? AND product_info_id = ? AND status <> ?", order.ID, snapshot.ProductInfoID, 3).Count(&existing).Error; err != nil {
return err
}
if existing == 0 {
record := models.DepositRecord{Entity: models.Entity{Identity: models.NewIdentity(), Status: 1}, DepositStatus: 10,
DepositNo: fmt.Sprintf("DEP%s-%s", paidAt.Format("20060102150405.000000"), snapshot.Identity), UserAccountID: order.UserAccountID, ProductInfoID: snapshot.ProductInfoID,
PolicyID: snapshot.PolicyID, GasorderID: order.ID, Amount: snapshot.Amount, PaidAt: paidAt}
if err := tx.Create(&record).Error; err != nil {
return err
}
}
if err := tx.Model(&snapshot).Where("deposit_status = ?", 10).Update("deposit_status", 23).Error; err != nil {
return err
}
}
return nil
}