diff --git a/api/handler/chat_handler.go b/api/handler/chat_handler.go index 3e683a9a..7ff98bec 100644 --- a/api/handler/chat_handler.go +++ b/api/handler/chat_handler.go @@ -152,7 +152,7 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session types.ChatSession } if userVo.Calls <= 0 && userVo.ChatConfig.ApiKey == "" { - replyMessage(ws, "您的对话次数已经用尽,请联系管理员充值!") + replyMessage(ws, "您的对话次数已经用尽,请联系管理员或者点击左下角菜单加入众筹获得100次对话!") replyMessage(ws, "![](/images/wx.png)") return nil } diff --git a/api/handler/reward_handler.go b/api/handler/reward_handler.go index 79f6ca82..dc03d13f 100644 --- a/api/handler/reward_handler.go +++ b/api/handler/reward_handler.go @@ -24,7 +24,7 @@ func NewRewardHandler(server *core.AppServer, db *gorm.DB) *RewardHandler { // Verify 打赏码核销 func (h *RewardHandler) Verify(c *gin.Context) { var data struct { - TxId string + TxId string `json:"tx_id"` } if err := c.ShouldBindJSON(&data); err != nil { resp.ERROR(c, types.InvalidArgs) @@ -34,12 +34,12 @@ func (h *RewardHandler) Verify(c *gin.Context) { var item model.Reward res := h.db.Where("tx_id = ?", data.TxId).First(&item) if res.Error != nil { - resp.ERROR(c, "无效的打赏交易流水号!") + resp.ERROR(c, "无效的众筹交易流水号!") return } if item.Status { - resp.ERROR(c, "当前打赏交易流水号已经被核销,请不要重复核销!") + resp.ERROR(c, "当前众筹交易流水号已经被核销,请不要重复核销!") return } @@ -50,7 +50,7 @@ func (h *RewardHandler) Verify(c *gin.Context) { } tx := h.db.Begin() - calls := (item.Amount + 0.01) * 10 + calls := (item.Amount + 0.1) * 10 res = h.db.Model(&user).UpdateColumn("calls", gorm.Expr("calls + ?", calls)) if res.Error != nil { resp.ERROR(c, "更新数据库失败!") diff --git a/api/main.go b/api/main.go index 4e6d7b10..01d2062e 100644 --- a/api/main.go +++ b/api/main.go @@ -107,7 +107,9 @@ func main() { fx.Invoke(func(bot *wexin.WeChatBot) { go func() { err := bot.Login() - log.Fatal(err) + if err != nil { + log.Fatal(err) + } }() }), @@ -188,7 +190,7 @@ func main() { }), fx.Invoke(func(s *core.AppServer, h *handler.RewardHandler) { group := s.Engine.Group("/api/reward/") - group.GET("verify", h.Verify) + group.POST("verify", h.Verify) }), // 管理后台控制器 diff --git a/database/reward.sql b/database/reward.sql index 054b6685..74011eb2 100644 --- a/database/reward.sql +++ b/database/reward.sql @@ -15,4 +15,5 @@ ALTER TABLE `chatgpt_rewards` ALTER TABLE `chatgpt_rewards` MODIFY `id` int NOT NULL AUTO_INCREMENT; -COMMIT; \ No newline at end of file + +update chatgpt_users set calls=0 \ No newline at end of file diff --git a/web/public/images/reward.png b/web/public/images/reward.png index d7f65b74..88f4234f 100644 Binary files a/web/public/images/reward.png and b/web/public/images/reward.png differ diff --git a/web/src/components/RewardVerify.vue b/web/src/components/RewardVerify.vue new file mode 100644 index 00000000..cfffaafd --- /dev/null +++ b/web/src/components/RewardVerify.vue @@ -0,0 +1,75 @@ + + + + + \ No newline at end of file diff --git a/web/src/views/ChatPlus.vue b/web/src/views/ChatPlus.vue index 17e16395..c6ee8c27 100644 --- a/web/src/views/ChatPlus.vue +++ b/web/src/views/ChatPlus.vue @@ -67,6 +67,20 @@ 绑定手机号 + + + + + 加入众筹 + + + + + + + 众筹核销 + + @@ -199,11 +213,14 @@ + + @@ -212,7 +229,7 @@ 账单和服务器的费用。

- +

@@ -226,11 +243,13 @@ import ChatReply from "@/components/ChatReply.vue"; import { ArrowDown, Check, + Checked, Close, Delete, Edit, Iphone, Plus, + Present, Promotion, RefreshRight, Search, @@ -249,9 +268,11 @@ import ConfigDialog from "@/components/ConfigDialog.vue"; import PasswordDialog from "@/components/PasswordDialog.vue"; import {checkSession} from "@/action/session"; import BindMobile from "@/components/BindMobile.vue"; +import RewardVerify from "@/components/RewardVerify.vue"; const title = ref('ChatGPT-智能助手'); const logo = 'images/logo.png'; +const rewardImg = ref('images/reward.png') const models = ref([]) const model = ref('gpt-3.5-turbo') const chatData = ref([]); @@ -271,6 +292,7 @@ const showConfigDialog = ref(false); const showPasswordDialog = ref(false); const showBindMobileDialog = ref(false); const showRewardDialog = ref(false); +const showRewardVerifyDialog = ref(false); const isLogin = ref(false) if (isMobile()) {