lin-jim-leon 7 months ago
parent
commit
d13a33a312
52 changed files with 2737 additions and 430 deletions
  1. 1 1
      config/init.go
  2. 94 0
      db/authkuaishou.go
  3. 130 0
      db/job.go
  4. 21 0
      db/project.go
  5. 16 0
      db/set_serveratio.go
  6. 226 0
      db/subaccount.go
  7. 450 428
      db/user.go
  8. 43 0
      db/worksapce.go
  9. 1 0
      go.mod
  10. 2 0
      go.sum
  11. 52 0
      handler/create_job.go
  12. 71 0
      handler/create_sub_account.go
  13. 50 0
      handler/delete_job.go
  14. 50 0
      handler/delete_ks.go
  15. 50 0
      handler/delete_project.go
  16. 56 0
      handler/delete_subaccount.go
  17. 56 0
      handler/get_takegoods_data.go
  18. 51 0
      handler/getauthorization.go
  19. 59 0
      handler/job_detail.go
  20. 51 0
      handler/kuaishouauthorization.go
  21. 55 0
      handler/project_review.go
  22. 78 0
      handler/send_code.go
  23. 51 0
      handler/set_serveratio.go
  24. 60 0
      handler/stop_subaccount.go
  25. 59 0
      handler/sub_account_detail.go
  26. 53 0
      handler/update_job_info.go
  27. 66 0
      handler/update_subaccount_info.go
  28. 23 0
      model/gorm_model/authkuaishou.go
  29. 18 0
      model/gorm_model/job.go
  30. 9 0
      model/gorm_model/serveratio.go
  31. 17 0
      model/gorm_model/subaccount.go
  32. 15 0
      model/http_model/Authkuaishou.go
  33. 28 0
      model/http_model/GetTakegoodsDataRequest.go
  34. 32 0
      model/http_model/SubAccountDetail.go
  35. 23 0
      model/http_model/create_job.go
  36. 24 0
      model/http_model/create_sub_account.go
  37. 10 0
      model/http_model/delete_job.go
  38. 12 0
      model/http_model/delete_ks.go
  39. 12 0
      model/http_model/delete_project.go
  40. 10 0
      model/http_model/delete_subaccount.go
  41. 25 0
      model/http_model/getksauthorization.go
  42. 29 0
      model/http_model/job_detail.go
  43. 17 0
      model/http_model/projectreviewnumberrequest.go
  44. 19 0
      model/http_model/send_code.go
  45. 13 0
      model/http_model/set_serveratio.go
  46. 15 0
      model/http_model/stop_subaccount.go
  47. 24 0
      model/http_model/update_job_info.go
  48. 18 0
      model/http_model/update_subaccount_info.go
  49. 29 1
      route/init.go
  50. 65 0
      service/register.go
  51. 152 0
      service/send_code.go
  52. 146 0
      service/workspace.go

+ 1 - 1
config/init.go

@@ -34,7 +34,7 @@ func loadExternelConfig(config *system_model.Config) {
 	db.Init(config.Mysql)
 	redis.Init(config.Redis)
 	service.LoginAuthInit(config.Server.Session)
-	//service.SendCodeInit(config.Server.Session)
+	service.SendCodeInit(config.Server.Session)
 	service.QrCodeInit(config.Server.Session)
 }
 

+ 94 - 0
db/authkuaishou.go

@@ -0,0 +1,94 @@
+package db
+
+import (
+	"context"
+	"fmt"
+	"github.com/lin-jim-leon/kuaishou/open/user"
+	"time"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+)
+
+func Authkuaishou(ctx context.Context, req *http_model.AuthkuaishouRequest) error {
+	db := GetReadDB(ctx)
+	fmt.Println("req", req)
+	now := time.Now()
+	ksuser := gorm_model.YoungeeKuaishouUserinfo{
+		Ksnumber:    req.KSNumber,
+		Name:        req.Name,
+		PhoneNumber: req.PhoneNumber,
+		CreateTime:  now,
+		UpdateTime:  now,
+	}
+	if err := db.Create(&ksuser).Error; err != nil {
+		fmt.Println("err", err)
+		return err
+	}
+	// 返回更新后的结果
+	return nil
+}
+
+func GetAuthorization(ctx context.Context, req *http_model.GetAuthorizationRequest) ([]*http_model.GetAuthorizationResponse, error) {
+	db := GetReadDB(ctx)
+	page := req.PageNum
+	pageSize := req.PageSize
+	if page < 1 {
+		page = 1
+	}
+	if pageSize < 1 {
+		pageSize = 10
+	}
+	offset := (page - 1) * pageSize
+	ksauthorizationInfo := []gorm_model.YoungeeKuaishouUserinfo{}
+	result := db.Limit(pageSize).Offset(offset).Find(&ksauthorizationInfo)
+	if result.Error != nil {
+		return nil, result.Error
+	}
+
+	var authorizationsInfoPointers []*http_model.GetAuthorizationResponse
+	layout := "2006-01-02 15:04:05"
+
+	for _, v := range ksauthorizationInfo {
+		res := &http_model.GetAuthorizationResponse{
+			Nickname:    v.NickName,
+			KSNumber:    v.Ksnumber,
+			Name:        v.Name,
+			Phonenumber: v.PhoneNumber,
+		}
+		if v.AccessToken == "" {
+			res.UPdatetime = ""
+			res.Expired = v.Expired
+		} else {
+			var expiredstatus int
+			_, err := user.GetUserinfo("ks651333097154138217", v.AccessToken)
+			if err != nil {
+				expiredstatus = 1
+			} else {
+				expiredstatus = 2
+			}
+
+			updateResult := db.Model(&gorm_model.YoungeeKuaishouUserinfo{}).Where("id = ?", v.Id).Update("expired", expiredstatus)
+			if updateResult.Error != nil {
+				return nil, updateResult.Error
+			}
+
+			res.UPdatetime = v.UpdateTime.Format(layout)
+			res.Expired = expiredstatus
+		}
+
+		authorizationsInfoPointers = append(authorizationsInfoPointers, res)
+	}
+	return authorizationsInfoPointers, nil
+}
+
+func DeleteKsauthorization(ctx context.Context, req *http_model.DeleteKsauthorizationRequest) error {
+	db := GetReadDB(ctx)
+	ks := gorm_model.YoungeeKuaishouUserinfo{
+		Ksnumber: req.KSNumber,
+	}
+	result := db.Where("ksnumber = ?", req.KSNumber).Delete(ks)
+	if result.Error != nil {
+		return result.Error
+	}
+	return nil
+}

+ 130 - 0
db/job.go

@@ -0,0 +1,130 @@
+package db
+
+import (
+	"context"
+	"fmt"
+	"github.com/caixw/lib.go/conv"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+)
+
+func CreateJob(ctx context.Context, req *http_model.CreateJobRequest) (*http_model.CreateJobResponse, error) {
+	db := GetReadDB(ctx)
+	job := gorm_model.YounggeeJob{
+		JobName:              req.JobName,
+		JobDetail:            req.JobDetail,
+		WorkshopPermission:   req.WorkspacePermission,
+		TaskcenterPermission: req.TaskcenterPermission,
+		SectaskPermisson:     req.SectaskPermission,
+		FinancialPermission:  req.FinancialPermission,
+		UsercenterPermission: req.UsercenterPermission,
+		OperatePermission:    req.OperatePermission,
+		AccountId:            req.AccountID,
+	}
+	if err := db.Create(&job).Error; err != nil {
+		return nil, err
+	}
+	// 返回更新后的结果
+
+	res := &http_model.CreateJobResponse{
+		JobName: job.JobName,
+		JobID:   job.JobId,
+	}
+	return res, nil
+}
+
+func UpdateJobInfo(ctx context.Context, req *http_model.UpdateJobInfoRequest) (*http_model.UpdateJobInfoResponse, error) {
+	db := GetReadDB(ctx)
+	JobInfo := gorm_model.YounggeeJob{}
+	wherecondition := gorm_model.YounggeeJob{JobId: req.JobID}
+	result := db.Where(&wherecondition).First(&JobInfo)
+	if result.Error != nil {
+		fmt.Println("result err:", result.Error)
+		return nil, result.Error
+	}
+	updateData := gorm_model.YounggeeJob{
+		JobName:              req.JobName,
+		JobDetail:            req.JobDetail,
+		WorkshopPermission:   req.WorkspacePermission,
+		TaskcenterPermission: req.TaskcenterPermission,
+		SectaskPermisson:     req.SectaskPermission,
+		FinancialPermission:  req.FinancialPermission,
+		UsercenterPermission: req.UsercenterPermission,
+		OperatePermission:    req.OperatePermission,
+		AccountId:            req.AccountID,
+	}
+	updateResult := db.Model(&JobInfo).Where("job_id = ?", req.JobID).Updates(updateData)
+	if updateResult.Error != nil {
+		fmt.Println("result err:", updateResult.Error)
+		return nil, updateResult.Error
+	}
+	res := &http_model.UpdateJobInfoResponse{
+		JobID:   JobInfo.JobId,
+		JobName: JobInfo.JobName,
+	}
+	return res, nil
+}
+
+func DeleteJob(ctx context.Context, req *http_model.DeleteJobRequest) error {
+	db := GetReadDB(ctx)
+	job := gorm_model.YounggeeJob{
+		JobId: req.JobId,
+	}
+	result := db.Where("job_id = ?", req.JobId).Delete(job)
+	if result.Error != nil {
+		return result.Error
+	}
+	return nil
+}
+
+func GetJobDetail(ctx context.Context, req *http_model.JobDetailRequest) (*http_model.JobData, error) {
+	db := GetReadDB(ctx)
+	// 获取分页参数
+	page := req.PageNum
+	pageSize := req.PageSize
+	if page < 1 {
+		page = 1
+	}
+	if pageSize < 1 {
+		pageSize = 10 // 设置默认每页记录数为 10
+	}
+
+	// 构建查询条件
+	query := db.Model(&gorm_model.YounggeeJob{})
+
+	// 查询总数
+	var total int64
+	countQuery := query.Count(&total)
+	if countQuery.Error != nil {
+		return nil, countQuery.Error
+	}
+
+	// 计算偏移量
+	offset := (page - 1) * pageSize
+	jobInfo := []gorm_model.YounggeeJob{}
+	result := query.Limit(pageSize).Offset(offset).Find(&jobInfo)
+	if result.Error != nil {
+		return nil, result.Error
+	}
+
+	var jobInfoPointers []*http_model.JobDetailResponse
+	for i := range jobInfo {
+		userInfo := gorm_model.YounggeeUser{}
+		userResult := db.Where(gorm_model.YounggeeUser{ID: jobInfo[i].AccountId}).First(&userInfo)
+		if userResult.Error != nil {
+			return nil, userResult.Error
+		}
+		response := &http_model.JobDetailResponse{
+			JobInfo: jobInfo[i],
+			Creater: userInfo.Username,
+		}
+		jobInfoPointers = append(jobInfoPointers, response)
+	}
+
+	// 构造返回结果
+	subaccountInfolist := &http_model.JobData{
+		Job:   jobInfoPointers,
+		Total: conv.MustString(total, ""),
+	}
+	return subaccountInfolist, nil
+}

+ 21 - 0
db/project.go

@@ -302,6 +302,15 @@ func CreateProject(ctx context.Context, projectInfo gorm_model.ProjectInfo) (str
 	return projectInfo.ProjectID, nil
 }
 
+func DeleteProject(ctx context.Context, projectInfo *http_model.DeleteProjectRequest) error {
+	db := GetWriteDB(ctx)
+	err := db.Where("project_id = ?", projectInfo.ProjectID).Delete(&gorm_model.ProjectInfo{}).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
 func ProjectHandle(ctx context.Context, data http_model.ProjectHandleRequest) error {
 	err := ChangeProjectStatus(ctx, data.ProjectID, data.ProjectStatus)
 	if err != nil {
@@ -445,3 +454,15 @@ func SetSpecialProjectFinish(ctx context.Context, projectId string) error {
 	}
 	return nil
 }
+
+func ProjectReviewNumber(ctx context.Context) (*http_model.Reviewnums, error) {
+	var reviewNums int64
+	db := GetReadDB(ctx)
+	err := db.Model(gorm_model.ProjectInfo{}).Where("project_status = 2").Count(&reviewNums).Error
+	if err != nil {
+		return nil, err
+	}
+	ReviewNums := new(http_model.Reviewnums)
+	ReviewNums.ReviewNums = reviewNums
+	return ReviewNums, err
+}

+ 16 - 0
db/set_serveratio.go

@@ -0,0 +1,16 @@
+package db
+
+import (
+	"context"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+)
+
+func SetServeratio(ctx context.Context, req *http_model.SetServeratioRequest) error {
+	db := GetReadDB(ctx)
+	serve_ratio := gorm_model.YounggeeServeRatio{Ratio: req.Ratio}
+	if err := db.Create(&serve_ratio).Error; err != nil {
+		return err
+	}
+	return nil
+}

+ 226 - 0
db/subaccount.go

@@ -0,0 +1,226 @@
+package db
+
+import (
+	"context"
+	"fmt"
+	"github.com/caixw/lib.go/conv"
+	"time"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+)
+
+func CreateSubAccount(ctx context.Context, req *http_model.CreateSubAccountRequest) (http_model.YounggeeSubAccountsRes, error) {
+	db := GetReadDB(ctx)
+	fmt.Println("req", req.Code)
+	// 开始事务
+	tx := db.Begin()
+	if tx.Error != nil {
+		return http_model.YounggeeSubAccountsRes{}, tx.Error
+	}
+	now := time.Now()
+	fmt.Println("now:", now)
+	younggee_user := gorm_model.YounggeeUser{
+		Phone:         req.PhoneNumber,
+		User:          req.SubAccountName,
+		Role:          "5",
+		LastLoginTime: now,
+		UpdatedAt:     now,
+		CreatedAt:     now,
+	}
+	err := tx.Create(&younggee_user).Error
+	fmt.Println("err:", err)
+	if err != nil {
+		tx.Rollback()
+		return http_model.YounggeeSubAccountsRes{}, err
+	}
+
+	user := gorm_model.YounggeeSubAccount{
+		PhoneNumber:    req.PhoneNumber,
+		SubAccountName: req.SubAccountName,
+		JobId:          req.Job,
+		SubAccountType: 2,
+		AccountStatus:  1,
+		SuperAdminId:   req.AccountID,
+		UserId:         younggee_user.ID,
+	}
+	err = tx.Create(&user).Error
+	if err != nil {
+		tx.Rollback()
+		return http_model.YounggeeSubAccountsRes{}, err
+	}
+	// 提交事务
+	tx.Commit()
+	// 构造返回结果
+	res := http_model.YounggeeSubAccountsRes{
+		JobID:          user.JobId,
+		PhoneNumber:    user.PhoneNumber,
+		SubAccountName: user.SubAccountName,
+	}
+	return res, nil
+}
+
+func UPdateSubaccountInfo(ctx context.Context, req *http_model.UpdateSubaccountInfoRequest) (*http_model.YounggeeSubAccountsRes, error) {
+	db := GetReadDB(ctx)
+
+	// 查找子账号
+	SubaccountInfo := gorm_model.YounggeeSubAccount{}
+	whereCondition := gorm_model.YounggeeSubAccount{SubAccountId: req.SubAccountID}
+	result := db.Where(&whereCondition).First(&SubaccountInfo)
+	if result.Error != nil {
+		return nil, result.Error
+	}
+	// 更新子账号信息
+	updateData := map[string]interface{}{
+		"phone_number":     req.PhoneNumber,
+		"sub_account_name": req.SubAccountName,
+		"job_id":           req.Job,
+		"sub_account_type": 2,
+	}
+	updateResult := db.Model(&SubaccountInfo).Where("sub_account_id = ?", req.SubAccountID).Updates(updateData)
+	if updateResult.Error != nil {
+		fmt.Println("updateResult.Error:", updateResult.Error)
+		return nil, updateResult.Error
+	}
+	// 返回更新后的结果
+	response := &http_model.YounggeeSubAccountsRes{
+		PhoneNumber:    SubaccountInfo.PhoneNumber,
+		SubAccountName: SubaccountInfo.SubAccountName,
+		JobID:          SubaccountInfo.JobId,
+	}
+
+	return response, nil
+}
+
+func GetSubAccountDetail(ctx context.Context, req *http_model.SubAccountDetailRequest) (http_model.SubAccountData, error) {
+	db := GetReadDB(ctx)
+	var subaccountInfo []gorm_model.YounggeeSubAccount
+
+	// 构建查询条件
+	query := db.Model(&gorm_model.YounggeeSubAccount{}).Where("sub_account_type = ?", 2)
+	if req.JobId != nil {
+		query = query.Where("job_id = ?", *req.JobId)
+	}
+	if req.AccountStatus != nil {
+		query = query.Where("account_status = ?", *req.AccountStatus)
+	}
+	if req.PhoneNumber != nil {
+		query = query.Where("phone_number = ?", *req.PhoneNumber)
+	}
+	if req.SubAccountName != nil {
+		query = query.Where("account_name = ?", *req.SubAccountName)
+	}
+
+	// 查询总数
+	var total int64
+	countQuery := query.Count(&total)
+	if countQuery.Error != nil {
+		return http_model.SubAccountData{}, countQuery.Error
+	}
+
+	// 添加分页逻辑
+	pageSize := req.PageSize
+	if pageSize == 0 {
+		pageSize = 10 // 设置默认页大小
+	}
+	pageNum := req.PageNum
+	if pageNum == 0 {
+		pageNum = 1 // 设置默认页码
+	}
+	offset := (pageNum - 1) * pageSize
+
+	// 执行分页查询
+	result := query.Offset(offset).Limit(pageSize).Find(&subaccountInfo)
+	if result.Error != nil {
+		return http_model.SubAccountData{}, result.Error
+	}
+
+	// 收集所有 SuperAdminId
+	var userIDs []int64
+	for _, acc := range subaccountInfo {
+		userIDs = append(userIDs, acc.SuperAdminId)
+	}
+
+	// 查询所有相关用户
+	var users []gorm_model.YounggeeUser
+	db.Where("id IN (?)", userIDs).Find(&users)
+
+	// 创建用户 ID 到用户名的映射
+	userMap := make(map[int64]string)
+	for _, user := range users {
+		userMap[user.ID] = user.Username
+	}
+
+	// 构造返回结果
+	var subaccountInfoPointers []*http_model.SubAccountDetailResponse
+	for _, acc := range subaccountInfo {
+		response := &http_model.SubAccountDetailResponse{
+			SubAccountInfo: acc,
+			Creater:        userMap[acc.SuperAdminId], // 从映射中获取用户名
+		}
+		subaccountInfoPointers = append(subaccountInfoPointers, response)
+	}
+	subaccountInfolist := http_model.SubAccountData{
+		SubAccountInfo: subaccountInfoPointers,
+		Total:          conv.MustString(total, ""),
+	}
+	return subaccountInfolist, nil
+}
+
+func StopSubAccount(ctx context.Context, req *http_model.StopSubAccountRequest) (*http_model.StopSubAccountResponse, error) {
+	db := GetReadDB(ctx)
+	SubaccountInfo := gorm_model.YounggeeSubAccount{}
+	whereCondition := gorm_model.YounggeeSubAccount{SubAccountId: req.SubAccountId}
+	result := db.Where(&whereCondition).First(&SubaccountInfo)
+	if result.Error != nil {
+		return nil, result.Error
+	}
+	updateData := gorm_model.YounggeeSubAccount{
+		AccountStatus: 2,
+	}
+	updateResult := db.Model(&SubaccountInfo).Where("sub_account_id = ?", req.SubAccountId).Updates(updateData)
+	if updateResult.Error != nil {
+		fmt.Println("updateResult.Error:", updateResult.Error)
+		return nil, updateResult.Error
+	}
+	response := &http_model.StopSubAccountResponse{
+		SubAccountName: SubaccountInfo.SubAccountName,
+		SubAccountID:   SubaccountInfo.SubAccountId,
+	}
+	return response, nil
+}
+
+func DeleteSubAccount(ctx context.Context, req *http_model.DeleteSubAccountRequest) error {
+	db := GetReadDB(ctx)
+	// 开始事务
+	tx := db.Begin()
+
+	var younggee_user gorm_model.YounggeeSubAccount
+	err := tx.Where("sub_account_id = ?", req.SubAccountId).First(&younggee_user).Error
+	if err != nil {
+		fmt.Println("FindYounggeeSubAccountError:", err)
+		tx.Rollback()
+		return err
+	}
+	// 删除 YounggeeSubAccount
+	err = tx.Where("sub_account_id = ?", req.SubAccountId).Delete(&younggee_user).Error
+	if err != nil {
+		fmt.Println("DeleteYounggeeSubAccountError:", err)
+		tx.Rollback()
+		return err
+	}
+
+	// 删除 YounggeeUser
+	var user gorm_model.YounggeeUser
+	if younggee_user.UserId != 0 {
+		err = tx.Where("id = ?", younggee_user.UserId).Delete(&user).Error
+		if err != nil {
+			fmt.Println("DeleteYounggeeUserError:", err)
+			tx.Rollback()
+			return err
+		}
+	}
+
+	// 提交事务
+	tx.Commit()
+	return nil
+}

+ 450 - 428
db/user.go

@@ -1,428 +1,450 @@
-package db
-
-import (
-	"context"
-	"fmt"
-	"github.com/caixw/lib.go/conv"
-	"github.com/sirupsen/logrus"
-	"gorm.io/gorm"
-	"reflect"
-	"time"
-	"youngee_m_api/consts"
-	"youngee_m_api/model/common_model"
-	"youngee_m_api/model/gorm_model"
-	"youngee_m_api/model/http_model"
-	"youngee_m_api/pack"
-	"youngee_m_api/util"
-)
-
-// GetUser 查找用户,查不到返回空
-func GetUser(ctx context.Context, User string) (*gorm_model.YounggeeUser, error) {
-	db := GetReadDB(ctx)
-	user := &gorm_model.YounggeeUser{}
-	err := db.Model(user).Where("user = ?", User).First(user).Error
-	if err != nil {
-		if err == gorm.ErrRecordNotFound {
-			fmt.Println("record not found")
-			return nil, nil
-		}
-		return nil, err
-	}
-	return user, nil
-}
-
-// GetUserByID 查不到返回空
-func GetUserByID(ctx context.Context, ID int64) (*gorm_model.YounggeeUser, error) {
-	db := GetReadDB(ctx)
-	user := &gorm_model.YounggeeUser{}
-	err := db.Model(user).Where("id = ?", ID).First(user).Error
-	if err != nil {
-		if err == gorm.ErrRecordNotFound {
-			fmt.Println("record not found")
-			return nil, nil
-		}
-		return nil, err
-	}
-	return user, nil
-}
-
-// GetAllUser 查找所有用户
-func GetAllUser(ctx context.Context) ([]string, error) {
-	db := GetReadDB(ctx)
-	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("role = ? or role = ?", "1", "2")
-	var user []gorm_model.YounggeeUser
-	db.Find(&user)
-	var total int64
-	if err := db.Count(&total).Error; err != nil {
-		logrus.WithContext(ctx).Errorf("[GetAllUser] error query mysql total, err:%+v", err)
-		return nil, err
-	}
-	var userList []string
-	for _, User := range user {
-		userList = append(userList, User.User)
-	}
-	return userList, nil
-}
-
-// GetUserList 获取员工用户列表
-func GetUserList(ctx context.Context, pageNum, pageSize int32) (*http_model.UserListData, error) {
-	db := GetReadDB(ctx)
-	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("role = ? or role = ?", "1", "2")
-	var user []gorm_model.YounggeeUser
-	// 查询总数
-	var total int64
-	if err := db.Count(&total).Error; err != nil {
-		logrus.WithContext(ctx).Errorf("[GetUserList] error query mysql total, err:%+v", err)
-		return nil, err
-	}
-	// 查询该页数据
-	limit := pageSize
-	offset := pageSize * pageNum // assert pageNum start with 0
-	err := db.Order("created_at desc").Limit(int(limit)).Offset(int(offset)).Find(&user).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetUserList] error query mysql find, err:%+v", err)
-		return nil, err
-	}
-	userList := new(http_model.UserListData)
-	userList.UserListPreview = pack.MGormUserListToHttpUserListPreview(user)
-	userList.Total = conv.MustString(total, "")
-	return userList, nil
-}
-
-func UpdateUserInfo(ctx context.Context, req *http_model.UpdateUserInfoRequest) (string, error) {
-	db := GetReadDB(ctx)
-	user, username, role, password, email, phone := req.User, req.Username, req.Role, req.Password, req.Email, req.Phone
-	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("user = ?", user)
-	err := db.Updates(map[string]interface{}{
-		"username": username, "password": password, "email": email, "phone": phone, "role": role}).Error
-	if err != nil {
-		return "", err
-	}
-	return "更新成功", nil
-}
-
-func CreateUser(ctx context.Context, req *http_model.CreateUserRequest) (string, error) {
-	db := GetReadDB(ctx)
-	username, role, password, email, phone := req.Username, req.Role, req.Password, req.Email, req.Phone
-	var IsUserPhone gorm_model.YounggeeUser
-	err := db.Debug().Where(" phone = ?", req.Phone).First(&IsUserPhone).Error
-	if err == nil {
-		return "手机号已存在,不能再次创建", nil
-	}
-	var user gorm_model.YounggeeUser
-	var userInfo gorm_model.YounggeeUser
-	getMonth := time.Now().Format("01") //获取月
-	getDay := time.Now().Day()          //获取日
-	dayString := ""
-	if getDay < 10 {
-		dayString = conv.MustString(getDay, "")
-		dayString = "0" + dayString
-	} else {
-		dayString = conv.MustString(getDay, "")
-	}
-	monthAndDay := conv.MustString(getMonth, "") + dayString
-	err = db.Debug().Where(fmt.Sprintf(" user like '%s%%'", monthAndDay)).Last(&userInfo).Error
-
-	num := 1
-	if userInfo.User != "" {
-		num = conv.MustInt(userInfo.User[4:6], 0)
-		num = num + 1 //获取日
-	} else {
-		num = 1
-	}
-	numString := ""
-	if num < 10 {
-		numString = conv.MustString(num, "")
-		numString = "0" + numString
-	} else {
-		numString = conv.MustString(num, "")
-	}
-
-	user.Username = username
-	user.RealName = username
-	user.User = monthAndDay + numString
-	user.Role = role
-	user.Password = password
-	user.Email = email
-	user.Phone = phone
-	user.LastLoginTime = time.Now()
-	user.CreatedAt = time.Now()
-	user.UpdatedAt = time.Now()
-	err = db.Debug().Create(&user).Error
-	if err != nil {
-		return "创建失败", err
-	}
-	return "创建成功", nil
-}
-
-func DisabledUser(ctx context.Context, user string) (string, error) {
-	db := GetReadDB(ctx)
-	err := db.Debug().Model(gorm_model.YounggeeUser{}).Where("user = ?", user).Update("user_state", "0").Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[DisabledUser] error Update mysql find, err:%+v", err)
-		return "禁用失败", err
-	}
-	return "账号已禁止使用", nil
-}
-
-func GetEnterpriseUserList(ctx context.Context, pageSize, pageNum int32, conditions *common_model.EnterpriseUserConditions) ([]*http_model.EnterpriseUserPreview, int64, error) {
-	db := GetReadDB(ctx)
-	// 查询user表信息,筛选出企业用户
-	db = db.Model([]gorm_model.YounggeeUser{}).Where("role = ? ", "3")
-	if conditions.User != "" {
-		userId := GetUserIDByEnterpriseID(ctx, conditions.User)
-		db = db.Where("id = ?", userId)
-	}
-	// 根据 查询条件过滤
-	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 != "created_at" && tag != "username" && tag != "user" {
-			db = db.Debug().Where(fmt.Sprintf("%s = ?", tag), value.Interface())
-		} else if tag == "created_at" && value.Interface() != nil {
-			db = db.Where(fmt.Sprintf("created_at like '%s%%'", value.Interface()))
-		} else if tag == "username" && value.Interface() != nil {
-			db = db.Debug().Where(fmt.Sprintf("username like '%%%s%%'", value.Interface()))
-		}
-	}
-	var totalUser int64
-	if err := db.Count(&totalUser).Error; err != nil {
-		logrus.WithContext(ctx).Errorf("[GetEnterpriseUserList] error query mysql total, err:%+v", err)
-		return nil, 0, err
-	}
-
-	var users []gorm_model.YounggeeUser
-	// 查询该页数据
-	limit := pageSize
-	offset := pageSize * pageNum // assert pageNum start with 0
-	err := db.Order("created_at desc").Limit(int(limit)).Offset(int(offset)).Find(&users).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetEnterpriseUserList] error query mysql total, err:%+v", err)
-		return nil, 0, err
-	}
-	// 查询 用户自增的id
-	var userIds []int64
-	userMap := make(map[int64]gorm_model.YounggeeUser)
-	for _, user := range users {
-		userIds = append(userIds, user.ID)
-		userMap[user.ID] = user
-	}
-
-	db1 := GetReadDB(ctx)
-	var enterprises []gorm_model.Enterprise
-	db1 = db1.Model(gorm_model.Enterprise{}).Where("user_id IN ?", userIds).Find(&enterprises)
-
-	enterpriseMap := make(map[int64]gorm_model.Enterprise)
-	for _, enterprise := range enterprises {
-		enterpriseMap[enterprise.UserID] = enterprise
-	}
-
-	var enterpriseUsers []*http_model.EnterpriseUser
-	for _, userId := range userIds {
-		enterpriseUser := new(http_model.EnterpriseUser)
-		_, ok1 := userMap[userId]
-		_, ok2 := enterpriseMap[userId]
-		if ok1 && ok2 {
-			enterpriseUser.Enterprise = enterpriseMap[userId]
-			enterpriseUser.YoungeeUser = userMap[userId]
-		}
-		enterpriseUsers = append(enterpriseUsers, enterpriseUser)
-	}
-
-	var enterpriseUserDatas []*http_model.EnterpriseUserPreview
-	enterpriseUserDatas = pack.EnterpriseUserToEnterpriseUserData(enterpriseUsers)
-	return enterpriseUserDatas, totalUser, nil
-}
-
-func GetCreatorList(ctx context.Context, pageSize, pageNum int32, conditions *common_model.CreatorListConditions) ([]*http_model.CreatorListPreview, int64, error) {
-	db := GetReadDB(ctx)
-	db = db.Debug().Model(gorm_model.YoungeeTalentInfo{}).Where("in_blacklist = ?", conditions.InBlacklist)
-	// 根据 条件过滤
-	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 != "create_date" && tag != "talent_wx_nickname" && tag != "id" {
-			db = db.Debug().Where(fmt.Sprintf("%s = ?", tag), value.Interface())
-		} else if tag == "create_date" && value.Interface() != nil {
-			db = db.Where(fmt.Sprintf("create_date like '%s%%'", value.Interface()))
-		} else if tag == "talent_wx_nickname" && value.Interface() != nil {
-			db = db.Where(fmt.Sprintf("talent_wx_nickname like '%%%s%%'", value.Interface()))
-		} else if tag == "id" && value.Interface() != nil {
-			db = db.Where(fmt.Sprintf("id like '%%%s%%'", value.Interface()))
-		}
-	}
-
-	// 查询总数
-	var total int64
-	var talentList []gorm_model.YoungeeTalentInfo
-	if err := db.Count(&total).Error; err != nil {
-		logrus.WithContext(ctx).Errorf("[GetCreatorList] error query mysql total, err:%+v", err)
-		return nil, 0, err
-	}
-	// 查询该页数据
-	limit := pageSize
-	offset := pageSize * pageNum // assert pageNum start with 0
-	err := db.Order("create_date desc").Limit(int(limit)).Offset(int(offset)).Find(&talentList).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetCreatorList] error query mysql total, err:%+v", err)
-		return nil, 0, err
-	}
-
-	var CreatorList []*http_model.CreatorListPreview
-
-	CreatorList = pack.TalentListToCreatorListData(talentList)
-	return CreatorList, total, nil
-}
-
-func AccountInfo(ctx context.Context, pageSize, pageNum int32, conditions *common_model.AccountInfoConditions) ([]*http_model.AccountInfoData, int64, error) {
-	db := GetReadDB(ctx)
-	db = db.Debug().Model(gorm_model.YoungeePlatformAccountInfo{})
-	// 根据 条件过滤
-	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 != "bind_date" && tag != "fans_low" && tag != "fans_high" && tag != "platform_nickname" {
-			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
-		} else if tag == "bind_date" && value.Interface() != nil {
-			db = db.Where(fmt.Sprintf("bind_date like '%s%%'", value.Interface()))
-		}
-		if !util.IsBlank(value) && tag == "fans_low" {
-			db = db.Where(fmt.Sprintf("%s >= ?", "fans_count"), value.Interface())
-		}
-		if !util.IsBlank(value) && tag == "fans_high" {
-			db = db.Where(fmt.Sprintf("%s <= ?", "fans_count"), value.Interface())
-		}
-		if !util.IsBlank(value) && tag == "platform_nickname" {
-			db = db.Where(fmt.Sprintf("platform_nickname like '%%%s%%'", value.Interface()))
-		}
-	}
-	db = db.Debug().Where("deleted = ?", 0)
-	var total int64
-	if err := db.Count(&total).Error; err != nil {
-		logrus.WithContext(ctx).Errorf("[GetAccountInfo] error query mysql total, err:%+v", err)
-		return nil, 0, err
-	}
-	var PlatformAccountInfos []*gorm_model.YoungeePlatformAccountInfo
-	// 查询该页数据
-	limit := pageSize
-	offset := pageSize * pageNum // assert pageNum start with 0
-	err := db.Order("bind_date desc").Limit(int(limit)).Offset(int(offset)).Find(&PlatformAccountInfos).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[GetAccountInfo] error query mysql total, err:%+v", err)
-		return nil, 0, err
-	}
-	phoneMap := map[string]string{}
-	for _, PlatformAccountInfo := range PlatformAccountInfos {
-		if _, ok := phoneMap[PlatformAccountInfo.TalentID]; !ok {
-			phoneMap[PlatformAccountInfo.TalentID] = getPhoneByTalentID(ctx, PlatformAccountInfo.TalentID)
-		}
-	}
-	var accountInfoDatas []*http_model.AccountInfoData
-	for _, PlatformAccountInfo := range PlatformAccountInfos {
-		accountInfo := new(http_model.AccountInfoData)
-		accountInfo.BindDate = conv.MustString(PlatformAccountInfo.BindDate, "")[0:19]
-		accountInfo.Platform = consts.GetProjectPlatform(PlatformAccountInfo.PlatformID)
-		accountInfo.PlatformNickname = PlatformAccountInfo.PlatformNickname
-		accountInfo.PlatformType = PlatformAccountInfo.PlatformType
-		accountInfo.TalentId = PlatformAccountInfo.TalentID
-		accountInfo.Phone = phoneMap[PlatformAccountInfo.TalentID]
-		accountInfo.Fans = util.GetNumString(PlatformAccountInfo.FansCount)
-		accountInfo.HomePageUrl = PlatformAccountInfo.HomePageUrl
-		accountInfo.HomePageCaptureUrl = PlatformAccountInfo.HomePageCaptureUrl
-		accountInfoDatas = append(accountInfoDatas, accountInfo)
-	}
-	return accountInfoDatas, total, nil
-}
-
-func getPhoneByTalentID(ctx context.Context, talentID string) string {
-	db := GetReadDB(ctx)
-	//talentInfo := gorm_model.YoungeeTalentInfo{}
-	phoneNumber := ""
-	err := db.Debug().Model(&gorm_model.YoungeeTalentDeliveryAddress{}).Select("phone_number").Where("talent_id = ?", talentID).First(&phoneNumber).Error
-	if err != nil {
-		if err == gorm.ErrRecordNotFound {
-			return ""
-		} else {
-			return ""
-		}
-	}
-	return phoneNumber
-}
-
-func DeleteAccount(ctx context.Context, PlatformID, PlatformNickname, TalentId string) error {
-	db := GetReadDB(ctx)
-	accountInfo := gorm_model.YoungeePlatformAccountInfo{}
-	db = db.Debug().Where("talent_id = ? "+
-		"AND platform_nickname = ? "+
-		"AND platform_id = ?",
-		TalentId, PlatformNickname, PlatformID).Find(&accountInfo)
-	err := CreateMessage(context.Background(), 15, 2, accountInfo.TalentID, "")
-	if err != nil {
-		logrus.WithContext(context.Background()).Errorf("[user db] call CreateMessageByTaskId error,err:%+v", err)
-	}
-	err = db.Delete(&accountInfo).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[user db] call DeleteAccount error,err:%+v", err)
-		return err
-	}
-	return nil
-}
-
-func GetEnterpriseIds(ctx context.Context) (*http_model.EnterPriseIds, error) {
-	var enterpriseIds []string
-	db := GetReadDB(ctx)
-	err := db.Model(gorm_model.Enterprise{}).Select("enterprise_id").Find(&enterpriseIds).Error
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[user db] call GetEnterpriseIds error,err:%+v", err)
-		return nil, err
-	}
-	EnterpriseIds := http_model.EnterPriseIds{}
-	EnterpriseIds.EnterPriseIds = enterpriseIds
-	return &EnterpriseIds, nil
-}
-
-func ModifyAccInfo(ctx context.Context, req *http_model.ModifyAccInfoRequest) error {
-	db := GetReadDB(ctx)
-	return db.Model(gorm_model.YoungeePlatformAccountInfo{}).Where("account_id = ?", req.AccountId).Updates(
-		gorm_model.YoungeePlatformAccountInfo{
-			FansCount:          req.Fans,
-			PlatformNickname:   req.PlatformNickname,
-			HomePageUrl:        req.HomePageUrl,
-			HomePageCaptureUrl: req.HomePageCaptureUrl,
-			UpdatedPerson:      1,
-			UpdatedAdminID:     req.User,
-		}).Error
-}
-
-// 拉黑创作者
-func Block(ctx context.Context, data http_model.BlockRequest) error {
-	err := Black(ctx, data.ID, data.InBlacklist)
-	if err != nil {
-		logrus.WithContext(ctx).Errorf("[project] call ChangeProjectStatus error,err:%+v", err)
-		return err
-	}
-	return nil
-}
-
-func Black(ctx context.Context, ID string, InBlacklist uint) error {
-	db := GetReadDB(ctx)
-	talentInfo := gorm_model.YoungeeTalentInfo{}
-	if err := db.Debug().Model(&talentInfo).
-		Where("id = ?", ID).
-		//Updates(gorm_model.YoungeeTalentInfo{InBlacklist: InBlacklist}). //这种方法置0不生效
-		UpdateColumn("in_blacklist", InBlacklist).
-		Error; err != nil {
-		logrus.WithContext(ctx).Errorf("[ChangeProjectStatus] error query mysql total, err:%+v", err)
-		return err
-	}
-	return nil
-}
+package db
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"github.com/caixw/lib.go/conv"
+	"github.com/sirupsen/logrus"
+	"gorm.io/gorm"
+	"reflect"
+	"time"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/common_model"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/pack"
+	"youngee_m_api/util"
+)
+
+// GetUser 查找用户,查不到返回空
+func GetUser(ctx context.Context, User string) (*gorm_model.YounggeeUser, error) {
+	db := GetReadDB(ctx)
+	user := &gorm_model.YounggeeUser{}
+	err := db.Model(user).Where("user = ?", User).First(user).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			fmt.Println("record not found")
+			return nil, nil
+		}
+		return nil, err
+	}
+	return user, nil
+}
+
+// GetUserByID 查不到返回空
+func GetUserByID(ctx context.Context, ID int64) (*gorm_model.YounggeeUser, error) {
+	db := GetReadDB(ctx)
+	user := &gorm_model.YounggeeUser{}
+	err := db.Model(user).Where("id = ?", ID).First(user).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			fmt.Println("record not found")
+			return nil, nil
+		}
+		return nil, err
+	}
+	return user, nil
+}
+
+// GetUserByPhone 查不到返回空 根据手机号在User表中查用户数据
+func GetUserByPhoneNumber(ctx context.Context, phoneNumber string) (*gorm_model.YounggeeUser, error) {
+	db := GetReadDB(ctx)
+	user := &gorm_model.YounggeeUser{}
+
+	// 执行查询
+	err := db.Where("phone = ? AND role = ?", phoneNumber, "5").First(user).Error
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			// 记录未找到时返回 nil 和 nil
+			return nil, nil
+		}
+		// 其他错误时记录日志并返回错误
+		logrus.WithContext(ctx).Errorf("[GetUserByPhoneNumber] error query mysql find, err:%+v", err)
+		return nil, err
+	}
+
+	// 查询成功,返回找到的用户
+	return user, nil
+}
+
+// GetAllUser 查找所有用户
+func GetAllUser(ctx context.Context) ([]string, error) {
+	db := GetReadDB(ctx)
+	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("role = ? or role = ?", "1", "2")
+	var user []gorm_model.YounggeeUser
+	db.Find(&user)
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetAllUser] error query mysql total, err:%+v", err)
+		return nil, err
+	}
+	var userList []string
+	for _, User := range user {
+		userList = append(userList, User.User)
+	}
+	return userList, nil
+}
+
+// GetUserList 获取员工用户列表
+func GetUserList(ctx context.Context, pageNum, pageSize int32) (*http_model.UserListData, error) {
+	db := GetReadDB(ctx)
+	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("role = ? or role = ?", "1", "2")
+	var user []gorm_model.YounggeeUser
+	// 查询总数
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetUserList] error query mysql total, err:%+v", err)
+		return nil, err
+	}
+	// 查询该页数据
+	limit := pageSize
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("created_at desc").Limit(int(limit)).Offset(int(offset)).Find(&user).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetUserList] error query mysql find, err:%+v", err)
+		return nil, err
+	}
+	userList := new(http_model.UserListData)
+	userList.UserListPreview = pack.MGormUserListToHttpUserListPreview(user)
+	userList.Total = conv.MustString(total, "")
+	return userList, nil
+}
+
+func UpdateUserInfo(ctx context.Context, req *http_model.UpdateUserInfoRequest) (string, error) {
+	db := GetReadDB(ctx)
+	user, username, role, password, email, phone := req.User, req.Username, req.Role, req.Password, req.Email, req.Phone
+	db = db.Debug().Model([]gorm_model.YounggeeUser{}).Where("user = ?", user)
+	err := db.Updates(map[string]interface{}{
+		"username": username, "password": password, "email": email, "phone": phone, "role": role}).Error
+	if err != nil {
+		return "", err
+	}
+	return "更新成功", nil
+}
+
+func CreateUser(ctx context.Context, req *http_model.CreateUserRequest) (string, error) {
+	db := GetReadDB(ctx)
+	username, role, password, email, phone := req.Username, req.Role, req.Password, req.Email, req.Phone
+	var IsUserPhone gorm_model.YounggeeUser
+	err := db.Debug().Where(" phone = ?", req.Phone).First(&IsUserPhone).Error
+	if err == nil {
+		return "手机号已存在,不能再次创建", nil
+	}
+	var user gorm_model.YounggeeUser
+	var userInfo gorm_model.YounggeeUser
+	getMonth := time.Now().Format("01") //获取月
+	getDay := time.Now().Day()          //获取日
+	dayString := ""
+	if getDay < 10 {
+		dayString = conv.MustString(getDay, "")
+		dayString = "0" + dayString
+	} else {
+		dayString = conv.MustString(getDay, "")
+	}
+	monthAndDay := conv.MustString(getMonth, "") + dayString
+	err = db.Debug().Where(fmt.Sprintf(" user like '%s%%'", monthAndDay)).Last(&userInfo).Error
+
+	num := 1
+	if userInfo.User != "" {
+		num = conv.MustInt(userInfo.User[4:6], 0)
+		num = num + 1 //获取日
+	} else {
+		num = 1
+	}
+	numString := ""
+	if num < 10 {
+		numString = conv.MustString(num, "")
+		numString = "0" + numString
+	} else {
+		numString = conv.MustString(num, "")
+	}
+
+	user.Username = username
+	user.RealName = username
+	user.User = monthAndDay + numString
+	user.Role = role
+	user.Password = password
+	user.Email = email
+	user.Phone = phone
+	user.LastLoginTime = time.Now()
+	user.CreatedAt = time.Now()
+	user.UpdatedAt = time.Now()
+	err = db.Debug().Create(&user).Error
+	if err != nil {
+		return "创建失败", err
+	}
+	return "创建成功", nil
+}
+
+func DisabledUser(ctx context.Context, user string) (string, error) {
+	db := GetReadDB(ctx)
+	err := db.Debug().Model(gorm_model.YounggeeUser{}).Where("user = ?", user).Update("user_state", "0").Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[DisabledUser] error Update mysql find, err:%+v", err)
+		return "禁用失败", err
+	}
+	return "账号已禁止使用", nil
+}
+
+func GetEnterpriseUserList(ctx context.Context, pageSize, pageNum int32, conditions *common_model.EnterpriseUserConditions) ([]*http_model.EnterpriseUserPreview, int64, error) {
+	db := GetReadDB(ctx)
+	// 查询user表信息,筛选出企业用户
+	db = db.Model([]gorm_model.YounggeeUser{}).Where("role = ? ", "3")
+	if conditions.User != "" {
+		userId := GetUserIDByEnterpriseID(ctx, conditions.User)
+		db = db.Where("id = ?", userId)
+	}
+	// 根据 查询条件过滤
+	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 != "created_at" && tag != "username" && tag != "user" {
+			db = db.Debug().Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		} else if tag == "created_at" && value.Interface() != nil {
+			db = db.Where(fmt.Sprintf("created_at like '%s%%'", value.Interface()))
+		} else if tag == "username" && value.Interface() != nil {
+			db = db.Debug().Where(fmt.Sprintf("username like '%%%s%%'", value.Interface()))
+		}
+	}
+	var totalUser int64
+	if err := db.Count(&totalUser).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetEnterpriseUserList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+
+	var users []gorm_model.YounggeeUser
+	// 查询该页数据
+	limit := pageSize
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("created_at desc").Limit(int(limit)).Offset(int(offset)).Find(&users).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetEnterpriseUserList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	// 查询 用户自增的id
+	var userIds []int64
+	userMap := make(map[int64]gorm_model.YounggeeUser)
+	for _, user := range users {
+		userIds = append(userIds, user.ID)
+		userMap[user.ID] = user
+	}
+
+	db1 := GetReadDB(ctx)
+	var enterprises []gorm_model.Enterprise
+	db1 = db1.Model(gorm_model.Enterprise{}).Where("user_id IN ?", userIds).Find(&enterprises)
+
+	enterpriseMap := make(map[int64]gorm_model.Enterprise)
+	for _, enterprise := range enterprises {
+		enterpriseMap[enterprise.UserID] = enterprise
+	}
+
+	var enterpriseUsers []*http_model.EnterpriseUser
+	for _, userId := range userIds {
+		enterpriseUser := new(http_model.EnterpriseUser)
+		_, ok1 := userMap[userId]
+		_, ok2 := enterpriseMap[userId]
+		if ok1 && ok2 {
+			enterpriseUser.Enterprise = enterpriseMap[userId]
+			enterpriseUser.YoungeeUser = userMap[userId]
+		}
+		enterpriseUsers = append(enterpriseUsers, enterpriseUser)
+	}
+
+	var enterpriseUserDatas []*http_model.EnterpriseUserPreview
+	enterpriseUserDatas = pack.EnterpriseUserToEnterpriseUserData(enterpriseUsers)
+	return enterpriseUserDatas, totalUser, nil
+}
+
+func GetCreatorList(ctx context.Context, pageSize, pageNum int32, conditions *common_model.CreatorListConditions) ([]*http_model.CreatorListPreview, int64, error) {
+	db := GetReadDB(ctx)
+	db = db.Debug().Model(gorm_model.YoungeeTalentInfo{}).Where("in_blacklist = ?", conditions.InBlacklist)
+	// 根据 条件过滤
+	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 != "create_date" && tag != "talent_wx_nickname" && tag != "id" {
+			db = db.Debug().Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		} else if tag == "create_date" && value.Interface() != nil {
+			db = db.Where(fmt.Sprintf("create_date like '%s%%'", value.Interface()))
+		} else if tag == "talent_wx_nickname" && value.Interface() != nil {
+			db = db.Where(fmt.Sprintf("talent_wx_nickname like '%%%s%%'", value.Interface()))
+		} else if tag == "id" && value.Interface() != nil {
+			db = db.Where(fmt.Sprintf("id like '%%%s%%'", value.Interface()))
+		}
+	}
+
+	// 查询总数
+	var total int64
+	var talentList []gorm_model.YoungeeTalentInfo
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetCreatorList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	// 查询该页数据
+	limit := pageSize
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("create_date desc").Limit(int(limit)).Offset(int(offset)).Find(&talentList).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetCreatorList] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+
+	var CreatorList []*http_model.CreatorListPreview
+
+	CreatorList = pack.TalentListToCreatorListData(talentList)
+	return CreatorList, total, nil
+}
+
+func AccountInfo(ctx context.Context, pageSize, pageNum int32, conditions *common_model.AccountInfoConditions) ([]*http_model.AccountInfoData, int64, error) {
+	db := GetReadDB(ctx)
+	db = db.Debug().Model(gorm_model.YoungeePlatformAccountInfo{})
+	// 根据 条件过滤
+	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 != "bind_date" && tag != "fans_low" && tag != "fans_high" && tag != "platform_nickname" {
+			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		} else if tag == "bind_date" && value.Interface() != nil {
+			db = db.Where(fmt.Sprintf("bind_date like '%s%%'", value.Interface()))
+		}
+		if !util.IsBlank(value) && tag == "fans_low" {
+			db = db.Where(fmt.Sprintf("%s >= ?", "fans_count"), value.Interface())
+		}
+		if !util.IsBlank(value) && tag == "fans_high" {
+			db = db.Where(fmt.Sprintf("%s <= ?", "fans_count"), value.Interface())
+		}
+		if !util.IsBlank(value) && tag == "platform_nickname" {
+			db = db.Where(fmt.Sprintf("platform_nickname like '%%%s%%'", value.Interface()))
+		}
+	}
+	db = db.Debug().Where("deleted = ?", 0)
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetAccountInfo] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	var PlatformAccountInfos []*gorm_model.YoungeePlatformAccountInfo
+	// 查询该页数据
+	limit := pageSize
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("bind_date desc").Limit(int(limit)).Offset(int(offset)).Find(&PlatformAccountInfos).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[GetAccountInfo] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	phoneMap := map[string]string{}
+	for _, PlatformAccountInfo := range PlatformAccountInfos {
+		if _, ok := phoneMap[PlatformAccountInfo.TalentID]; !ok {
+			phoneMap[PlatformAccountInfo.TalentID] = getPhoneByTalentID(ctx, PlatformAccountInfo.TalentID)
+		}
+	}
+	var accountInfoDatas []*http_model.AccountInfoData
+	for _, PlatformAccountInfo := range PlatformAccountInfos {
+		accountInfo := new(http_model.AccountInfoData)
+		accountInfo.BindDate = conv.MustString(PlatformAccountInfo.BindDate, "")[0:19]
+		accountInfo.Platform = consts.GetProjectPlatform(PlatformAccountInfo.PlatformID)
+		accountInfo.PlatformNickname = PlatformAccountInfo.PlatformNickname
+		accountInfo.PlatformType = PlatformAccountInfo.PlatformType
+		accountInfo.TalentId = PlatformAccountInfo.TalentID
+		accountInfo.Phone = phoneMap[PlatformAccountInfo.TalentID]
+		accountInfo.Fans = util.GetNumString(PlatformAccountInfo.FansCount)
+		accountInfo.HomePageUrl = PlatformAccountInfo.HomePageUrl
+		accountInfo.HomePageCaptureUrl = PlatformAccountInfo.HomePageCaptureUrl
+		accountInfoDatas = append(accountInfoDatas, accountInfo)
+	}
+	return accountInfoDatas, total, nil
+}
+
+func getPhoneByTalentID(ctx context.Context, talentID string) string {
+	db := GetReadDB(ctx)
+	//talentInfo := gorm_model.YoungeeTalentInfo{}
+	phoneNumber := ""
+	err := db.Debug().Model(&gorm_model.YoungeeTalentDeliveryAddress{}).Select("phone_number").Where("talent_id = ?", talentID).First(&phoneNumber).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return ""
+		} else {
+			return ""
+		}
+	}
+	return phoneNumber
+}
+
+func DeleteAccount(ctx context.Context, PlatformID, PlatformNickname, TalentId string) error {
+	db := GetReadDB(ctx)
+	accountInfo := gorm_model.YoungeePlatformAccountInfo{}
+	db = db.Debug().Where("talent_id = ? "+
+		"AND platform_nickname = ? "+
+		"AND platform_id = ?",
+		TalentId, PlatformNickname, PlatformID).Find(&accountInfo)
+	err := CreateMessage(context.Background(), 15, 2, accountInfo.TalentID, "")
+	if err != nil {
+		logrus.WithContext(context.Background()).Errorf("[user db] call CreateMessageByTaskId error,err:%+v", err)
+	}
+	err = db.Delete(&accountInfo).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[user db] call DeleteAccount error,err:%+v", err)
+		return err
+	}
+	return nil
+}
+
+func GetEnterpriseIds(ctx context.Context) (*http_model.EnterPriseIds, error) {
+	var enterpriseIds []string
+	db := GetReadDB(ctx)
+	err := db.Model(gorm_model.Enterprise{}).Select("enterprise_id").Find(&enterpriseIds).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[user db] call GetEnterpriseIds error,err:%+v", err)
+		return nil, err
+	}
+	EnterpriseIds := http_model.EnterPriseIds{}
+	EnterpriseIds.EnterPriseIds = enterpriseIds
+	return &EnterpriseIds, nil
+}
+
+func ModifyAccInfo(ctx context.Context, req *http_model.ModifyAccInfoRequest) error {
+	db := GetReadDB(ctx)
+	return db.Model(gorm_model.YoungeePlatformAccountInfo{}).Where("account_id = ?", req.AccountId).Updates(
+		gorm_model.YoungeePlatformAccountInfo{
+			FansCount:          req.Fans,
+			PlatformNickname:   req.PlatformNickname,
+			HomePageUrl:        req.HomePageUrl,
+			HomePageCaptureUrl: req.HomePageCaptureUrl,
+			UpdatedPerson:      1,
+			UpdatedAdminID:     req.User,
+		}).Error
+}
+
+// 拉黑创作者
+func Block(ctx context.Context, data http_model.BlockRequest) error {
+	err := Black(ctx, data.ID, data.InBlacklist)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[project] call ChangeProjectStatus error,err:%+v", err)
+		return err
+	}
+	return nil
+}
+
+func Black(ctx context.Context, ID string, InBlacklist uint) error {
+	db := GetReadDB(ctx)
+	talentInfo := gorm_model.YoungeeTalentInfo{}
+	if err := db.Debug().Model(&talentInfo).
+		Where("id = ?", ID).
+		//Updates(gorm_model.YoungeeTalentInfo{InBlacklist: InBlacklist}). //这种方法置0不生效
+		UpdateColumn("in_blacklist", InBlacklist).
+		Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[ChangeProjectStatus] error query mysql total, err:%+v", err)
+		return err
+	}
+	return nil
+}

+ 43 - 0
db/worksapce.go

@@ -0,0 +1,43 @@
+package db
+
+import (
+	"context"
+	"errors"
+	"github.com/sirupsen/logrus"
+	"gorm.io/gorm"
+	"time"
+	"youngee_m_api/model/gorm_model"
+)
+
+// 根据enterpriseId查询指定某天的所有带货数据
+func GetSelectionInfoListOfDay(ctx context.Context, enterpriseId string, date time.Time) ([]gorm_model.YounggeeSelectionInfo, error) {
+	db := GetWriteDB(ctx)
+	var selectionInfos []gorm_model.YounggeeSelectionInfo
+	query := db.Model(&gorm_model.YounggeeSelectionInfo{})
+
+	// 构建查询条件
+	if enterpriseId != "" {
+		query = query.Where("enterprise_id = ?", enterpriseId)
+	}
+
+	// 将日期部分提取出来进行匹配
+	query = query.Where("DATE(created_at) = ?", date.Format("2006-01-02"))
+
+	// 执行查询
+	result := query.Find(&selectionInfos)
+	if result.Error != nil {
+		if errors.Is(result.Error, gorm.ErrRecordNotFound) {
+			return nil, nil
+		}
+		logrus.WithContext(ctx).Errorf("[GetSelectionInfoListOfDay] error query mysql takegoodsdata, err:%+v", result.Error)
+		return nil, result.Error
+	}
+	return selectionInfos, nil
+}
+
+func CountBySelectionId(ctx context.Context, selectionId string) (int64, error) {
+	var count int64
+	db := GetWriteDB(ctx)
+	err := db.Model(&gorm_model.YounggeeSecTaskInfo{}).Where("selection_id = ?", selectionId).Count(&count).Error
+	return count, err
+}

+ 1 - 0
go.mod

@@ -21,6 +21,7 @@ require (
 	github.com/issue9/conv v1.2.1
 	github.com/lin-jim-leon/kuaishou v0.3.0
 	github.com/robfig/cron/v3 v3.0.0
+	github.com/satori/go.uuid v1.2.0
 	github.com/tidwall/gjson v1.14.3
 	github.com/wechatpay-apiv3/wechatpay-go v0.2.15
 )

+ 2 - 0
go.sum

@@ -86,6 +86,8 @@ github.com/robfig/cron/v3 v3.0.0/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzG
 github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
 github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
 github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
+github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
+github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
 github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
 github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=

+ 52 - 0
handler/create_job.go

@@ -0,0 +1,52 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapCreateJobHandler(ctx *gin.Context) {
+	handler := newCreateJobHandler(ctx)
+	BaseRun(handler)
+}
+
+type CreateJobHandler struct {
+	ctx  *gin.Context
+	req  *http_model.CreateJobRequest
+	resp *http_model.CommonResponse
+}
+
+func (c CreateJobHandler) getContext() *gin.Context { return c.ctx }
+func (c CreateJobHandler) getResponse() interface{} { return c.resp }
+func (c CreateJobHandler) getRequest() interface{} {
+	return c.req
+}
+func (c CreateJobHandler) run() {
+	data := http_model.CreateJobRequest{}
+	data = *c.req
+	res, err := db.CreateJob(c.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[CreateJobHandler] call CreateJob err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("CreateJobHandler fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功创建岗位"
+	c.resp.Data = res
+
+}
+func (c CreateJobHandler) checkParam() error {
+	return nil
+}
+
+func newCreateJobHandler(ctx *gin.Context) *CreateJobHandler {
+	return &CreateJobHandler{
+		ctx:  ctx,
+		req:  http_model.NewCreateJobRequest(),
+		resp: http_model.NewCreateJobResponse(),
+	}
+}

+ 71 - 0
handler/create_sub_account.go

@@ -0,0 +1,71 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	log "github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapCreateSubAccountHandler(ctx *gin.Context) {
+	handler := newCreateSubAccountHandler(ctx)
+	BaseRun(handler)
+}
+
+type CreateSubAccountHandler struct {
+	ctx  *gin.Context
+	req  *http_model.CreateSubAccountRequest
+	resp *http_model.CommonResponse
+}
+
+func (c CreateSubAccountHandler) getContext() *gin.Context { return c.ctx }
+func (c CreateSubAccountHandler) getResponse() interface{} { return c.resp }
+func (c CreateSubAccountHandler) getRequest() interface{} {
+	return c.req
+}
+func (c CreateSubAccountHandler) run() {
+	data := http_model.CreateSubAccountRequest{}
+	data = *c.req
+	message, err := service.Register.AuthRegister(c.ctx, data.PhoneNumber, data.Code)
+	if err != nil {
+		// 数据库查询失败,redis失败
+		logrus.Errorf("[CreateSubAccountHandler] call CreateSubAccount err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("CreateSubAccountHandler fail,req:%+v", c.req)
+		return
+	}
+	if message == "" {
+		res, Error := db.CreateSubAccount(c.ctx, &data)
+		if Error != nil {
+			logrus.Errorf("[RegisterHandler] call CreateEnterpriseUser err:%+v\n", err)
+			util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+			log.Info("Register fail,req:%+v", c.req)
+			return
+		}
+		c.resp.Message = "创建成功"
+		// 4. 返回ok
+		c.resp.Data = res
+	} else if message == "手机号已存在" {
+		c.resp.Message = message
+		c.resp.Status = 1
+	} else {
+		c.resp.Message = message
+		c.resp.Status = 2
+	}
+
+}
+func (c CreateSubAccountHandler) checkParam() error {
+	return nil
+}
+
+func newCreateSubAccountHandler(ctx *gin.Context) *CreateSubAccountHandler {
+	return &CreateSubAccountHandler{
+		ctx:  ctx,
+		req:  http_model.NewCreateSubAccountRequest(),
+		resp: http_model.NewCreateSubAccountResponse(),
+	}
+}

+ 50 - 0
handler/delete_job.go

@@ -0,0 +1,50 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapDeleteJobHandler(ctx *gin.Context) {
+	handler := newDeleteJobHandler(ctx)
+	BaseRun(handler)
+}
+
+type DeleteJobHandler struct {
+	ctx  *gin.Context
+	req  *http_model.DeleteJobRequest
+	resp *http_model.CommonResponse
+}
+
+func (c DeleteJobHandler) getContext() *gin.Context { return c.ctx }
+func (c DeleteJobHandler) getResponse() interface{} { return c.resp }
+func (c DeleteJobHandler) getRequest() interface{} {
+	return c.req
+}
+func (c DeleteJobHandler) run() {
+	data := http_model.DeleteJobRequest{}
+	data = *c.req
+	err := db.DeleteJob(c.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[DeleteJobHandler] call DeleteJob err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("DeleteJobHandler fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功删除岗位"
+}
+func (c DeleteJobHandler) checkParam() error {
+	return nil
+}
+
+func newDeleteJobHandler(ctx *gin.Context) *DeleteJobHandler {
+	return &DeleteJobHandler{
+		ctx:  ctx,
+		req:  http_model.NewDeleteJobRequest(),
+		resp: http_model.NewDeleteJobResponse(),
+	}
+}

+ 50 - 0
handler/delete_ks.go

@@ -0,0 +1,50 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapDeleteauthorizationHandler(ctx *gin.Context) {
+	handler := newDeleteKsauthorizationHandler(ctx)
+	BaseRun(handler)
+}
+
+type DeleteKsauthorizationHandler struct {
+	ctx  *gin.Context
+	req  *http_model.DeleteKsauthorizationRequest
+	resp *http_model.CommonResponse
+}
+
+func (c DeleteKsauthorizationHandler) getContext() *gin.Context { return c.ctx }
+func (c DeleteKsauthorizationHandler) getResponse() interface{} { return c.resp }
+func (c DeleteKsauthorizationHandler) getRequest() interface{} {
+	return c.req
+}
+func (c DeleteKsauthorizationHandler) run() {
+	data := http_model.DeleteKsauthorizationRequest{}
+	data = *c.req
+	err := db.DeleteKsauthorization(c.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[DeleteKsauthorizationHandler] call DeleteKsauthorization err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("DeleteKsauthorizationHandler fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功删除授权"
+}
+func (c DeleteKsauthorizationHandler) checkParam() error {
+	return nil
+}
+
+func newDeleteKsauthorizationHandler(ctx *gin.Context) *DeleteKsauthorizationHandler {
+	return &DeleteKsauthorizationHandler{
+		ctx:  ctx,
+		req:  http_model.NewDeleteKsauthorizationRequest(),
+		resp: http_model.NewDeleteKsauthorizationResponse(),
+	}
+}

+ 50 - 0
handler/delete_project.go

@@ -0,0 +1,50 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapDeleteProjectHandler(ctx *gin.Context) {
+	handler := newDeleteProjectHandler(ctx)
+	BaseRun(handler)
+}
+
+type DeleteProjectHandler struct {
+	ctx  *gin.Context
+	req  *http_model.DeleteProjectRequest
+	resp *http_model.CommonResponse
+}
+
+func (c DeleteProjectHandler) getContext() *gin.Context { return c.ctx }
+func (c DeleteProjectHandler) getResponse() interface{} { return c.resp }
+func (c DeleteProjectHandler) getRequest() interface{} {
+	return c.req
+}
+func (c DeleteProjectHandler) run() {
+	data := http_model.DeleteProjectRequest{}
+	data = *c.req
+	err := db.DeleteProject(c.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[DeleteProjectHandler] call DeleteProject err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("DeleteProjectHandler fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功删除种草"
+}
+func (c DeleteProjectHandler) checkParam() error {
+	return nil
+}
+
+func newDeleteProjectHandler(ctx *gin.Context) *DeleteProjectHandler {
+	return &DeleteProjectHandler{
+		ctx:  ctx,
+		req:  http_model.NewDeleteProjectRequest(),
+		resp: http_model.NewDeleteProjectResponse(),
+	}
+}

+ 56 - 0
handler/delete_subaccount.go

@@ -0,0 +1,56 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapDeleteSubAccountHandler(ctx *gin.Context) {
+	handler := newDeleteSubAccountHandler(ctx)
+	BaseRun(handler)
+}
+
+type DeleteSubAccount struct {
+	ctx  *gin.Context
+	req  *http_model.DeleteSubAccountRequest
+	resp *http_model.CommonResponse
+}
+
+func (d DeleteSubAccount) getContext() *gin.Context {
+	return d.ctx
+}
+
+func (d DeleteSubAccount) getResponse() interface{} {
+	return d.resp
+}
+
+func (d DeleteSubAccount) getRequest() interface{} {
+	return d.req
+}
+
+func (d DeleteSubAccount) run() {
+	err := db.DeleteSubAccount(d.ctx, d.req)
+	if err != nil {
+		logrus.Errorf("[DeleteSubAccountHandler] call Delete err:%+v\n", err)
+		util.HandlerPackErrorResp(d.resp, consts.ErrorInternal, "")
+		logrus.Info("DeleteSubAccount fail,req:%+v", d.req)
+		return
+	}
+	d.resp.Message = "删除成功"
+}
+
+func (d DeleteSubAccount) checkParam() error {
+	return nil
+}
+
+func newDeleteSubAccountHandler(ctx *gin.Context) *DeleteSubAccount {
+	return &DeleteSubAccount{
+		ctx:  ctx,
+		req:  http_model.NewDeleteSubAccountRequest(),
+		resp: http_model.NewDeleteSubAccountResponse(),
+	}
+}

+ 56 - 0
handler/get_takegoods_data.go

@@ -0,0 +1,56 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapGetTakegoodsDataHandler(ctx *gin.Context) {
+	handler := newGetTakegoodsDataHandler(ctx)
+	BaseRun(handler)
+}
+
+func newGetTakegoodsDataHandler(ctx *gin.Context) *GetTakegoodsDataHandler {
+	return &GetTakegoodsDataHandler{
+		req:  http_model.NewGetTakegoodsDataRequest(),
+		resp: http_model.NewGetTakegoodsDataReponse(),
+		ctx:  ctx,
+	}
+}
+
+type GetTakegoodsDataHandler struct {
+	req  *http_model.GetTakegoodsDataRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *GetTakegoodsDataHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *GetTakegoodsDataHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *GetTakegoodsDataHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *GetTakegoodsDataHandler) run() {
+	data := http_model.GetTakegoodsDataRequest{}
+	data = *h.req
+	res, err := service.Workspace.GetTakegoodsInfo(h.ctx, data.EnterpriseId, data.DateRange)
+	if err != nil {
+		logrus.Errorf("[GetSelectionDetail] call Show err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		logrus.Info("GetSelectionDetail fail,req:%+v", h.req)
+		return
+	}
+	h.resp.Message = "成功查询带货量"
+	h.resp.Data = res
+}
+
+func (h *GetTakegoodsDataHandler) checkParam() error {
+	return nil
+}

+ 51 - 0
handler/getauthorization.go

@@ -0,0 +1,51 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapGetAuthorizationListHandler(ctx *gin.Context) {
+	handler := newGetAuthorizationHandler(ctx)
+	BaseRun(handler)
+}
+
+type GetAuthorizationHandler struct {
+	ctx  *gin.Context
+	req  *http_model.GetAuthorizationRequest
+	resp *http_model.CommonResponse
+}
+
+func (c GetAuthorizationHandler) getContext() *gin.Context { return c.ctx }
+func (c GetAuthorizationHandler) getResponse() interface{} { return c.resp }
+func (c GetAuthorizationHandler) getRequest() interface{} {
+	return c.req
+}
+func (c GetAuthorizationHandler) run() {
+	data := http_model.GetAuthorizationRequest{}
+	data = *c.req
+	res, err := db.GetAuthorization(c.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[GetAuthorizationHandler] call GetAuthorization err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("GetAuthorizationHandler fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功查询"
+	c.resp.Data = res
+}
+func (c GetAuthorizationHandler) checkParam() error {
+	return nil
+}
+
+func newGetAuthorizationHandler(ctx *gin.Context) *GetAuthorizationHandler {
+	return &GetAuthorizationHandler{
+		ctx:  ctx,
+		req:  http_model.NewGetAuthorizationRequest(),
+		resp: http_model.NewGetAuthorizationResponse(),
+	}
+}

+ 59 - 0
handler/job_detail.go

@@ -0,0 +1,59 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapJobDetailHandler(ctx *gin.Context) {
+	handler := newJobDetail(ctx)
+	BaseRun(handler)
+}
+
+type JobDetailHandler struct {
+	ctx  *gin.Context
+	req  *http_model.JobDetailRequest
+	resp *http_model.CommonResponse
+}
+
+func (s JobDetailHandler) getContext() *gin.Context {
+	return s.ctx
+}
+
+func (s JobDetailHandler) getResponse() interface{} {
+	return s.resp
+}
+
+func (s JobDetailHandler) getRequest() interface{} {
+	return s.req
+}
+
+func (s JobDetailHandler) run() {
+	//enterpriseID := middleware.GetSessionAuth(s.ctx).EnterpriseID
+
+	res, err := db.GetJobDetail(s.ctx, s.req)
+	if err != nil {
+		logrus.Errorf("[GetJobDetail] call Show err:%+v\n", err)
+		util.HandlerPackErrorResp(s.resp, consts.ErrorInternal, "")
+		logrus.Info("GetJobDetail fail,req:%+v", s.req)
+		return
+	}
+	s.resp.Message = "成功查询岗位"
+	s.resp.Data = res
+}
+
+func (s JobDetailHandler) checkParam() error {
+	return nil
+}
+
+func newJobDetail(ctx *gin.Context) *JobDetailHandler {
+	return &JobDetailHandler{
+		ctx:  ctx,
+		req:  http_model.NewJobDetailRequest(),
+		resp: http_model.NewJobDetailResponse(),
+	}
+}

+ 51 - 0
handler/kuaishouauthorization.go

@@ -0,0 +1,51 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapAuthkuaishouHandler(ctx *gin.Context) {
+	handler := newAuthkuaishouHandler(ctx)
+	BaseRun(handler)
+}
+
+type AuthkuaishouHandler struct {
+	ctx  *gin.Context
+	req  *http_model.AuthkuaishouRequest
+	resp *http_model.CommonResponse
+}
+
+func (c AuthkuaishouHandler) getContext() *gin.Context { return c.ctx }
+func (c AuthkuaishouHandler) getResponse() interface{} { return c.resp }
+func (c AuthkuaishouHandler) getRequest() interface{} {
+	return c.req
+}
+func (c AuthkuaishouHandler) run() {
+	data := http_model.AuthkuaishouRequest{}
+	data = *c.req
+	err := db.Authkuaishou(c.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[AuthkuaishouHandler] call Authkuaishou err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("AuthkuaishouHandler fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功创建授权账号"
+
+}
+func (c AuthkuaishouHandler) checkParam() error {
+	return nil
+}
+
+func newAuthkuaishouHandler(ctx *gin.Context) *AuthkuaishouHandler {
+	return &AuthkuaishouHandler{
+		ctx:  ctx,
+		req:  http_model.NewAuthkuaishouRequest(),
+		resp: http_model.NewAuthkuaishouResponse(),
+	}
+}

+ 55 - 0
handler/project_review.go

@@ -0,0 +1,55 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapProjectReviewNumberHandler(ctx *gin.Context) {
+	handler := newProjectReviewNumberHandler(ctx)
+	BaseRun(handler)
+}
+
+type ProjectReviewNumberHandler struct {
+	ctx  *gin.Context
+	req  *http_model.ProjectReviewNumberRequest
+	resp *http_model.CommonResponse
+}
+
+func (g ProjectReviewNumberHandler) getContext() *gin.Context {
+	return g.ctx
+}
+
+func (g ProjectReviewNumberHandler) getResponse() interface{} {
+	return g.resp
+}
+
+func (g ProjectReviewNumberHandler) getRequest() interface{} {
+	return g.req
+}
+
+func (g ProjectReviewNumberHandler) run() {
+	data, err := db.ProjectReviewNumber(g.ctx)
+	if err != nil {
+		logrus.WithContext(g.ctx).Errorf("[ProjectReviewNumberHandler] error ProjectReviewNumber, err:%+v", err)
+		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	g.resp.Data = data
+}
+
+func (g ProjectReviewNumberHandler) checkParam() error {
+	return nil
+}
+
+func newProjectReviewNumberHandler(ctx *gin.Context) *ProjectReviewNumberHandler {
+	return &ProjectReviewNumberHandler{
+		ctx:  ctx,
+		req:  http_model.NewProjectReviewNumberRequest(),
+		resp: http_model.NewProjectReviewNumberResponse(),
+	}
+}

+ 78 - 0
handler/send_code.go

@@ -0,0 +1,78 @@
+package handler
+
+import (
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	log "github.com/sirupsen/logrus"
+)
+
+// WrapSendCodeHandler
+// @BasePath /
+// SendCode godoc
+// @Summary sendCode 发送验证码
+// @Schemes
+// @Description 发送验证码,每次发送到邮箱
+// @Accept json
+// @Produce json
+// @Param req body http_model.SendCodeRequest true "发送验证码请求参数结构体"
+// @Success 200 {object} http_model.CommonResponse{data=http_model.SendCodeData} "发送验证码请求相应结构体"
+// @Router /sendCode [post]
+func WrapSendCodeHandler(ctx *gin.Context) {
+	handler := newSendCodeHandler(ctx)
+	BaseRun(handler)
+}
+
+func newSendCodeHandler(ctx *gin.Context) *SendCodeHandler {
+	return &SendCodeHandler{
+		req:  http_model.NewSendCodeRequest(),
+		resp: http_model.NewSendCodeResponse(),
+		ctx:  ctx,
+	}
+}
+
+type SendCodeHandler struct {
+	req  *http_model.SendCodeRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *SendCodeHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *SendCodeHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *SendCodeHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *SendCodeHandler) run() {
+	data := http_model.SendCodeRequest{}
+	data = *h.req
+	// 1. 生成验证码
+	vcode := service.SendCode.GetCode(h.ctx)
+	// 2. 发送验证码
+	//fmt.Println(vcode)
+	err := service.SendCode.SendCode(h.ctx, data.Phone, vcode)
+	if err != nil {
+		logrus.Errorf("[SendeCodeHandler] call SetSession err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		log.Info("SendeCode fail,req:%+v", h.req)
+		return
+	}
+	err = service.SendCode.SetSession(h.ctx, data.Phone, vcode)
+	if err != nil {
+		logrus.Errorf("[SendeCodeHandler] call SetSession err:%+v\n", err)
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		log.Info("SendeCode fail,req:%+v", h.req)
+		return
+	}
+	h.resp.Message = "验证码发送成功,请注意查收"
+}
+func (h *SendCodeHandler) checkParam() error {
+	return nil
+}

+ 51 - 0
handler/set_serveratio.go

@@ -0,0 +1,51 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapSetServeratioHandler(ctx *gin.Context) {
+	handler := newSetServeratioHandler(ctx)
+	BaseRun(handler)
+}
+
+type SetServeratioHandler struct {
+	ctx  *gin.Context
+	req  *http_model.SetServeratioRequest
+	resp *http_model.CommonResponse
+}
+
+func (c SetServeratioHandler) getContext() *gin.Context { return c.ctx }
+func (c SetServeratioHandler) getResponse() interface{} { return c.resp }
+func (c SetServeratioHandler) getRequest() interface{} {
+	return c.req
+}
+func (c SetServeratioHandler) run() {
+	data := http_model.SetServeratioRequest{}
+	data = *c.req
+	err := db.SetServeratio(c.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[SetServeratioHandler] call SetServeratio err:%+v\n", err)
+		util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
+		logrus.Info("SetServeratioHandler fail,req:%+v", c.req)
+		return
+	}
+	c.resp.Message = "成功设置服务费率"
+
+}
+func (c SetServeratioHandler) checkParam() error {
+	return nil
+}
+
+func newSetServeratioHandler(ctx *gin.Context) *SetServeratioHandler {
+	return &SetServeratioHandler{
+		ctx:  ctx,
+		req:  http_model.NewSetServeratioRequest(),
+		resp: http_model.NewSetServeratioResponse(),
+	}
+}

+ 60 - 0
handler/stop_subaccount.go

@@ -0,0 +1,60 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapStopSubAccountHandler(ctx *gin.Context) {
+	handler := newStopSubAccount(ctx)
+	BaseRun(handler)
+}
+
+type StopSubAccountHandler struct {
+	ctx  *gin.Context
+	req  *http_model.StopSubAccountRequest
+	resp *http_model.CommonResponse
+}
+
+func (s StopSubAccountHandler) getContext() *gin.Context {
+	return s.ctx
+}
+
+func (s StopSubAccountHandler) getResponse() interface{} {
+	return s.resp
+}
+
+func (s StopSubAccountHandler) getRequest() interface{} {
+	return s.req
+}
+
+func (s StopSubAccountHandler) run() {
+	data := http_model.StopSubAccountRequest{}
+	data = *s.req
+	res, err := db.StopSubAccount(s.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[StopSubAccountHandler] call StopSubAccount err:%+v\n", err)
+		util.HandlerPackErrorResp(s.resp, consts.ErrorInternal, "")
+		logrus.Info("StopSubAccountHandler fail,req:%+v", s.req)
+		return
+	}
+	s.resp.Message = "成功停用岗位"
+	s.resp.Data = res
+
+}
+
+func (s StopSubAccountHandler) checkParam() error {
+	return nil
+}
+
+func newStopSubAccount(ctx *gin.Context) *StopSubAccountHandler {
+	return &StopSubAccountHandler{
+		ctx:  ctx,
+		req:  http_model.NewStopSubAccountRequest(),
+		resp: http_model.NewStopSubAccountResponse(),
+	}
+}

+ 59 - 0
handler/sub_account_detail.go

@@ -0,0 +1,59 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapSubAccountDetailHandler(ctx *gin.Context) {
+	handler := newSubAccountDetail(ctx)
+	BaseRun(handler)
+}
+
+type SubAccountDetailHandler struct {
+	ctx  *gin.Context
+	req  *http_model.SubAccountDetailRequest
+	resp *http_model.CommonResponse
+}
+
+func (s SubAccountDetailHandler) getContext() *gin.Context {
+	return s.ctx
+}
+
+func (s SubAccountDetailHandler) getResponse() interface{} {
+	return s.resp
+}
+
+func (s SubAccountDetailHandler) getRequest() interface{} {
+	return s.req
+}
+
+func (s SubAccountDetailHandler) run() {
+	//enterpriseID := middleware.GetSessionAuth(s.ctx).EnterpriseID
+
+	res, err := db.GetSubAccountDetail(s.ctx, s.req)
+	if err != nil {
+		logrus.Errorf("[GetSubAccountDetail] call Show err:%+v\n", err)
+		util.HandlerPackErrorResp(s.resp, consts.ErrorInternal, "")
+		logrus.Info("GetSubAccountDetail fail,req:%+v", s.req)
+		return
+	}
+	s.resp.Data = res
+
+}
+
+func (s SubAccountDetailHandler) checkParam() error {
+	return nil
+}
+
+func newSubAccountDetail(ctx *gin.Context) *SubAccountDetailHandler {
+	return &SubAccountDetailHandler{
+		ctx:  ctx,
+		req:  http_model.NewSubAccountDetailRequest(),
+		resp: http_model.NewSubAccountDetailResponse(),
+	}
+}

+ 53 - 0
handler/update_job_info.go

@@ -0,0 +1,53 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func WrapEditJobHandler(ctx *gin.Context) {
+	handler := newUpdateJobHandler(ctx)
+	BaseRun(handler)
+}
+
+func newUpdateJobHandler(ctx *gin.Context) *UpdateJobInfoHandler {
+	return &UpdateJobInfoHandler{
+		req:  http_model.NewUpdateJobInfoRequest(),
+		resp: http_model.NewUpdateJobInfoResponse(),
+		ctx:  ctx,
+	}
+}
+
+type UpdateJobInfoHandler struct {
+	req  *http_model.UpdateJobInfoRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (u UpdateJobInfoHandler) getContext() *gin.Context { return u.ctx }
+func (u UpdateJobInfoHandler) getResponse() interface{} {
+	return u.resp
+}
+func (u UpdateJobInfoHandler) getRequest() interface{} {
+	return u.req
+}
+func (u UpdateJobInfoHandler) run() {
+	data := http_model.UpdateJobInfoRequest{}
+	data = *u.req
+	res, err := db.UpdateJobInfo(u.ctx, &data)
+	if err != nil {
+		logrus.Errorf("[UpdateJobInfoHandler] call UpdateJobInfo err:%+v\n", err)
+		util.HandlerPackErrorResp(u.resp, consts.ErrorInternal, "")
+		logrus.Info("UpdateJobInfoHandler fail,req:%+v", u.req)
+		return
+	}
+	u.resp.Message = "编辑创建岗位"
+	u.resp.Data = res
+}
+func (u UpdateJobInfoHandler) checkParam() error {
+	return nil
+}

+ 66 - 0
handler/update_subaccount_info.go

@@ -0,0 +1,66 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	log "github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapEditSubAccountHandler(ctx *gin.Context) {
+	handler := newUpdateSubAccountHandler(ctx)
+	BaseRun(handler)
+}
+
+func newUpdateSubAccountHandler(ctx *gin.Context) *UpdateSubAccountInfoHandler {
+	return &UpdateSubAccountInfoHandler{
+		req:  http_model.NewUpdateSubAccountInfoRequest(),
+		resp: http_model.NewUpdateSubAccountInfoResponse(),
+		ctx:  ctx,
+	}
+}
+
+type UpdateSubAccountInfoHandler struct {
+	req  *http_model.UpdateSubaccountInfoRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (u UpdateSubAccountInfoHandler) getContext() *gin.Context { return u.ctx }
+func (u UpdateSubAccountInfoHandler) getResponse() interface{} {
+	return u.resp
+}
+func (u UpdateSubAccountInfoHandler) getRequest() interface{} {
+	return u.req
+}
+func (u UpdateSubAccountInfoHandler) run() {
+	data := http_model.UpdateSubaccountInfoRequest{}
+	data = *u.req
+	message, err := service.Register.CodeJudge(u.ctx, data.PhoneNumber, data.Code)
+	if err != nil {
+		logrus.Errorf("[UpdateSubaccountInfoHandler] call UpdateSubaccountInfo err:%+v\n", err)
+		util.HandlerPackErrorResp(u.resp, consts.ErrorInternal, "")
+		logrus.Info("UpdateSubaccountInfoHandler fail,req:%+v", u.req)
+		return
+	}
+	if message == "" {
+		res, Error := db.UPdateSubaccountInfo(u.ctx, &data)
+		if Error != nil {
+			logrus.Errorf("[UpdateSubaccountInfoHandler] call UpdateSubaccountInfo err:%+v\n", err)
+			util.HandlerPackErrorResp(u.resp, consts.ErrorInternal, "")
+			log.Info("UpdateSubaccountInfo fail,req:%+v", u.req)
+			return
+		}
+		u.resp.Message = "编辑成功"
+		u.resp.Data = res
+	} else {
+		u.resp.Message = message
+	}
+}
+func (u UpdateSubAccountInfoHandler) checkParam() error {
+	return nil
+}

+ 23 - 0
model/gorm_model/authkuaishou.go

@@ -0,0 +1,23 @@
+package gorm_model
+
+import (
+	"time"
+)
+
+type YoungeeKuaishouUserinfo struct {
+	Id           int       `gorm:"column:id"`            //id
+	Code         string    `gorm:"column:code"`          //扫码后获得的临时票据
+	AccessToken  string    `gorm:"column:access_token"`  //调用API需要的参数
+	RefreshToken string    `gorm:"column:refresh_token"` //用于刷新access_token
+	NickName     string    `gorm:"column:nick_name"`     //快手昵称
+	CreateTime   time.Time `gorm:"column:create_time"`   //创建时间
+	Expired      int       `gorm:"column:expired"`       //是否可用
+	UpdateTime   time.Time `gorm:"column:update_time"`   //授权更新时间
+	Ksnumber     string    `gorm:"column:ksnumber"`      //快手号
+	Name         string    `gorm:"column:name"`          //所属人
+	PhoneNumber  string    `gorm:"column:phone_number"`  //所属人手机号
+}
+
+func (m *YoungeeKuaishouUserinfo) TableName() string {
+	return "youngee_m_kuaishou_userinfo"
+}

+ 18 - 0
model/gorm_model/job.go

@@ -0,0 +1,18 @@
+package gorm_model
+
+type YounggeeJob struct {
+	JobId                int    `gorm:"column:job_id"`                //岗位ID
+	JobName              string `gorm:"column:job_name"`              //岗位名称
+	JobDetail            string `gorm:"column:job_detail"`            //岗位描述
+	WorkshopPermission   string `gorm:"column:workshop_permission"`   //工作台权限
+	TaskcenterPermission string `gorm:"column:taskcenter_permission"` //任务中心权限
+	SectaskPermisson     string `gorm:"column:sectask_permisson"`     //商单中心权限
+	FinancialPermission  string `gorm:"column:financial_permission"`  //财务结算权限
+	UsercenterPermission string `gorm:"column:usercenter_permission"` //用户中心权限
+	OperatePermission    string `gorm:"column:operate_permission"`    //运营中心权限
+	AccountId            int64  `gorm:"column:account_id"`            //岗位创建者(用户)ID
+}
+
+func (m *YounggeeJob) TableName() string {
+	return "younggee_m_job"
+}

+ 9 - 0
model/gorm_model/serveratio.go

@@ -0,0 +1,9 @@
+package gorm_model
+
+type YounggeeServeRatio struct {
+	Ratio string `gorm:"column:ratio"`
+}
+
+func (m *YounggeeServeRatio) TableName() string {
+	return "younggee_serve_ratio"
+}

+ 17 - 0
model/gorm_model/subaccount.go

@@ -0,0 +1,17 @@
+package gorm_model
+
+type YounggeeSubAccount struct {
+	SubAccountId   int    `gorm:"column:sub_account_id"`   //子账号ID
+	PhoneNumber    string `gorm:"column:phone_number"`     //电话号
+	SubAccountName string `gorm:"column:sub_account_name"` //子账号名称
+	JobId          int    `gorm:"column:job_id"`           //岗位ID
+	EnterpriseId   string `gorm:"column:enterprise_id"`    //企业ID
+	AccountStatus  int    `gorm:"column:account_status"`   //帐号状态1为正常,2为已停用
+	SubAccountType int    `gorm:"column:sub_account_type"` //子账号类型,1为商家端子账号,2为管理后台子账号
+	SuperAdminId   int64  `gorm:"column:super_admin_id"`   //管理后台子账号创建者ID
+	UserId         int64  `gorm:"column:user_id"`          //用户ID
+}
+
+func (m *YounggeeSubAccount) TableName() string {
+	return "younggee_sub_account"
+}

+ 15 - 0
model/http_model/Authkuaishou.go

@@ -0,0 +1,15 @@
+package http_model
+
+type AuthkuaishouRequest struct {
+	KSNumber    string `json:"ksnumber"`     //快手号
+	Name        string `json:"name"`         //所属人
+	PhoneNumber string `json:"phone_number"` //绑定手机号
+}
+
+type AuthkuaishouResponse struct {
+}
+
+func NewAuthkuaishouRequest() *AuthkuaishouRequest { return new(AuthkuaishouRequest) }
+func NewAuthkuaishouResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 28 - 0
model/http_model/GetTakegoodsDataRequest.go

@@ -0,0 +1,28 @@
+package http_model
+
+type GetTakegoodsDataRequest struct {
+	EnterpriseId string `json:"enterprise_id"`
+	DateRange    string `json:"days"`
+}
+
+type TakegoodsData struct {
+	Pay                float64   `json:"pay"`
+	PayList            []float64 `json:"pay_list"`
+	Finish             float64   `json:"finish"`
+	FinishList         []float64 `json:"finish_list"`
+	Commission         float64   `json:"commission"`
+	CommissionList     []float64 `json:"commission_list"`
+	Order              int64     `json:"order"`
+	OrderList          []int64   `json:"order_list"`
+	Person             int64     `json:"person"`
+	PersonList         []int64   `json:"person_list"`
+	CommissionRate     float64   `json:"commissionRate"`
+	CommissionRateList []float64 `json:"commissionRate_list"`
+}
+
+func NewGetTakegoodsDataRequest() *GetTakegoodsDataRequest { return new(GetTakegoodsDataRequest) }
+func NewGetTakegoodsDataReponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(TakegoodsData)
+	return resp
+}

+ 32 - 0
model/http_model/SubAccountDetail.go

@@ -0,0 +1,32 @@
+package http_model
+
+import "youngee_m_api/model/gorm_model"
+
+type SubAccountDetailRequest struct {
+	PageSize       int     `json:"page_size"`
+	PageNum        int     `json:"page_num"`
+	JobId          *int    `json:"job_id,omitempty"`           // 可选的岗位类型
+	AccountStatus  *int    `json:"account_status,omitempty"`   // 可选的账号状态
+	PhoneNumber    *string `json:"phone_number,omitempty"`     // 可选的手机号
+	SubAccountName *string `json:"sub_account_name,omitempty"` // 可选的账号名称
+}
+
+type SubAccountDetailResponse struct {
+	SubAccountInfo gorm_model.YounggeeSubAccount //子账号详情
+	Creater        string                        `json:"creater"`
+}
+
+type SubAccountData struct {
+	SubAccountInfo []*SubAccountDetailResponse `json:"SubAccountData"`
+	Total          string                      `json:"total"`
+}
+
+func NewSubAccountDetailRequest() *SubAccountDetailRequest {
+	return new(SubAccountDetailRequest)
+}
+
+func NewSubAccountDetailResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(SubAccountDetailResponse)
+	return resp
+}

+ 23 - 0
model/http_model/create_job.go

@@ -0,0 +1,23 @@
+package http_model
+
+type CreateJobRequest struct {
+	JobName              string `json:"job_name"`
+	JobDetail            string `json:"job_detail"`
+	WorkspacePermission  string `json:"workspace_permission"`
+	TaskcenterPermission string `json:"taskcenter_permission"`
+	SectaskPermission    string `json:"sectask_permission"`
+	FinancialPermission  string `json:"financial_permission"`
+	UsercenterPermission string `json:"usercenter_permission"`
+	OperatePermission    string `json:"operate_permission"`
+	AccountID            int64  `json:"account_id"`
+}
+
+type CreateJobResponse struct {
+	JobName string `json:"job_name"`
+	JobID   int    `json:"job_id"`
+}
+
+func NewCreateJobRequest() *CreateJobRequest { return new(CreateJobRequest) }
+func NewCreateJobResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 24 - 0
model/http_model/create_sub_account.go

@@ -0,0 +1,24 @@
+package http_model
+
+type CreateSubAccountRequest struct {
+	SubAccountName string `json:"sub_account_name"`
+	Job            int    `json:"job_id"`
+	PhoneNumber    string `json:"phone_number"`
+	Code           string `json:"code"`
+	AccountID      int64  `json:"account_id"`
+}
+
+type YounggeeSubAccountsRes struct {
+	PhoneNumber    string `json:"phone_number"`
+	SubAccountName string `json:"sub_account_name"`
+	JobID          int    `json:"job_id"`
+}
+
+func NewCreateSubAccountRequest() *CreateSubAccountRequest {
+	return new(CreateSubAccountRequest)
+}
+
+func NewCreateSubAccountResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 10 - 0
model/http_model/delete_job.go

@@ -0,0 +1,10 @@
+package http_model
+
+type DeleteJobRequest struct {
+	JobId int `json:"job_id"`
+}
+
+func NewDeleteJobRequest() *DeleteJobRequest { return new(DeleteJobRequest) }
+func NewDeleteJobResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 12 - 0
model/http_model/delete_ks.go

@@ -0,0 +1,12 @@
+package http_model
+
+type DeleteKsauthorizationRequest struct {
+	KSNumber string `json:"ksnumber"`
+}
+
+func NewDeleteKsauthorizationRequest() *DeleteKsauthorizationRequest {
+	return new(DeleteKsauthorizationRequest)
+}
+func NewDeleteKsauthorizationResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 12 - 0
model/http_model/delete_project.go

@@ -0,0 +1,12 @@
+package http_model
+
+type DeleteProjectRequest struct {
+	ProjectID string `json:"project_id"`
+}
+
+func NewDeleteProjectRequest() *DeleteProjectRequest {
+	return new(DeleteProjectRequest)
+}
+func NewDeleteProjectResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 10 - 0
model/http_model/delete_subaccount.go

@@ -0,0 +1,10 @@
+package http_model
+
+type DeleteSubAccountRequest struct {
+	SubAccountId int `json:"sub_account_id"`
+}
+
+func NewDeleteSubAccountRequest() *DeleteSubAccountRequest { return new(DeleteSubAccountRequest) }
+func NewDeleteSubAccountResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 25 - 0
model/http_model/getksauthorization.go

@@ -0,0 +1,25 @@
+package http_model
+
+type GetAuthorizationRequest struct {
+	PageSize int `json:"page_size"`
+	PageNum  int `json:"page_num"`
+}
+
+type GetAuthorizationResponse struct {
+	Nickname    string `json:"nick_name"`
+	KSNumber    string `json:"ksnumber"`
+	Name        string `json:"name"`
+	Phonenumber string `json:"phone_number"`
+	UPdatetime  string `json:"update_time"`
+	Expired     int    `json:"expired"`
+}
+
+func NewGetAuthorizationRequest() *GetAuthorizationRequest {
+	return new(GetAuthorizationRequest)
+}
+
+func NewGetAuthorizationResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(GetAuthorizationResponse)
+	return resp
+}

+ 29 - 0
model/http_model/job_detail.go

@@ -0,0 +1,29 @@
+package http_model
+
+import "youngee_m_api/model/gorm_model"
+
+type JobDetailRequest struct {
+	PageSize  int   `json:"page_size"`
+	PageNum   int   `json:"page_num"`
+	AccountID int64 `json:"account_id"`
+}
+
+type JobDetailResponse struct {
+	JobInfo gorm_model.YounggeeJob //岗位详情
+	Creater string                 `json:"creater"`
+}
+
+type JobData struct {
+	Job   []*JobDetailResponse `json:"jobdata"`
+	Total string               `json:"total"`
+}
+
+func NewJobDetailRequest() *JobDetailRequest {
+	return new(JobDetailRequest)
+}
+
+func NewJobDetailResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(JobDetailResponse)
+	return resp
+}

+ 17 - 0
model/http_model/projectreviewnumberrequest.go

@@ -0,0 +1,17 @@
+package http_model
+
+type ProjectReviewNumberRequest struct {
+}
+
+type Reviewnums struct {
+	ReviewNums int64 `json:"review_nums"` // 选品待审核数量
+}
+
+func NewProjectReviewNumberRequest() *ProjectReviewNumberRequest {
+	return new(ProjectReviewNumberRequest)
+}
+func NewProjectReviewNumberResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(ReviewNums)
+	return resp
+}

+ 19 - 0
model/http_model/send_code.go

@@ -0,0 +1,19 @@
+package http_model
+
+// SendCodeRequest 发送验证码请求的格式
+type SendCodeRequest struct {
+	Phone string `json:"phone"`
+}
+
+// SendCodeData 发送验证码请求返回的数据
+type SendCodeData struct {
+}
+
+func NewSendCodeRequest() *SendCodeRequest {
+	return new(SendCodeRequest)
+}
+func NewSendCodeResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(SendCodeData)
+	return resp
+}

+ 13 - 0
model/http_model/set_serveratio.go

@@ -0,0 +1,13 @@
+package http_model
+
+type SetServeratioRequest struct {
+	Ratio string `json:"ratio"`
+}
+
+type SetServeratioResponse struct {
+}
+
+func NewSetServeratioRequest() *SetServeratioRequest { return new(SetServeratioRequest) }
+func NewSetServeratioResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 15 - 0
model/http_model/stop_subaccount.go

@@ -0,0 +1,15 @@
+package http_model
+
+type StopSubAccountRequest struct {
+	SubAccountId int `json:"sub_account_id"`
+}
+
+type StopSubAccountResponse struct {
+	SubAccountID   int    `json:"sub_account_id"`
+	SubAccountName string `json:"sub_account_name"`
+}
+
+func NewStopSubAccountRequest() *StopSubAccountRequest { return new(StopSubAccountRequest) }
+func NewStopSubAccountResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 24 - 0
model/http_model/update_job_info.go

@@ -0,0 +1,24 @@
+package http_model
+
+type UpdateJobInfoRequest struct {
+	JobName              string `json:"job_name"`
+	JobDetail            string `json:"job_detail"`
+	WorkspacePermission  string `json:"workspace_permission"`
+	TaskcenterPermission string `json:"taskcenter_permission"`
+	SectaskPermission    string `json:"sectask_permission"`
+	FinancialPermission  string `json:"financial_permission"`
+	UsercenterPermission string `json:"usercenter_permission"`
+	OperatePermission    string `json:"operate_permission"`
+	AccountID            int64  `json:"account_id"`
+	JobID                int    `json:"job_id"`
+}
+
+type UpdateJobInfoResponse struct {
+	JobName string `json:"job_name"`
+	JobID   int    `json:"job_id"`
+}
+
+func NewUpdateJobInfoRequest() *UpdateJobInfoRequest { return new(UpdateJobInfoRequest) }
+func NewUpdateJobInfoResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 18 - 0
model/http_model/update_subaccount_info.go

@@ -0,0 +1,18 @@
+package http_model
+
+type UpdateSubaccountInfoRequest struct {
+	SubAccountName string `json:"sub_account_name"`
+	Job            int    `json:"job_id"`
+	PhoneNumber    string `json:"phone_number"`
+	Code           string `json:"code"`
+	SubAccountID   int    `json:"sub_account_id"`
+}
+
+func NewUpdateSubAccountInfoRequest() *UpdateSubaccountInfoRequest {
+	return new(UpdateSubaccountInfoRequest)
+}
+
+func NewUpdateSubAccountInfoResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 29 - 1
route/init.go

@@ -36,12 +36,14 @@ func InitRoute(r *gin.Engine) {
 			c.JSON(200, resp)
 		})
 		m.GET("/product/getEnterpriseIds", handler.WrapGetEnterpriseIdsHandler)                    // 获取所有企业用户id
-		m.POST("/product/list", handler.WrapFullProjectListHandler)                                // 查询项目(全流程)列表
+		m.POST("/project/list", handler.WrapFullProjectListHandler)                                // 查询项目(全流程)列表
 		m.POST("/project/show", handler.WrapShowProjectHandler)                                    // 项目展示查询
 		m.POST("/project/handle", handler.WrapProjectHandleHandler)                                // 项目线索处理
 		m.POST("/product/findall", handler.WrapFindEnterpriseAllProductHandler)                    // 企业用户详情所有产品
 		m.POST("/product/findAllProduct", handler.WrapFindAllProductHandler)                       // 查找企业绑定的所有产品
+		m.GET("/project/reviewnumber", handler.WrapProjectReviewNumberHandler)                     // 查询种草项目待审核的数量
 		m.POST("/project/create", handler.WrapCreateProjectHandler)                                // 创建项目
+		m.POST("/project/delete", handler.WrapDeleteProjectHandler)                                //删除项目
 		m.POST("/product/create", handler.WrapCreateProductHandler)                                // 创建产品
 		m.POST("/product/find", handler.WrapFindProductHandler)                                    // 查询产品信息
 		m.POST("/product/findKuaishou", handler.WrapFindKuaishouProductHandler)                    // 查询快手产品信息
@@ -213,4 +215,30 @@ func InitRoute(r *gin.Engine) {
 		s.POST("/task/logistics/update", handler.WrapUpdateSecTaskLogisticsHandler) // 修改物流信息
 		s.POST("/task/settle", handler.WrapSettleSecTaskHandler)                    // 结算
 	}
+
+	//工作台相关接口
+	w := r.Group("youngee/m/workspace")
+	{
+		w.Use(middleware.LoginAuthMiddleware)
+		w.POST("/takegoods", handler.WrapGetTakegoodsDataHandler) //查询时间内带货量
+	}
+	//运营中心相关接口
+	n := r.Group("/youngee/run")
+	{
+		n.Use(middleware.LoginAuthMiddleware)
+		n.POST("/sendCode", handler.WrapSendCodeHandler)                         //发送验证码
+		n.POST("/addNewSubAccount", handler.WrapCreateSubAccountHandler)         //创建子账号
+		n.POST("/editsubaccount", handler.WrapEditSubAccountHandler)             //编辑子账号
+		n.POST("/addnewjob", handler.WrapCreateJobHandler)                       //创建岗位
+		n.POST("/editjob", handler.WrapEditJobHandler)                           //编辑岗位
+		n.POST("/subaccountdetail", handler.WrapSubAccountDetailHandler)         //查询子账号列表
+		n.POST("/stopsubaccount", handler.WrapStopSubAccountHandler)             //停用子账号
+		n.POST("/deletesubaccount", handler.WrapDeleteSubAccountHandler)         //删除子账号
+		n.POST("/deletejob", handler.WrapDeleteJobHandler)                       //删除岗位
+		n.POST("/jobdetail", handler.WrapJobDetailHandler)                       //岗位列表
+		n.POST("/addauthorization", handler.WrapAuthkuaishouHandler)             //新增快手授权
+		n.POST("/KSauthorizationlist", handler.WrapGetAuthorizationListHandler)  //查询授权结果
+		n.POST("/deleteksauthorization", handler.WrapDeleteauthorizationHandler) //删除授权
+		n.POST("/serveratio", handler.WrapSetServeratioHandler)                  //设置服务费率
+	}
 }

+ 65 - 0
service/register.go

@@ -0,0 +1,65 @@
+package service
+
+import (
+	"context"
+	"fmt"
+	"time"
+	"youngee_m_api/consts"
+	"youngee_m_api/db"
+	"youngee_m_api/redis"
+)
+
+var Register *register
+
+type register struct {
+	sessionTTL time.Duration
+}
+
+func (r *register) CodeJudge(ctx context.Context, phone string, code string) (string, error) {
+	vcode, err := r.getSession(ctx, phone)
+	if err != nil {
+		return "", err
+	}
+	// 校验验证码
+	if *vcode != code {
+		return "验证码有误", nil
+	}
+	return "", nil
+}
+func (r *register) AuthRegister(ctx context.Context, phone string, code string) (string, error) {
+	// 获取验证码
+	vcode, err := r.getSession(ctx, phone)
+	if err != nil {
+		return "", err
+	}
+	// 校验验证码
+	fmt.Println("*vcode", *vcode)
+	if *vcode != code {
+		return "验证码有误", nil
+	}
+	// 获取用户信息
+	user, err := db.GetUserByPhoneNumber(ctx, phone)
+	if err != nil {
+		return "", err
+	}
+	// 检查用户是否已存在
+	if user != nil {
+		return "手机号已存在", nil
+	}
+	return "", nil
+}
+
+func (r *register) getSession(ctx context.Context, phone string) (*string, error) {
+	value, err := redis.Get(ctx, r.getRedisKey(phone))
+	if err != nil {
+		if err == consts.RedisNil {
+			return nil, fmt.Errorf("not found in redis,phone:%+v", phone)
+		}
+		return nil, err
+	}
+	return &value, nil
+}
+
+func (r *register) getRedisKey(key string) string {
+	return fmt.Sprintf("%s%s", consts.SessionRedisPrefix, key)
+}

+ 152 - 0
service/send_code.go

@@ -0,0 +1,152 @@
+package service
+
+import (
+	// "apig-sdk/go/core"
+	"bytes"
+	"context"
+	"crypto/sha256"
+	"crypto/tls"
+	"encoding/base64"
+	"fmt"
+	"io/ioutil"
+	"math/rand"
+	"net/http"
+	"net/url"
+	"strings"
+	"time"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/system_model"
+	"youngee_m_api/redis"
+
+	uuid "github.com/satori/go.uuid"
+)
+
+var SendCode *sendCode
+
+// 无需修改,用于格式化鉴权头域,给"X-WSSE"参数赋值
+const WSSE_HEADER_FORMAT = "UsernameToken Username=\"%s\",PasswordDigest=\"%s\",Nonce=\"%s\",Created=\"%s\""
+
+// 无需修改,用于格式化鉴权头域,给"Authorization"参数赋值
+const AUTH_HEADER_VALUE = "WSSE realm=\"SDP\",profile=\"UsernameToken\",type=\"Appkey\""
+
+func SendCodeInit(config *system_model.Session) {
+	sendCode := new(sendCode)
+	sendCode.sessionTTL = time.Duration(config.TTL) * time.Minute
+	SendCode = sendCode
+}
+
+type sendCode struct {
+	sessionTTL time.Duration
+}
+
+func (s *sendCode) GetCode(ctx context.Context) string {
+	rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
+	vcode := fmt.Sprintf("%06v", rnd.Int31n(1000000))
+	return vcode
+}
+
+func (s *sendCode) SetSession(ctx context.Context, phone string, vcode string) error {
+	fmt.Println("set session phone:", phone, vcode, s.sessionTTL)
+	err := redis.Set(ctx, s.getRedisKey(phone), vcode, s.sessionTTL)
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func (s *sendCode) getRedisKey(key string) string {
+	return fmt.Sprintf("%s%s", consts.SessionRedisPrefix, key)
+}
+
+func (s *sendCode) SendCode(ctx context.Context, phone string, vcode string) error {
+	//必填,请参考"开发准备"获取如下数据,替换为实际值
+	apiAddress := "https://smsapi.cn-south-1.myhuaweicloud.com:443/sms/batchSendSms/v1" //APP接入地址(在控制台"应用管理"页面获取)+接口访问URI
+	appKey := "NETTvTJJie9ax03v9K5T4DFB9EV6"                                            //APP_Key
+	appSecret := "txi9kXIrxW0dVNMyAulrJf7XFNP7"                                         //APP_Secret
+	sender := "8823022707732"                                                           //国内短信签名通道号或国际/港澳台短信通道号
+	templateId := "7103cdd480d14d0aa8c68954a7dbeb6e"                                    //模板ID
+
+	//条件必填,国内短信关注,当templateId指定的模板类型为通用模板时生效且必填,必须是已审核通过的,与模板类型一致的签名名称
+	//国际/港澳台短信不用关注该参数
+	signature := "样叽" //签名名称
+
+	//必填,全局号码格式(包含国家码),示例:+86151****6789,多个号码之间用英文逗号分隔
+	receiver := "+86" + phone //短信接收人号码
+
+	//选填,短信状态报告接收地址,推荐使用域名,为空或者不填表示不接收状态报告
+	statusCallBack := ""
+
+	/*
+	 * 选填,使用无变量模板时请赋空值 string templateParas = "";
+	 * 单变量模板示例:模板内容为"您的验证码是${1}"时,templateParas可填写为"[\"369751\"]"
+	 * 双变量模板示例:模板内容为"您有${1}件快递请到${2}领取"时,templateParas可填写为"[\"3\",\"人民公园正门\"]"
+	 * 模板中的每个变量都必须赋值,且取值不能为空
+	 * 查看更多模板和变量规范:产品介绍>模板和变量规范
+	 */
+	templateParas := "[\"" + vcode + "\"]" //模板变量,此处以单变量验证码短信为例,请客户自行生成6位验证码,并定义为字符串类型,以杜绝首位0丢失的问题(例如:002569变成了2569)。
+	// templateParas := "[\"12345678\"]" //模板变量,此处以单变量验证码短信为例,请客户自行生成6位验证码,并定义为字符串类型,以杜绝首位0丢失的问题(例如:002569变成了2569)。
+
+	body := buildRequestBody(sender, receiver, templateId, templateParas, statusCallBack, signature)
+	headers := make(map[string]string)
+	headers["Content-Type"] = "application/x-www-form-urlencoded"
+	headers["Authorization"] = AUTH_HEADER_VALUE
+	headers["X-WSSE"] = buildWsseHeader(appKey, appSecret)
+	resp, err := post(apiAddress, []byte(body), headers)
+	if err != nil {
+		return err
+	}
+	fmt.Println(resp)
+	return nil
+}
+
+/**
+* sender,receiver,templateId不能为空
+ */
+func buildRequestBody(sender, receiver, templateId, templateParas, statusCallBack, signature string) string {
+	param := "from=" + url.QueryEscape(sender) + "&to=" + url.QueryEscape(receiver) + "&templateId=" + url.QueryEscape(templateId)
+	if templateParas != "" {
+		param += "&templateParas=" + url.QueryEscape(templateParas)
+	}
+	if statusCallBack != "" {
+		param += "&statusCallback=" + url.QueryEscape(statusCallBack)
+	}
+	if signature != "" {
+		param += "&signature=" + url.QueryEscape(signature)
+	}
+	return param
+}
+
+func post(url string, param []byte, headers map[string]string) (string, error) {
+	tr := &http.Transport{
+		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
+	}
+	client := &http.Client{Transport: tr}
+
+	req, err := http.NewRequest("POST", url, bytes.NewBuffer(param))
+	if err != nil {
+		return "", err
+	}
+	for key, header := range headers {
+		req.Header.Set(key, header)
+	}
+
+	resp, err := client.Do(req)
+	defer resp.Body.Close()
+	body, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		return "", err
+	}
+	return string(body), nil
+}
+
+func buildWsseHeader(appKey, appSecret string) string {
+	var cTime = time.Now().Format("2006-01-02T15:04:05Z")
+	var nonce = uuid.NewV4().String()
+	nonce = strings.ReplaceAll(nonce, "-", "")
+
+	h := sha256.New()
+	h.Write([]byte(nonce + cTime + appSecret))
+	passwordDigestBase64Str := base64.StdEncoding.EncodeToString(h.Sum(nil))
+
+	return fmt.Sprintf(WSSE_HEADER_FORMAT, appKey, passwordDigestBase64Str, nonce, cTime)
+}

+ 146 - 0
service/workspace.go

@@ -0,0 +1,146 @@
+package service
+
+import (
+	"context"
+	"errors"
+	"github.com/issue9/conv"
+	"math"
+	"time"
+	"youngee_m_api/db"
+	"youngee_m_api/model/http_model"
+)
+
+var Workspace *workspace
+
+type workspace struct{}
+
+func (*workspace) GetTakegoodsInfo(ctx context.Context, enterpriseId string, dateRange string) (*http_model.TakegoodsData, error) {
+	takegoodsInfo := http_model.TakegoodsData{}
+	var dates []time.Time
+	switch dateRange {
+	case "7days":
+		dates = getLastNDays(7)
+	case "30days":
+		dates = getLastNDays(30)
+	case "90days":
+		dates = getLastNDays(90)
+	case "monthly":
+		dates = getCurrentMonthDates()
+	default:
+		return nil, errors.New("unsupported date range")
+	}
+
+	takegoodsInfo = calcTakegoodsInfo(ctx, dates, enterpriseId)
+	if hasNaN(&takegoodsInfo) {
+		return nil, errors.New("calculation resulted in NaN")
+	}
+
+	return &takegoodsInfo, nil
+}
+
+func hasNaN(data *http_model.TakegoodsData) bool {
+	if math.IsNaN(data.CommissionRate) {
+		return true
+	}
+	return false
+}
+func getLastNDays(n int) []time.Time {
+	var dates []time.Time
+	today := time.Now()
+	for i := 0; i < n; i++ {
+		date := today.AddDate(0, 0, -i)
+		dates = append(dates, date)
+	}
+	return dates
+}
+
+func getCurrentMonthDates() []time.Time {
+	var dates []time.Time
+	today := time.Now()
+	year, month, _ := today.Date()
+	location := today.Location()
+
+	firstOfMonth := time.Date(year, month, 1, 0, 0, 0, 0, location)
+	nextMonth := firstOfMonth.AddDate(0, 1, 0)
+
+	for current := firstOfMonth; current.Before(nextMonth); current = current.AddDate(0, 0, 1) {
+		dates = append(dates, current)
+	}
+	return dates
+}
+
+func calcTakegoodsInfo(ctx context.Context, dates []time.Time, enterpriseId string) http_model.TakegoodsData {
+	var pay, finish, commission, commissionRate float64
+	var order, person int64
+	var payList, finishList, commissionList, commissionRateList []float64
+	var orderList, personList []int64
+	var count int64
+	for _, date := range dates {
+		enterprises, _ := db.GetSelectionInfoListOfDay(ctx, enterpriseId, date)
+		if enterprises != nil {
+			var currentPay float64
+			var currentFinish float64
+			var currentCommission float64
+			var currentCommissionRate float64
+			var currrentseccommissionrate float64
+			var currentOrder int64
+			var currentPerson int64
+			var currentsecperson int64
+
+			for _, enterprise := range enterprises {
+				// 带货数据
+				currentPay += conv.MustFloat64(enterprise.EstimatedCost, 0.0)
+				currentFinish += conv.MustFloat64(enterprise.SettlementAmount, 0.0)
+				currentCommission += conv.MustFloat64(enterprise.EstimatedCost, 0.0) * conv.MustFloat64(enterprise.CommissionRate, 0.0)
+				currentOrder += conv.MustInt64(enterprise.SampleNum, 0) - conv.MustInt64(enterprise.RemainNum, 0)
+				// 出单数量
+				currentsecperson, _ = db.CountBySelectionId(ctx, enterprise.SelectionID) //当天当前任务达人数
+				if currentsecperson > 0 {
+					currrentseccommissionrate = conv.MustFloat64(enterprise.SettlementAmount, 0.0) / float64(currentsecperson) //该任务佣金率
+				} else {
+					currrentseccommissionrate = 0.0
+				}
+				currentPerson += currentsecperson
+				currentCommissionRate += currrentseccommissionrate
+				count++
+			}
+			// 带货数据
+
+			pay += currentPay
+			payList = append(payList, currentPay)
+			finish += currentFinish
+			finishList = append(finishList, currentFinish)
+			commission += currentCommission
+			commissionList = append(commissionList, currentCommission)
+			order += currentOrder
+			orderList = append(orderList, currentOrder)
+			// 出单数量
+			person += currentPerson
+			personList = append(personList, person)
+			commissionRate += currentCommissionRate
+			commissionRateList = append(commissionRateList, currentCommissionRate)
+
+		}
+		if count > 0 {
+			commissionRate = commissionRate / float64(count)
+		} else {
+			commissionRate = 0.0
+		}
+
+	}
+	res := http_model.TakegoodsData{
+		Pay:                pay,
+		PayList:            payList,
+		Finish:             finish,
+		FinishList:         finishList,
+		Commission:         commission,
+		CommissionList:     commissionList,
+		Order:              order,
+		OrderList:          orderList,
+		Person:             person,
+		PersonList:         personList,
+		CommissionRate:     commissionRate,
+		CommissionRateList: commissionRateList,
+	}
+	return res
+}