fix: 修正零售价架构错误 + 清理旧微信配置 + 归档提案 + 前端接口文档
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m12s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m12s
1. 修正 retail_price 架构:
- 删除 batch-pricing 接口的 pricing_target 字段和 retail_price 分支
(上级只能改下级成本价,不能改零售价)
- 新增 PATCH /api/admin/packages/:id/retail-price 接口
(代理自己改自己的零售价,校验 retail_price >= cost_price)
2. 清理旧微信 YAML 配置(已全部迁移到数据库 tb_wechat_config):
- 删除 config.yaml 中 wechat.official_account 配置节
- 删除 NewOfficialAccountApp() 旧工厂函数
- 清理 personal_customer service 中的死代码(旧登录/绑定微信方法)
- 清理 docker-compose.prod.yml 中旧微信环境变量和证书挂载注释
3. 归档四个已完成提案到 openspec/changes/archive/
4. 新增前端接口变更说明文档(docs/前端接口变更说明.md)
5. 修正归档提案和 specs 中关于 pricing_target 的错误描述
This commit is contained in:
@@ -24,7 +24,6 @@ type Config struct {
|
||||
DefaultAdmin DefaultAdminConfig `mapstructure:"default_admin"`
|
||||
Storage StorageConfig `mapstructure:"storage"`
|
||||
Gateway GatewayConfig `mapstructure:"gateway"`
|
||||
Wechat WechatConfig `mapstructure:"wechat"`
|
||||
}
|
||||
|
||||
// ServerConfig HTTP 服务器配置
|
||||
@@ -157,20 +156,6 @@ type PresignConfig struct {
|
||||
DownloadExpires time.Duration `mapstructure:"download_expires"` // 下载 URL 有效期(默认:24h)
|
||||
}
|
||||
|
||||
// WechatConfig 微信配置
|
||||
type WechatConfig struct {
|
||||
OfficialAccount OfficialAccountConfig `mapstructure:"official_account"`
|
||||
}
|
||||
|
||||
// OfficialAccountConfig 微信公众号配置
|
||||
type OfficialAccountConfig struct {
|
||||
AppID string `mapstructure:"app_id"`
|
||||
AppSecret string `mapstructure:"app_secret"`
|
||||
Token string `mapstructure:"token"`
|
||||
AESKey string `mapstructure:"aes_key"`
|
||||
OAuthRedirectURL string `mapstructure:"oauth_redirect_url"`
|
||||
}
|
||||
|
||||
type requiredField struct {
|
||||
value string
|
||||
name string
|
||||
|
||||
@@ -116,12 +116,3 @@ gateway:
|
||||
app_secret: "BZeQttaZQt0i73moF"
|
||||
timeout: 30
|
||||
|
||||
# 微信配置(必填项需通过环境变量设置)
|
||||
wechat:
|
||||
official_account:
|
||||
app_id: "" # 必填:JUNHONG_WECHAT_OFFICIAL_ACCOUNT_APP_ID
|
||||
app_secret: "" # 必填:JUNHONG_WECHAT_OFFICIAL_ACCOUNT_APP_SECRET(敏感)
|
||||
token: "" # 可选:JUNHONG_WECHAT_OFFICIAL_ACCOUNT_TOKEN
|
||||
aes_key: "" # 可选:JUNHONG_WECHAT_OFFICIAL_ACCOUNT_AES_KEY(敏感)
|
||||
oauth_redirect_url: "" # 可选:JUNHONG_WECHAT_OFFICIAL_ACCOUNT_OAUTH_REDIRECT_URL
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/ArtisanCloud/PowerWeChat/v3/src/officialAccount"
|
||||
"github.com/ArtisanCloud/PowerWeChat/v3/src/payment"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/config"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
@@ -22,37 +21,6 @@ func NewRedisCache(rdb *redis.Client) kernel.CacheInterface {
|
||||
})
|
||||
}
|
||||
|
||||
// NewOfficialAccountApp 创建微信公众号应用实例
|
||||
func NewOfficialAccountApp(cfg *config.Config, cache kernel.CacheInterface, logger *zap.Logger) (*officialAccount.OfficialAccount, error) {
|
||||
oaCfg := cfg.Wechat.OfficialAccount
|
||||
if oaCfg.AppID == "" || oaCfg.AppSecret == "" {
|
||||
return nil, fmt.Errorf("微信公众号配置不完整:缺少 AppID 或 AppSecret")
|
||||
}
|
||||
|
||||
userConfig := &officialAccount.UserConfig{
|
||||
AppID: oaCfg.AppID,
|
||||
Secret: oaCfg.AppSecret,
|
||||
Cache: cache,
|
||||
}
|
||||
|
||||
// 可选配置:消息验证 Token 和 AESKey
|
||||
if oaCfg.Token != "" {
|
||||
userConfig.Token = oaCfg.Token
|
||||
}
|
||||
if oaCfg.AESKey != "" {
|
||||
userConfig.AESKey = oaCfg.AESKey
|
||||
}
|
||||
|
||||
app, err := officialAccount.NewOfficialAccount(userConfig)
|
||||
if err != nil {
|
||||
logger.Error("创建微信公众号应用失败", zap.Error(err))
|
||||
return nil, fmt.Errorf("创建微信公众号应用失败: %w", err)
|
||||
}
|
||||
|
||||
logger.Info("微信公众号应用初始化成功", zap.String("app_id", oaCfg.AppID))
|
||||
return app, nil
|
||||
}
|
||||
|
||||
// NewOfficialAccountAppFromConfig 从数据库配置创建微信公众号应用实例
|
||||
func NewOfficialAccountAppFromConfig(wechatConfig *model.WechatConfig, cache kernel.CacheInterface, logger *zap.Logger) (*officialAccount.OfficialAccount, error) {
|
||||
if wechatConfig == nil {
|
||||
|
||||
Reference in New Issue
Block a user