unknown 2 жил өмнө
parent
commit
20f16d5981

+ 17 - 0
db/enterprise.go

@@ -66,3 +66,20 @@ func GetEnterpriseBalance(ctx context.Context, EnterpriseID int64) (*http_model.
 	}
 	return res, nil
 }
+
+// 支付-修改企业账户余额
+func UpdateEnterpriseBalance(ctx context.Context, EnterpriseID int64, balance int64, availableBalance int64, frozenBalance int64) (*int64, error) {
+	db := GetReadDB(ctx)
+	err := db.Model(gorm_model.Enterprise{}).Where("enterprise_id", EnterpriseID).
+		Updates(map[string]interface{}{"balance": gorm.Expr("balance + ?", balance), "available_balance": gorm.Expr("available_balance + ?", availableBalance), "frozen_balance": gorm.Expr("frozen_balance + ?", frozenBalance)}).Error
+	if err != nil {
+		return nil, err
+	}
+	enterprise := gorm_model.Enterprise{}
+	err = db.Model(gorm_model.Enterprise{}).Where("enterprise_id", EnterpriseID).Scan(&enterprise).Error
+	if err != nil {
+		return nil, err
+	}
+
+	return &enterprise.Balance, nil
+}

+ 134 - 7
db/logistics.go

@@ -2,30 +2,157 @@ package db
 
 import (
 	"context"
-	"gorm.io/gorm"
+	"fmt"
+	"reflect"
+	"time"
+	"youngee_b_api/model/common_model"
 	"youngee_b_api/model/gorm_model"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/pack"
+	"youngee_b_api/util"
+
+	"github.com/issue9/conv"
+	"github.com/sirupsen/logrus"
 )
 
-//实物邮寄
+//新增
 func CreateLogistics(ctx context.Context, logistics gorm_model.YoungeeTaskLogistics, RecruitStrategyID int64) (*int64, error) {
 	db := GetReadDB(ctx)
 	err := db.Create(&logistics).Error
-	err1 := db.Model(gorm_model.RecruitStrategy{}).Where("recruit_strategy_id = ?", RecruitStrategyID).Updates(map[string]interface{}{"delivered_number": gorm.Expr("delivered_number + ?", 1), "waiting_number": gorm.Expr("waiting_number - ?", 1)}).Error
 	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics db] call CreateLogistics error,err:%+v", err)
 		return nil, err
 	}
-	if err1 != nil {
-		return nil, err1
-	}
+
 	return &logistics.LogisticsID, nil
 }
 
 //修改接口
 func UpdateLogistics(ctx context.Context, logistics gorm_model.YoungeeTaskLogistics) (*int64, error) {
 	db := GetReadDB(ctx)
-	err := db.Model(&logistics).Updates(logistics).Error
+	err := db.Model(&logistics).Where("task_id = ?", logistics.TaskID).Updates(logistics).Error
 	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics db] call UpdateLogistics error,err:%+v", err)
 		return nil, err
 	}
 	return &logistics.LogisticsID, nil
 }
+
+// 更改签收时间
+func SignForReceipt(ctx context.Context, taskID int64) error {
+	db := GetReadDB(ctx)
+	time := time.Now()
+	err := db.Model(gorm_model.YoungeeTaskLogistics{}).Where("task_id = ?", taskID).Update("signed_time", time).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics db] call UpdateLogistics error,err:%+v", err)
+		return err
+	}
+	return nil
+}
+
+// 查询包含物流信息的task list
+func GetTaskLogisticsList(ctx context.Context, projectID string, pageSize, pageNum int64, conditions *common_model.TalentConditions) ([]*http_model.TaskLogisticsInfo, int64, error) {
+	db := GetReadDB(ctx)
+	// 查询Task表信息
+	db = db.Debug().Model(gorm_model.YoungeeTaskInfo{})
+	// 根据Project条件过滤
+	conditionType := reflect.TypeOf(conditions).Elem()
+	conditionValue := reflect.ValueOf(conditions).Elem()
+	for i := 0; i < conditionType.NumField(); i++ {
+		field := conditionType.Field(i)
+		tag := field.Tag.Get("condition")
+		value := conditionValue.FieldByName(field.Name)
+		if !util.IsBlank(value) && tag != "platform_nickname" {
+			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		} else if tag == "platform_nickname" {
+			continue
+		}
+	}
+	var taskInfos []gorm_model.YoungeeTaskInfo
+	db = db.Model(gorm_model.YoungeeTaskInfo{})
+	// 查询总数
+	var totalTask int64
+	if err := db.Count(&totalTask).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	db.Order("task_id").Find(&taskInfos)
+
+	// 查询任务id
+	var taskIds []int
+	taskMap := make(map[int]gorm_model.YoungeeTaskInfo)
+	for _, taskInfo := range taskInfos {
+		taskIds = append(taskIds, taskInfo.TaskID)
+		taskMap[taskInfo.TaskID] = taskInfo
+	}
+	db1 := GetReadDB(ctx)
+	db1 = db1.Debug().Model(gorm_model.YoungeeTaskLogistics{})
+
+	// 根据Project条件过滤
+	conditionType2 := reflect.TypeOf(conditions).Elem()
+	conditionValue2 := reflect.ValueOf(conditions).Elem()
+	for i := 0; i < conditionType2.NumField(); i++ {
+		field := conditionType2.Field(i)
+		tag := field.Tag.Get("condition")
+		value := conditionValue2.FieldByName(field.Name)
+		if !util.IsBlank(value) && tag == "platform_nickname" { // input:1		taskIdsbase:1,2,3    string
+			db1 = db1.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		}
+	}
+	var logisticsInfos []gorm_model.YoungeeTaskLogistics
+	db1 = db1.Model(gorm_model.YoungeeTaskLogistics{}).Where("task_id IN ?", taskIds).Find(&logisticsInfos)
+	logisticsMap := make(map[int]gorm_model.YoungeeTaskLogistics)
+	for _, logisticsInfo := range logisticsInfos {
+		logisticsMap[conv.MustInt(logisticsInfo.TaskID)] = logisticsInfo
+	}
+	// 查询总数
+	var totalLogistics int64
+	if err := db1.Count(&totalLogistics).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectTalentList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	var misNum int64
+	if totalLogistics > totalTask {
+		misNum = totalLogistics - totalTask
+	} else {
+		misNum = totalTask - totalLogistics
+	}
+	logrus.Println("totalLogistics,totalTalent,misNum:", totalLogistics, totalTask, misNum)
+
+	// 查询该页数据
+	limit := pageSize + misNum
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("task_id").Limit(int(limit)).Offset(int(offset)).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+
+	var TaskLogisticss []*http_model.TaskLogistics
+	var taskLogisticss []*http_model.TaskLogisticsInfo
+	for _, taskId := range taskIds {
+		TaskLogistics := new(http_model.TaskLogistics)
+		TaskLogistics.Talent = taskMap[taskId]
+		TaskLogistics.Logistics = logisticsMap[taskId]
+		TaskLogisticss = append(TaskLogisticss, TaskLogistics)
+	}
+
+	taskLogisticss = pack.TaskLogisticsToTaskInfo(TaskLogisticss)
+
+	for _, v := range taskLogisticss {
+		fmt.Println("taskLogisticss: \n", *v)
+	}
+	// return fulltaskLogisticss, total, nil
+	return taskLogisticss, totalTask, nil
+}
+
+// 修改任务表的物流状态
+func ChangeLogisticsStatus(ctx context.Context, taskIds []string) error {
+	db := GetReadDB(ctx)
+	err := db.Debug().Model(gorm_model.YoungeeTaskInfo{}).Where("task_id IN ?", taskIds).Update("logistics_status", 3).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[ChangeTaskStatus] error query mysql total, err:%+v", err)
+		return err
+	}
+	return nil
+}

+ 29 - 0
db/pay_record.go

@@ -0,0 +1,29 @@
+package db
+
+import (
+	"context"
+	"time"
+	"youngee_b_api/model/gorm_model"
+
+	"github.com/sirupsen/logrus"
+)
+
+//新增
+func CreatePayRecord(ctx context.Context, enterpriseId int64, payment int64, balance int64, payType int64, projectId int64) (*int64, error) {
+	db := GetReadDB(ctx)
+	payRecord := gorm_model.EnterprisePayRecord{
+		EnterpriseID: enterpriseId,
+		Payment:      payment,
+		Balance:      balance,
+		PayType:      payType,
+		PayAt:        time.Now(),
+		ProjectID:    projectId,
+	}
+	err := db.Create(&payRecord).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics db] call CreatePayRecord error,err:%+v", err)
+		return nil, err
+	}
+
+	return &payRecord.ID, nil
+}

+ 6 - 140
db/project.go

@@ -3,9 +3,7 @@ package db
 import (
 	"context"
 	"fmt"
-	"github.com/issue9/conv"
 	"reflect"
-	"strconv"
 	"youngee_b_api/model/common_model"
 	"youngee_b_api/model/gorm_model"
 	"youngee_b_api/model/http_model"
@@ -13,6 +11,7 @@ import (
 	"youngee_b_api/util"
 
 	"github.com/sirupsen/logrus"
+	log "github.com/sirupsen/logrus"
 	"gorm.io/gorm"
 )
 
@@ -118,7 +117,7 @@ func GetProjectTaskList(ctx context.Context, projectID string, pageSize, pageNum
 		field := conditionType2.Field(i)
 		tag := field.Tag.Get("condition")
 		value := conditionValue2.FieldByName(field.Name)
-		if !util.IsBlank(value) && tag == "platform_nickname" { // input:1		database:1,2,3    string
+		if !util.IsBlank(value) && tag == "platform_nickname" { // input:1		taskIdsbase:1,2,3    string
 			db1 = db1.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
 		}
 	}
@@ -214,146 +213,13 @@ func GetRecruitStrategys(ctx context.Context, ProjectID int64) ([]gorm_model.Rec
 	return RecruitStrategys, nil
 }
 
-func ChangeTaskStatus(ctx context.Context, data []string, taskStatus string) error {
+func UpdateProjectStatus(ctx context.Context, projectId int64, status int64) error {
 	db := GetReadDB(ctx)
-	taskInfo := gorm_model.YoungeeTaskInfo{}
-	taskSta, err := strconv.Atoi(taskStatus)
+	err := db.Model(gorm_model.ProjectInfo{}).
+		Where("project_id = ?", projectId).Update("project_status", status).Error
 	if err != nil {
-		return err
-	}
-	if err := db.Debug().Model(&taskInfo).Where("task_id IN ?", data).
-		Updates(gorm_model.YoungeeTaskInfo{TaskStatus: taskSta}).Error; err != nil {
-
-		logrus.WithContext(ctx).Errorf("[ChangeTaskStatus] error query mysql total, err:%+v", err)
+		log.Println("DB UpdateProjectStatus error :", err)
 		return err
 	}
 	return nil
 }
-
-func GetProjectTalentList(ctx context.Context, projectID string, pageSize, pageNum int64, conditions *common_model.TalentConditions) ([]*http_model.ProjectTalentInfo, int64, error) {
-	db := GetReadDB(ctx)
-	// 查询Task表信息
-	db = db.Debug().Model(gorm_model.YoungeeTaskInfo{})
-	// 根据Project条件过滤
-	conditionType := reflect.TypeOf(conditions).Elem()
-	conditionValue := reflect.ValueOf(conditions).Elem()
-	for i := 0; i < conditionType.NumField(); i++ {
-		field := conditionType.Field(i)
-		tag := field.Tag.Get("condition")
-		value := conditionValue.FieldByName(field.Name)
-		if !util.IsBlank(value) && tag != "platform_nickname" {
-			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
-		} else if tag == "platform_nickname" {
-			continue
-		}
-	}
-	var taskInfos []gorm_model.YoungeeTaskInfo
-	db = db.Model(gorm_model.YoungeeTaskInfo{})
-	// 查询总数
-	var totalTask int64
-	if err := db.Count(&totalTask).Error; err != nil {
-		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql total, err:%+v", err)
-		return nil, 0, err
-	}
-	db.Order("task_id").Find(&taskInfos)
-
-	// 查询账号id
-	var taskIds []int
-	taskMap := make(map[int]gorm_model.YoungeeTaskInfo)
-	for _, taskInfo := range taskInfos {
-		taskIds = append(taskIds, taskInfo.TaskID)
-		taskMap[taskInfo.TaskID] = taskInfo
-	}
-	db1 := GetReadDB(ctx)
-	db1 = db1.Debug().Model(gorm_model.YoungeeTaskLogistics{})
-	// 根据Project条件过滤
-	conditionType2 := reflect.TypeOf(conditions).Elem()
-	conditionValue2 := reflect.ValueOf(conditions).Elem()
-	for i := 0; i < conditionType2.NumField(); i++ {
-		field := conditionType2.Field(i)
-		tag := field.Tag.Get("condition")
-		value := conditionValue2.FieldByName(field.Name)
-		if !util.IsBlank(value) && tag == "platform_nickname" { // input:1		database:1,2,3    string
-			db1 = db1.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
-		}
-	}
-	var logisticsInfos []gorm_model.YoungeeTaskLogistics
-	db1 = db1.Model(gorm_model.YoungeeTaskLogistics{}).Where("task_id IN ?", taskIds).Find(&logisticsInfos)
-	logisticsMap := make(map[int]gorm_model.YoungeeTaskLogistics)
-	for _, logisticsInfo := range logisticsInfos {
-		logisticsMap[conv.MustInt(logisticsInfo.TaskID)] = logisticsInfo
-	}
-	/*
-		db1 := GetReadDB(ctx)
-		db1 = db1.Debug().Model(gorm_model.YoungeePlatformAccountInfo{})
-		// 根据Project条件过滤
-		conditionType2 := reflect.TypeOf(conditions).Elem()
-		conditionValue2 := reflect.ValueOf(conditions).Elem()
-		for i := 0; i < conditionType2.NumField(); i++ {
-			field := conditionType2.Field(i)
-			tag := field.Tag.Get("condition")
-			value := conditionValue2.FieldByName(field.Name)
-			if !util.IsBlank(value) && tag == "platform_nickname" { // input:1		database:1,2,3    string
-				db1 = db1.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
-			}
-		}
-		var accountInfos []gorm_model.YoungeePlatformAccountInfo
-		db1 = db1.Model(gorm_model.YoungeePlatformAccountInfo{}).Where("account_id IN ?", accountIds).Find(&accountInfos)
-	*/
-	// 查询总数
-	var totalAccount int64
-	if err := db1.Count(&totalAccount).Error; err != nil {
-		logrus.WithContext(ctx).Errorf("[GetProjectTalentList] error query mysql total, err:%+v", err)
-		return nil, 0, err
-	}
-	var misNum int64
-	if totalAccount > totalTask {
-		misNum = totalAccount - totalTask
-	} else {
-		misNum = totalTask - totalAccount
-	}
-	logrus.Println("totalAccount,totalTalent,misNum:", totalAccount, totalTask, misNum)
-
-	// 查询该页数据
-	limit := pageSize + misNum
-	offset := pageSize * pageNum // assert pageNum start with 0
-	err := db.Order("task_id").Limit(int(limit)).Offset(int(offset)).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetProjectTaskList] error query mysql total, err:%+v", err)
-		return nil, 0, err
-	}
-	/*
-		accountMap := make(map[int]gorm_model.YoungeePlatformAccountInfo)
-		for _, accountInfo := range accountInfos {
-			accountMap[accountInfo.AccountID] = accountInfo
-		}
-	*/
-	var talentAccounts []*http_model.TalentAccount
-	var projectTalents []*http_model.ProjectTalentInfo
-	for _, taskId := range taskIds {
-		talentAccount := new(http_model.TalentAccount)
-		_, ok := taskMap[taskId]
-		_, ok2 := logisticsMap[taskId]
-		if ok && ok2 {
-			talentAccount.Talent = taskMap[taskId]
-			talentAccount.Logistics = logisticsMap[taskId]
-		}
-		talentAccounts = append(talentAccounts, talentAccount)
-	}
-
-	projectTalents = pack.TalentAccountToTaskInfo(talentAccounts)
-	var fullProjectTalents []*http_model.ProjectTalentInfo
-	// 删除只存在于一个表中的元素
-	for i := 0; i < len(projectTalents); i++ {
-		if projectTalents[i].TaskID != 0 {
-			fullProjectTalents = append(fullProjectTalents, projectTalents[i])
-		}
-	}
-	var total int64
-	if totalTask > totalAccount {
-		total = totalAccount
-	} else {
-		total = totalTask
-	}
-	return fullProjectTalents, total, nil
-}

+ 24 - 12
db/recruit_strategy.go

@@ -3,6 +3,9 @@ package db
 import (
 	"context"
 	"youngee_b_api/model/gorm_model"
+
+	"github.com/sirupsen/logrus"
+	"gorm.io/gorm"
 )
 
 func CreateRecruitStrategy(ctx context.Context, recruitStrategys []gorm_model.RecruitStrategy) error {
@@ -36,15 +39,24 @@ func CalculateSelectedNumberByRecruitStrategyID(ctx context.Context, recruitstra
 	return nil
 }
 
-//func UpdateProject(ctx context.Context, project gorm_model.ProjectInfo) (*int64, error) {
-//	db := GetReadDB(ctx)
-//	err := db.Model(&project).Updates(project).Error
-//	if err != nil {
-//		return nil, err
-//	}
-//	return &project.ProjectID, nil
-//}
-//func UpdateRecruitStrategy(ctx context.Context,project gorm_model.RecruitStrategy)
-//{
-//
-//}
+func UpdateLogisticsNumber(ctx context.Context, RecruitStrategyID int64, delivered_value int64, waiting_value int64, signed_value int64) error {
+	db := GetReadDB(ctx)
+	err := db.Model(gorm_model.RecruitStrategy{}).Where("recruit_strategy_id = ?", RecruitStrategyID).
+		Updates(map[string]interface{}{"delivered_number": gorm.Expr("delivered_number + ?", delivered_value), "waiting_number": gorm.Expr("waiting_number + ?", waiting_value), "signed_number": gorm.Expr("signed_number + ?", signed_value)}).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics db] call CreateLogistics error,err:%+v", err)
+		return err
+	}
+	return nil
+}
+
+func GetRecruitStrategyIdByTS(ctx context.Context, projectId int, strategyID int64) (*int64, error) {
+	db := GetReadDB(ctx)
+	RecruitStrategy := &gorm_model.RecruitStrategy{}
+	err := db.Model(gorm_model.RecruitStrategy{}).Where("project_id = ? AND strategy_id = ?", projectId, strategyID).Scan(RecruitStrategy).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics db] call CreateLogistics error,err:%+v", err)
+		return nil, err
+	}
+	return &RecruitStrategy.RecruitStrategyID, nil
+}

+ 41 - 0
db/task.go

@@ -2,7 +2,10 @@ package db
 
 import (
 	"context"
+	"strconv"
 	"youngee_b_api/model/gorm_model"
+
+	"github.com/sirupsen/logrus"
 )
 
 func GetTaskList(ctx context.Context, projectID int64) ([]gorm_model.YoungeeTaskInfo, error) {
@@ -15,3 +18,41 @@ func GetTaskList(ctx context.Context, projectID int64) ([]gorm_model.YoungeeTask
 	}
 	return tasks, nil
 }
+
+func UpdateLogisticsStatus(ctx context.Context, taskID int64, status int64) error {
+
+	db := GetReadDB(ctx)
+	err := db.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskID).Update("logistics_status", status).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[task db] call UpdateLogisticsStatus error,err:%+v", err)
+		return err
+	}
+	return nil
+}
+
+func GetProjectIdByTaskId(ctx context.Context, taskID int64) (*int, error) {
+	db := GetReadDB(ctx)
+	task := &gorm_model.YoungeeTaskInfo{}
+	err := db.Model(gorm_model.YoungeeTaskInfo{}).Where("task_id = ?", taskID).Scan(task).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[task db] call UpdateLogisticsStatus error,err:%+v", err)
+		return nil, err
+	}
+	return &task.ProjectID, nil
+}
+
+func ChangeTaskStatus(ctx context.Context, taskIds []string, taskStatus string) error {
+	db := GetReadDB(ctx)
+	taskInfo := gorm_model.YoungeeTaskInfo{}
+	taskSta, err := strconv.Atoi(taskStatus)
+	if err != nil {
+		return err
+	}
+	if err := db.Debug().Model(&taskInfo).Where("task_id IN ?", taskIds).
+		Updates(gorm_model.YoungeeTaskInfo{TaskStatus: taskSta}).Error; err != nil {
+
+		logrus.WithContext(ctx).Errorf("[ChangeTaskStatus] error query mysql total, err:%+v", err)
+		return err
+	}
+	return nil
+}

+ 1 - 1
go.mod

@@ -23,7 +23,7 @@ require (
 	github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2
 	github.com/swaggo/gin-swagger v1.4.1
 	github.com/swaggo/swag v1.8.1
-	github.com/tidwall/gjson v1.14.1 // indirect
+	github.com/tidwall/gjson v1.14.1
 	github.com/ugorji/go v1.2.7 // indirect
 	golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 // indirect
 	golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3 // indirect

+ 2 - 0
handler/logistics_create.go

@@ -1,6 +1,7 @@
 package handler
 
 import (
+	"fmt"
 	"youngee_b_api/consts"
 	"youngee_b_api/model/http_model"
 	"youngee_b_api/service"
@@ -44,6 +45,7 @@ func (h *CreateLogisticsHandler) run() {
 	data = *h.req
 	isUpdate := data.IsUpdate
 	if isUpdate == 0 {
+		fmt.Println("Create in")
 		res, err := service.Logistics.Create(h.ctx, data)
 		if err != nil {
 			logrus.Errorf("[CreateLogisticsHandler] call Create err:%+v\n", err)

+ 0 - 1
handler/project_change_logisticsStatus.go

@@ -1 +0,0 @@
-package handler

+ 2 - 1
handler/project_list.go

@@ -3,7 +3,6 @@ package handler
 import (
 	"errors"
 	"fmt"
-	"github.com/issue9/conv"
 	"time"
 	"youngee_b_api/consts"
 	"youngee_b_api/middleware"
@@ -12,6 +11,8 @@ import (
 	"youngee_b_api/service"
 	"youngee_b_api/util"
 
+	"github.com/issue9/conv"
+
 	"github.com/gin-gonic/gin"
 	"github.com/sirupsen/logrus"
 )

+ 56 - 0
handler/project_pay.go

@@ -0,0 +1,56 @@
+package handler
+
+import (
+	"youngee_b_api/consts"
+	"youngee_b_api/middleware"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service"
+	"youngee_b_api/util"
+
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+)
+
+func WrapProjectPayHandler(ctx *gin.Context) {
+	handler := newProjectPayHandler(ctx)
+	baseRun(handler)
+}
+
+func newProjectPayHandler(ctx *gin.Context) *ProjectPayHandler {
+	return &ProjectPayHandler{
+		req:  http_model.NewProjectPayRequest(),
+		resp: http_model.NewProjectPayResponse(),
+		ctx:  ctx,
+	}
+}
+
+type ProjectPayHandler struct {
+	req  *http_model.ProjectPayRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *ProjectPayHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *ProjectPayHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *ProjectPayHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *ProjectPayHandler) run() {
+	enterpriseID := middleware.GetSessionAuth(h.ctx).EnterpriseID
+	data := http_model.ProjectPayRequest{}
+	data = *h.req
+	record, err := service.ProjectPay.Pay(h.ctx, data, enterpriseID)
+	if err != nil {
+		logrus.WithContext(h.ctx).Errorf("[ProjectPayHandler] error Pay, err:%+v", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	h.resp.Data = record
+}
+func (h *ProjectPayHandler) checkParam() error {
+	return nil
+}

+ 0 - 88
handler/project_talentlist.go

@@ -1,88 +0,0 @@
-package handler
-
-import (
-	"errors"
-	"fmt"
-	"youngee_b_api/consts"
-	"youngee_b_api/model/http_model"
-	"youngee_b_api/pack"
-	"youngee_b_api/service"
-	"youngee_b_api/util"
-
-	"github.com/gin-gonic/gin"
-	"github.com/issue9/conv"
-	"github.com/sirupsen/logrus"
-)
-
-// WrapProjectTaskListHandler
-// @BasePath /youngee/m/
-// SendCode godoc
-// @Summary ProjectTalentList 项目达人列表
-// @Schemes
-// @Description 展示某个项目的已选达人列表
-// @Accept json
-// @Produce json
-// @Param req body http_model.ProjectTaskListRequest true "查询项目的任务列表的请求结构体"
-// @Success 200 {object} http_model.CommonResponse{data=http_model.ProjectTaskListData} "查询项目的任务列表相应结构体"
-// @Router /product/taskList [post]
-func WrapProjectTalentListHandler(ctx *gin.Context) {
-	handler := newProjectTalentListHandler(ctx)
-	baseRun(handler)
-}
-
-func newProjectTalentListHandler(ctx *gin.Context) *ProjectTalentListHandler {
-	return &ProjectTalentListHandler{
-		req:  http_model.NewProjectTalentListRequest(),
-		resp: http_model.NewProjectTalentListResponse(),
-		ctx:  ctx,
-	}
-}
-
-type ProjectTalentListHandler struct {
-	req  *http_model.ProjectTalentListRequest
-	resp *http_model.CommonResponse
-	ctx  *gin.Context
-}
-
-func (h *ProjectTalentListHandler) getRequest() interface{} {
-	return h.req
-}
-func (h *ProjectTalentListHandler) getContext() *gin.Context {
-	return h.ctx
-}
-func (h *ProjectTalentListHandler) getResponse() interface{} {
-	return h.resp
-}
-func (h *ProjectTalentListHandler) run() {
-	conditions := pack.HttpProjectTalentRequestToCondition(h.req)
-	data, err := service.Project.GetProjectTalentList(h.ctx, h.req.ProjectId, h.req.PageSize, h.req.PageNum, conditions)
-	if err != nil {
-		logrus.WithContext(h.ctx).Errorf("[ProjectTalentListHandler] error GetProjectTaskList, err:%+v", err)
-		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
-		return
-	}
-	h.resp.Data = data
-}
-func (h *ProjectTalentListHandler) checkParam() error {
-	var errs []error
-	if h.req.PageNum < 0 || h.req.PageSize <= 0 {
-		errs = append(errs, errors.New("page param error"))
-	}
-	h.req.PageNum--
-	h.req.ProjectId = util.IsNull(h.req.ProjectId)
-	if _, err := conv.Int64(h.req.ProjectId); err != nil {
-		errs = append(errs, err)
-	}
-	h.req.StrategyId = util.IsNull(h.req.StrategyId)
-	if _, err := conv.Int64(h.req.StrategyId); err != nil {
-		errs = append(errs, err)
-	}
-	h.req.TaskStatus = util.IsNull(h.req.TaskStatus)
-	if _, err := conv.Int64(h.req.TaskStatus); err != nil {
-		errs = append(errs, err)
-	}
-	if len(errs) != 0 {
-		return fmt.Errorf("check param errs:%+v", errs)
-	}
-	return nil
-}

+ 60 - 0
handler/sign_for_receipt.go

@@ -0,0 +1,60 @@
+package handler
+
+import (
+	"youngee_b_api/consts"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service"
+	"youngee_b_api/util"
+
+	"github.com/sirupsen/logrus"
+
+	"github.com/gin-gonic/gin"
+)
+
+func WrapSignForReceiptHandler(ctx *gin.Context) {
+	handler := newSignForReceiptHandler(ctx)
+	baseRun(handler)
+}
+
+func newSignForReceiptHandler(ctx *gin.Context) *SignForReceiptHandler {
+	return &SignForReceiptHandler{
+		req:  http_model.NewSignForReceiptRequst(),
+		resp: http_model.NewSignForReceiptResponse(),
+		ctx:  ctx,
+	}
+}
+
+type SignForReceiptHandler struct {
+	req  *http_model.SignForReceiptRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (p *SignForReceiptHandler) getContext() *gin.Context {
+	return p.ctx
+}
+
+func (p *SignForReceiptHandler) getResponse() interface{} {
+	return p.resp
+}
+
+func (p *SignForReceiptHandler) getRequest() interface{} {
+	return p.req
+}
+
+func (p *SignForReceiptHandler) run() {
+	data := http_model.SignForReceiptRequest{}
+	data = *p.req
+	err := service.Logistics.SignForReceipt(p.ctx, data)
+	if err != nil {
+		logrus.Errorf("[ChangeLogisticsStatusHandler] call Create err:%+v\n", err)
+		util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
+		logrus.Info("ChangeLogisticsStatus fail,req:%+v", p.req)
+		return
+	}
+	p.resp.Message = "物流状态更换成功"
+}
+
+func (p *SignForReceiptHandler) checkParam() error {
+	return nil
+}

+ 77 - 0
handler/task_logistics_list.go

@@ -0,0 +1,77 @@
+package handler
+
+import (
+	"errors"
+	"fmt"
+	"youngee_b_api/consts"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/pack"
+	"youngee_b_api/service"
+	"youngee_b_api/util"
+
+	"github.com/gin-gonic/gin"
+	"github.com/issue9/conv"
+	"github.com/sirupsen/logrus"
+)
+
+func WrapTaskLogisticsListHandler(ctx *gin.Context) {
+	handler := newTaskLogisticsListHandler(ctx)
+	baseRun(handler)
+}
+
+func newTaskLogisticsListHandler(ctx *gin.Context) *TaskLogisticsListHandler {
+	return &TaskLogisticsListHandler{
+		req:  http_model.NewTaskLogisticsListRequest(),
+		resp: http_model.NewTaskLogisticsListResponse(),
+		ctx:  ctx,
+	}
+}
+
+type TaskLogisticsListHandler struct {
+	req  *http_model.TaskLogisticsListRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *TaskLogisticsListHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *TaskLogisticsListHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *TaskLogisticsListHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *TaskLogisticsListHandler) run() {
+	conditions := pack.HttpTaskLogisticsListRequestToCondition(h.req)
+	data, err := service.Project.GetTaskLogisticsList(h.ctx, h.req.ProjectId, h.req.PageSize, h.req.PageNum, conditions)
+	if err != nil {
+		logrus.WithContext(h.ctx).Errorf("[TaskLogisticsListHandler] error GetProjectTaskList, err:%+v", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	h.resp.Data = data
+}
+func (h *TaskLogisticsListHandler) checkParam() error {
+	var errs []error
+	if h.req.PageNum < 0 || h.req.PageSize <= 0 {
+		errs = append(errs, errors.New("page param error"))
+	}
+	h.req.PageNum--
+	h.req.ProjectId = util.IsNull(h.req.ProjectId)
+	if _, err := conv.Int64(h.req.ProjectId); err != nil {
+		errs = append(errs, err)
+	}
+	h.req.StrategyId = util.IsNull(h.req.StrategyId)
+	if _, err := conv.Int64(h.req.StrategyId); err != nil {
+		errs = append(errs, err)
+	}
+	h.req.LogisticsStatus = util.IsNull(h.req.LogisticsStatus)
+	if _, err := conv.Int64(h.req.LogisticsStatus); err != nil {
+		errs = append(errs, err)
+	}
+	if len(errs) != 0 {
+		return fmt.Errorf("check param errs:%+v", errs)
+	}
+	return nil
+}

+ 5 - 5
model/gorm_model/logistics.go

@@ -1,9 +1,8 @@
+// Code generated by sql2gorm. DO NOT EDIT.
 package gorm_model
 
-
-// Code generated by sql2gorm. DO NOT EDIT.
 import (
-"time"
+	"time"
 )
 
 type YoungeeTaskLogistics struct {
@@ -16,5 +15,6 @@ type YoungeeTaskLogistics struct {
 	CouponCodeInformation string    `gorm:"column:coupon_code_information"`                 // 虚拟产品-券码信息
 	TaskID                int64       `gorm:"column:task_id;NOT NULL"`                        // 任务id
 	DeliveryTime          time.Time `gorm:"column:delivery_time"`                           // 发货时间
-	ThingsType            int       `gorm:"column:things_type;NOT NULL"`                    // 任务类型:1 实物,2:线下探店,3:虚拟产品
-}
+	ThingsType            int64       `gorm:"column:things_type;NOT NULL"`                    // 任务类型:1 实物,2:线下探店,3:虚拟产品
+	SignedTime            time.Time `gorm:"column:signed_time"`                             // 实物商品-签收时间
+}

+ 22 - 0
model/gorm_model/pay_record.go

@@ -0,0 +1,22 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+import (
+	"time"
+)
+
+type EnterprisePayRecord struct {
+	ID           int64       `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id
+	Payment      int64       `gorm:"column:payment;NOT NULL"`              // 交易金额
+	Balance      int64       `gorm:"column:balance"`                       // 交易后账户可用余额
+	PayType      int64       `gorm:"column:pay_type;NOT NULL"`             // 交易类型,1表示充值,2表示支付
+	RechargeType int64       `gorm:"column:recharge_type"`                 // 充值方式,1表示在线交易,2表示对公转账
+	EnterpriseID int64       `gorm:"column:enterprise_id;NOT NULL"`        // 企业id
+	PayAt        time.Time `gorm:"column:pay_at;NOT NULL"`               // 交易时间
+	ProjectID    int64       `gorm:"column:project_id"`                    // 支付的项目id
+}
+
+func (m *EnterprisePayRecord) TableName() string {
+	return "enterprise_pay_record"
+}
+

+ 1 - 1
model/gorm_model/project_task.go

@@ -24,7 +24,7 @@ type YoungeeTaskInfo struct {
 	ServiceRate            int       `gorm:"column:service_rate"`                                   // 服务费率,千分之
 	TaskStatus             int       `gorm:"column:task_status;default:1;NOT NULL"`                 // 任务状态 1待选 2已选 3落选
 	TaskStage              int       `gorm:"column:task_stage;NOT NULL"`                            // 任务阶段
-	CreateDate             time.Time `gorm:"column:create_date;default:CURRENT_TIMESTAMP;NOT NULL"` // 创建时间
+	CreateDate             time.Time `gorm:"column:create_date;NOT NULL"` // 创建时间
 	SelectDate             time.Time `gorm:"column:select_date"`                                    // 反选时间
 	CompleteStatus         int       `gorm:"column:complete_status;default:1;NOT NULL"`             // 结束方式 1未结束 2正常结束 3反选失败 4被解约
 	CompleteDate           time.Time `gorm:"column:complete_date"`                                  // 结束时间

+ 2 - 2
model/http_model/logistics_create.go

@@ -12,8 +12,8 @@ type CreateLogisticsRequest struct {
 	ExplorestorePeriod    string    `json:"explorestore_period"`     // 线下探店-探店持续时间
 	CouponCodeInformation string    `json:"coupon_code_information"` // 虚拟产品-券码信息
 	TaskID                int64     `json:"task_id"`                 // 任务id
-	DeliveryTime          time.Time `json:"delivery_time"`           // 发货时间
-	ThingsType            int       `json:"things_type"`             //产品类型 1:实物, 2:线下探店,3:虚拟产品
+	DeliveryTime          string    `json:"delivery_time"`           // 发货时间
+	ThingsType            int       `json:"things_type"`             //产品类型 1:实物, 2:虚拟产品,3:线下探店
 	IsUpdate              int       `json:"is_update"`               //更新标志位 0:不更新 1:更新
 }
 

+ 19 - 0
model/http_model/project_pay.go

@@ -0,0 +1,19 @@
+package http_model
+
+type ProjectPayRequest struct {
+	ProjectID string `json:"project_id"`
+	PaySum    int64  `json:"pay_sum"`
+}
+
+type ProjectPayData struct {
+	RecordId int64 `json:"record_id"`
+}
+
+func NewProjectPayRequest() *ProjectPayRequest {
+	return new(ProjectPayRequest)
+}
+func NewProjectPayResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(ProjectPayData)
+	return resp
+}

+ 11 - 9
model/http_model/project_show.go

@@ -8,15 +8,17 @@ type ShowProjectPhoto struct {
 }
 
 type ShowRecruitStrategy struct {
-	FeeForm         string `json:"fee_form"`         // 稿费形式,1-3分别代表自报价、固定稿费、产品置换
-	StrategyID      string `json:"strategy_id"`      // 策略id
-	FollowersLow    string `json:"followers_low"`    // 达人粉丝数下限
-	FollowersUp     string `json:"followers_up"`     // 达人粉丝数上限
-	RecruitNumber   string `json:"recruit_number"`   // 招募数量
-	Offer           string `json:"offer"`            // 报价
-	WaitingNumber   int64  `json:"waiting_number"`   // 待发货
-	DeliveredNumber int64  `json:"delivered_number"` // 已发货
-	SignedNumber    int64  `json:"signed_number"`    // 已签收
+	RecruitStrategyID string `json:"recruit_strategy_id"`
+	FeeForm           string `json:"fee_form"`       // 稿费形式,1-3分别代表自报价、固定稿费、产品置换
+	StrategyID        string `json:"strategy_id"`    // 策略id
+	FollowersLow      string `json:"followers_low"`  // 达人粉丝数下限
+	FollowersUp       string `json:"followers_up"`   // 达人粉丝数上限
+	RecruitNumber     string `json:"recruit_number"` // 招募数量
+	Offer             string `json:"offer"`          // 报价
+	SelectedNumber    int64  `json:"selected_number"`
+	WaitingNumber     int64  `json:"waiting_number"`   // 待发货
+	DeliveredNumber   int64  `json:"delivered_number"` // 已发货
+	SignedNumber      int64  `json:"signed_number"`    // 已签收
 }
 
 type ShowProjectData struct {

+ 0 - 61
model/http_model/project_talentlist.go

@@ -1,61 +0,0 @@
-package http_model
-
-import (
-	"time"
-	"youngee_b_api/model/gorm_model"
-)
-
-type ProjectTalentListRequest struct {
-	PageSize         int64  `json:"page_size"`
-	PageNum          int64  `json:"page_num"`
-	ProjectId        string `json:"project_id"`        // 项目ID
-	TaskId           string `json:"task_id"`           // 任务ID
-	StrategyId       string `json:"strategy_id"`       // 策略ID
-	TaskStatus       string `json:"task_status"`       // 任务状态
-	PlatformNickname string `json:"platform_nickname"` // 账号昵称
-}
-
-type ProjectTalentPreview struct {
-	TaskID             string `json:"task_id"`             // 任务ID
-	PlatformNickname   string `json:"platform_nickname"`   // 账号昵称
-	FansCount          string `json:"fans_count"`          // 粉丝数
-	StrategyID         string `json:"strategy_id"`         // 报名选择的招募策略id
-	DetailAddr         string `json:"detail_addr"`         // 物流信息
-	CompanyName        string `json:"company_name"`        // 物流公司
-	LogisticsNumber    string `json:"logistics_number"`    // 物流单号
-	DeliveryTime       string `json:"delivery_time"`       // 发货时间
-	ExplorestorePeriod string `json:"explorestore_period"` // 线下探店-探店持续时间
-}
-
-type ProjectTalentInfo struct {
-	TaskID             int       `json:"task_id"`             // 任务ID
-	PlatformNickname   string    `json:"platform_nickname"`   // 账号昵称
-	FansCount          string    `json:"fans_count"`          // 粉丝数
-	StrategyID         int       `json:"strategy_id"`         // 报名选择的招募策略id
-	DetailAddr         string    `json:"detail_addr"`         // 物流信息
-	CompanyName        string    `json:"company_name"`        // 物流公司
-	LogisticsNumber    string    `json:"logistics_number"`    // 物流单号
-	DeliveryTime       time.Time `json:"delivery_time"`       // 发货时间
-	ExplorestorePeriod string    `json:"explorestore_period"` // 线下探店-探店持续时间
-}
-
-type TalentAccount struct {
-	Talent    gorm_model.YoungeeTaskInfo
-	Logistics gorm_model.YoungeeTaskLogistics
-	//Account   gorm_model.YoungeePlatformAccountInfo
-}
-
-type ProjectTalentListData struct {
-	ProjectTalentPreview []*ProjectTalentPreview `json:"project_talent_pre_view"`
-	Total                string                  `json:"total"`
-}
-
-func NewProjectTalentListRequest() *ProjectTalentListRequest {
-	return new(ProjectTalentListRequest)
-}
-
-func NewProjectTalentListResponse() *CommonResponse {
-	resp := new(CommonResponse)
-	resp.Data = new(ProjectTaskListData)
-	return resp
-}

+ 19 - 0
model/http_model/sign_for_receipt.go

@@ -0,0 +1,19 @@
+package http_model
+
+type TaskStrategyID struct {
+	TaskId     string `json:"task_id"`
+	StrategyId string `json:"strategy_id"`
+}
+
+type SignForReceiptRequest struct {
+	TaskStrategyIds []TaskStrategyID `json:"task_strategy_ids"`
+}
+
+func NewSignForReceiptRequst() *SignForReceiptRequest {
+	return new(SignForReceiptRequest)
+}
+
+func NewSignForReceiptResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 69 - 0
model/http_model/task_logistics.go

@@ -0,0 +1,69 @@
+package http_model
+
+import (
+	"time"
+	"youngee_b_api/model/gorm_model"
+)
+
+type TaskLogisticsListRequest struct {
+	PageSize         int64  `json:"page_size"`
+	PageNum          int64  `json:"page_num"`
+	ProjectId        string `json:"project_id"`        // 项目ID
+	TaskId           string `json:"task_id"`           // 任务ID
+	StrategyId       string `json:"strategy_id"`       // 策略ID
+	LogisticsStatus  string `json:"logistics_status"`  // 任务状态
+	PlatformNickname string `json:"platform_nickname"` // 账号昵称
+}
+
+type TaskLogisticsPreview struct {
+	TaskID                string    `json:"task_id"`           // 任务ID
+	PlatformNickname      string    `json:"platform_nickname"` // 账号昵称
+	FansCount             string    `json:"fans_count"`        // 粉丝数
+	RecruitStrategyID     string    `json:"recruit_strategy_id"`
+	StrategyID            string    `json:"strategy_id"`            // 报名选择的招募策略id
+	DetailAddr            string    `json:"detail_addr"`            // 物流信息
+	CompanyName           string    `json:"company_name"`           // 物流公司
+	LogisticsNumber       string    `json:"logistics_number"`       // 物流单号
+	DeliveryTime          string    `json:"delivery_time"`          // 发货时间
+	ExplorestoreStarttime time.Time `json:"explorestore_starttime"` // 线下探店-探店开始时间
+	ExplorestoreEndtime   time.Time `json:"explorestore_endtime"`   // 线下探店-探店结束时间
+	ExplorestorePeriod    string    `json:"explorestore_period"`    // 线下探店-探店持续时间
+	CouponCode            string    `json:"coupon_code"`            // 券码信息
+}
+
+type TaskLogisticsInfo struct {
+	TaskID                int       `json:"task_id"`           // 任务ID
+	PlatformNickname      string    `json:"platform_nickname"` // 账号昵称
+	FansCount             string    `json:"fans_count"`        // 粉丝数
+	RecruitStrategyID     int       `json:"recruit_strategy_id"`
+	StrategyID            int       `json:"strategy_id"`            // 报名选择的招募策略id
+	DetailAddr            string    `json:"detail_addr"`            // 物流信息
+	CompanyName           string    `json:"company_name"`           // 物流公司
+	LogisticsNumber       string    `json:"logistics_number"`       // 物流单号
+	DeliveryTime          string    `json:"delivery_time"`          // 发货时间
+	ExplorestoreStarttime time.Time `json:"explorestore_starttime"` // 线下探店-探店开始时间
+	ExplorestoreEndtime   time.Time `json:"explorestore_endtime"`   // 线下探店-探店结束时间
+	ExplorestorePeriod    string    `json:"explorestore_period"`    // 线下探店-探店持续时间
+	CouponCode            string    `json:"coupon_code"`            // 券码信息
+}
+
+type TaskLogistics struct {
+	Talent    gorm_model.YoungeeTaskInfo
+	Logistics gorm_model.YoungeeTaskLogistics
+	//Account   gorm_model.YoungeePlatformAccountInfo
+}
+
+type TaskLogisticsListData struct {
+	TaskLogisticsPreview []*TaskLogisticsPreview `json:"project_talent_pre_view"`
+	Total                string                  `json:"total"`
+}
+
+func NewTaskLogisticsListRequest() *TaskLogisticsListRequest {
+	return new(TaskLogisticsListRequest)
+}
+
+func NewTaskLogisticsListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(ProjectTaskListData)
+	return resp
+}

+ 0 - 58
pack/project._talent_list.go

@@ -1,58 +0,0 @@
-package pack
-
-import (
-	"github.com/tidwall/gjson"
-	"youngee_b_api/model/http_model"
-
-	"github.com/issue9/conv"
-)
-
-func MGormProjectTalentToHttpProjectTaskPreview(gormProjectTalentInfos []*http_model.ProjectTalentInfo) []*http_model.ProjectTalentPreview {
-	var httpProjectPreviews []*http_model.ProjectTalentPreview
-	for _, gormProjectTalentInfo := range gormProjectTalentInfos {
-		httpProjectTalentPreview := GormFullProjectToHttpProjectTalentPreview(gormProjectTalentInfo)
-		httpProjectPreviews = append(httpProjectPreviews, httpProjectTalentPreview)
-	}
-	return httpProjectPreviews
-}
-
-func GormFullProjectToHttpProjectTalentPreview(projectTalentInfo *http_model.ProjectTalentInfo) *http_model.ProjectTalentPreview {
-	deliveryTime := conv.MustString(projectTalentInfo.DeliveryTime)
-	deliveryTime = deliveryTime[0:19]
-	return &http_model.ProjectTalentPreview{
-		TaskID:             conv.MustString(projectTalentInfo.TaskID),
-		PlatformNickname:   conv.MustString(projectTalentInfo.PlatformNickname),
-		FansCount:          conv.MustString(projectTalentInfo.FansCount),
-		StrategyID:         conv.MustString(projectTalentInfo.StrategyID),
-		DetailAddr:         conv.MustString(projectTalentInfo.DetailAddr),
-		CompanyName:        conv.MustString(projectTalentInfo.CompanyName),
-		LogisticsNumber:    conv.MustString(projectTalentInfo.LogisticsNumber),
-		DeliveryTime:       deliveryTime,
-		ExplorestorePeriod: conv.MustString(projectTalentInfo.ExplorestorePeriod),
-	}
-}
-
-func TalentAccountToTaskInfo(talentAccounts []*http_model.TalentAccount) []*http_model.ProjectTalentInfo {
-	var projectTalents []*http_model.ProjectTalentInfo
-	for _, talentAccount := range talentAccounts {
-		projectTalent := GetTalentInfoStruct(talentAccount)
-		projectTalents = append(projectTalents, projectTalent)
-	}
-	return projectTalents
-}
-
-func GetTalentInfoStruct(talentAccount *http_model.TalentAccount) *http_model.ProjectTalentInfo {
-	TalentPlatformInfoSnap := talentAccount.Talent.TalentPlatformInfoSnap
-	TalentPostAddrSnap := talentAccount.Talent.TalentPostAddrSnap
-	return &http_model.ProjectTalentInfo{
-		TaskID:             talentAccount.Talent.TaskID,
-		PlatformNickname:   conv.MustString(gjson.Get(TalentPlatformInfoSnap, "PlatformInfo.platform_name")),
-		FansCount:          conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count")),
-		StrategyID:         talentAccount.Talent.StrategyID,
-		DetailAddr:         conv.MustString(gjson.Get(TalentPostAddrSnap, "detail_addr")),
-		CompanyName:        talentAccount.Logistics.CompanyName,
-		LogisticsNumber:    talentAccount.Logistics.LogisticsNumber,
-		DeliveryTime:       talentAccount.Logistics.DeliveryTime,
-		ExplorestorePeriod: talentAccount.Logistics.ExplorestorePeriod,
-	}
-}

+ 0 - 0
pack/project_taskList_conditions.go → pack/project_task_list_conditions.go


+ 65 - 0
pack/task_logistics_list.go

@@ -0,0 +1,65 @@
+package pack
+
+import (
+	"youngee_b_api/model/http_model"
+
+	"github.com/tidwall/gjson"
+
+	"github.com/issue9/conv"
+)
+
+func MGormTaskLogisticsInfoListToHttpTaskLogisticsPreviewList(gormTaskLogisticsInfos []*http_model.TaskLogisticsInfo) []*http_model.TaskLogisticsPreview {
+	var httpProjectPreviews []*http_model.TaskLogisticsPreview
+	for _, gormTaskLogisticsInfo := range gormTaskLogisticsInfos {
+		httpTaskLogisticsPreview := MGormTaskLogisticsInfoToHttpTaskLogisticsPreview(gormTaskLogisticsInfo)
+		httpProjectPreviews = append(httpProjectPreviews, httpTaskLogisticsPreview)
+	}
+	return httpProjectPreviews
+}
+
+func MGormTaskLogisticsInfoToHttpTaskLogisticsPreview(TaskLogisticsInfo *http_model.TaskLogisticsInfo) *http_model.TaskLogisticsPreview {
+	deliveryTime := conv.MustString(TaskLogisticsInfo.DeliveryTime)
+	deliveryTime = deliveryTime[0:19]
+	return &http_model.TaskLogisticsPreview{
+		TaskID:                conv.MustString(TaskLogisticsInfo.TaskID),
+		PlatformNickname:      conv.MustString(TaskLogisticsInfo.PlatformNickname),
+		FansCount:             conv.MustString(TaskLogisticsInfo.FansCount),
+		RecruitStrategyID:     conv.MustString(TaskLogisticsInfo.RecruitStrategyID),
+		StrategyID:            conv.MustString(TaskLogisticsInfo.StrategyID),
+		DetailAddr:            conv.MustString(TaskLogisticsInfo.DetailAddr),
+		CompanyName:           conv.MustString(TaskLogisticsInfo.CompanyName),
+		LogisticsNumber:       conv.MustString(TaskLogisticsInfo.LogisticsNumber),
+		DeliveryTime:          deliveryTime,
+		ExplorestoreStarttime: TaskLogisticsInfo.ExplorestoreStarttime,
+		ExplorestoreEndtime:   TaskLogisticsInfo.ExplorestoreEndtime,
+		ExplorestorePeriod:    conv.MustString(TaskLogisticsInfo.ExplorestorePeriod),
+		CouponCode:            conv.MustString(TaskLogisticsInfo.CouponCode),
+	}
+}
+
+func TaskLogisticsToTaskInfo(TaskLogisticss []*http_model.TaskLogistics) []*http_model.TaskLogisticsInfo {
+	var TaskLogisticsInfos []*http_model.TaskLogisticsInfo
+	for _, TaskLogistics := range TaskLogisticss {
+		TaskLogistics := GetTalentInfoStruct(TaskLogistics)
+		TaskLogisticsInfos = append(TaskLogisticsInfos, TaskLogistics)
+	}
+	return TaskLogisticsInfos
+}
+
+func GetTalentInfoStruct(TaskLogistics *http_model.TaskLogistics) *http_model.TaskLogisticsInfo {
+	TalentPlatformInfoSnap := TaskLogistics.Talent.TalentPlatformInfoSnap
+	TalentPostAddrSnap := TaskLogistics.Talent.TalentPostAddrSnap
+	return &http_model.TaskLogisticsInfo{
+		TaskID:                TaskLogistics.Talent.TaskID,
+		PlatformNickname:      conv.MustString(gjson.Get(TalentPlatformInfoSnap, "PlatformInfo.platform_name")),
+		FansCount:             conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count")),
+		StrategyID:            TaskLogistics.Talent.StrategyID,
+		DetailAddr:            conv.MustString(gjson.Get(TalentPostAddrSnap, "detail_addr")),
+		CompanyName:           TaskLogistics.Logistics.CompanyName,
+		LogisticsNumber:       TaskLogistics.Logistics.LogisticsNumber,
+		DeliveryTime:          conv.MustString(TaskLogistics.Logistics.DeliveryTime),
+		ExplorestoreStarttime: TaskLogistics.Logistics.ExplorestoreStarttime,
+		ExplorestoreEndtime:   TaskLogistics.Logistics.ExplorestoreEndtime,
+		ExplorestorePeriod:    TaskLogistics.Logistics.ExplorestorePeriod,
+	}
+}

+ 2 - 2
pack/project_talentlist_conditions.go → pack/task_logistics_list_conditions.go

@@ -7,10 +7,10 @@ import (
 	"github.com/issue9/conv"
 )
 
-func HttpProjectTalentRequestToCondition(req *http_model.ProjectTalentListRequest) *common_model.TalentConditions {
+func HttpTaskLogisticsListRequestToCondition(req *http_model.TaskLogisticsListRequest) *common_model.TalentConditions {
 	return &common_model.TalentConditions{
 		ProjectId:        conv.MustInt64(req.ProjectId),
-		LogisticsStatus:  conv.MustInt64(req.TaskStatus),
+		LogisticsStatus:  conv.MustInt64(req.LogisticsStatus),
 		StrategyId:       conv.MustInt64(req.StrategyId),
 		TaskId:           conv.MustString(req.TaskId),
 		PlatformNickname: conv.MustString(req.PlatformNickname),

+ 3 - 1
route/init.go

@@ -53,10 +53,12 @@ func InitRoute(r *gin.Engine) {
 		m.POST("/project/taskList", handler.WrapProjectTaskListHandler)
 		m.POST("/project/changeTaskStatus", handler.WrapProjectChangeTaskStatusHandler)
 		m.POST("/pay/paysum", handler.WrapPaySumHandler)
+		m.POST("/pay/projectpay", handler.WrapProjectPayHandler)
 		m.POST("/enterprise/balance", handler.WrapEnterpriseBalanceHandler)
 		m.POST("/project/recruitstrategycalculate", handler.WrapRecruitStrategyNumberCalculate)
-		m.POST("/project/talentList", handler.WrapProjectTalentListHandler)
+		m.POST("/project/tasklogisticslist", handler.WrapTaskLogisticsListHandler)
 		m.POST("/project/createlogistics", handler.WrapCreateLogisticsHandler)
+		m.POST("/project/signforreceipt", handler.WrapSignForReceiptHandler)
 	}
 
 }

+ 90 - 12
service/logistics.go

@@ -2,9 +2,15 @@ package service
 
 import (
 	"context"
+	"fmt"
+	"time"
 	"youngee_b_api/db"
 	"youngee_b_api/model/gorm_model"
 	"youngee_b_api/model/http_model"
+
+	"github.com/gin-gonic/gin"
+	"github.com/issue9/conv"
+	"github.com/sirupsen/logrus"
 )
 
 var Logistics *logistics
@@ -12,55 +18,85 @@ var Logistics *logistics
 type logistics struct {
 }
 
+// 在物流信息表插入记录
 func (*logistics) Create(ctx context.Context, newLogistics http_model.CreateLogisticsRequest) (*http_model.CreateLogisticsData, error) {
 	ThingsType := newLogistics.ThingsType
 	RecruitStrategyID := newLogistics.RecruitStrategyID
 	Logistics := gorm_model.YoungeeTaskLogistics{
-		LogisticsID: newLogistics.LogisticsID,
-		TaskID:      newLogistics.TaskID,
-		ThingsType:  ThingsType,
+		LogisticsID:           newLogistics.LogisticsID,
+		TaskID:                newLogistics.TaskID,
+		ThingsType:            int64(ThingsType),
+		ExplorestoreStarttime: time.Now(),
+		ExplorestoreEndtime:   time.Now(),
+		DeliveryTime:          time.Now(),
+		SignedTime:            time.Now(),
 	}
+	fmt.Println("ThingsType:", ThingsType)
 	//实物
 	if ThingsType == 1 {
 		Logistics.CompanyName = newLogistics.CompanyName
-		Logistics.DeliveryTime = newLogistics.DeliveryTime
-	} else if ThingsType == 2 {
+		Logistics.LogisticsNumber = newLogistics.LogisticsNumber
+		Logistics.DeliveryTime = time.Now()
+	} else if ThingsType == 3 {
+		fmt.Println("开始时间:", newLogistics.ExplorestoreStarttime)
 		Logistics.ExplorestoreStarttime = newLogistics.ExplorestoreStarttime
 		Logistics.ExplorestoreEndtime = newLogistics.ExplorestoreEndtime
-		Logistics.ExplorestorePeriod = newLogistics.ExplorestorePeriod
+		// Logistics.ExplorestorePeriod = newLogistics.ExplorestorePeriod
 	} else {
 		Logistics.CouponCodeInformation = newLogistics.CouponCodeInformation
 	}
+
 	logisticsID, err := db.CreateLogistics(ctx, Logistics, RecruitStrategyID)
 	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics service] call CreateLogistics error,err:%+v", err)
+		return nil, err
+	}
+	// 修改招募策略中已发货待发货数量
+	err = db.UpdateLogisticsNumber(ctx, RecruitStrategyID, 1, -1, 0)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics service] call UpdateLogisticsNumber error,err:%+v", err)
 		return nil, err
 	}
+	// 修改task_info中发货状态
+	err = db.UpdateLogisticsStatus(ctx, Logistics.TaskID, 2)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics service] call UpdateLogisticsStatus error,err:%+v", err)
+		return nil, err
+	}
+
+	// 对应招募策略待发货--,已发货++
+
 	res := &http_model.CreateLogisticsData{
 		LogisticsID: *logisticsID,
 	}
 	return res, nil
 }
 
+// 修改物流信息表
 func (*logistics) Update(ctx context.Context, newLogistics http_model.CreateLogisticsRequest) (*http_model.CreateLogisticsData, error) {
 	ThingsType := newLogistics.ThingsType
 	Logistics := gorm_model.YoungeeTaskLogistics{
-		LogisticsID: newLogistics.LogisticsID,
-		TaskID:      newLogistics.TaskID,
-		ThingsType:  ThingsType,
+		LogisticsID:  newLogistics.LogisticsID,
+		TaskID:       newLogistics.TaskID,
+		ThingsType:   int64(ThingsType),
+		DeliveryTime: time.Now(),
+		SignedTime:   time.Now(),
 	}
 	//实物
 	if ThingsType == 1 {
 		Logistics.CompanyName = newLogistics.CompanyName
-		Logistics.DeliveryTime = newLogistics.DeliveryTime
-	} else if ThingsType == 2 {
+		Logistics.LogisticsNumber = newLogistics.LogisticsNumber
+	} else if ThingsType == 3 {
+		fmt.Println("开始时间:", newLogistics.ExplorestoreStarttime)
 		Logistics.ExplorestoreStarttime = newLogistics.ExplorestoreStarttime
 		Logistics.ExplorestoreEndtime = newLogistics.ExplorestoreEndtime
-		Logistics.ExplorestorePeriod = newLogistics.ExplorestorePeriod
+		// Logistics.ExplorestorePeriod = newLogistics.ExplorestorePeriod
 	} else {
 		Logistics.CouponCodeInformation = newLogistics.CouponCodeInformation
 	}
 	logisticsID, err := db.UpdateLogistics(ctx, Logistics)
 	if err != nil {
+		logrus.WithContext(ctx).Errorf("[logistics service] call UpdateLogistics error,err:%+v", err)
 		return nil, err
 	}
 	res := &http_model.CreateLogisticsData{
@@ -68,3 +104,45 @@ func (*logistics) Update(ctx context.Context, newLogistics http_model.CreateLogi
 	}
 	return res, nil
 }
+
+// 签收
+func (*logistics) SignForReceipt(ctx *gin.Context, data http_model.SignForReceiptRequest) interface{} {
+	for _, value := range data.TaskStrategyIds {
+		taskId := conv.MustInt64(value.TaskId)
+		strategyId := conv.MustInt64(value.StrategyId)
+		err := db.UpdateLogisticsStatus(ctx, taskId, 3)
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[project service] call UpdateLogisticsStatus error,err:%+v", err)
+			return err
+		}
+
+		// 签收时间
+		err = db.SignForReceipt(ctx, taskId)
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[project service] call SignForReceipt error,err:%+v", err)
+			return err
+		}
+
+		projectId, err1 := db.GetProjectIdByTaskId(ctx, taskId)
+		if err1 != nil {
+			logrus.WithContext(ctx).Errorf("[project service] call GetProjectIdByTaskId error,err:%+v", err1)
+			return err1
+		}
+
+		// 查询recruitStrategyID 通过 StrategyID 和 projectId
+		recruitStrategyId, err2 := db.GetRecruitStrategyIdByTS(ctx, *projectId, strategyId)
+		if err2 != nil {
+			logrus.WithContext(ctx).Errorf("[project service] call GetRecruitStrategyIdByTS error,err:%+v", err1)
+			return err2
+		}
+
+		// 修改招募策略中已签收数量
+		err = db.UpdateLogisticsNumber(ctx, *recruitStrategyId, 0, 0, 1)
+		if err != nil {
+			logrus.WithContext(ctx).Errorf("[project service] call UpdateLogisticsNumber error,err:%+v", err)
+			return err
+		}
+	}
+
+	return nil
+}

+ 23 - 17
service/project.go

@@ -3,7 +3,6 @@ package service
 import (
 	"context"
 	"fmt"
-	"github.com/gin-gonic/gin"
 	"strconv"
 	"strings"
 	"youngee_b_api/db"
@@ -12,6 +11,8 @@ import (
 	"youngee_b_api/model/http_model"
 	"youngee_b_api/pack"
 
+	"github.com/gin-gonic/gin"
+
 	"github.com/issue9/conv"
 	"github.com/sirupsen/logrus"
 )
@@ -202,7 +203,7 @@ func (*project) GetPorjectDetail(ctx context.Context, projectID int64) (*http_mo
 		return nil, err
 	}
 	enterprise, err := db.GetEnterpriseByEnterpriseID(ctx, project.EnterpriseID)
-	fmt.Println("%+v", enterprise.UserID)
+	// fmt.Println("%+v", enterprise.UserID)
 	if err != nil {
 		logrus.WithContext(ctx).Errorf("[project service] call GetEnterpriseByEnterpriseID error,err:%+v", err)
 		return nil, err
@@ -212,7 +213,7 @@ func (*project) GetPorjectDetail(ctx context.Context, projectID int64) (*http_mo
 		logrus.WithContext(ctx).Errorf("[project service] call GetUserByID error,err:%+v", err)
 		return nil, err
 	}
-	fmt.Println("%+v", user.Phone)
+	// fmt.Println("%+v", user.Phone)
 	//var RecruitStrategys []http_model.ShowRecruitStrategy
 	ProjectDetail := http_model.ShowProjectData{
 		ProjectID:       conv.MustString(project.ProjectID),
@@ -233,19 +234,24 @@ func (*project) GetPorjectDetail(ctx context.Context, projectID int64) (*http_mo
 		Phone:           user.Phone,
 	}
 	Strategys, err := db.GetRecruitStrategys(ctx, projectID)
+	fmt.Println("招募策略:", Strategys)
 	if err != nil {
 		logrus.WithContext(ctx).Error()
 		return nil, err
 	}
 	for _, strategy := range Strategys {
 		RecruitStrategy := http_model.ShowRecruitStrategy{
-			FeeForm:       conv.MustString(strategy.FeeForm),
-			StrategyID:    conv.MustString(strategy.StrategyID),
-			FollowersLow:  conv.MustString(strategy.FollowersLow),
-			FollowersUp:   conv.MustString(strategy.FollowersUp),
-			RecruitNumber: conv.MustString(strategy.RecruitNumber),
-			Offer:         conv.MustString(strategy.Offer),
-			WaitingNumber: strategy.WaitingNumber,
+			RecruitStrategyID: conv.MustString(strategy.RecruitStrategyID),
+			FeeForm:           conv.MustString(strategy.FeeForm),
+			StrategyID:        conv.MustString(strategy.StrategyID),
+			FollowersLow:      conv.MustString(strategy.FollowersLow),
+			FollowersUp:       conv.MustString(strategy.FollowersUp),
+			RecruitNumber:     conv.MustString(strategy.RecruitNumber),
+			Offer:             conv.MustString(strategy.Offer),
+			SelectedNumber:    strategy.SelectedNumber,
+			WaitingNumber:     strategy.WaitingNumber,
+			DeliveredNumber:   strategy.DeliveredNumber,
+			SignedNumber:      strategy.SignedNumber,
 		}
 		ProjectDetail.RecruitStrategys = append(ProjectDetail.RecruitStrategys, RecruitStrategy)
 	}
@@ -264,16 +270,16 @@ func (*project) GetPorjectDetail(ctx context.Context, projectID int64) (*http_mo
 	return &ProjectDetail, nil
 }
 
-func (*project) GetProjectTalentList(ctx context.Context, projectID string, pageSize, pageNum int64, conditions *common_model.TalentConditions) (*http_model.ProjectTalentListData, error) {
-	projectTalents, total, err := db.GetProjectTalentList(ctx, projectID, pageSize, pageNum, conditions)
+func (*project) GetTaskLogisticsList(ctx context.Context, projectID string, pageSize, pageNum int64, conditions *common_model.TalentConditions) (*http_model.TaskLogisticsListData, error) {
+	TaskLogisticss, total, err := db.GetTaskLogisticsList(ctx, projectID, pageSize, pageNum, conditions)
 	if err != nil {
-		logrus.WithContext(ctx).Errorf("[project service] call GetProjectTalentList error,err:%+v", err)
+		logrus.WithContext(ctx).Errorf("[project service] call GetTaskLogisticsList error,err:%+v", err)
 		return nil, err
 	}
-	projectTalentListData := new(http_model.ProjectTalentListData)
-	projectTalentListData.ProjectTalentPreview = pack.MGormProjectTalentToHttpProjectTaskPreview(projectTalents)
-	projectTalentListData.Total = conv.MustString(total)
-	return projectTalentListData, nil
+	TaskLogisticsListData := new(http_model.TaskLogisticsListData)
+	TaskLogisticsListData.TaskLogisticsPreview = pack.MGormTaskLogisticsInfoListToHttpTaskLogisticsPreviewList(TaskLogisticss)
+	TaskLogisticsListData.Total = conv.MustString(total)
+	return TaskLogisticsListData, nil
 }
 
 func (*project) ChangeTaskStatus(ctx *gin.Context, data http_model.ProjectChangeTaskStatusRequest) interface{} {

+ 40 - 0
service/project_pay.go

@@ -0,0 +1,40 @@
+package service
+
+import (
+	"context"
+	"youngee_b_api/db"
+	"youngee_b_api/model/http_model"
+
+	"github.com/issue9/conv"
+	"github.com/sirupsen/logrus"
+)
+
+var ProjectPay *projectPay
+
+type projectPay struct {
+}
+
+func (*projectPay) Pay(ctx context.Context, projectPay http_model.ProjectPayRequest, enterpriseID int64) (*int64, error) {
+	// 修改企业账户金额
+	balance, err := db.UpdateEnterpriseBalance(ctx, enterpriseID, 0, -projectPay.PaySum, projectPay.PaySum)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[projectPay service] call UpdateEnterpriseBalance error,err:%+v", err)
+		return nil, err
+	}
+
+	// 修改项目状态为执行中
+	err = db.UpdateProjectStatus(ctx, conv.MustInt64(projectPay.ProjectID), 9)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[projectPay service] call UpdateEnterpriseBalance error,err:%+v", err)
+		return nil, err
+	}
+
+	// 插入支付记录
+	recordId, err1 := db.CreatePayRecord(ctx, enterpriseID, projectPay.PaySum, *balance, 2, conv.MustInt64(projectPay.ProjectID))
+	if err1 != nil {
+		logrus.WithContext(ctx).Errorf("[projectPay service] call CreatePayRecord error,err:%+v", err)
+		return nil, err1
+	}
+
+	return recordId, nil
+}