Xingyu Xian 1 hónapja
szülő
commit
abd654c246
5 módosított fájl, 48 hozzáadás és 13 törlés
  1. 1 3
      handler/qrcode.go
  2. 7 2
      model/http_model/qecode.go
  3. 7 3
      route/init.go
  4. 1 1
      service/product.go
  5. 32 4
      service/qrcode.go

+ 1 - 3
handler/qrcode.go

@@ -34,9 +34,7 @@ func (q GetWxQRCodeHandler) getRequest() interface{} {
 }
 
 func (q GetWxQRCodeHandler) run() {
-	req := http_model.GetWxQRCodeRequest{}
-	req = *q.req
-	data, err := service.QrCode.GetWxQrCode(q.ctx, req.Scene, req.Page)
+	data, err := service.QrCode.GetWxQrCode(q.ctx, q.req)
 	if err != nil {
 		logrus.WithContext(q.ctx).Errorf("[GetWxQRCodeHandler] error GetWxQrCode, err:%+v", err)
 		util.HandlerPackErrorResp(q.resp, consts.ErrorInternal, consts.DefaultToast)

+ 7 - 2
model/http_model/qecode.go

@@ -1,8 +1,13 @@
 package http_model
 
 type GetWxQRCodeRequest struct {
-	Scene string `json:"scene"` // 需要携带的参数,目前为任务id
-	Page  string `json:"page"`  // 页面path
+	Scene       string `json:"scene"`        // 需要携带的参数,目前为任务id
+	Page        string `json:"page"`         // 页面path
+	SelectionId string `json:"selection_id"` // 带货任务ID
+	ProjectId   string `json:"project_id"`   // 种草任务ID
+	SProjectId  int    `json:"s_project_id"` // 服务商种草任务ID
+	LocalId     string `json:"local_id"`     // 本地生活ID
+	SLocalId    int    `json:"s_local_id"`   // 服务商本地生活ID
 }
 
 type WxAccessTokenResponse struct {

+ 7 - 3
route/init.go

@@ -57,6 +57,12 @@ func InitRoute(r *gin.Engine) {
 		accountInfo.POST("/contactInfo/update", handler.WrapUpdateContactInfoHandler) // 联系方式-更新
 	}
 
+	qrCode := r.Group("/youngee/qrCode")
+	{
+		qrCode.Use(middleware.LoginAuthMiddleware)
+		qrCode.POST("/getWXQrCode", handler.WrapGetWxQRCodeHandler) // 获取微信二维码
+	}
+
 	//r.Any("/testDemo", func(c *gin.Context) {
 	//	resp := http_model.CommonResponse{
 	//		Status:  0,
@@ -159,9 +165,7 @@ func InitRoute(r *gin.Engine) {
 		m.POST("/workspace/ddlproject", handler.WrapWorkspaceDDLprojectHandler)                  // 工作台项目统计
 		m.POST("/project/recruit/getservicecharge", handler.WrapGetServiceChargeHandler)         // 获取产品置换服务费
 		m.POST("/product/deletePhotoUrl", handler.WrapDeletePhotoUrlHandler)                     // 在数据库中删除图片url
-		m.POST("/qrcode/getwxqrcode", handler.WrapGetWxQRCodeHandler)                            // 获取微信二维码
-
-		m.POST("/project/getAllProduct", handler.WrapGetAllProjectHandler) // 查询项目广场项目列表
+		m.POST("/project/getAllProduct", handler.WrapGetAllProjectHandler)                       // 查询项目广场项目列表
 
 	}
 

+ 1 - 1
service/product.go

@@ -180,7 +180,7 @@ func (*product) QueryKuaishouProduct(ctx context.Context, newKuaishouProduct htt
 	//var SignSecret string = "dBt0rVRhTpUqcrOYGGpv0A"
 
 	// 1. 拿到快手的AccessToken
-	kuaishouUserInfo, userErr := db.FindUserInfoByOpenId(ctx, "f1b0d3a11c24fcde14bf5724d0d1cdfc")
+	kuaishouUserInfo, userErr := db.FindUserInfoByOpenId(ctx, "f1b0d3a11c24fcde14bf5725dd27c0ef")
 	if userErr != nil {
 		return nil, userErr
 	}

+ 32 - 4
service/qrcode.go

@@ -8,6 +8,7 @@ import (
 	"fmt"
 	"io/ioutil"
 	"net/http"
+	"strconv"
 	"strings"
 	"time"
 	"youngee_b_api/consts"
@@ -37,7 +38,8 @@ func QrCodeInit(config *system_model.Session) {
 // getAndCacheWxAccessToken 获取并缓存微信的access token
 func getAndCacheWxAccessToken(ctx context.Context) (string, error) {
 	appId := "wxac396a3be7a16844"
-	secret := "c82ae9e75b4ed7d8022db5bda5371892"
+	// secret := "c82ae9e75b4ed7d8022db5bda5371892"
+	secret := "abbf27d46c46212c86e60f2ed3c534ee"
 	url := fmt.Sprintf(accessTokenUrlFormat, appId, secret)
 
 	resp, err := http.Get(url)
@@ -65,7 +67,7 @@ func getAndCacheWxAccessToken(ctx context.Context) (string, error) {
 	return accessTokenRes.AccessToken, nil
 }
 
-func (q *qrcode) GetWxQrCode(ctx context.Context, Scene string, Page string) (*http_model.GetWxQRCodeData, error) {
+func (q *qrcode) GetWxQrCode(ctx context.Context, req *http_model.GetWxQRCodeRequest) (*http_model.GetWxQRCodeData, error) {
 	// 获取access_token
 	accessToken, err := redis.Get(ctx, wxAccesssTokenKey)
 	if err != nil && err != consts.RedisNil {
@@ -81,9 +83,35 @@ func (q *qrcode) GetWxQrCode(ctx context.Context, Scene string, Page string) (*h
 		}
 	}
 
+	var reqPath string
+	var reqData string
+
+	if req.SelectionId != "" {
+		reqPath = ""
+		reqData = req.SelectionId
+	}
+	if req.SProjectId != 0 || req.ProjectId != "" {
+		reqPath = ""
+		if req.SProjectId != 0 {
+			reqData = "0" + "-" + strconv.Itoa(req.SProjectId)
+		} else {
+			reqData = req.ProjectId + "-" + "0"
+		}
+	}
+	if req.SLocalId != 0 || req.LocalId != "" {
+		reqPath = ""
+		if req.SLocalId != 0 {
+			reqData = "0" + "-" + strconv.Itoa(req.SLocalId)
+		} else {
+			reqData = req.LocalId + "-" + "0"
+		}
+	}
+
+	fmt.Printf("reqData: %+v\n", reqData)
+
 	qrRequest := http_model.WxQrCodeRequest{
-		Scene:      Scene,
-		Page:       Page,
+		Scene:      reqData,
+		Page:       reqPath,
 		Width:      430,
 		CheckPath:  false,
 		EnvVersion: "release",