删除 miniprogram2 目录及其所有文件,包括项目配置、样式、图标和自定义组件,简化项目结构,专注于 miniprogram 目录的开发和维护。

This commit is contained in:
Alex-larget
2026-02-25 16:26:13 +08:00
parent 44f995a5a3
commit 04abcb2a87
171 changed files with 3703 additions and 21333 deletions

View File

@@ -20,7 +20,15 @@ func GetPublicDBConfig(c *gin.Context) {
defaultFree := []string{"preface", "epilogue", "1.1", "appendix-1", "appendix-2", "appendix-3"}
defaultPrices := gin.H{"section": float64(1), "fullbook": 9.9}
defaultFeatures := gin.H{"matchEnabled": true, "referralEnabled": true, "searchEnabled": true, "aboutEnabled": true}
defaultMp := gin.H{"appId": "wxb8bbb2b10dec74aa", "apiDomain": "https://soul.quwanzhi.com", "buyerDiscount": 5, "referralBindDays": 30, "minWithdraw": 10}
defaultMp := gin.H{
"appId": "wxb8bbb2b10dec74aa",
"apiDomain": "https://soulapi.quwanzhi.com", // 保留以兼容线上旧版小程序(仍从 config 读取)
"buyerDiscount": 5,
"referralBindDays": 30,
"minWithdraw": 10,
"withdrawSubscribeTmplId": "u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",
"mchId": "1318592501",
}
out := gin.H{
"success": true,
@@ -88,8 +96,16 @@ func GetPublicDBConfig(c *gin.Context) {
}
case "mp_config":
if m, ok := val.(map[string]interface{}); ok {
out["mpConfig"] = m
out["configs"].(gin.H)["mp_config"] = m
// 合并默认值DB 有则覆盖
merged := make(gin.H)
for k, v := range defaultMp {
merged[k] = v
}
for k, v := range m {
merged[k] = v
}
out["mpConfig"] = merged
out["configs"].(gin.H)["mp_config"] = merged
}
}
}
@@ -137,16 +153,24 @@ func DBConfigGet(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"success": true, "data": data})
}
// AdminSettingsGet GET /api/admin/settings 系统设置页专用:仅返回免费章节、功能开关、站点/作者与价格
// AdminSettingsGet GET /api/admin/settings 系统设置页专用:仅返回免费章节、功能开关、站点/作者与价格、小程序配置
func AdminSettingsGet(c *gin.Context) {
db := database.DB()
defaultMp := gin.H{
"appId": "wxb8bbb2b10dec74aa",
"apiDomain": "https://soulapi.quwanzhi.com", // 保留以兼容线上旧版小程序
"withdrawSubscribeTmplId": "u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",
"mchId": "1318592501",
"minWithdraw": float64(10),
}
out := gin.H{
"success": true,
"freeChapters": []string{"preface", "epilogue", "1.1", "appendix-1", "appendix-2", "appendix-3"},
"featureConfig": gin.H{"matchEnabled": true, "referralEnabled": true, "searchEnabled": true, "aboutEnabled": true},
"siteSettings": gin.H{"sectionPrice": float64(1), "baseBookPrice": 9.9, "distributorShare": float64(90), "authorInfo": gin.H{}},
"mpConfig": defaultMp,
}
keys := []string{"free_chapters", "feature_config", "site_settings"}
keys := []string{"free_chapters", "feature_config", "site_settings", "mp_config"}
for _, k := range keys {
var row model.SystemConfig
if err := db.Where("config_key = ?", k).First(&row).Error; err != nil {
@@ -177,17 +201,29 @@ func AdminSettingsGet(c *gin.Context) {
if m, ok := val.(map[string]interface{}); ok && len(m) > 0 {
out["siteSettings"] = m
}
case "mp_config":
if m, ok := val.(map[string]interface{}); ok {
merged := make(gin.H)
for k, v := range defaultMp {
merged[k] = v
}
for k, v := range m {
merged[k] = v
}
out["mpConfig"] = merged
}
}
}
c.JSON(http.StatusOK, out)
}
// AdminSettingsPost POST /api/admin/settings 系统设置页专用:一次性保存免费章节、功能开关、站点/作者与价格(不包含小程序配置,该配置已移除)
// AdminSettingsPost POST /api/admin/settings 系统设置页专用:一次性保存免费章节、功能开关、站点/作者与价格小程序配置
func AdminSettingsPost(c *gin.Context) {
var body struct {
FreeChapters []string `json:"freeChapters"`
FeatureConfig map[string]interface{} `json:"featureConfig"`
SiteSettings map[string]interface{} `json:"siteSettings"`
MpConfig map[string]interface{} `json:"mpConfig"`
}
if err := c.ShouldBindJSON(&body); err != nil {
c.JSON(http.StatusOK, gin.H{"success": false, "error": "请求体无效"})
@@ -229,6 +265,12 @@ func AdminSettingsPost(c *gin.Context) {
return
}
}
if body.MpConfig != nil {
if err := saveKey("mp_config", "小程序专用配置", body.MpConfig); err != nil {
c.JSON(http.StatusOK, gin.H{"success": false, "error": "保存小程序配置失败: " + err.Error()})
return
}
}
c.JSON(http.StatusOK, gin.H{"success": true, "message": "设置已保存"})
}
@@ -342,13 +384,14 @@ func DBConfigPost(c *gin.Context) {
func DBUsersList(c *gin.Context) {
db := database.DB()
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
pageSize, _ := strconv.Atoi(c.DefaultQuery("pageSize", "15"))
pageSize, _ := strconv.Atoi(c.DefaultQuery("pageSize", "10"))
search := strings.TrimSpace(c.DefaultQuery("search", ""))
vipFilter := c.Query("vip") // "true" 时仅返回 VIPhasFullBook
if page < 1 {
page = 1
}
if pageSize < 1 || pageSize > 100 {
pageSize = 15
pageSize = 10
}
q := db.Model(&model.User{})
@@ -356,11 +399,24 @@ func DBUsersList(c *gin.Context) {
pattern := "%" + search + "%"
q = q.Where("COALESCE(nickname,'') LIKE ? OR COALESCE(phone,'') LIKE ? OR id LIKE ?", pattern, pattern, pattern)
}
if vipFilter == "true" || vipFilter == "1" {
q = q.Where("id IN (SELECT user_id FROM orders WHERE product_type IN ? AND status = ?)",
[]string{"fullbook", "vip"}, "paid")
}
var total int64
q.Count(&total)
var users []model.User
if err := q.Order("created_at DESC").
query := db.Model(&model.User{})
if search != "" {
pattern := "%" + search + "%"
query = query.Where("COALESCE(nickname,'') LIKE ? OR COALESCE(phone,'') LIKE ? OR id LIKE ?", pattern, pattern, pattern)
}
if vipFilter == "true" || vipFilter == "1" {
query = query.Where("id IN (SELECT user_id FROM orders WHERE product_type IN ? AND status = ?)",
[]string{"fullbook", "vip"}, "paid")
}
if err := query.Order("created_at DESC").
Offset((page - 1) * pageSize).
Limit(pageSize).
Find(&users).Error; err != nil {
@@ -403,7 +459,7 @@ func DBUsersList(c *gin.Context) {
var fullbookRows []struct {
UserID string
}
db.Model(&model.Order{}).Select("user_id").Where("product_type = ? AND status = ?", "fullbook", "paid").Find(&fullbookRows)
db.Model(&model.Order{}).Select("user_id").Where("product_type IN ? AND status = ?", []string{"fullbook", "vip"}, "paid").Find(&fullbookRows)
for _, r := range fullbookRows {
hasFullBookMap[r.UserID] = true
}
@@ -745,17 +801,40 @@ func DBInit(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"message": "初始化接口已就绪(表结构由迁移维护)"}})
}
// DBDistribution GET /api/db/distribution
// DBDistribution GET /api/db/distribution(支持分页 page、pageSize筛选 status、search
func DBDistribution(c *gin.Context) {
userId := c.Query("userId")
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
pageSize, _ := strconv.Atoi(c.DefaultQuery("pageSize", "10"))
statusFilter := c.Query("status")
if page < 1 {
page = 1
}
if pageSize < 1 || pageSize > 100 {
pageSize = 10
}
db := database.DB()
var bindings []model.ReferralBinding
q := db.Order("binding_date DESC").Limit(500)
q := db.Model(&model.ReferralBinding{})
if userId != "" {
q = q.Where("referrer_id = ?", userId)
}
if err := q.Find(&bindings).Error; err != nil {
c.JSON(http.StatusOK, gin.H{"success": true, "bindings": []interface{}{}, "total": 0})
if statusFilter != "" && statusFilter != "all" {
q = q.Where("status = ?", statusFilter)
}
var total int64
q.Count(&total)
var bindings []model.ReferralBinding
query := db.Model(&model.ReferralBinding{}).Order("binding_date DESC")
if userId != "" {
query = query.Where("referrer_id = ?", userId)
}
if statusFilter != "" && statusFilter != "all" {
query = query.Where("status = ?", statusFilter)
}
if err := query.Offset((page-1)*pageSize).Limit(pageSize).Find(&bindings).Error; err != nil {
c.JSON(http.StatusOK, gin.H{"success": true, "bindings": []interface{}{}, "total": 0, "page": page, "pageSize": pageSize, "totalPages": 0})
return
}
referrerIds := make(map[string]bool)
@@ -825,7 +904,14 @@ func DBDistribution(c *gin.Context) {
"daysRemaining": days, "commission": commissionVal, "totalCommission": commissionVal, "source": "miniprogram",
})
}
c.JSON(http.StatusOK, gin.H{"success": true, "bindings": out, "total": len(out)})
totalPages := int(total) / pageSize
if int(total)%pageSize > 0 {
totalPages++
}
c.JSON(http.StatusOK, gin.H{
"success": true, "bindings": out,
"total": total, "page": page, "pageSize": pageSize, "totalPages": totalPages,
})
}
// DBChapters GET/POST /api/db/chapters