Ver código fonte

可以更新用户信息

yuliang1112 2 anos atrás
pai
commit
98084acd4a

+ 4 - 3
db/finance.go

@@ -226,7 +226,7 @@ func GetInvoiceRecords(ctx context.Context, req *http_model.InvoiceRecordsReques
 		logrus.WithContext(ctx).Errorf("[GetInvoiceRecords] error query mysql total, err:%+v", err)
 		return nil, err
 	}
-	if req.InvoiceStatus == 1 {
+	if req.InvoiceStatus != 3 {
 		db.Order("submit_at")
 	} else {
 		db.Order("billing_at desc")
@@ -382,8 +382,9 @@ func OperateRecharge(ctx context.Context, req *http_model.OperateRechargeRequest
 		return err
 	}
 	err1 := db.Model(gorm_model.YounggeeRechargeRecord{}).Where("recharge_id = ?", req.RechargeId).Updates(gorm_model.YounggeeRechargeRecord{
-		Status:    2,
-		ConfirmAt: time.Now(),
+		Status:        2,
+		InvoiceStatus: 2,
+		ConfirmAt:     time.Now(),
 	}).Error
 	if err1 != nil {
 		logrus.WithContext(ctx).Errorf("[OperateRecharge] error Updates Status, err:%+v", err)

+ 2 - 1
db/project.go

@@ -108,10 +108,11 @@ func ApproveProject(ctx context.Context, projectId string, isApprove int64) (err
 	db := GetReadDB(ctx)
 	projectInfo := gorm_model.ProjectInfo{}
 	db = db.Debug().Model(gorm_model.ProjectInfo{}).Where("project_id = ?", project_id).First(&projectInfo)
+	t := time.Now()
 	if isApprove == 1 && projectInfo.ProjectStatus == 2 {
 		err := db.Updates(gorm_model.ProjectInfo{
 			ProjectStatus: 4,
-			FinishAt:      time.Now(),
+			FinishAt:      &t,
 		}).Error
 		message = "审核通过"
 		if err != nil {

+ 13 - 0
db/user.go

@@ -371,3 +371,16 @@ func GetEnterpriseIds(ctx context.Context) (*http_model.EnterPriseIds, error) {
 	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
+}

+ 57 - 0
handler/modifyAccInfo.go

@@ -0,0 +1,57 @@
+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 WrapModifyAccInfoHandler(ctx *gin.Context) {
+	handler := newModifyAccInfoHandler(ctx)
+	BaseRun(handler)
+}
+
+type ModifyAccInfoHandler struct {
+	ctx  *gin.Context
+	req  *http_model.ModifyAccInfoRequest
+	resp *http_model.CommonResponse
+}
+
+func (m ModifyAccInfoHandler) getContext() *gin.Context {
+	return m.ctx
+}
+
+func (m ModifyAccInfoHandler) getResponse() interface{} {
+	return m.resp
+}
+
+func (m ModifyAccInfoHandler) getRequest() interface{} {
+	return m.req
+}
+
+func (m ModifyAccInfoHandler) run() {
+	err := db.ModifyAccInfo(m.ctx, m.req)
+	if err != nil {
+		// 数据库查询失败,返回5001
+		logrus.Errorf("[ModifyAccInfoHandler] call ModifyAccInfo err:%+v\n", err)
+		util.HandlerPackErrorResp(m.resp, consts.ErrorInternal, "")
+		logrus.Info("ModifyAccInfo fail,req:%+v", m.req)
+		return
+	}
+	m.resp.Message = "更新成功"
+}
+
+func (m ModifyAccInfoHandler) checkParam() error {
+	return nil
+}
+
+func newModifyAccInfoHandler(ctx *gin.Context) *ModifyAccInfoHandler {
+	return &ModifyAccInfoHandler{
+		ctx:  ctx,
+		req:  http_model.NewModifyAccInfoRequest(),
+		resp: http_model.NewModifyAccInfoResponse(),
+	}
+}

+ 1 - 1
model/gorm_model/platform_account_info.go

@@ -17,7 +17,7 @@ type YoungeePlatformAccountInfo struct {
 	Deleted            int       `gorm:"column:deleted;default:0"`              // 是否被解绑
 	UpdatedAt          time.Time `gorm:"column:updated_at"`                     // 更新时间
 	UpdatedPerson      int       `gorm:"column:updated_person"`                 // 更新人,0代表本人,1代表管理员
-	UpdatedAdminID     int       `gorm:"column:updated_admin_id"`               // 上一次更新的管理员id
+	UpdatedAdminID     string    `gorm:"column:updated_admin_id"`               // 上一次更新的管理员id
 }
 
 func (m *YoungeePlatformAccountInfo) TableName() string {

+ 6 - 6
model/gorm_model/project.go

@@ -13,15 +13,15 @@ type ProjectInfo struct {
 	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"`                           // 招募截止时间
+	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"`                            // 修改时间
+	CreatedAt         *time.Time `gorm:"column:created_at"`                            // 创建时间
+	UpdatedAt         *time.Time `gorm:"column:updated_at"`                            // 修改时间
 	FeeForm           string     `gorm:"column:fee_form"`                              // 稿费形式列表
 	AutoFailAt        *time.Time `gorm:"column:auto_fail_at"`                          // 失效自动处理时间
 	AutoTaskID        int64      `gorm:"column:auto_task_id;NOT NULL"`                 // 定时任务id
@@ -30,9 +30,9 @@ type ProjectInfo struct {
 	PayAt             *time.Time `gorm:"column:pay_at"`                                // 支付时间
 	AutoScriptBreakAt *time.Time `gorm:"column:auto_script_break_at"`                  // 脚本违约自动处理时间
 	AutoSketchBreakAt *time.Time `gorm:"column:auto_sketch_break_at"`                  // 初稿违约自动处理时间
-	FailReason        int        `gorm:"column:fail_reason"`                           // 失效原因,1、2分别表示逾期未支付、项目存在风险
-	PassAt            time.Time  `gorm:"column:pass_at"`                               // 审核通过时间
-	FinishAt          time.Time  `gorm:"column:finish_at"`                             // 结案时间
+	FailReason        int64      `gorm:"column:fail_reason"`                           // 失效原因,1、2分别表示逾期未支付、项目存在风险
+	PassAt            *time.Time `gorm:"column:pass_at"`                               // 审核通过时间
+	FinishAt          *time.Time `gorm:"column:finish_at"`                             // 结案时间
 }
 
 func (m *ProjectInfo) TableName() string {

+ 18 - 0
model/http_model/ModifyAccInfoRequest.go

@@ -0,0 +1,18 @@
+package http_model
+
+type ModifyAccInfoRequest struct {
+	User               string `json:"user"`                  //管理员id
+	AccountId          int    `json:"account_id"`            //账号所属id
+	PlatformNickname   string `json:"platform_nickname"`     //账号昵称
+	Fans               int64  `json:"fans"`                  //粉丝量
+	HomePageCaptureUrl string `json:"home_page_capture_url"` //主页截图链接
+	HomePageUrl        string `json:"home_page_url"`         //主页链接
+}
+
+func NewModifyAccInfoRequest() *ModifyAccInfoRequest {
+	return new(ModifyAccInfoRequest)
+}
+
+func NewModifyAccInfoResponse() *CommonResponse {
+	return new(CommonResponse)
+}

+ 1 - 0
model/http_model/platform_acc_info.go

@@ -5,6 +5,7 @@ type PlatformAccInfoRequest struct {
 }
 
 type PlatformAccInfoData struct {
+	AccountId          int    `json:"account_id"`            //账号所属id
 	Platform           string `json:"platform"`              //社媒平台
 	PlatformNickname   string `json:"platform_nickname"`     //账号昵称
 	Fans               string `json:"fans"`                  //粉丝量

+ 8 - 5
model/http_model/project_show.go

@@ -36,12 +36,15 @@ type ShowProjectData struct {
 	ProjectPhotos    []ShowProjectPhoto    `json:"project_photos"`    // 项目图片
 	ProductID        string                `json:"product_id"`        // 关联商品id
 	EnterpriseID     string                `json:"enterprise_id"`     // 企业id
-	Balance          string                `json:"balance"`           //企业余额
+	Balance          string                `json:"balance"`           // 企业余额
 	ProjectID        string                `json:"project_id"`        // 项目id
-	FailReason       string                `json:"fail_reason"`
-	CreateAt         time.Time             `json:"create_at"` //创建时间
-	UpdateAt         time.Time             `json:"update_at"` //更新时间
-	Phone            string                `json:"phone"`     //联系方式
+	FailReason       string                `json:"fail_reason"`       // 失效原因
+	Phone            string                `json:"phone"`             // 联系方式
+	CreateAt         time.Time             `json:"create_at"`         // 创建时间
+	UpdateAt         time.Time             `json:"update_at"`         // 更新时间
+	PassAt           time.Time             `json:"pass_at"`           // 审核通过时间
+	FinishAt         time.Time             `json:"finish_at"`         // 结案时间
+	PayAt            time.Time             `json:"pay_at"`            // 支付时间
 }
 
 type ShowProjectRequest struct {

+ 1 - 0
pack/platform.go

@@ -18,6 +18,7 @@ func GormPlatformToHttpPlatform(gormPlatform []*gorm_model.YoungeePlatformAccoun
 
 func gormPlatformToHttpPlatform(platformAccountInfo *gorm_model.YoungeePlatformAccountInfo) *http_model.PlatformAccInfoData {
 	return &http_model.PlatformAccInfoData{
+		AccountId:          platformAccountInfo.AccountID,
 		Platform:           consts.GetProjectPlatform(platformAccountInfo.PlatformID),
 		PlatformNickname:   platformAccountInfo.PlatformNickname,
 		Fans:               util.GetNumString(platformAccountInfo.FansCount),

+ 1 - 0
route/init.go

@@ -91,6 +91,7 @@ func InitRoute(r *gin.Engine) {
 		u.POST("/accountInfo", handler.WrapAccountInfoHandler)
 		u.POST("/deleteAccount", handler.WrapDeleteAccountHandler)
 		u.POST("/getTaskRecord", handler.WrapGetTaskRecordHandler)
+		u.POST("/modifyAccInfo", handler.WrapModifyAccInfoHandler) // 更新用户账号信息
 	}
 	o := r.Group("/youngee/m/operate")
 	{

+ 15 - 8
service/project.go

@@ -13,6 +13,7 @@ import (
 	"youngee_m_api/model/gorm_model"
 	"youngee_m_api/model/http_model"
 	"youngee_m_api/pack"
+	"youngee_m_api/util"
 )
 
 var Project *project
@@ -59,16 +60,19 @@ func (*project) GetProjectDetail(ctx context.Context, projectID int64) (*http_mo
 		ProjectPlatform: conv.MustString(project.ProjectPlatform, ""),
 		ProjectForm:     conv.MustString(project.ProjectForm, ""),
 		TalentType:      conv.MustString(project.TalentType, ""),
-		RecruitDdl:      project.RecruitDdl,
+		RecruitDdl:      util.GetTimePointer(project.RecruitDdl),
 		ContentType:     conv.MustString(project.ContentType, ""),
 		ProjectDetail:   conv.MustString(project.ProjectDetail, ""),
 		ProductID:       conv.MustString(project.ProductID, ""),
 		EnterpriseID:    conv.MustString(project.EnterpriseID, ""),
 		Balance:         conv.MustString(enterprise.Balance, ""),
 		FailReason:      conv.MustString(project.FailReason, ""),
-		CreateAt:        project.CreatedAt,
-		UpdateAt:        project.UpdatedAt,
+		CreateAt:        util.GetTimePointer(project.CreatedAt),
+		UpdateAt:        util.GetTimePointer(project.UpdatedAt),
 		Phone:           user.Phone,
+		FinishAt:        util.GetTimePointer(project.FinishAt),
+		PassAt:          util.GetTimePointer(project.PassAt),
+		PayAt:           util.GetTimePointer(project.PayAt),
 	}
 	Strategys, err := db.GetRecruitStrategys(ctx, projectID)
 	fmt.Println("招募策略:", Strategys)
@@ -324,7 +328,7 @@ func (*project) Create(ctx context.Context, newProject http_model.CreateProjectR
 		TalentType:      newProject.TalentType,
 		ProjectPlatform: newProject.ProjectPlatform,
 		ProjectForm:     newProject.ProjectForm,
-		RecruitDdl:      newProject.RecruitDdl,
+		RecruitDdl:      &newProject.RecruitDdl,
 		ProjectDetail:   newProject.ProjectDetail,
 		ContentType:     newProject.ContentType,
 		EnterpriseID:    enterpriseID,
@@ -381,7 +385,7 @@ func (*project) Update(ctx context.Context, newProject http_model.UpdateProjectR
 	fmt.Println("newproject:", newProject)
 	project := gorm_model.ProjectInfo{
 		ProjectID:     conv.MustInt64(newProject.ProjectID, 0),
-		RecruitDdl:    newProject.RecruitDdl,
+		RecruitDdl:    &newProject.RecruitDdl,
 		TalentType:    newProject.TalentType,
 		ContentType:   conv.MustInt64(newProject.ContentType, 0),
 		ProjectDetail: newProject.ProjectDetail,
@@ -499,16 +503,19 @@ func (*project) GetPorjectDetail(ctx context.Context, projectID int64) (*http_mo
 		ProjectPlatform: conv.MustString(project.ProjectPlatform, ""),
 		ProjectForm:     conv.MustString(project.ProjectForm, ""),
 		TalentType:      conv.MustString(project.TalentType, ""),
-		RecruitDdl:      project.RecruitDdl,
+		RecruitDdl:      util.GetTimePointer(project.RecruitDdl),
 		ContentType:     conv.MustString(project.ContentType, ""),
 		ProjectDetail:   conv.MustString(project.ProjectDetail, ""),
 		ProductID:       conv.MustString(project.ProductID, ""),
 		EnterpriseID:    conv.MustString(project.EnterpriseID, ""),
 		Balance:         conv.MustString(enterprise.Balance, ""),
 		FailReason:      conv.MustString(project.FailReason, ""),
-		CreateAt:        project.CreatedAt,
-		UpdateAt:        project.UpdatedAt,
+		CreateAt:        util.GetTimePointer(project.CreatedAt),
+		UpdateAt:        util.GetTimePointer(project.UpdatedAt),
 		Phone:           user.Phone,
+		FinishAt:        util.GetTimePointer(project.FinishAt),
+		PassAt:          util.GetTimePointer(project.PassAt),
+		PayAt:           util.GetTimePointer(project.PayAt),
 	}
 	Strategys, err := db.GetRecruitStrategys(ctx, projectID)
 	fmt.Println("招募策略:", Strategys)

+ 8 - 0
util/type.go

@@ -58,3 +58,11 @@ func GetRandomString(l int) string {
 	}
 	return string(result)
 }
+
+func GetTimePointer(t *time.Time) time.Time {
+	if t == nil {
+		return time.Now()
+	} else {
+		return *t
+	}
+}