|
|
@@ -3,12 +3,9 @@ package user
|
|
|
import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
- "time"
|
|
|
-
|
|
|
+ "git.i2edu.net/i2/go-zero/core/logx"
|
|
|
"git.i2edu.net/i2/i2-bill-api/internal/svc"
|
|
|
"git.i2edu.net/i2/i2-bill-api/internal/types"
|
|
|
-
|
|
|
- "git.i2edu.net/i2/go-zero/core/logx"
|
|
|
)
|
|
|
|
|
|
type JzQrCodeLogic struct {
|
|
|
@@ -29,18 +26,30 @@ func NewJzQrCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) JzQrCodeL
|
|
|
|
|
|
// JzQrCode 兼职人员兼职码
|
|
|
func (l *JzQrCodeLogic) JzQrCode() (*types.JzQrcodeResponse, error) {
|
|
|
- uid, err := l.svcCtx.Wechat.GenUserQrId(svc.QrcodeJzPrefix, l.UserId, map[string]interface{}{
|
|
|
- "userId": l.UserId,
|
|
|
- "timestamp": time.Now().Unix(),
|
|
|
- "type": "JzQrCode",
|
|
|
- })
|
|
|
- fmt.Println("--uid=", uid)
|
|
|
+ //uid, err := l.svcCtx.Wechat.GenUserQrId(svc.QrcodeJzPrefix, l.UserId, map[string]interface{}{
|
|
|
+ // "userId": l.UserId,
|
|
|
+ // "timestamp": time.Now().Unix(),
|
|
|
+ // "type": "JzQrCode",
|
|
|
+ //})
|
|
|
+ //fmt.Println("--uid=", uid)
|
|
|
// l.svcCtx.Wechat.GetQrParams(qrcodeJzPrefix, uid, map[string]interface{}{})
|
|
|
+ //if err != nil {
|
|
|
+ // return nil, err
|
|
|
+ //}
|
|
|
+ userId := l.svcCtx.GetUserIdByJwt(l.ctx)
|
|
|
+ attr, err := l.svcCtx.Wechat.GenQrCode(fmt.Sprintf("%d", userId), "/pages/code/code")
|
|
|
+ tx := l.svcCtx.DB.NewSession()
|
|
|
+ _, err = tx.Where("user_id = ?", userId).Update(map[string]interface{}{"qr": attr.Url})
|
|
|
+ if err != nil {
|
|
|
+ tx.Rollback()
|
|
|
+ return &types.JzQrcodeResponse{}, err
|
|
|
+ }
|
|
|
+ _, err = tx.Insert(attr)
|
|
|
if err != nil {
|
|
|
- return nil, err
|
|
|
+ tx.Rollback()
|
|
|
+ return &types.JzQrcodeResponse{}, err
|
|
|
}
|
|
|
- uri, err := l.svcCtx.Wechat.GenQrCode(uid, "/pages/code/code")
|
|
|
return &types.JzQrcodeResponse{
|
|
|
- FileId: uri,
|
|
|
- }, err
|
|
|
+ FileId: attr.Url,
|
|
|
+ }, nil
|
|
|
}
|