调整微信扫码登录相关接口,拆分门店奖励:奖励类型、奖励详情

This commit is contained in:
2025-06-03 11:06:00 +08:00
parent ea87bc829e
commit fdc9cc3463
37 changed files with 698 additions and 189 deletions

View File

@ -32,7 +32,12 @@ func init() {
glog.Errorf(ctx, "init casbin error: %v", err)
}
enforcer.LoadPolicy()
{
enforcer.AddPolicy("admin", "/x/admin/info", "GET", "获取管理员用户信息")
}
instance = &myCasbin{Enforcer: enforcer}
})
glog.Infof(ctx, "init casbin success")
}

View File

@ -2,14 +2,16 @@ package wechat
import (
"context"
"github.com/go-resty/resty/v2"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/glog"
"io"
"os"
"server/utility/ecode"
"sync"
"time"
"github.com/go-resty/resty/v2"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/glog"
"github.com/google/uuid"
)
type weChatClient struct {
@ -94,13 +96,13 @@ func (c *weChatClient) autoRefreshToken(ctx context.Context) {
time.Sleep(refreshAfter)
}
}
func (c *weChatClient) GetTicket(sceneID string) (string, error) {
func (c *weChatClient) GetTicket(sceneId string) (string, error) {
body := map[string]interface{}{
"expire_seconds": c.TicketExpire,
"action_name": "QR_SCENE",
"action_name": "QR_STR_SCENE",
"action_info": map[string]interface{}{
"scene": map[string]interface{}{
"scene_str": sceneID,
"scene": map[string]string{
"scene_str": sceneId,
},
},
}
@ -129,7 +131,7 @@ func (c *weChatClient) GetTicket(sceneID string) (string, error) {
return result.Ticket, nil
}
func (c *weChatClient) GetQrCode(ticket string, filename string) (imagePath string, err error) {
func (c *weChatClient) GetQrCode(ticket string) (imagePath string, err error) {
qrCodeUrl := "https://mp.weixin.qq.com/cgi-bin/showqrcode"
resp, err := resty.New().R().
SetDoNotParseResponse(true).
@ -144,8 +146,7 @@ func (c *weChatClient) GetQrCode(ticket string, filename string) (imagePath stri
glog.Errorf(context.Background(), "获取二维码图片响应异常: %+v", resp.Status())
return "", ecode.Fail.Sub("获取二维码图片失败")
}
imagePath = filename
imagePath = uuid.New().String() + ".jpg"
data, readErr := io.ReadAll(resp.RawBody())
if readErr != nil {
@ -163,3 +164,7 @@ func (c *weChatClient) GetQrCode(ticket string, filename string) (imagePath stri
glog.Infof(context.Background(), "二维码图片保存成功: %s", imagePath)
return imagePath, nil
}
func (c *weChatClient) GetToken() string {
return c.Token
}