|
@@ -172,15 +172,31 @@ func (*product) GetAllProduct(ctx context.Context, req *http_model.GetAllProduct
|
|
|
|
|
|
// QueryKuaishouProduct 通过快手商品ID从SDK拉取快手商品信息
|
|
|
func (*product) QueryKuaishouProduct(ctx context.Context, newKuaishouProduct http_model.FindKuaishouProductRequest) (*http_model.FindKuaishouProductData, error) {
|
|
|
- AccessToken := "ChFvYXV0aC5hY2Nlc3NUb2tlbhJgpNyhn_OyOXO-hSkJDAmlssr8lCAzT0CePeh-9-NyQEK3quECYOVm40RG0ppGMSnV0xq-_hlLrO7BoBOj-ai75oD4hzJ1QDNWChUhEZaXWwv9BtHAPp4Hioa08mw3ZiakGhI3fO2jrXtNfq7z9Xoxtovjx-YiINfD-RUDsg0A2tscTHxuBVd4yaWdtWWbN9QNeaTOLf31KAUwAQ"
|
|
|
appKey := "ks651333097154138217"
|
|
|
signSecret := "bf6393dce0a2b669ee348bebb837b0da"
|
|
|
- kuaishouProduct, err := kuaishou.Queryselectiondetail(appKey, signSecret, AccessToken, newKuaishouProduct.ItemList)
|
|
|
+ var SignSecret string = "dBt0rVRhTpUqcrOYGGpv0A"
|
|
|
+
|
|
|
+ // 1. 拿到快手的AccessToken
|
|
|
+ kuaishouUserInfo, userErr := db.FindUserInfoByTalentId(ctx, "207235984")
|
|
|
+ if userErr != nil {
|
|
|
+ return nil, userErr
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 可能需要刷新Token
|
|
|
+ newAccessToken, Tokenerr := kuaishou.RefreshAccessToken(kuaishouUserInfo.RefreshToken, appKey, SignSecret)
|
|
|
+ if Tokenerr != nil {
|
|
|
+ return nil, Tokenerr
|
|
|
+ }
|
|
|
+ fmt.Println(newAccessToken.AccessToken)
|
|
|
+
|
|
|
+ // 3. 查找对应的快手商品
|
|
|
+ kuaishouProduct, err := kuaishou.Queryselectiondetail(appKey, signSecret, newAccessToken.AccessToken, newKuaishouProduct.ItemList)
|
|
|
if err != nil {
|
|
|
fmt.Println("快手错误信息: ", err)
|
|
|
return nil, err
|
|
|
}
|
|
|
- fmt.Println("kuaishouProduct: ", kuaishouProduct)
|
|
|
+
|
|
|
+ // 4. 组织返回数据
|
|
|
findKuaishouProductData := http_model.FindKuaishouProductData{
|
|
|
ProductName: kuaishouProduct.ItemList[0].ItemTitle,
|
|
|
ProductPrice: float64(kuaishouProduct.ItemList[0].ItemPrice) * 0.01,
|
|
@@ -192,6 +208,5 @@ func (*product) QueryKuaishouProduct(ctx context.Context, newKuaishouProduct htt
|
|
|
MerchantSoldCountThirtyDays: kuaishouProduct.ItemList[0].MerchantSoldCountThirtyDays,
|
|
|
KuaishouProductId: kuaishouProduct.ItemList[0].ItemID,
|
|
|
}
|
|
|
- // print("kuaoshou_product: ", findKuaishouProductData.ProductName)
|
|
|
return &findKuaishouProductData, err
|
|
|
}
|