Ver código fonte

我的样叽页面

yuliang1112 2 anos atrás
pai
commit
48516ab230

+ 31 - 0
consts/product.go

@@ -0,0 +1,31 @@
+package consts
+
+var projectTypeMap = map[int64]string{
+	1:  "3C及电器",
+	2:  "食品饮料",
+	3:  "服装配饰",
+	4:  "医疗",
+	5:  "房地产",
+	6:  "家居建材",
+	7:  "教育培训",
+	8:  "出行旅游",
+	9:  "游戏",
+	10: "互联网平台",
+	11: "汽车",
+	12: "文体娱乐",
+	13: "影视传媒",
+	14: "线下店铺",
+	15: "软件服务",
+	16: "美妆",
+	17: "母婴宠物",
+	18: "日化",
+	19: "其他",
+}
+
+func GetProjectTypes(projectType int64) string {
+	toast, contain := projectTypeMap[projectType]
+	if contain {
+		return toast
+	}
+	return "未知"
+}

+ 21 - 0
db/enterprise.go

@@ -3,6 +3,7 @@ package db
 import (
 	"context"
 	"youngee_b_api/model/gorm_model"
+	"youngee_b_api/model/http_model"
 
 	"gorm.io/gorm"
 )
@@ -45,3 +46,23 @@ func GetEnterpriseByEnterpriseID(ctx context.Context, EnterpriseID int64) (*gorm
 	}
 	return &enterprise, nil
 }
+
+// GetEnterpriseBalance 获取企业可用余额等信息
+func GetEnterpriseBalance(ctx context.Context, EnterpriseID int64) (*http_model.EnterpriseBalanceData, error) {
+	db := GetReadDB(ctx)
+	enterprise := gorm_model.Enterprise{}
+	err := db.Where("enterprise_id = ?", EnterpriseID).First(&enterprise).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	res := &http_model.EnterpriseBalanceData{
+		Balance:          enterprise.Balance,
+		FrozenBalance:    enterprise.FrozenBalance,
+		AvailableBalance: enterprise.AvailableBalance,
+	}
+	return res, nil
+}

+ 2 - 2
db/project.go

@@ -49,7 +49,7 @@ func GetFullProjectList(ctx context.Context, enterpriseID int64, pageSize, pageN
 		if !util.IsBlank(value) && tag != "updated_at" && tag != "project_name" {
 			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
 		}
-		if tag == "updated_at" {
+		if tag == "updated_at" && value.Interface() != "0" {
 			db = db.Where(fmt.Sprintf("%s > ?", tag), value.Interface())
 		}
 		if tag == "project_name" && !util.IsBlank(value) {
@@ -117,7 +117,7 @@ func GetProjectTaskList(ctx context.Context, projectID string, pageSize, pageNum
 		field := conditionType2.Field(i)
 		tag := field.Tag.Get("condition")
 		value := conditionValue2.FieldByName(field.Name)
-		if !util.IsBlank(value) && tag == "platform_nickname" {
+		if !util.IsBlank(value) && tag == "platform_nickname" { // input:1		database:1,2,3    string
 			db1 = db1.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
 		}
 	}

+ 60 - 0
handler/enterprise_balance.go

@@ -0,0 +1,60 @@
+package handler
+
+import (
+	"youngee_b_api/consts"
+	"youngee_b_api/db"
+	"youngee_b_api/middleware"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/util"
+
+	"github.com/sirupsen/logrus"
+
+	"github.com/gin-gonic/gin"
+)
+
+func WrapEnterpriseBalanceHandler(ctx *gin.Context) {
+	handler := newEnterpriseBalanceHandler(ctx)
+	baseRun(handler)
+}
+
+func newEnterpriseBalanceHandler(ctx *gin.Context) *EnterpriseBalanceHandler {
+	return &EnterpriseBalanceHandler{
+		req:  http_model.NewEnterpriseBalanceRequest(),
+		resp: http_model.NewEnterpriseBalanceResponse(),
+		ctx:  ctx,
+	}
+}
+
+type EnterpriseBalanceHandler struct {
+	req  *http_model.EnterpriseBalanceRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (e *EnterpriseBalanceHandler) getContext() *gin.Context {
+	return e.ctx
+}
+
+func (e *EnterpriseBalanceHandler) getResponse() interface{} {
+	return e.resp
+}
+
+func (e *EnterpriseBalanceHandler) getRequest() interface{} {
+	return e.req
+}
+
+func (e *EnterpriseBalanceHandler) run() {
+	enterpriseID := middleware.GetSessionAuth(e.ctx).EnterpriseID
+	logrus.Println(enterpriseID)
+	data, err := db.GetEnterpriseBalance(e.ctx, enterpriseID)
+	if err != nil {
+		logrus.WithContext(e.ctx).Errorf("[FullProjectListHandler] error GetFullProjectList, err:%+v", err)
+		util.HandlerPackErrorResp(e.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	e.resp.Data = data
+}
+
+func (e *EnterpriseBalanceHandler) checkParam() error {
+	return nil
+}

+ 17 - 15
model/gorm_model/project.go

@@ -6,23 +6,25 @@ import (
 )
 
 type ProjectInfo struct {
-	ProjectID       int64       `gorm:"column:project_id;primary_key;AUTO_INCREMENT"` // 项目id
-	ProjectName     string    `gorm:"column:project_name"`           // 项目名称
-	ProjectStatus   int64       `gorm:"column:project_status"`         // 项目状态,1-7分别代表创建中、待审核、招募中、待支付、失效、执行中、已结案
-	ProjectType     int64       `gorm:"column:project_type"`           // 项目类型,1代表全流程项目,2代表专项项目
-	ProjectPlatform int64       `gorm:"column:project_platform"`       // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
-	ProjectForm     int64       `gorm:"column:project_form"`           // 项目形式,1-4分别代表实体商品寄拍、虚拟产品测评、线下探店打卡、素材微原创
-	TalentType      string       `gorm:"column:talent_type"`            // 达人类型
-	RecruitDdl      time.Time `gorm:"column:recruit_ddl"`            // 招募截止时间
-	ContentType     int64       `gorm:"column:content_type"`           // 内容形式,1代表图文,2代表视频
-	ProjectDetail   string    `gorm:"column:project_detail"`         // 项目详情
-	EnterpriseID    int64       `gorm:"column:enterprise_id"`          // 所属企业id
-	ProductID       int64       `gorm:"column:product_id"`             // 关联商品id
-	CreatedAt       time.Time `gorm:"column:created_at"`             // 创建时间
-	UpdatedAt       time.Time `gorm:"column:updated_at"`             // 修改时间
+	ProjectID       int64     `gorm:"column:project_id;primary_key;AUTO_INCREMENT"` // 项目id
+	ProjectName     string    `gorm:"column:project_name"`                          // 项目名称
+	ProjectStatus   int64     `gorm:"column:project_status"`                        // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、失效、执行中、已结案
+	ProjectType     int64     `gorm:"column:project_type"`                          // 项目类型,1代表全流程项目,2代表专项项目
+	ProjectPlatform int64     `gorm:"column:project_platform"`                      // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	ProjectForm     int64     `gorm:"column:project_form"`                          // 项目形式,1-4分别代表实体商品寄拍、虚拟产品测评、线下探店打卡、素材微原创
+	TalentType      string    `gorm:"column:talent_type"`                           // 达人类型
+	RecruitDdl      time.Time `gorm:"column:recruit_ddl"`                           // 招募截止时间
+	ContentType     int64     `gorm:"column:content_type"`                          // 内容形式,1代表图文,2代表视频
+	ProjectDetail   string    `gorm:"column:project_detail"`                        // 项目详情
+	ApplyNum        int64     `gorm:"column:apply_num;default:0;NOT NULL"`          // 报名人数
+	RecruitNum      int64     `gorm:"column:recruit_num;default:0;NOT NULL"`        // 已招募人数
+	EnterpriseID    int64     `gorm:"column:enterprise_id"`                         // 所属企业id
+	ProductID       int64     `gorm:"column:product_id"`                            // 关联商品id
+	CreatedAt       time.Time `gorm:"column:created_at"`                            // 创建时间
+	UpdatedAt       time.Time `gorm:"column:updated_at"`                            // 修改时间
+	FeeForm         string    `gorm:"column:fee_form"`                              // 稿费形式列表
 }
 
 func (m *ProjectInfo) TableName() string {
 	return "project_info"
 }
-

+ 23 - 0
model/http_model/enterprise_balance.go

@@ -0,0 +1,23 @@
+package http_model
+
+type EnterpriseBalanceRequest struct {
+	//EnterpriseId int64 `json:"enterprise_id"` // 企业id
+}
+
+type EnterpriseBalanceData struct {
+	Balance          int64 `json:"balance"`
+	FrozenBalance    int64 `json:"frozen_balance"`
+	AvailableBalance int64 `json:"available_balance"`
+	Recharging       int64 `json:"recharging"`
+	BillableAmount   int64 `json:"billable_amount"`
+	Invoicing        int64 `json:"invoicing"`
+}
+
+func NewEnterpriseBalanceRequest() *EnterpriseBalanceRequest {
+	return new(EnterpriseBalanceRequest)
+}
+func NewEnterpriseBalanceResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(EnterpriseBalanceData)
+	return resp
+}

+ 1 - 0
model/http_model/product_findall.go

@@ -7,6 +7,7 @@ type ProductInfo struct {
 	ProductID   int64  `json:"product_id"`
 	BrandName   string `json:"brand_name"`
 	ProductName string `json:"product_name"`
+	ProductType string `json:"product_type"`
 }
 
 type FindAllProductData struct {

+ 1 - 0
route/init.go

@@ -52,6 +52,7 @@ func InitRoute(r *gin.Engine) {
 		m.POST("/product/list", handler.WrapFullProjectListHandler)
 		m.POST("/project/taskList", handler.WrapProjectTaskListHandler)
 		m.POST("/project/changeTaskStatus", handler.WrapProjectChangeTaskStatusHandler)
+		m.POST("/enterprise/balance", handler.WrapEnterpriseBalanceHandler)
 	}
 
 }

+ 2 - 0
service/product.go

@@ -2,6 +2,7 @@ package service
 
 import (
 	"context"
+	"youngee_b_api/consts"
 	"youngee_b_api/db"
 	"youngee_b_api/model/gorm_model"
 	"youngee_b_api/model/http_model"
@@ -105,6 +106,7 @@ func (*product) FindAll(ctx context.Context, enterpriseID int64) (*http_model.Fi
 			ProductID:   product.ProductID,
 			BrandName:   product.BrandName,
 			ProductName: product.ProductName,
+			ProductType: consts.GetProjectTypes(product.ProductType),
 		}
 		findAllProductData.ProductInfos = append(findAllProductData.ProductInfos, productData)
 	}

+ 13 - 0
service/project.go

@@ -3,6 +3,8 @@ package service
 import (
 	"context"
 	"fmt"
+	"strconv"
+	"strings"
 	"youngee_b_api/db"
 	"youngee_b_api/model/common_model"
 	"youngee_b_api/model/gorm_model"
@@ -29,6 +31,15 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
 	}
 	// 按照品牌名-商品名对项目进行命名
 	projectName := product.BrandName + "-" + product.ProductName
+	//feeForm := fmt.Sprintf("[")
+	feeFrom := []string{}
+	for _, strategy := range newProject.RecruitStrategys {
+		//if strategy.StrategyID
+		feeFrom = append(feeFrom, strconv.FormatInt(strategy.FeeForm, 10))
+		//feeForm += string(strategy.StrategyID)
+	}
+	feeFroms := strings.Join(feeFrom, ",")
+
 	projectInfo := gorm_model.ProjectInfo{
 		ProjectName:     projectName,
 		ProjectStatus:   1,
@@ -41,6 +52,7 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
 		ContentType:     newProject.ContentType,
 		EnterpriseID:    enterpriseID,
 		ProductID:       newProject.ProductID,
+		FeeForm:         feeFroms,
 	}
 	// db create ProjectInfo
 	projectID, err := db.CreateProject(ctx, projectInfo)
@@ -89,6 +101,7 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
 	return res, nil
 }
 func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectRequest, enterpriseID int64) (*http_model.UpdateProjectData, error) {
+	fmt.Println("newproject:", newProject)
 	project := gorm_model.ProjectInfo{
 		ProjectID:     conv.MustInt64(newProject.ProjectID),
 		RecruitDdl:    newProject.RecruitDdl,