mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-09-17 16:56:38 +08:00
feat: reward verify is ready
This commit is contained in:
parent
dd88622c64
commit
e02badf7bb
@ -152,7 +152,7 @@ func (h *ChatHandler) sendMessage(ctx context.Context, session types.ChatSession
|
|||||||
}
|
}
|
||||||
|
|
||||||
if userVo.Calls <= 0 && userVo.ChatConfig.ApiKey == "" {
|
if userVo.Calls <= 0 && userVo.ChatConfig.ApiKey == "" {
|
||||||
replyMessage(ws, "您的对话次数已经用尽,请联系管理员充值!")
|
replyMessage(ws, "您的对话次数已经用尽,请联系管理员或者点击左下角菜单加入众筹获得100次对话!")
|
||||||
replyMessage(ws, "")
|
replyMessage(ws, "")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ func NewRewardHandler(server *core.AppServer, db *gorm.DB) *RewardHandler {
|
|||||||
// Verify 打赏码核销
|
// Verify 打赏码核销
|
||||||
func (h *RewardHandler) Verify(c *gin.Context) {
|
func (h *RewardHandler) Verify(c *gin.Context) {
|
||||||
var data struct {
|
var data struct {
|
||||||
TxId string
|
TxId string `json:"tx_id"`
|
||||||
}
|
}
|
||||||
if err := c.ShouldBindJSON(&data); err != nil {
|
if err := c.ShouldBindJSON(&data); err != nil {
|
||||||
resp.ERROR(c, types.InvalidArgs)
|
resp.ERROR(c, types.InvalidArgs)
|
||||||
@ -34,12 +34,12 @@ func (h *RewardHandler) Verify(c *gin.Context) {
|
|||||||
var item model.Reward
|
var item model.Reward
|
||||||
res := h.db.Where("tx_id = ?", data.TxId).First(&item)
|
res := h.db.Where("tx_id = ?", data.TxId).First(&item)
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
resp.ERROR(c, "无效的打赏交易流水号!")
|
resp.ERROR(c, "无效的众筹交易流水号!")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.Status {
|
if item.Status {
|
||||||
resp.ERROR(c, "当前打赏交易流水号已经被核销,请不要重复核销!")
|
resp.ERROR(c, "当前众筹交易流水号已经被核销,请不要重复核销!")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ func (h *RewardHandler) Verify(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tx := h.db.Begin()
|
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))
|
res = h.db.Model(&user).UpdateColumn("calls", gorm.Expr("calls + ?", calls))
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
resp.ERROR(c, "更新数据库失败!")
|
resp.ERROR(c, "更新数据库失败!")
|
||||||
|
@ -107,7 +107,9 @@ func main() {
|
|||||||
fx.Invoke(func(bot *wexin.WeChatBot) {
|
fx.Invoke(func(bot *wexin.WeChatBot) {
|
||||||
go func() {
|
go func() {
|
||||||
err := bot.Login()
|
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) {
|
fx.Invoke(func(s *core.AppServer, h *handler.RewardHandler) {
|
||||||
group := s.Engine.Group("/api/reward/")
|
group := s.Engine.Group("/api/reward/")
|
||||||
group.GET("verify", h.Verify)
|
group.POST("verify", h.Verify)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// 管理后台控制器
|
// 管理后台控制器
|
||||||
|
@ -15,4 +15,5 @@ ALTER TABLE `chatgpt_rewards`
|
|||||||
|
|
||||||
ALTER TABLE `chatgpt_rewards`
|
ALTER TABLE `chatgpt_rewards`
|
||||||
MODIFY `id` int NOT NULL AUTO_INCREMENT;
|
MODIFY `id` int NOT NULL AUTO_INCREMENT;
|
||||||
COMMIT;
|
|
||||||
|
update chatgpt_users set calls=0
|
Binary file not shown.
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 261 KiB |
75
web/src/components/RewardVerify.vue
Normal file
75
web/src/components/RewardVerify.vue
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
v-model="showDialog"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:show-close="mobile !== ''"
|
||||||
|
:before-close="close"
|
||||||
|
:title="title"
|
||||||
|
>
|
||||||
|
<div class="form" id="bind-mobile-form">
|
||||||
|
<el-alert v-if="mobile !== ''" type="info" show-icon :closable="false" style="margin-bottom: 20px;">
|
||||||
|
<p>请输入您参与众筹的微信支付转账单号兑换相应的对话次数。</p>
|
||||||
|
</el-alert>
|
||||||
|
|
||||||
|
<el-form :model="form" label-width="120px">
|
||||||
|
<el-form-item label="转账单号">
|
||||||
|
<el-input v-model="form.tx_id"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="save">
|
||||||
|
确认核销
|
||||||
|
</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {computed, ref} from "vue";
|
||||||
|
import {ElMessage} from "element-plus";
|
||||||
|
import {httpPost} from "@/utils/http";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
show: Boolean,
|
||||||
|
mobile: String
|
||||||
|
});
|
||||||
|
|
||||||
|
const showDialog = computed(() => {
|
||||||
|
return props.show
|
||||||
|
})
|
||||||
|
|
||||||
|
const title = ref('众筹码核销')
|
||||||
|
const form = ref({
|
||||||
|
tx_id: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
const emits = defineEmits(['hide']);
|
||||||
|
|
||||||
|
const save = () => {
|
||||||
|
if (form.value.tx_id === '') {
|
||||||
|
return ElMessage.error({message: "请输入微信支付转账单号"});
|
||||||
|
}
|
||||||
|
|
||||||
|
httpPost('/api/reward/verify', form.value).then(() => {
|
||||||
|
ElMessage.success({
|
||||||
|
message: '核销成功',
|
||||||
|
duration: 1000,
|
||||||
|
onClose: () => emits('hide', false)
|
||||||
|
})
|
||||||
|
}).catch(e => {
|
||||||
|
ElMessage.error({message: "核销失败:" + e.message});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const close = function () {
|
||||||
|
emits('hide', false);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
@ -67,6 +67,20 @@
|
|||||||
<span>绑定手机号</span>
|
<span>绑定手机号</span>
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
|
|
||||||
|
<el-dropdown-item @click="showRewardDialog = true">
|
||||||
|
<el-icon>
|
||||||
|
<Present/>
|
||||||
|
</el-icon>
|
||||||
|
<span>加入众筹</span>
|
||||||
|
</el-dropdown-item>
|
||||||
|
|
||||||
|
<el-dropdown-item @click="showRewardVerifyDialog = true">
|
||||||
|
<el-icon>
|
||||||
|
<Checked/>
|
||||||
|
</el-icon>
|
||||||
|
<span>众筹核销</span>
|
||||||
|
</el-dropdown-item>
|
||||||
|
|
||||||
<el-dropdown-item @click="clearAllChats">
|
<el-dropdown-item @click="clearAllChats">
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<Delete/>
|
<Delete/>
|
||||||
@ -199,11 +213,14 @@
|
|||||||
<bind-mobile v-if="isLogin" :show="showBindMobileDialog" :mobile="loginUser.mobile"
|
<bind-mobile v-if="isLogin" :show="showBindMobileDialog" :mobile="loginUser.mobile"
|
||||||
@hide="showBindMobileDialog = false"/>
|
@hide="showBindMobileDialog = false"/>
|
||||||
|
|
||||||
|
<reward-verify v-if="isLogin" :show="showRewardVerifyDialog" @hide="showRewardVerifyDialog = false"/>
|
||||||
|
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="showRewardDialog"
|
v-model="showRewardDialog"
|
||||||
:show-close="true"
|
:show-close="true"
|
||||||
custom-class="donate-dialog"
|
custom-class="donate-dialog"
|
||||||
width="400px"
|
width="400px"
|
||||||
|
top="5vh"
|
||||||
title="参与众筹"
|
title="参与众筹"
|
||||||
>
|
>
|
||||||
<el-alert type="info" :closable="false">
|
<el-alert type="info" :closable="false">
|
||||||
@ -212,7 +229,7 @@
|
|||||||
账单和服务器的费用。</p>
|
账单和服务器的费用。</p>
|
||||||
</el-alert>
|
</el-alert>
|
||||||
<p>
|
<p>
|
||||||
<el-image :src="donateImg"/>
|
<el-image :src="rewardImg"/>
|
||||||
</p>
|
</p>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
@ -226,11 +243,13 @@ import ChatReply from "@/components/ChatReply.vue";
|
|||||||
import {
|
import {
|
||||||
ArrowDown,
|
ArrowDown,
|
||||||
Check,
|
Check,
|
||||||
|
Checked,
|
||||||
Close,
|
Close,
|
||||||
Delete,
|
Delete,
|
||||||
Edit,
|
Edit,
|
||||||
Iphone,
|
Iphone,
|
||||||
Plus,
|
Plus,
|
||||||
|
Present,
|
||||||
Promotion,
|
Promotion,
|
||||||
RefreshRight,
|
RefreshRight,
|
||||||
Search,
|
Search,
|
||||||
@ -249,9 +268,11 @@ import ConfigDialog from "@/components/ConfigDialog.vue";
|
|||||||
import PasswordDialog from "@/components/PasswordDialog.vue";
|
import PasswordDialog from "@/components/PasswordDialog.vue";
|
||||||
import {checkSession} from "@/action/session";
|
import {checkSession} from "@/action/session";
|
||||||
import BindMobile from "@/components/BindMobile.vue";
|
import BindMobile from "@/components/BindMobile.vue";
|
||||||
|
import RewardVerify from "@/components/RewardVerify.vue";
|
||||||
|
|
||||||
const title = ref('ChatGPT-智能助手');
|
const title = ref('ChatGPT-智能助手');
|
||||||
const logo = 'images/logo.png';
|
const logo = 'images/logo.png';
|
||||||
|
const rewardImg = ref('images/reward.png')
|
||||||
const models = ref([])
|
const models = ref([])
|
||||||
const model = ref('gpt-3.5-turbo')
|
const model = ref('gpt-3.5-turbo')
|
||||||
const chatData = ref([]);
|
const chatData = ref([]);
|
||||||
@ -271,6 +292,7 @@ const showConfigDialog = ref(false);
|
|||||||
const showPasswordDialog = ref(false);
|
const showPasswordDialog = ref(false);
|
||||||
const showBindMobileDialog = ref(false);
|
const showBindMobileDialog = ref(false);
|
||||||
const showRewardDialog = ref(false);
|
const showRewardDialog = ref(false);
|
||||||
|
const showRewardVerifyDialog = ref(false);
|
||||||
const isLogin = ref(false)
|
const isLogin = ref(false)
|
||||||
|
|
||||||
if (isMobile()) {
|
if (isMobile()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user