Kaynağa Gözat

choose talent and logistic

Xingyu Xian 8 ay önce
ebeveyn
işleme
20893a857e

+ 36 - 14
db/sectask.go

@@ -32,31 +32,50 @@ func GetSecTaskById(ctx context.Context, secTaskId string) (*gorm_model.Younggee
 
 func GetSecTaskList(ctx context.Context, selectionId string, taskStatus int, searchValue string, pageSize, pageNum int64) ([]*http_model.SecTaskInfo, int64, error) {
 	db := GetReadDB(ctx)
-	var taskStages []int
+	// var taskStages []int
+	var freeStages []int
+	var rewardStages []int
 	switch taskStatus {
 	case 3:
-		taskStages = []int{3}
+		// 待选
+		freeStages = []int{1}
 		break
 	case 4:
-		taskStages = []int{4, 6, 7, 8, 9, 10}
+		// 申请成功
+		freeStages = []int{3, 4, 5}
 		break
 	case 6:
-		taskStages = []int{6}
+		// 待发货
+		freeStages = []int{3}
 		break
 	case 7:
-		taskStages = []int{7}
+		// 已发货
+		freeStages = []int{4}
 		break
 	case 8:
-		taskStages = []int{8, 9, 10}
+		// 已收货
+		freeStages = []int{5}
 	case 9:
-		taskStages = []int{9}
+		// 待领悬赏
+		rewardStages = []int{1}
 		break
 	case 10:
-		taskStages = []int{10}
+		// 已领悬赏
+		rewardStages = []int{2}
 		break
+	case 11:
+		// 返回全部 使用场景-绑定免费领样策略
+		freeStages = []int{0, 1, 2, 3, 4, 5}
+		rewardStages = []int{0, 1}
+	}
+	fmt.Println("task_stages: ", freeStages, rewardStages)
+	if len(freeStages) == 0 {
+		// 根据悬赏阶段筛选
+		db = db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("selection_id = ? and reward_stage in ?", selectionId, rewardStages)
+	} else {
+		// 根据免费领样阶段筛选
+		db = db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("selection_id = ? and free_stage in ?", selectionId, freeStages)
 	}
-	db = db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("selection_id = ? and task_stage in ?", selectionId, taskStages)
-
 	// 查询总数
 	var total int64
 	var secTaskInfoList []*gorm_model.YounggeeSecTaskInfo
@@ -105,7 +124,7 @@ func PassSecTaskCoop(ctx context.Context, selectionId string, taskIds []string)
 	// 1. 校验
 	var count int64
 	fmt.Println("task_ids: ", taskIds)
-	err := db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND task_stage = 3", taskIds).Count(&count).Error
+	err := db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND free_stage = 1", taskIds).Count(&count).Error
 
 	fmt.Println("count: ", count)
 	if err != nil {
@@ -149,13 +168,15 @@ func PassSecTaskCoop(ctx context.Context, selectionId string, taskIds []string)
 				return err
 			}
 		} else {
+			// 免费领样
 			updateData := gorm_model.YounggeeSecTaskInfo{
 				TaskStatus:      2,
 				TaskStage:       6,
 				SelectDate:      time.Now(),
 				LogisticsStatus: 1,
+				FreeStage:       3,
 			}
-			err = tx.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND task_stage = 3", taskIds).Updates(updateData).Error
+			err = tx.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND free_stage = 1", taskIds).Updates(updateData).Error
 			if err != nil {
 				return err
 			}
@@ -187,7 +208,7 @@ func RefuseSecTaskCoop(ctx context.Context, taskIds []string) (bool, error) {
 	db := GetWriteDB(ctx)
 	// 1. 校验
 	var count int64
-	err := db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND task_stage = 3", taskIds).Count(&count).Error
+	err := db.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND free_stage = 1", taskIds).Count(&count).Error
 	if err != nil {
 		return false, err
 	}
@@ -209,8 +230,9 @@ func RefuseSecTaskCoop(ctx context.Context, taskIds []string) (bool, error) {
 			TaskStage:      5,
 			CompleteDate:   time.Now(),
 			CompleteStatus: 3,
+			FreeStage:      2,
 		}
-		err = tx.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND task_stage = 3", taskIds).Updates(updateData).Error
+		err = tx.Model(gorm_model.YounggeeSecTaskInfo{}).Where("task_id IN ? AND free_stage = 1", taskIds).Updates(updateData).Error
 		if err != nil {
 			return err
 		}

+ 39 - 32
model/gorm_model/selection_task_info.go

@@ -1,42 +1,49 @@
 package gorm_model
 
-// Code generated by sql2gorm. DO NOT EDIT.
-
 import (
 	"time"
 )
 
 type YounggeeSecTaskInfo struct {
-	ID                     int       `gorm:"column:id;primary_key"`                        // 递增id
-	TaskID                 string    `gorm:"column:task_id"`                               // 选品任务id
-	SelectionID            string    `gorm:"column:selection_id"`                          // 选品id
-	TalentID               string    `gorm:"column:talent_id"`                             // 达人id
-	AccountID              int       `gorm:"column:account_id"`                            // 账号id
-	TalentPlatformInfoSnap string    `gorm:"column:talent_platform_info_snap"`             // 达人平台信息快照
-	TalentPersonalInfoSnap string    `gorm:"column:talent_personal_info_snap"`             // 达人个人信息快照
-	TalentPostAddrSnap     string    `gorm:"column:talent_post_addr_snap"`                 // 收货地址快照
-	TaskReward             string    `gorm:"column:task_reward"`                           //  达人赏金
-	TalentPayment          string    `gorm:"column:talent_payment"`                        // 达人垫付金额
-	IsPayPayment           int       `gorm:"column:is_pay_payment"`                        // 企业是否返样品钱
-	IsPayReward            int       `gorm:"column:is_pay_reward"`                         // 企业是否结算悬赏
-	TaskMode               int       `gorm:"column:task_mode"`                             // 任务形式,1、2分别表示纯佣带货、悬赏任务
-	SampleMode             int       `gorm:"column:sample_mode"`                           // 领样形式,1-3分别表示免费领样、垫付买样、不提供样品
-	TaskStatus             int       `gorm:"column:task_status;default:1"`                 // 任务状态 1待选 2已选 3落选
-	TaskStage              int       `gorm:"column:task_stage"`                            // 任务阶段,详情见info_sec_task_stage表
-	CreateDate             time.Time `gorm:"column:create_date"` // 创建时间
-	SelectDate             time.Time `gorm:"column:select_date"`                           // 反选时间
-	DeliveryDate           time.Time `gorm:"column:delivery_date"`                         // 发货时间
-	CompleteDate           time.Time `gorm:"column:complete_date"`                         // 结束时间
-	WithdrawDate           time.Time `gorm:"column:withdraw_date"`                         // 提现时间
-	CompleteStatus         int       `gorm:"column:complete_status;default:1"`             // 结束方式 1未结束 2正常结束 3反选失败
-	LogisticsStatus        int       `gorm:"column:logistics_status;default:1"`            // 发货状态 1 待发货 2已发货 3 已签收
-	AssignmentStatus       uint      `gorm:"column:assignment_status;default:1"`           // 作业上传状态 1-5分别代表待添加、已添加、待修改、已修改、已通过
-	UpdateAt               time.Time `gorm:"column:update_at"`                             // 更新时间
-	WithdrawStatus         int       `gorm:"column:withdraw_status;default:1"`             // 提现状态,1-4分别代表不可提现、可提现、提现中、已提现
-	LeadTeamID             string    `gorm:"column:lead_team_id"`                          // 作为团长的young之团id,对应younggee_talent_team中的team_id字段
-	TeamID                 string    `gorm:"column:team_id"`                               // 作为团员的young之团id,对应younggee_talent_team中的team_id字段
-	TeamIncome             int       `gorm:"column:team_income"`                           // young之团团长现金收益
-	TeamPoint              int       `gorm:"column:team_point"`                            // young之团团长积分收益
+	ID                     int       `gorm:"column:id;primary_key"`              // 递增id
+	TaskID                 string    `gorm:"column:task_id"`                     // 选品任务id
+	SelectionID            string    `gorm:"column:selection_id"`                // 选品id
+	TalentID               string    `gorm:"column:talent_id"`                   // 达人id
+	AccountID              int       `gorm:"column:account_id"`                  // 账号id
+	TalentPlatformInfoSnap string    `gorm:"column:talent_platform_info_snap"`   // 达人平台信息快照
+	TalentPersonalInfoSnap string    `gorm:"column:talent_personal_info_snap"`   // 达人个人信息快照
+	TalentPostAddrSnap     string    `gorm:"column:talent_post_addr_snap"`       // 收货地址快照
+	TaskReward             string    `gorm:"column:task_reward"`                 //  达人赏金
+	TalentPayment          string    `gorm:"column:talent_payment"`              // 达人垫付金额
+	IsPayPayment           int       `gorm:"column:is_pay_payment"`              // 企业是否返样品钱
+	IsPayReward            int       `gorm:"column:is_pay_reward"`               // 企业是否结算悬赏
+	TaskMode               int       `gorm:"column:task_mode"`                   // 任务形式,1、2分别表示纯佣带货、悬赏任务
+	SampleMode             int       `gorm:"column:sample_mode"`                 // 领样形式,1-3分别表示免费领样、垫付买样、不提供样品
+	TaskStatus             int       `gorm:"column:task_status;default:1"`       // 任务状态 1待选 2已选 3落选
+	TaskStage              int       `gorm:"column:task_stage"`                  // 任务阶段,详情见info_sec_task_stage表
+	CreateDate             time.Time `gorm:"column:create_date"`                 // 创建时间
+	SelectDate             time.Time `gorm:"column:select_date"`                 // 反选时间
+	DeliveryDate           time.Time `gorm:"column:delivery_date"`               // 发货时间
+	CompleteDate           time.Time `gorm:"column:complete_date"`               // 结束时间
+	WithdrawDate           time.Time `gorm:"column:withdraw_date"`               // 提现时间
+	CompleteStatus         int       `gorm:"column:complete_status;default:1"`   // 结束方式 1未结束 2正常结束 3反选失败
+	LogisticsStatus        int       `gorm:"column:logistics_status;default:1"`  // 发货状态 1 待发货 2已发货 3 已签收
+	AssignmentStatus       uint      `gorm:"column:assignment_status;default:1"` // 作业上传状态 1-5分别代表待添加、已添加、待修改、已修改、已通过
+	UpdateAt               time.Time `gorm:"column:update_at"`                   // 更新时间
+	WithdrawStatus         int       `gorm:"column:withdraw_status;default:1"`   // 提现状态,1-4分别代表不可提现、可提现、提现中、已提现
+	LeadTeamID             string    `gorm:"column:lead_team_id"`                // 作为团长的young之团id,对应younggee_talent_team中的team_id字段
+	TeamID                 string    `gorm:"column:team_id"`                     // 作为团员的young之团id,对应younggee_talent_team中的team_id字段
+	TeamIncome             int       `gorm:"column:team_income"`                 // young之团团长现金收益
+	TeamPoint              int       `gorm:"column:team_point"`                  // young之团团长积分收益
+	SignedTime             time.Time `gorm:"column:signed_time"`                 // 快递签收时间
+	SaleNum                int       `gorm:"column:sale_num"`                    // 30天橱窗销量
+	FreeStrategyId         int       `gorm:"column:free_strategy_id"`            // 免费领样策略id
+	ProductId              int       `gorm:"column:product_id"`                  // 商品id
+	SaleActual             int       `gorm:"column:sale_actual"`                 // 实际带货量
+	SaleNumAll             int       `gorm:"column:sale_num_all"`                // 达人对此商品的全部销售量(大于1表示已出单)
+	FansNum                int       `gorm:"column:fans_num"`                    // 粉丝数
+	FreeStage              int       `gorm:"column:free_stage"`                  // 免费领样阶段,1-5分别代表已申请、已拒绝、待发货、已发货、已收货
+	RewardStage            int       `gorm:"column:reward_stage"`                // 悬赏阶段,1-2分别代表待结算(管理后台设置)、已结算(小程序端设置)
 }
 
 func (m *YounggeeSecTaskInfo) TableName() string {

+ 16 - 6
model/http_model/GetSecTaskList.go

@@ -9,6 +9,9 @@ type GetSecTaskListRequest struct {
 	SecTaskStatus int    `json:"sec_task_status"`
 	SearchValue   string `json:"search_value"`
 	Type          int    `json:"type"` // 查询类型,1、2、3分别表示确定达人查询、发货管理查询、结算管理查询
+	TaskStage     int    `json:"sec_task_stage"`
+	FreeStage     int    `json:"free_stage"`   // 免费领样阶段,1-5分别代表已申请、已拒绝、待发货、已发货、已收货
+	RewardStage   int    `json:"reward_stage"` // 悬赏阶段,1-2分别代表待结算(管理后台设置)、已结算(小程序端设置)
 }
 
 type GetSecTaskListData struct {
@@ -17,12 +20,13 @@ type GetSecTaskListData struct {
 }
 
 type SecTaskInfo struct {
-	SecTaskId             string    `json:"sec_task_id"`
-	PlatformNickname      string    `json:"platform_nickname"`     // 帐号昵称
-	FansCount             string    `json:"fans_count"`            // 粉丝数
-	HomePageCaptureUrl    string    `json:"home_page_capture_url"` // 主页截图链接
-	HomePageUrl           string    `json:"home_page_url"`         // 主页链接
-	RegionCode            int       `json:"region_code"`
+	SecTaskId             string    `json:"sec_task_id"`            // 带货任务ID
+	PlatformNickname      string    `json:"platform_nickname"`      // 帐号昵称
+	TalentId              string    `json:"talent_id"`              // 达人ID
+	FansCount             string    `json:"fans_count"`             // 粉丝数
+	HomePageCaptureUrl    string    `json:"home_page_capture_url"`  // 主页截图链接
+	HomePageUrl           string    `json:"home_page_url"`          // 主页链接
+	RegionCode            int       `json:"region_code"`            // 区域编码
 	DetailAddr            string    `json:"detail_addr"`            // 物流信息
 	CompanyName           string    `json:"company_name"`           // 物流公司
 	LogisticsNumber       string    `json:"logistics_number"`       // 物流单号
@@ -39,6 +43,12 @@ type SecTaskInfo struct {
 	SelectDate            string    `json:"select_date"`            // 反选时间
 	DeliveryDate          string    `json:"delivery_date"`          // 发货时间
 	CompleteDate          string    `json:"complete_date"`          // 结算时间
+	SignedTime            string    `json:"signed_time"`            // 快递签收时间
+	SaleNum               int       `json:"sale_num"`               // 30天橱窗销量
+	FreeStrategyId        int       `json:"free_strategy_id"`       // 免费领样策略id
+	ProductId             int       `json:"product_id"`             // 商品ID
+	FreeStage             int       `json:"free_stage"`             // 免费领样阶段,1-5分别代表已申请、已拒绝、待发货、已发货、已收货
+	RewardStage           int       `json:"reward_stage"`           // 悬赏阶段,1-2分别代表待结算(管理后台设置)、已结算(小程序端设置)
 }
 
 func NewGetSecTaskListRequest() *GetSecTaskListRequest {

+ 5 - 0
pack/sec_task_list.go

@@ -35,5 +35,10 @@ func GormSecTaskToHttpSecTask(secTask *gorm_model.YounggeeSecTaskInfo) *http_mod
 		CompleteDate:       conv.MustString(secTask.CompleteDate, ""),
 		IsPayReward:        secTask.IsPayReward,
 		IsPayPayment:       secTask.IsPayPayment,
+		SignedTime:         conv.MustString(secTask.SignedTime, "0000"),
+		SaleNum:            secTask.SaleNum,
+		FreeStrategyId:     secTask.FreeStrategyId,
+		TalentId:           secTask.TalentID,
+		ProductId:          secTask.ProductId,
 	}
 }

+ 6 - 7
route/init.go

@@ -1,14 +1,13 @@
 package route
 
 import (
-	"youngee_b_api/handler"
-	"youngee_b_api/middleware"
-	"youngee_b_api/model/http_model"
-
 	"github.com/gin-gonic/gin"
 	"github.com/sirupsen/logrus"
 	swaggerFiles "github.com/swaggo/files"
 	ginSwagger "github.com/swaggo/gin-swagger"
+	"youngee_b_api/handler"
+	"youngee_b_api/middleware"
+	"youngee_b_api/model/http_model"
 )
 
 func InitRoute(r *gin.Engine) {
@@ -143,9 +142,9 @@ func InitRoute(r *gin.Engine) {
 	s := r.Group("/youngee/s")
 	{
 		s.Use(middleware.LoginAuthMiddleware)
-		s.POST("/selection/delete", handler.WrapDeleteSelectionHandler)                       //删除选品
-		s.POST("/selection/findAll", handler.WrapFindAllSelectionHandler)                     //选品列表
-		s.POST("/selection/detail", handler.WrapSelectionDetailHandler)                       //选品详情
+		s.POST("/selection/delete", handler.WrapDeleteSelectionHandler)                       // 删除选品
+		s.POST("/selection/findAll", handler.WrapFindAllSelectionHandler)                     // 选品列表
+		s.POST("/selection/detail", handler.WrapSelectionDetailHandler)                       // 选品详情
 		s.POST("/selection/create", handler.WrapCreateSelectionHandler)                       // 创建选品
 		s.POST("/selection/update", handler.WrapUpdateSelectionHandler)                       // 更新选品
 		s.POST("/selection/pay", handler.WrapPaySelectionHandler)                             // 支付选品项目

+ 1 - 0
service/sectask_service/logistics.go

@@ -47,6 +47,7 @@ func (*logistics) Create(ctx context.Context, request http_model.CreateSecTaskLo
 		LogisticsStatus: 2,
 		TaskStage:       8,
 		DeliveryDate:    time.Now(),
+		FreeStage:       4,
 	}
 	_, err = db.UpdateSecTask(ctx, updatdSecTask)
 	if err != nil {