diff --git a/api/core/config.go b/api/core/config.go index 90e5abfb..3184dda8 100644 --- a/api/core/config.go +++ b/api/core/config.go @@ -36,7 +36,7 @@ func NewDefaultConfig() *types.AppConfig { MjConfig: types.MidJourneyConfig{Enabled: false}, SdConfig: types.StableDiffusionConfig{Enabled: false, Txt2ImgJsonPath: "res/text2img.json"}, WeChatBot: false, - AlipayConfig: types.AlipayConfig{Enabled: false}, + AlipayConfig: types.AlipayConfig{Enabled: false, SandBox: false}, } } diff --git a/api/core/types/config.go b/api/core/types/config.go index c4b1100d..fdf6b9a0 100644 --- a/api/core/types/config.go +++ b/api/core/types/config.go @@ -62,6 +62,7 @@ type AliYunSmsConfig struct { type AlipayConfig struct { Enabled bool // 是否启用该服务 + SandBox bool // 是否沙盒环境 Company string // 公司名称 UserId string // 支付宝用户 ID AppId string // 支付宝 AppID @@ -69,7 +70,6 @@ type AlipayConfig struct { PublicKey string // 用户公钥文件路径 AlipayPublicKey string // 支付宝公钥文件路径 RootCert string // Root 秘钥路径 - ReturnURL string // 支付成功返回 URL NotifyURL string // 异步通知回调 } @@ -144,5 +144,6 @@ type SystemConfig struct { RewardImg string `json:"reward_img"` // 众筹收款二维码地址 EnabledFunction bool `json:"enabled_function"` // 启用 API 函数功能 EnabledReward bool `json:"enabled_reward"` // 启用众筹功能 + EnabledAlipay bool `json:"enabled_alipay"` // 是否启用支付宝支付通道 DefaultModels []string `json:"default_models"` // 默认开通的 AI 模型 } diff --git a/api/handler/payment_handler.go b/api/handler/payment_handler.go index 39ce615d..4b2dd64a 100644 --- a/api/handler/payment_handler.go +++ b/api/handler/payment_handler.go @@ -62,7 +62,7 @@ func (h *PaymentHandler) Alipay(c *gin.Context) { h.db.Model(&order).UpdateColumn("status", types.OrderScanned) // 生成支付链接 notifyURL := h.App.Config.AlipayConfig.NotifyURL - returnURL := h.App.Config.AlipayConfig.ReturnURL + returnURL := "" // 关闭同步回跳 amount := fmt.Sprintf("%.2f", order.Amount) uri, err := h.alipayService.PayUrlMobile(order.OrderNo, notifyURL, returnURL, amount, order.Subject) @@ -113,6 +113,11 @@ func (h *PaymentHandler) OrderQuery(c *gin.Context) { // AlipayQrcode 生成支付宝支付 URL 二维码 func (h *PaymentHandler) AlipayQrcode(c *gin.Context) { + if !h.App.SysConfig.EnabledAlipay { + resp.ERROR(c, "当前支付通道已经关闭,请联系管理员开通!") + return + } + var data struct { ProductId uint `json:"product_id"` UserId int `json:"user_id"` diff --git a/api/handler/user_handler.go b/api/handler/user_handler.go index 0208e5dc..746392dc 100644 --- a/api/handler/user_handler.go +++ b/api/handler/user_handler.go @@ -232,6 +232,7 @@ type userProfile struct { TotalTokens int64 `json:"total_tokens"` Tokens int64 `json:"tokens"` ExpiredTime int64 `json:"expired_time"` + Vip bool `json:"vip"` } func (h *UserHandler) Profile(c *gin.Context) { diff --git a/api/service/payment/alipay_service.go b/api/service/payment/alipay_service.go index 9dd1a9c5..d33d5032 100644 --- a/api/service/payment/alipay_service.go +++ b/api/service/payment/alipay_service.go @@ -28,7 +28,7 @@ func NewAlipayService(appConfig *types.AppConfig) (*AlipayService, error) { return nil, fmt.Errorf("error with read App Private key: %v", err) } - xClient, err := alipay.New(config.AppId, priKey, false) + xClient, err := alipay.New(config.AppId, priKey, !config.SandBox) if err != nil { return nil, fmt.Errorf("error with initialize alipay service: %v", err) } diff --git a/web/src/components/BindMobile.vue b/web/src/components/BindMobile.vue index 1f04fecf..75b3b5de 100644 --- a/web/src/components/BindMobile.vue +++ b/web/src/components/BindMobile.vue @@ -16,8 +16,14 @@ - - + + + + + + + + @@ -81,6 +87,12 @@ const close = function () { } - \ No newline at end of file diff --git a/web/src/components/UserProfile.vue b/web/src/components/UserProfile.vue index 2ba963b3..e803c89d 100644 --- a/web/src/components/UserProfile.vue +++ b/web/src/components/UserProfile.vue @@ -16,6 +16,14 @@ {{ user.mobile }} + + + {{ user['calls'] }} @@ -60,6 +68,7 @@ import {dateFormat} from "@/utils/libs"; import {checkSession} from "@/action/session"; const user = ref({ + vip: false, username: '', nickname: '', avatar: '', @@ -68,6 +77,7 @@ const user = ref({ tokens: 0, chat_config: {api_keys: {OpenAI: "", Azure: "", ChatGLM: ""}} }) +const vipImg = ref("/images/vip.png") onMounted(() => { checkSession().then(() => { diff --git a/web/src/views/ChatPlus.vue b/web/src/views/ChatPlus.vue index 525e4bb9..977dc899 100644 --- a/web/src/views/ChatPlus.vue +++ b/web/src/views/ChatPlus.vue @@ -194,8 +194,7 @@ - + diff --git a/web/src/views/Member.vue b/web/src/views/Member.vue index 87384567..b67ea5bc 100644 --- a/web/src/views/Member.vue +++ b/web/src/views/Member.vue @@ -10,16 +10,20 @@ - 修改密码 + 修改密码 - 绑定手机号 + 绑定手机号 - 加入众筹 + 加入众筹 - 众筹核销 + 众筹核销 + + + + 退出登录 @@ -67,7 +71,7 @@ - @@ -81,7 +85,7 @@
您好,众筹 9.9元,就可以兑换 100 次对话,以此来覆盖我们的 OpenAI 账单和服务器的费用。由于本人没有开通微信支付,付款后请凭借转账单号进入核销【众筹核销】菜单手动核销。 + style="color: #f56c6c">由于本人没有开通微信支付,付款后请凭借转账单号,点击【众筹核销】按钮手动核销。
@@ -94,7 +98,7 @@ :close-on-click-modal="false" :show-close="true" :width="400" - title="用户登录"> + title="充值订单支付">
@@ -130,6 +134,7 @@ import PasswordDialog from "@/components/PasswordDialog.vue"; import BindMobile from "@/components/BindMobile.vue"; import RewardVerify from "@/components/RewardVerify.vue"; import {useRouter} from "vue-router"; +import {removeUserToken} from "@/store/session"; const listBoxHeight = window.innerHeight - 97 const list = ref([]) @@ -201,6 +206,15 @@ const queryOrder = (orderNo) => { }) } +const logout = function () { + httpGet('/api/user/logout').then(() => { + removeUserToken(); + router.push('/login'); + }).catch(() => { + ElMessage.error('注销失败!'); + }) +} +