Selaa lähdekoodia

带货悬赏兑现

Ethan 4 kuukautta sitten
vanhempi
commit
c4815304a7

+ 18 - 0
app/controller/task_controller.go

@@ -911,3 +911,21 @@ func (t TaskController) SelectionDataDetail(c *gin.Context) {
 	resultMap["dataInfo"] = result
 	returnSuccess(c, 20000, resultMap)
 }
+
+// 电商带货执行中-悬赏兑现
+func (t TaskController) SelectionRewardCash(c *gin.Context) {
+	param := &vo.SelectionRewardCashParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "Parameter Error: "+err.Error())
+		return
+	}
+	result, err1 := service.TaskInfoService{}.SelectionRewardCashDetail(param)
+	if err1 != nil {
+		logrus.Errorf("[SelectionRewardCash] call Show err:%+v\n", err)
+		returnError(c, 40000, err1.Error())
+		return
+	}
+	returnSuccess(c, 20000, result)
+}

+ 24 - 1
app/dao/sec_task_info_dao.go

@@ -1,6 +1,8 @@
 package dao
 
-import "youngee_b_api/app/entity"
+import (
+	"youngee_b_api/app/entity"
+)
 
 type SecTaskInfoDao struct{}
 
@@ -9,3 +11,24 @@ func (s SecTaskInfoDao) CountBySelectionId(selectionId string) (int64, error) {
 	err := Db.Model(&entity.SecTaskInfo{}).Where("selection_id = ?", selectionId).Count(&count).Error
 	return count, err
 }
+
+// 获取带货子任务中指定悬赏阶段的数据
+func (s SecTaskInfoDao) GetRewardDetailByRewardStage(selectionId string, rewardStage int64, order int64, page int, pageSize int) ([]*entity.SecTaskInfo, int64, error) {
+	secTaskInfos := []*entity.SecTaskInfo{}
+	var total int64
+	query := Db.Debug().Model(&entity.SecTaskInfo{}).Where("selection_id = ? AND reward_stage = ?", selectionId, rewardStage)
+	query.Count(&total)
+	query = query.Select("talent_id, sale_actual, withdraw_date")
+	offset := (page - 1) * pageSize
+	var err error
+	if order == 1 {
+		err = query.Order("withdraw_date asc").Offset(offset).Limit(pageSize).Find(&secTaskInfos).Error
+	} else {
+		err = query.Order("withdraw_date desc").Offset(offset).Limit(pageSize).Find(&secTaskInfos).Error
+	}
+	if err != nil {
+		return nil, 0, err
+	}
+
+	return secTaskInfos, total, nil
+}

+ 16 - 14
app/entity/sec_task_info.go

@@ -7,36 +7,38 @@ import (
 )
 
 type SecTaskInfo struct {
-	ID                     int       `gorm:"column:id;primary_key"`              // 递增id
+	ID                     int64     `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
+	AccountID              int64     `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表
+	IsPayPayment           int64     `gorm:"column:is_pay_payment"`              // 企业是否返样品钱
+	IsPayReward            int64     `gorm:"column:is_pay_reward"`               // 企业是否结算悬赏
+	TaskMode               int64     `gorm:"column:task_mode"`                   // 任务形式,1、2分别表示纯佣带货、悬赏任务
+	SampleMode             int64     `gorm:"column:sample_mode"`                 // 领样形式,1-3分别表示免费领样、垫付买样、不提供样品
+	TaskStatus             int64     `gorm:"column:task_status;default:1"`       // 任务状态 1待选 2已选 3落选
+	TaskStage              int64     `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分别代表待添加、已添加、待修改、已修改、已通过
+	CompleteStatus         int64     `gorm:"column:complete_status;default:1"`   // 结束方式 1未结束 2正常结束 3反选失败
+	LogisticsStatus        int64     `gorm:"column:logistics_status;default:1"`  // 发货状态 1 待发货 2已发货 3 已签收
+	AssignmentStatus       uint64    `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分别代表不可提现、可提现、提现中、已提现
+	WithdrawStatus         int64     `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之团团长积分收益
+	TeamIncome             int64     `gorm:"column:team_income"`                 // young之团团长现金收益
+	TeamPoint64            int64     `gorm:"column:team_point64"`                // young之团团长积分收益
+	SaleActual             int64     `gorm:"column:sale_actual"`                 // 实际带货量
+
 }
 
 func (m *SecTaskInfo) TableName() string {

+ 1 - 1
app/entity/talent_info.go

@@ -10,7 +10,7 @@ type YoungeeTalentInfo struct {
 	TalentWxOpenid    string    `gorm:"column:talent_wx_openid;NOT NULL"` // 达人的微信openid
 	Avatar            string    `gorm:"column:avatar;NOT NULL"`
 	TalentWxNickname  string    `gorm:"column:talent_wx_nickname"`           // 达人的微信昵称
-	TalentWxNumber    string    `gorm:"column:talent_wx_number"`             // 达人微信号
+	TalentNickname    string    `gorm:"column:talent_nickname"`              // 达人昵称
 	Income            float64   `gorm:"column:income;default:0"`             // 收益总数
 	Withdrawing       float64   `gorm:"column:withdrawing;default:0"`        // 提现中金额
 	Canwithdraw       float64   `gorm:"column:canwithdraw;default:0"`        // 可提现金额

+ 48 - 0
app/service/task_info_service.go

@@ -8,6 +8,7 @@ import (
 
 type TaskInfoService struct{}
 
+// 达人物流管理
 func (t TaskInfoService) LogisticsTalentList(param *vo.LogisticsTalentParam) (*vo.ResultVO, error) {
 	if param.Page <= 0 {
 		param.Page = 1
@@ -83,3 +84,50 @@ func (t TaskInfoService) LogisticsTalentList(param *vo.LogisticsTalentParam) (*v
 	}
 	return &result, nil
 }
+
+func (t TaskInfoService) SelectionRewardCashDetail(param *vo.SelectionRewardCashParam) (*vo.ReSelectionRewardCash, error) {
+	if param.Page == 0 {
+		param.Page = 1
+	}
+	if param.PageSize == 0 {
+		param.PageSize = 10
+	}
+	selectionInfo, err := dao.SelectionInfoDAO{}.GetSelectionInfoById(param.SelectionId)
+	if err != nil {
+		return nil, err
+	}
+	rewardPoolAmount := selectionInfo.EstimatedCost
+	rewardPoolCashed := selectionInfo.TaskReward
+	secTaskInfos, total, err1 := dao.SecTaskInfoDao{}.GetRewardDetailByRewardStage(param.SelectionId, 2, param.Order, param.Page, param.PageSize)
+	if err1 != nil {
+		return nil, err1
+	}
+	var talentRewardMsgs []vo.TalentRewardMsg
+	for _, secTaskInfo := range secTaskInfos {
+		talentInfo, _ := dao.TalentInfoDao{}.SelectTalentInfo(secTaskInfo.TalentID)
+		talentRewardMsg := vo.TalentRewardMsg{
+			PhotoUrl: talentInfo.Avatar,
+			Nickname: talentInfo.TalentNickname,
+			Account:  talentInfo.TalentWxOpenid,
+			Gender:   talentInfo.Sex,
+			OrderNum: secTaskInfo.SaleActual,
+			CashTime: secTaskInfo.WithdrawDate.Format("2006-01-02 15:04:05"),
+		}
+		talentRewardMsgs = append(talentRewardMsgs, talentRewardMsg)
+	}
+	talentMsgList := vo.ResultVO{
+		Page:     param.Page,
+		PageSize: param.PageSize,
+		Total:    total,
+		Data:     talentRewardMsgs,
+	}
+	reSelectionRewardCash := &vo.ReSelectionRewardCash{
+		RewardPoolAmount: rewardPoolAmount,
+		RewardPoolCashed: rewardPoolCashed,
+		CashedRate:       rewardPoolCashed / rewardPoolAmount,
+		TalentNum:        total,
+		TalentMsgList:    talentMsgList,
+	}
+
+	return reSelectionRewardCash, nil
+}

+ 1 - 0
app/vo/re_selection_data.go

@@ -46,4 +46,5 @@ type TalentMsg struct {
 	Account  string  `json:"account"`
 	OrderNum int64   `json:"orderNum"`
 	GMV      float64 `json:"GMV"`
+	Gender   int64   `json:"gender"`
 }

+ 18 - 0
app/vo/re_selection_reward_cash.go

@@ -0,0 +1,18 @@
+package vo
+
+type ReSelectionRewardCash struct {
+	RewardPoolAmount float64  `json:"rewardPoolAmount"`
+	RewardPoolCashed float64  `json:"rewardPoolCashed"`
+	CashedRate       float64  `json:"cashedRate"`
+	TalentNum        int64    `json:"talentNum"`
+	TalentMsgList    ResultVO `json:"talentMsgList"`
+}
+
+type TalentRewardMsg struct {
+	PhotoUrl string `json:"photoUrl"`
+	Nickname string `json:"nickname"`
+	Account  string `json:"account"`
+	OrderNum int64  `json:"orderNum"`
+	CashTime string `json:"cashTime"`
+	Gender   int64  `json:"gender"` // 0未知 1男 2女
+}

+ 11 - 0
app/vo/selection_reward_cash_param.go

@@ -0,0 +1,11 @@
+package vo
+
+type SelectionRewardCashParam struct {
+	SelectionId  string `json:"selection_id"`
+	EnterpriseId string `json:"enterprise_id"`
+	SubAccountId int64  `json:"sub_account_id"`
+	Nickname     string `json:"nickname"`
+	Order        int64  `json:"order"`
+	Page         int    `json:"page"`
+	PageSize     int    `json:"page_size"`
+}

+ 1 - 0
route/init.go

@@ -181,6 +181,7 @@ func InitRoute(r *gin.Engine) {
 		task.POST("/selection/data/talent", controller.TaskController{}.TalentDataDetail)       // 电商带货看数据-达人数据
 		task.POST("/selection/data/sample", controller.TaskController{}.SampleDataDetail)       // 电商带货看数据-领样数据
 		task.POST("/selection/data/selection", controller.TaskController{}.SelectionDataDetail) // 电商带货看数据-带货数据
+		task.POST("/selection/reward/cash", controller.TaskController{}.SelectionRewardCash)    // 电商带货执行中-悬赏兑现
 
 		task.POST("/project/create", controller.TaskController{}.CreateProject)              // 创建种草任务
 		task.POST("/project/update", controller.TaskController{}.UpdateProject)              // 更新公开种草任务