Xingyu Xian 4 meses atrás
pai
commit
92e7659d4c

+ 11 - 0
db/platform_kuaishou_user.go

@@ -14,3 +14,14 @@ func FindUserInfoByTalentId(ctx context.Context, talentId string) (*gorm_model.P
 	}
 	return &userInfo, nil
 }
+
+// FindUserInfoByOpenId 根据openID去查找快手授权信息
+func FindUserInfoByOpenId(ctx context.Context, openId string) (*gorm_model.PlatformKuaishouUserInfo, error) {
+	db := GetReadDB(ctx)
+	var userInfo gorm_model.PlatformKuaishouUserInfo
+	err := db.Model(gorm_model.PlatformKuaishouUserInfo{}).Where("open_id = ? and platform_id = ?", openId, 4).Find(&userInfo).Error
+	if err != nil {
+		return nil, err
+	}
+	return &userInfo, nil
+}

+ 10 - 0
db/sectask.go

@@ -120,6 +120,16 @@ func GetSecTaskList(ctx context.Context, selectionId string, taskStatus int, sea
 		v.FansCount = kuaishouUserInfo.Fan
 	}
 
+	// 写入带货任务信息
+	for _, v := range newSecTaskInfoList {
+		selectionInfo, selectionInfoErr := GetSelectionById(ctx, v.SelectionId)
+		if selectionInfoErr != nil {
+			return nil, 0, selectionInfoErr
+		}
+		v.EnterpriseId = selectionInfo.EnterpriseID
+		v.SubAccountId = 0
+	}
+
 	// 按照saleMin和saleMax区间过滤
 	var saleCondition []*http_model.SecTaskInfo
 	if saleNumMin != 0 && saleNumMax != 0 {

+ 3 - 0
model/http_model/GetSecTaskList.go

@@ -22,6 +22,7 @@ type GetSecTaskListData struct {
 }
 
 type SecTaskInfo struct {
+	SelectionId           string    `json:"selection_id"`            // 带货任务ID
 	SecTaskId             string    `json:"sec_task_id"`             // 带货任务ID
 	PlatformNickname      string    `json:"platform_nickname"`       // 帐号昵称
 	TalentId              string    `json:"talent_id"`               // 达人ID
@@ -30,6 +31,8 @@ type SecTaskInfo struct {
 	KuaiShouUserGender    string    `json:"kuai_shou_user_gender"`   // 快手用户性别
 	KuaiShouUserLocation  string    `json:"kuai_shou_user_location"` // 快手用户ip属地
 	FansCount             string    `json:"fans_count"`              // 粉丝数
+	EnterpriseId          string    `json:"enterprise_id"`           // 商家ID
+	SubAccountId          int       `json:"sub_account_id"`          // 商家子账号ID
 	HomePageCaptureUrl    string    `json:"home_page_capture_url"`   // 主页截图链接
 	HomePageUrl           string    `json:"home_page_url"`           // 主页链接
 	RegionCode            int       `json:"region_code"`             // 区域编码

+ 5 - 4
pack/sec_task_list.go

@@ -22,6 +22,7 @@ func GormSecTaskToHttpSecTask(secTask *gorm_model.YounggeeSecTaskInfo) *http_mod
 	TalentPlatformInfoSnap := secTask.TalentPlatformInfoSnap
 	regionCode, _ := strconv.Atoi(conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "region_code"), ""))
 	return &http_model.SecTaskInfo{
+		SelectionId:        secTask.SelectionID,
 		SecTaskId:          secTask.TaskID,
 		PlatformNickname:   conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname"), ""),
 		FansCount:          conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count"), ""),
@@ -29,10 +30,10 @@ func GormSecTaskToHttpSecTask(secTask *gorm_model.YounggeeSecTaskInfo) *http_mod
 		HomePageUrl:        conv.MustString(gjson.Get(TalentPlatformInfoSnap, "home_page_url"), ""),
 		RegionCode:         regionCode,
 		DetailAddr:         conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "detail_addr"), "") + " " + conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "receiver_name"), "") + " " + conv.MustString(gjson.Get(secTask.TalentPostAddrSnap, "phone_number"), ""),
-		CreateDate:         conv.MustString(secTask.CreateDate, ""),
-		SelectDate:         conv.MustString(secTask.SelectDate, ""),
-		DeliveryDate:       conv.MustString(secTask.DeliveryDate, ""),
-		CompleteDate:       conv.MustString(secTask.CompleteDate, ""),
+		CreateDate:         conv.MustString(secTask.CreateDate, "")[:19],
+		SelectDate:         conv.MustString(secTask.SelectDate, "")[:19],
+		DeliveryDate:       conv.MustString(secTask.DeliveryDate, "")[:19],
+		CompleteDate:       conv.MustString(secTask.CompleteDate, "")[:19],
 		IsPayReward:        secTask.IsPayReward,
 		IsPayPayment:       secTask.IsPayPayment,
 		SignedTime:         conv.MustString(secTask.SignedTime, "0000"),

+ 2 - 3
service/product.go

@@ -180,11 +180,10 @@ func (*product) QueryKuaishouProduct(ctx context.Context, newKuaishouProduct htt
 	//var SignSecret string = "dBt0rVRhTpUqcrOYGGpv0A"
 
 	// 1. 拿到快手的AccessToken
-	kuaishouUserInfo, userErr := db.FindUserInfoByTalentId(ctx, "214300313")
+	kuaishouUserInfo, userErr := db.FindUserInfoByOpenId(ctx, "f1b0d3a11c24fcde14bf5724d0d1cdfc")
 	if userErr != nil {
 		return nil, userErr
 	}
-	fmt.Println(kuaishouUserInfo.Gender)
 
 	// 2. 可能需要刷新Token
 	//newAccessToken, Tokenerr := kuaishou.RefreshAccessToken(kuaishouUserInfo.RefreshToken, appKey, SignSecret)
@@ -194,7 +193,7 @@ func (*product) QueryKuaishouProduct(ctx context.Context, newKuaishouProduct htt
 	//fmt.Println(newAccessToken.AccessToken)
 
 	// 3. 查找对应的快手商品
-	kuaishouProduct, err := kuaishou.Queryselectiondetail(appKey, signSecret, "ChFvYXV0aC5hY2Nlc3NUb2tlbhJguunmqaSJl6KpNGd6LZBpzcomDJulOGcqpJmcDR_F7yhqAzVj9JY9twn-T3ebjSGkmQqo9D7tnlgHHsvX6tAla48KqQvyBDWFW1GxyOV_mNwys0AmFK1ykWFDrG1k-LEvGhL_b_zNSCZFGYoK2F52yMh0D74iIDGRpbkYe1faOtbvi-FUghbLHkTU8Y9JU2ga6XdHYxikKAUwAQ", newKuaishouProduct.ItemList)
+	kuaishouProduct, err := kuaishou.Queryselectiondetail(appKey, signSecret, kuaishouUserInfo.AccessToken, newKuaishouProduct.ItemList)
 	if err != nil {
 		fmt.Println("快手错误信息: ", err)
 		return nil, err