Browse Source

定价策略

yuliang1112 2 years ago
parent
commit
b9d2985137
47 changed files with 868 additions and 39 deletions
  1. 59 0
      consts/project.go
  2. 122 0
      db/operate.go
  3. 50 0
      db/talent.go
  4. 1 1
      handler/account_income.go
  5. 1 1
      handler/account_info.go
  6. 1 1
      handler/base.go
  7. 3 3
      handler/create_user.go
  8. 1 1
      handler/creator_list.go
  9. 1 1
      handler/delete_account.go
  10. 1 1
      handler/disabled_user.go
  11. 1 1
      handler/enterprise_user.go
  12. 2 2
      handler/get_login_user.go
  13. 59 0
      handler/get_task_record.go
  14. 1 1
      handler/get_userInfo.go
  15. 1 1
      handler/get_user_list.go
  16. 1 1
      handler/login.go
  17. 81 0
      handler/operate/add_pricing.go
  18. 49 0
      handler/operate/base.go
  19. 63 0
      handler/operate/modify_pricing.go
  20. 80 0
      handler/operate/search_pricing.go
  21. 1 1
      handler/pay_sum.go
  22. 1 1
      handler/platform_acc_info.go
  23. 1 1
      handler/product_create.go
  24. 1 1
      handler/product_find.go
  25. 1 1
      handler/product_findAll.go
  26. 1 1
      handler/product_list.go
  27. 1 1
      handler/project_all.go
  28. 4 4
      handler/project_approve.go
  29. 1 1
      handler/project_create.go
  30. 1 1
      handler/project_handle.go
  31. 2 2
      handler/project_show.go
  32. 1 1
      handler/project_taskList.go
  33. 1 1
      handler/project_update.go
  34. 1 1
      handler/update_user_info.go
  35. 8 0
      model/common_model/pricing_conditions.go
  36. 27 0
      model/gorm_model/info_pricing_strategy.go
  37. 1 0
      model/gorm_model/project_task.go
  38. 23 0
      model/http_model/add_pricing.go
  39. 24 0
      model/http_model/modify_pricing.go
  40. 36 0
      model/http_model/search_pricing.go
  41. 30 0
      model/http_model/task_record.go
  42. 60 0
      pack/operate.go
  43. 8 0
      route/init.go
  44. 28 0
      service/operate.go
  45. 9 0
      service/user.go
  46. 1 1
      util/deduplication.go
  47. 17 5
      util/type.go

+ 59 - 0
consts/project.go

@@ -106,3 +106,62 @@ func GetCreatorIsBindAccountType(status int) string {
 	}
 	return "未知"
 }
+
+var ProjectType = map[int64]string{
+	1: "全流程项目",
+	2: "专项项目",
+}
+
+func GetProjectType(project_type int64) string {
+	toast, contain := ProjectType[project_type]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
+var FeeForm = map[int64]string{
+	1: "产品置换",
+	2: "固定稿费",
+	3: "自报价",
+}
+
+func GetFeeForm(fee_form int64) string {
+	toast, contain := FeeForm[fee_form]
+	if contain {
+		return toast
+	}
+	return "未知"
+}
+
+var TaskStage = map[int]string{
+	1:  "已报名",
+	2:  "待选号",
+	3:  "申请成功",
+	4:  "申请失败",
+	5:  "待发货",
+	6:  "已发货",
+	7:  "已签收",
+	8:  "待传脚本",
+	9:  "脚本待审",
+	10: "脚本通过",
+	11: "待传初稿",
+	12: "初稿待审",
+	13: "初稿通过",
+	14: "待传链接",
+	15: "链接待审",
+	16: "链接通过",
+	17: "待传数据",
+	18: "数据待审",
+	19: "已结案",
+	20: "解约待处理",
+	21: "解约",
+}
+
+func GetTaskStage(task_stage int) string {
+	toast, contain := TaskStage[task_stage]
+	if contain {
+		return toast
+	}
+	return "未知"
+}

+ 122 - 0
db/operate.go

@@ -0,0 +1,122 @@
+package db
+
+import (
+	"context"
+	"fmt"
+	"github.com/caixw/lib.go/conv"
+	"github.com/sirupsen/logrus"
+	"reflect"
+	"time"
+	"youngee_m_api/model/common_model"
+	"youngee_m_api/model/gorm_model"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/util"
+)
+
+func CreatePricingStrategy(ctx context.Context, req *http_model.AddPricingRequest) (string, string, error) {
+	db := GetReadDB(ctx)
+	project_type, fee_form, platform, fans_low, fans_up, service_charge, base_offer := req.ProjectType, req.ManuscriptForm, req.Platform, req.FansLow, req.FansHigh, req.PlatformFee, req.BaseOffer
+	var IsExclusive gorm_model.InfoPricingStrategy
+	err := db.Debug().Where(" fee_form = ? && platform = ? && fans_low <= ? && fans_up >= ?", fee_form, platform, fans_low, fans_up).First(&IsExclusive).Error
+	if err == nil {
+		return "该策略与已经运行的策略互斥,请修改相关字段后重新创建", "", nil
+	}
+	var newStrategy gorm_model.InfoPricingStrategy
+	var strategyInfo gorm_model.InfoPricingStrategy
+	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(" strategyId like '%s%%'", monthAndDay)).Last(&strategyInfo).Error
+
+	num := 1
+	if strategyInfo.StrategyId != "" {
+		num = conv.MustInt(strategyInfo.StrategyId[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, "")
+	}
+	newStrategy.StrategyId = monthAndDay + numString
+	newStrategy.Status = 0
+	newStrategy.FansLow = fans_low
+	newStrategy.FansUp = fans_up
+	newStrategy.ProjectType = conv.MustInt64(project_type, 0)
+	newStrategy.BaseOffer = conv.MustInt64(base_offer, 0)
+	newStrategy.Platform = conv.MustInt64(platform, 0)
+	newStrategy.FeeForm = conv.MustInt64(fee_form, 0)
+	newStrategy.ServiceCharge = conv.MustInt64(service_charge, 0)
+	newStrategy.CreateAt = time.Now()
+	newStrategy.UpdateAt = time.Now()
+	err = db.Create(&newStrategy).Error
+	if err != nil {
+		return "创建失败", "", err
+	}
+	return "创建成功", monthAndDay + numString, nil
+}
+
+func SearchPricing(ctx context.Context, pageSize, pageNum int32, conditions *common_model.PricingConditions) ([]*gorm_model.InfoPricingStrategy, int64, error) {
+	db := GetReadDB(ctx)
+	db = db.Debug().Model(gorm_model.InfoPricingStrategy{})
+	// 根据 查询条件过滤
+	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 != "update_at" {
+			db = db.Where(fmt.Sprintf("%s = ?", tag), value.Interface())
+		} else if tag == "created_at" && value.Interface() != nil {
+			db = db.Where(fmt.Sprintf("update_at like '%s%%'", value.Interface()))
+		}
+	}
+	// 查询总数
+	var total int64
+	var PricingDatas []*gorm_model.InfoPricingStrategy
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[SearchPricing] error query mysql total, err:%+v", err)
+		return nil, 0, err
+	}
+	// 查询该页数据
+	limit := pageSize
+	offset := pageSize * pageNum // assert pageNum start with 0
+	err := db.Order("update_at desc").Limit(int(limit)).Offset(int(offset)).Find(&PricingDatas).Error
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[SearchPricing] error query mysql find, err:%+v", err)
+		return nil, 0, err
+	}
+	return PricingDatas, total, nil
+}
+
+func ModifyPricing(ctx context.Context, req *http_model.ModifyPricingRequest) (string, error) {
+	db := GetReadDB(ctx)
+	strategyId := req.StrategyId
+	db = db.Debug().Model(gorm_model.InfoPricingStrategy{}).Where("strategyId = ?", strategyId)
+	project_type, fee_form, platform, fans_low, fans_up, service_charge, base_offer := req.ProjectType, req.FeeForm, req.Platform, req.FansLow, req.FansHigh, req.PlatformFee, req.BaseOffer
+	var IsExclusive gorm_model.InfoPricingStrategy
+	err := db.Debug().Where(" fee_form = ? && platform = ? && fans_low <= ? && fans_up >= ?", fee_form, platform, fans_low, fans_up).First(&IsExclusive).Error
+	if err == nil {
+		return "要修改策略与已经运行的策略互斥,请修改相关字段", nil
+	}
+	err = db.Updates(map[string]interface{}{
+		"project_type": project_type, "base_offer": base_offer, "fee_form": fee_form,
+		"platform": platform, "fans_low": fans_low, "fans_up": fans_up, "service_charge": service_charge,
+	}).Error
+	if err != nil {
+		return "", err
+	}
+	return "修改成功", nil
+}

+ 50 - 0
db/talent.go

@@ -5,6 +5,7 @@ import (
 	"github.com/caixw/lib.go/conv"
 	"github.com/sirupsen/logrus"
 	"gorm.io/gorm"
+	"youngee_m_api/consts"
 	"youngee_m_api/model/gorm_model"
 	"youngee_m_api/model/http_model"
 	"youngee_m_api/pack"
@@ -76,3 +77,52 @@ func AccountIncome(ctx context.Context, talentId string) (*http_model.TalentInfo
 	}
 	return data, err
 }
+
+func GetTaskRecord(ctx context.Context, talentId string) (*http_model.GetTaskRecordResponse, error) {
+	db := GetReadDB(ctx)
+	var taskInfos []*gorm_model.YoungeeTaskInfo
+	// 根据 talent_id 进行筛选
+	db = db.Debug().Model(gorm_model.YoungeeTaskInfo{}).Where("talent_id = ?", talentId)
+	// 查询总数
+	var total int64
+	if err := db.Count(&total).Error; err != nil {
+		logrus.WithContext(ctx).Errorf("[GetTaskRecord] error query mysql total, err:%+v", err)
+		return nil, err
+	}
+	err := db.Order("update_at desc").Find(&taskInfos).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	projectIdMap := map[int]gorm_model.ProjectInfo{}
+	for _, taskInfo := range taskInfos {
+		if _, ok := projectIdMap[taskInfo.ProjectId]; !ok {
+			db1 := GetReadDB(ctx)
+			projectInfo := gorm_model.ProjectInfo{}
+			db1.Where("project_id = ?", taskInfo.ProjectId).First(&projectInfo)
+			projectIdMap[taskInfo.ProjectId] = projectInfo
+		}
+	}
+	var taskRecordDatas []*http_model.TaskRecordData
+	for _, taskInfo := range taskInfos {
+		updateAt := conv.MustString(taskInfo.UpdateAt, "")
+		updateAt = updateAt[0:19]
+		taskRecordData := http_model.TaskRecordData{
+			ProjectId:       conv.MustString(taskInfo.ProjectId, ""),
+			ProjectName:     projectIdMap[taskInfo.ProjectId].ProjectName,
+			ProjectType:     consts.GetProjectType(projectIdMap[taskInfo.ProjectId].ProjectType),
+			ProjectPlatform: consts.GetProjectPlatform(projectIdMap[taskInfo.ProjectId].ProjectPlatform),
+			TaskId:          conv.MustString(taskInfo.TaskId, ""),
+			TaskStage:       consts.GetTaskStage(taskInfo.TaskStage),
+			UpdatedAt:       updateAt,
+		}
+		taskRecordDatas = append(taskRecordDatas, &taskRecordData)
+	}
+	taskRecordResponse := new(http_model.GetTaskRecordResponse)
+	taskRecordResponse.TaskRecordData = taskRecordDatas
+	taskRecordResponse.Total = conv.MustString(total, "")
+	return taskRecordResponse, nil
+}

+ 1 - 1
handler/account_income.go

@@ -11,7 +11,7 @@ import (
 
 func WrapTalentInfoHandler(ctx *gin.Context) {
 	handler := newTalentInfo(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newTalentInfo(ctx *gin.Context) *TalentInfo {

+ 1 - 1
handler/account_info.go

@@ -13,7 +13,7 @@ import (
 
 func WrapAccountInfoHandler(ctx *gin.Context) {
 	handler := newAccountInfoHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 type accountHandler struct {

+ 1 - 1
handler/base.go

@@ -17,7 +17,7 @@ type BaseHandler interface {
 	checkParam() error
 }
 
-func baseRun(baseHandler BaseHandler) {
+func BaseRun(baseHandler BaseHandler) {
 	ctx := baseHandler.getContext()
 	method := ctx.Request.Method
 	req := baseHandler.getRequest()

+ 3 - 3
handler/create_user.go

@@ -10,11 +10,11 @@ import (
 )
 
 func WrapCreateUserHandler(ctx *gin.Context) {
-	handler := newCreateUserhandler(ctx)
-	baseRun(handler)
+	handler := newCreateUserHandler(ctx)
+	BaseRun(handler)
 }
 
-func newCreateUserhandler(ctx *gin.Context) *CreateUserHandler {
+func newCreateUserHandler(ctx *gin.Context) *CreateUserHandler {
 	return &CreateUserHandler{
 		req:  http_model.NewCreateUserRequest(),
 		resp: http_model.NewCreateUserResponse(),

+ 1 - 1
handler/creator_list.go

@@ -14,7 +14,7 @@ import (
 
 func WrapCreatorListHandler(ctx *gin.Context) {
 	handler := newCreatorListHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newCreatorListHandler(ctx *gin.Context) *CreatorList {

+ 1 - 1
handler/delete_account.go

@@ -11,7 +11,7 @@ import (
 
 func WrapDeleteAccountHandler(ctx *gin.Context) {
 	handler := newDeleteAccountHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 type DeleteAccount struct {

+ 1 - 1
handler/disabled_user.go

@@ -11,7 +11,7 @@ import (
 
 func WrapDisabledUserHandler(ctx *gin.Context) {
 	handler := newDisabledUserHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newDisabledUserHandler(ctx *gin.Context) *DisabledUserHandler {

+ 1 - 1
handler/enterprise_user.go

@@ -14,7 +14,7 @@ import (
 
 func WrapEnterpriseUserHandler(ctx *gin.Context) {
 	handler := newEnterpriseUser(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newEnterpriseUser(ctx *gin.Context) *EnterpriseUser {

+ 2 - 2
handler/get_login_user.go

@@ -9,7 +9,7 @@ import (
 
 func WrapGetLoginUserHandler(ctx *gin.Context) {
 	handler := newGetLoginUserHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newGetLoginUserHandler(ctx *gin.Context) *GetLoginUserHandler {
@@ -36,7 +36,7 @@ func (h *GetLoginUserHandler) getResponse() interface{} {
 	return h.resp
 }
 func (h *GetLoginUserHandler) run() {
-	user,err := db.GetAllUser(h.ctx)
+	user, err := db.GetAllUser(h.ctx)
 	if err != nil {
 		logrus.Errorf("[GetLoginUserHandler] get LoginUser err:%+v\n", err)
 		logrus.Info("GetLoginUser fail,req:%+v", h.req)

+ 59 - 0
handler/get_task_record.go

@@ -0,0 +1,59 @@
+package handler
+
+import (
+	"fmt"
+	"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 WrapGetTaskRecordHandler(ctx *gin.Context) {
+	handler := newGetTaskRecordHandler(ctx)
+	BaseRun(handler)
+}
+
+type GetTaskRecordHandler struct {
+	req  *http_model.GetTaskRecordRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func newGetTaskRecordHandler(ctx *gin.Context) *GetTaskRecordHandler {
+	return &GetTaskRecordHandler{
+		req:  http_model.NewGetTaskRecordRequest(),
+		resp: http_model.NewGetTaskRecordResponse(),
+		ctx:  ctx,
+	}
+}
+
+func (g GetTaskRecordHandler) getContext() *gin.Context {
+	return g.ctx
+}
+
+func (g GetTaskRecordHandler) getResponse() interface{} {
+	return g.resp
+}
+
+func (g GetTaskRecordHandler) getRequest() interface{} {
+	return g.req
+}
+
+func (g GetTaskRecordHandler) run() {
+	fmt.Println(g.req)
+	data, err := service.User.GetTaskRecord(g.ctx, g.req.TalentId)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[GetTaskRecordHandler] call GetTaskRecord err:%+v\n", err)
+		util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, "")
+		logrus.Info("GetTaskRecordHandler fail,req:%+v", g.req)
+		return
+	}
+	g.resp.Data = data
+}
+
+func (g GetTaskRecordHandler) checkParam() error {
+	return nil
+}

+ 1 - 1
handler/get_userInfo.go

@@ -11,7 +11,7 @@ import (
 
 func WrapGetUserInfoHandler(ctx *gin.Context) {
 	handler := newGetUserInfo(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newGetUserInfo(ctx *gin.Context) *UserInfo {

+ 1 - 1
handler/get_user_list.go

@@ -10,7 +10,7 @@ import (
 
 func WrapGetUserListHandler(ctx *gin.Context) {
 	handler := newGetUserListHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newGetUserListHandler(ctx *gin.Context) *GetUserListHandler {

+ 1 - 1
handler/login.go

@@ -11,7 +11,7 @@ import (
 
 func WrapCodeLoginHandler(ctx *gin.Context) {
 	handler := newCodeLoginHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newCodeLoginHandler(ctx *gin.Context) *CodeLoginHandler {

+ 81 - 0
handler/operate/add_pricing.go

@@ -0,0 +1,81 @@
+package operate
+
+import (
+	"fmt"
+	"github.com/caixw/lib.go/conv"
+	"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 WrapAddPricingHandler(ctx *gin.Context) {
+	handler := newPricingHandler(ctx)
+	BaseRun(handler)
+}
+
+type PricingHandler struct {
+	req  *http_model.AddPricingRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func newPricingHandler(ctx *gin.Context) *PricingHandler {
+	return &PricingHandler{
+		req:  http_model.NewAddPricingRequest(),
+		resp: http_model.NewAddPricingResponse(),
+		ctx:  ctx,
+	}
+}
+
+func (p PricingHandler) getContext() *gin.Context {
+	return p.ctx
+}
+
+func (p PricingHandler) getResponse() interface{} {
+	return p.resp
+}
+
+func (p PricingHandler) getRequest() interface{} {
+	return p.req
+}
+
+func (p PricingHandler) run() {
+	toast, strategyId, err := db.CreatePricingStrategy(p.ctx, p.req)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[PricingHandler] call AddPricing err:%+v\n", err)
+		util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "")
+		logrus.Info("PricingHandler fail,req:%+v", p.req)
+		return
+	}
+	if toast == "创建成功" {
+		p.resp.Message = "编号为" + strategyId + "的策略添加成功"
+	} else if toast == "该策略与已经运行的策略互斥,请修改相关字段后重新创建" {
+		p.resp.Status = 1
+	} else {
+		p.resp.Status = 2
+	}
+}
+
+func (p PricingHandler) checkParam() error {
+	var errs []error
+	p.req.ProjectType = util.IsNull(p.req.ProjectType)
+	if _, err := conv.Int64(p.req.ProjectType); err != nil {
+		errs = append(errs, err)
+	}
+	p.req.Platform = util.IsNull(p.req.Platform)
+	if _, err := conv.Int64(p.req.Platform); err != nil {
+		errs = append(errs, err)
+	}
+	p.req.ManuscriptForm = util.IsNull(p.req.ManuscriptForm)
+	if _, err := conv.Int64(p.req.ManuscriptForm); err != nil {
+		errs = append(errs, err)
+	}
+	if len(errs) != 0 {
+		return fmt.Errorf("check param errs:%+v", errs)
+	}
+	return nil
+}

+ 49 - 0
handler/operate/base.go

@@ -0,0 +1,49 @@
+package operate
+
+import (
+	"net/http"
+	"youngee_m_api/consts"
+	"youngee_m_api/util"
+
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+)
+
+type BaseHandler interface {
+	getContext() *gin.Context
+	getResponse() interface{}
+	getRequest() interface{}
+	run()
+	checkParam() error
+}
+
+func BaseRun(baseHandler BaseHandler) {
+	ctx := baseHandler.getContext()
+	method := ctx.Request.Method
+	req := baseHandler.getRequest()
+	var err error
+	if method == http.MethodPost || method == http.MethodPut {
+		err = ctx.ShouldBindJSON(req)
+	} else if method == http.MethodGet {
+		err = ctx.BindQuery(req)
+	}
+	if err != nil {
+		util.PackErrorResp(ctx, consts.ErrorParamCheck)
+		ctx.Abort()
+		logrus.Infof("[baseHandler] bind json error,err:%+v", err)
+		return
+	}
+	if err = baseHandler.checkParam(); err != nil {
+		util.PackErrorResp(ctx, consts.ErrorParamCheck)
+		ctx.Abort()
+		logrus.Infof("[baseHandler] checkParam error,err:%+v", err)
+		return
+	}
+	baseHandler.run()
+	if ctx.IsAborted() {
+		return
+	}
+	resp := baseHandler.getResponse()
+	ctx.JSON(http.StatusOK, resp)
+	logrus.Infof("[baseHandler] http success")
+}

+ 63 - 0
handler/operate/modify_pricing.go

@@ -0,0 +1,63 @@
+package operate
+
+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 WrapModifyPricingHandler(ctx *gin.Context) {
+	handler := newModifyPricingHandler(ctx)
+	BaseRun(handler)
+}
+
+type ModifyPricingHandler struct {
+	req  *http_model.ModifyPricingRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func newModifyPricingHandler(ctx *gin.Context) *ModifyPricingHandler {
+	return &ModifyPricingHandler{
+		req:  http_model.NewModifyPricingRequest(),
+		resp: http_model.NewModifyPricingResponse(),
+		ctx:  ctx,
+	}
+}
+
+func (m ModifyPricingHandler) getContext() *gin.Context {
+	return m.ctx
+}
+
+func (m ModifyPricingHandler) getResponse() interface{} {
+	return m.resp
+}
+
+func (m ModifyPricingHandler) getRequest() interface{} {
+	return m.req
+}
+
+func (m ModifyPricingHandler) run() {
+	toast, err := db.ModifyPricing(m.ctx, m.req)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[ModifyPricingHandler] call ModifyPricing err:%+v\n", err)
+		util.HandlerPackErrorResp(m.resp, consts.ErrorInternal, "")
+		logrus.Info("PricingHandler fail,req:%+v", m.req)
+		return
+	}
+	if toast == "修改成功" {
+		m.resp.Message = "编号为" + m.req.StrategyId + "的策略修改成功"
+	} else if toast == "要修改策略与已经运行的策略互斥,请修改相关字段" {
+		m.resp.Status = 1
+	} else {
+		m.resp.Status = 2
+	}
+}
+
+func (m ModifyPricingHandler) checkParam() error {
+	return nil
+}

+ 80 - 0
handler/operate/search_pricing.go

@@ -0,0 +1,80 @@
+package operate
+
+import (
+	"errors"
+	"fmt"
+	"github.com/caixw/lib.go/conv"
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/pack"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapSearchPricingHandler(ctx *gin.Context) {
+	handler := newSearchPricing(ctx)
+	BaseRun(handler)
+}
+
+type SearchPricingHandler struct {
+	req  *http_model.SearchPricingRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func newSearchPricing(ctx *gin.Context) *SearchPricingHandler {
+	return &SearchPricingHandler{
+		req:  http_model.NewSearchPricingRequest(),
+		resp: http_model.NewSearchPricingResponse(),
+		ctx:  ctx,
+	}
+}
+
+func (s SearchPricingHandler) getContext() *gin.Context {
+	return s.ctx
+}
+
+func (s SearchPricingHandler) getResponse() interface{} {
+	return s.resp
+}
+
+func (s SearchPricingHandler) getRequest() interface{} {
+	return s.req
+}
+
+func (s SearchPricingHandler) run() {
+	conditions := pack.HttpPricingRequestToConditions(s.req)
+	data, err := service.Operate.SearchPricing(s.ctx, s.req.PageSize, s.req.PageNum, conditions)
+	if err != nil {
+		logrus.WithContext(s.ctx).Errorf("[SearchPricingHandler] error SearchPricing , err:%+v", err)
+		util.HandlerPackErrorResp(s.resp, consts.ErrorInternal, consts.DefaultToast)
+		return
+	}
+	s.resp.Data = data
+}
+
+func (s SearchPricingHandler) checkParam() error {
+	var errs []error
+	if s.req.PageNum < 0 || s.req.PageSize <= 0 {
+		errs = append(errs, errors.New("page param error"))
+	}
+	s.req.PageNum--
+	s.req.Platform = util.IsNull(s.req.Platform)
+	if _, err := conv.Int64(s.req.Platform); err != nil {
+		errs = append(errs, err)
+	}
+	s.req.FeeForm = util.IsNull(s.req.FeeForm)
+	if _, err := conv.Int64(s.req.FeeForm); err != nil {
+		errs = append(errs, err)
+	}
+	s.req.ProjectType = util.IsNull(s.req.ProjectType)
+	if _, err := conv.Int64(s.req.ProjectType); err != nil {
+		errs = append(errs, err)
+	}
+	if len(errs) != 0 {
+		return fmt.Errorf("check param errs:%+v", errs)
+	}
+	return nil
+}

+ 1 - 1
handler/pay_sum.go

@@ -11,7 +11,7 @@ import (
 
 func WrapPaySumHandler(ctx *gin.Context) {
 	handler := newPaySumHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newPaySumHandler(ctx *gin.Context) *PaySumHandler {

+ 1 - 1
handler/platform_acc_info.go

@@ -11,7 +11,7 @@ import (
 
 func WrapPlatformAccInfoHandler(ctx *gin.Context) {
 	handler := newPlatformAccInfo(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newPlatformAccInfo(ctx *gin.Context) *PlatformAccInfo {

+ 1 - 1
handler/product_create.go

@@ -13,7 +13,7 @@ import (
 
 func WrapCreateProductHandler(ctx *gin.Context) {
 	handler := newCreateProductHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newCreateProductHandler(ctx *gin.Context) *CreateProductHandler {

+ 1 - 1
handler/product_find.go

@@ -11,7 +11,7 @@ import (
 
 func WrapFindProductHandler(ctx *gin.Context) {
 	handler := newFindProductHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newFindProductHandler(ctx *gin.Context) *FindProductHandler {

+ 1 - 1
handler/product_findAll.go

@@ -13,7 +13,7 @@ import (
 
 func WrapFindAllProductHandler(ctx *gin.Context) {
 	handler := newFindAllProductHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newFindAllProductHandler(ctx *gin.Context) *FindAllProductHandler {

+ 1 - 1
handler/product_list.go

@@ -17,7 +17,7 @@ import (
 
 func WrapFullProjectListHandler(ctx *gin.Context) {
 	handler := newFullProjectListHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newFullProjectListHandler(ctx *gin.Context) *FullProjectListHandler {

+ 1 - 1
handler/project_all.go

@@ -12,7 +12,7 @@ import (
 
 func WrapGetAllProjectHandler(ctx *gin.Context) {
 	handler := newGetAllProjectHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newGetAllProjectHandler(ctx *gin.Context) *GetAllProjectHandler {

+ 4 - 4
handler/project_approve.go

@@ -12,7 +12,7 @@ import (
 
 func WrapApproveProjectHandler(ctx *gin.Context) {
 	handler := newApproveProjectHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newApproveProjectHandler(ctx *gin.Context) *ApproveProjectHandler {
@@ -41,8 +41,8 @@ func (h *ApproveProjectHandler) getResponse() interface{} {
 func (h *ApproveProjectHandler) run() {
 	data := http_model.ApproveProjectRequest{}
 	data = *h.req
-	fmt.Println(data.IsApprove,data.ProjectId)
-	err,message := service.Project.ApproveProject(h.ctx, data)
+	fmt.Println(data.IsApprove, data.ProjectId)
+	err, message := service.Project.ApproveProject(h.ctx, data)
 	if err != nil {
 		// 数据库查询失败,返回5001
 		logrus.Errorf("[FindAllProductHandler] call FindAll err:%+v\n", err)
@@ -50,7 +50,7 @@ func (h *ApproveProjectHandler) run() {
 		logrus.Info("FindAllProduct fail,req:%+v", h.req)
 		return
 	}
-	if message == "操作失败"{
+	if message == "操作失败" {
 		h.resp.Status = 1
 	}
 	h.resp.Message = message

+ 1 - 1
handler/project_create.go

@@ -13,7 +13,7 @@ import (
 
 func WrapCreateProjectHandler(ctx *gin.Context) {
 	handler := newCreateProjectHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newCreateProjectHandler(ctx *gin.Context) *CreateProjectHandler {

+ 1 - 1
handler/project_handle.go

@@ -11,7 +11,7 @@ import (
 
 func WrapProjectHandleHandler(ctx *gin.Context) {
 	handler := NewProjectHandleHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func NewProjectHandleHandler(ctx *gin.Context) *ProjectHandleHandler {

+ 2 - 2
handler/project_show.go

@@ -11,7 +11,7 @@ import (
 
 func WrapShowProjectHandler(ctx *gin.Context) {
 	handler := newShowProjectHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newShowProjectHandler(ctx *gin.Context) *ShowProjectHandler {
@@ -40,7 +40,7 @@ func (h *ShowProjectHandler) getResponse() interface{} {
 func (h *ShowProjectHandler) run() {
 	data := http_model.ShowProjectRequest{}
 	data = *h.req
-	res, err := service.Project.GetProjectDetail(h.ctx,data.EnterpriseID, data.ProjectID)
+	res, err := service.Project.GetProjectDetail(h.ctx, data.EnterpriseID, data.ProjectID)
 	if err != nil {
 		logrus.Errorf("[ShowProjectHandler] call Show err:%+v\n", err)
 		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")

+ 1 - 1
handler/project_taskList.go

@@ -27,7 +27,7 @@ import (
 // @Router /product/taskList [post]
 func WrapProjectTaskListHandler(ctx *gin.Context) {
 	handler := newProjectTaskListHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newProjectTaskListHandler(ctx *gin.Context) *ProjectTaskListHandler {

+ 1 - 1
handler/project_update.go

@@ -11,7 +11,7 @@ import (
 
 func WrapUpdateProjectHandler(ctx *gin.Context) {
 	handler := newUpdateProjectHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newUpdateProjectHandler(ctx *gin.Context) *UpdateProjectHandler {

+ 1 - 1
handler/update_user_info.go

@@ -11,7 +11,7 @@ import (
 
 func WrapUpdateUserInfoHandler(ctx *gin.Context) {
 	handler := newUpdateUserInfoHandler(ctx)
-	baseRun(handler)
+	BaseRun(handler)
 }
 
 func newUpdateUserInfoHandler(ctx *gin.Context) *UpdateUserInfoHandler {

+ 8 - 0
model/common_model/pricing_conditions.go

@@ -0,0 +1,8 @@
+package common_model
+
+type PricingConditions struct {
+	ProjectType int64  `condition:"project_type"` //项目类型
+	FeeForm     int64  `condition:"fee_form"`     //稿费形式
+	Platform    int64  `condition:"platform"`     //社媒平台
+	UpdateAt    string `condition:"update_at"`    // 更新时间
+}

+ 27 - 0
model/gorm_model/info_pricing_strategy.go

@@ -0,0 +1,27 @@
+// Package gorm_model Code generated by sql2gorm. DO NOT EDIT.
+package gorm_model
+
+import (
+	"time"
+)
+
+type InfoPricingStrategy struct {
+	ID            int64     `gorm:"column:id;primary_key;AUTO_INCREMENT"` //  id
+	StrategyId    string    `gorm:"column:strategyId;NOT NULL"`           // 定价策略编号
+	ProjectType   int64     `gorm:"column:project_type;NOT NULL"`         // 项目类型,0表示不限,1为全流程项目
+	FeeForm       int64     `gorm:"column:fee_form;NOT NULL"`             // 稿费形式,1,2,3分别代表产品置换、固定稿费、自报价
+	Platform      int64     `gorm:"column:platform;NOT NULL"`             // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	FansLow       int64     `gorm:"column:fans_low;NOT NULL"`             // 对应粉丝量下限
+	FansUp        int64     `gorm:"column:fans_up;NOT NULL"`              // 对应粉丝量上限
+	ServiceCharge int64     `gorm:"column:service_charge"`                // 服务费,稿费形式为产品置换时填写,可以为空
+	BaseOffer     int64     `gorm:"column:base_offer"`                    // 基础报价
+	Status        int64     `gorm:"column:status;NOT NULL"`               // 定价策略当前状态,0表示正常,1表示禁用
+	ServiceRate   int64     `gorm:"column:service_rate"`                  // 服务费率*1000,稿费形式为固定稿费和自报价时填写,可以为空
+	UpdateID      int64     `gorm:"column:update_id"`                     // 修改管理人员id,对应user表中主键
+	UpdateAt      time.Time `gorm:"column:update_at"`                     // 修改时间
+	CreateAt      time.Time `gorm:"column:create_at;NOT NULL"`            // 创建时间
+}
+
+func (m *InfoPricingStrategy) TableName() string {
+	return "info_pricing_strategy"
+}

+ 1 - 0
model/gorm_model/project_task.go

@@ -28,6 +28,7 @@ type YoungeeTaskInfo struct {
 	SelectDate             time.Time `gorm:"column:select_date;type:datetime;comment:反选时间" json:"select_date"`
 	CompleteStatus         int       `gorm:"column:complete_status;type:tinyint(1);default:1;comment:结束方式 1未结束 2正常结束 3反选失败 4被解约;NOT NULL" json:"complete_status"`
 	CompleteDate           time.Time `gorm:"column:complete_date;type:datetime;comment:结束时间" json:"complete_date"`
+	UpdateAt               time.Time `gorm:"column:update_at"` // 更新时间
 }
 
 func (m *YoungeeTaskInfo) TableName() string {

+ 23 - 0
model/http_model/add_pricing.go

@@ -0,0 +1,23 @@
+package http_model
+
+type AddPricingRequest struct {
+	ProjectType    string `json:"project_type"`    //项目类型
+	ManuscriptForm string `json:"manuscript_form"` //稿费形式
+	Platform       string `json:"platform"`        //社媒平台
+	FansLow        int64  `json:"fans_low"`        //对应创作者 粉丝量
+	FansHigh       int64  `json:"fans_high"`       //对应创作者 粉丝量
+	BaseOffer      int64  `json:"base_offer"`      //基础报价
+	PlatformFee    int64  `json:"platform_fee"`    //平台服务费
+}
+
+type AddPricingResponse struct {
+}
+
+func NewAddPricingRequest() *AddPricingRequest {
+	return new(AddPricingRequest)
+}
+
+func NewAddPricingResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 24 - 0
model/http_model/modify_pricing.go

@@ -0,0 +1,24 @@
+package http_model
+
+type ModifyPricingRequest struct {
+	StrategyId  string `json:"strategy_id"`
+	ProjectType string `json:"project_type"` //项目类型
+	FeeForm     string `json:"fee_form"`     //稿费形式
+	Platform    string `json:"platform"`     //社媒平台
+	FansLow     int64  `json:"fans_low"`     //对应创作者 粉丝量
+	FansHigh    int64  `json:"fans_high"`    //对应创作者 粉丝量
+	BaseOffer   int64  `json:"base_offer"`   //基础报价
+	PlatformFee int64  `json:"platform_fee"` //平台服务费
+}
+
+type ModifyPricingResponse struct {
+}
+
+func NewModifyPricingRequest() *ModifyPricingRequest {
+	return new(ModifyPricingRequest)
+}
+
+func NewModifyPricingResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	return resp
+}

+ 36 - 0
model/http_model/search_pricing.go

@@ -0,0 +1,36 @@
+package http_model
+
+type SearchPricingRequest struct {
+	PageSize    int32  `json:"page_size"`
+	PageNum     int32  `json:"page_num"`
+	ProjectType string `json:"project_type"` //项目类型
+	FeeForm     string `json:"fee_form"`     //稿费形式
+	Platform    string `json:"platform"`     //社媒平台
+	UpdateAt    string `json:"update_at"`    // 创建时间
+}
+
+type SearchPricingPreview struct {
+	StrategyId     string `json:"strategyId"`      //定价策略编号
+	ProjectType    string `json:"project_type"`    //项目类型
+	Platform       string `json:"platform"`        //社媒平台
+	ManuscriptForm string `json:"manuscript_form"` //稿费形式
+	Fans           string `json:"fans"`            //对应创作者粉丝量
+	BaseOffer      string `json:"base_offer"`      //基础报价
+	PlatformFee    string `json:"platform_fee"`    //平台服务费
+	UpdateTime     string `json:"update_time"`     // 更新时间
+}
+
+type SearchPricingData struct {
+	SearchPricingPreview []*SearchPricingPreview `json:"search_pricing_preview"`
+	Total                string                  `json:"total"`
+}
+
+func NewSearchPricingRequest() *SearchPricingRequest {
+	return new(SearchPricingRequest)
+}
+
+func NewSearchPricingResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(SearchPricingPreview)
+	return resp
+}

+ 30 - 0
model/http_model/task_record.go

@@ -0,0 +1,30 @@
+package http_model
+
+type GetTaskRecordRequest struct {
+	TalentId string `json:"talent_id"`
+}
+
+type GetTaskRecordResponse struct {
+	TaskRecordData []*TaskRecordData `json:"task_record_data"`
+	Total          string            `json:"total"`
+}
+
+type TaskRecordData struct {
+	ProjectId       string `json:"project_id"`
+	ProjectName     string `json:"project_name"`
+	ProjectType     string `json:"project_type"`
+	ProjectPlatform string `json:"project_platform"`
+	TaskId          string `json:"task_id"`
+	TaskStage       string `json:"task_stage"`
+	UpdatedAt       string `json:"updated_at"`
+}
+
+func NewGetTaskRecordRequest() *GetTaskRecordRequest {
+	return new(GetTaskRecordRequest)
+}
+
+func NewGetTaskRecordResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(GetTaskRecordResponse)
+	return resp
+}

+ 60 - 0
pack/operate.go

@@ -0,0 +1,60 @@
+package pack
+
+import (
+	"github.com/caixw/lib.go/conv"
+	"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/util"
+)
+
+func HttpPricingRequestToConditions(req *http_model.SearchPricingRequest) *common_model.PricingConditions {
+	pricingUpdated := conv.MustString(req.UpdateAt, "")
+	return &common_model.PricingConditions{
+		ProjectType: conv.MustInt64(req.ProjectType, 0),
+		FeeForm:     conv.MustInt64(req.FeeForm, 0),
+		Platform:    conv.MustInt64(req.Platform, 0),
+		UpdateAt:    pricingUpdated,
+	}
+}
+
+func GormSearchPricingDataToHttpData(gormPricings []*gorm_model.InfoPricingStrategy) []*http_model.SearchPricingPreview {
+	var httpPricingPreviews []*http_model.SearchPricingPreview
+	for _, gormPricing := range gormPricings {
+		httpPricingPreview := MGromSearchPricingDataToHttpData(gormPricing)
+		httpPricingPreviews = append(httpPricingPreviews, httpPricingPreview)
+	}
+	return httpPricingPreviews
+}
+
+func MGromSearchPricingDataToHttpData(gormPricing *gorm_model.InfoPricingStrategy) *http_model.SearchPricingPreview {
+	updatedTime := conv.MustString(gormPricing.UpdateAt, "")
+	updatedTime = updatedTime[0:19]
+	fans := ""
+	if gormPricing.FansLow == 0 && gormPricing.FansUp == 0 {
+		fans = "不限"
+	} else if gormPricing.FansLow == 0 && gormPricing.FansUp != 0 {
+		fans = util.GetNum(gormPricing.FansUp) + "以下"
+	} else if gormPricing.FansLow != 0 && gormPricing.FansUp != 0 {
+		fans = util.GetNum(gormPricing.FansLow) + "-" + util.GetNum(gormPricing.FansUp)
+	} else if gormPricing.FansLow != 0 && gormPricing.FansUp == 0 {
+		fans = util.GetNum(gormPricing.FansLow) + "以上"
+	}
+	baseOffer := ""
+	if gormPricing.BaseOffer == 0 {
+		baseOffer = "不限"
+	} else {
+		baseOffer = conv.MustString(gormPricing.BaseOffer, "")
+	}
+	return &http_model.SearchPricingPreview{
+		StrategyId:     gormPricing.StrategyId,
+		ProjectType:    consts.GetProjectType(gormPricing.ProjectType),
+		Platform:       consts.GetProjectPlatform(gormPricing.Platform),
+		ManuscriptForm: consts.GetFeeForm(gormPricing.FeeForm),
+		Fans:           fans,
+		BaseOffer:      baseOffer,
+		PlatformFee:    conv.MustString(gormPricing.ServiceCharge, "") + "%",
+		UpdateTime:     updatedTime,
+	}
+}

+ 8 - 0
route/init.go

@@ -3,6 +3,7 @@ package route
 import (
 	"github.com/gin-gonic/gin"
 	"youngee_m_api/handler"
+	"youngee_m_api/handler/operate"
 	"youngee_m_api/model/http_model"
 )
 
@@ -54,5 +55,12 @@ func InitRoute(r *gin.Engine) {
 		u.POST("/talentInfo", handler.WrapTalentInfoHandler)
 		u.POST("/accountInfo", handler.WrapAccountInfoHandler)
 		u.POST("/deleteAccount", handler.WrapDeleteAccountHandler)
+		u.POST("/getTaskRecord", handler.WrapGetTaskRecordHandler)
+	}
+	o := r.Group("/youngee/m/operate")
+	{
+		o.POST("/addPricing", operate.WrapAddPricingHandler)
+		o.POST("/searchPricing", operate.WrapSearchPricingHandler)
+		o.POST("/modifyPricing", operate.WrapModifyPricingHandler)
 	}
 }

+ 28 - 0
service/operate.go

@@ -0,0 +1,28 @@
+package service
+
+import (
+	"context"
+	"github.com/caixw/lib.go/conv"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/db"
+	"youngee_m_api/model/common_model"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/pack"
+)
+
+var Operate *operate
+
+type operate struct {
+}
+
+func (*operate) SearchPricing(ctx context.Context, pagesize, pagenum int32, conditions *common_model.PricingConditions) (*http_model.SearchPricingData, error) {
+	searchPricings, total, err := db.SearchPricing(ctx, pagesize, pagenum, conditions)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[operate service] call SearchPricing error,err:%+v", err)
+		return nil, err
+	}
+	searchPricingData := new(http_model.SearchPricingData)
+	searchPricingData.SearchPricingPreview = pack.GormSearchPricingDataToHttpData(searchPricings)
+	searchPricingData.Total = conv.MustString(total, "")
+	return searchPricingData, nil
+}

+ 9 - 0
service/user.go

@@ -49,3 +49,12 @@ func (u *user) AccountInfo(ctx context.Context, pageSize int32, pageNum int32, c
 	accountInfoPreView.Total = conv.MustString(total, "")
 	return accountInfoPreView, nil
 }
+
+func (u *user) GetTaskRecord(ctx context.Context, talentId string) (*http_model.GetTaskRecordResponse, error) {
+	data, err := db.GetTaskRecord(ctx, talentId)
+	if err != nil {
+		logrus.WithContext(ctx).Errorf("[user service] call GetTaskRecord error,err:%+v", err)
+		return nil, err
+	}
+	return data, nil
+}

+ 1 - 1
util/deduplication.go

@@ -2,7 +2,7 @@ package util
 
 // RemoveRepByMap 通过map主键唯一的特性过滤重复元素
 func RemoveRepByMap(slc []int64) []int64 {
-	result := []int64{}
+	var result []int64
 	tempMap := map[int64]byte{} // 存放不重复主键
 	for _, e := range slc {
 		l := len(tempMap)

+ 17 - 5
util/type.go

@@ -1,16 +1,19 @@
 package util
 
-import "reflect"
+import (
+	"fmt"
+	"reflect"
+)
 
-// 判断是否为空字符串
+// IsNull 判断是否为空字符串
 func IsNull(s string) string {
-	if s == ""{
+	if s == "" {
 		return "0"
 	}
 	return s
 }
 
-// 判断 reflect.Value 是否为空
+// IsBlank 判断 reflect.Value 是否为空
 func IsBlank(value reflect.Value) bool {
 	switch value.Kind() {
 	case reflect.String:
@@ -27,4 +30,13 @@ func IsBlank(value reflect.Value) bool {
 		return value.IsNil()
 	}
 	return reflect.DeepEqual(value.Interface(), reflect.Zero(value.Type()).Interface())
-}
+}
+
+func GetNum(num int64) string {
+	if num < 10000 {
+		return fmt.Sprintf("%v", num)
+	}
+	mean := float32(num) / float32(10000)
+	str := fmt.Sprintf("%v", mean)
+	return str + "万"
+}