feat:优化项目信息
This commit is contained in:
@ -1 +0,0 @@
|
||||
package api
|
@ -116,8 +116,9 @@ type (
|
||||
}
|
||||
// achievementForm 成果参数
|
||||
achievementForm struct {
|
||||
Mode int `json:"mode" form:"mode" binding:"required"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Mode int `json:"mode" form:"mode" binding:"required"`
|
||||
Title string `json:"title" form:"title" binding:"required"`
|
||||
Description string `json:"description" form:"description" binding:"required"`
|
||||
api.ImageForm
|
||||
File string `json:"file" form:"file" binding:"required"`
|
||||
Industrys []string `json:"industrys" form:"industrys"`
|
||||
@ -732,7 +733,7 @@ func (*Technology) AchievementAdd(c *gin.Context) {
|
||||
err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).
|
||||
Form(&technology2.AchievementParams{Mode: form.Mode,
|
||||
Title: form.Title, Image: form.FilterImageURL(), File: form.FilterFile(),
|
||||
Introduce: form.Introduce, Industrys: form.Industrys,
|
||||
Description: form.Description, Introduce: form.Introduce, Industrys: form.Industrys,
|
||||
Maturity: form.Maturity, LeadStandard: form.LeadStandard, CooperationMode: form.CooperationMode,
|
||||
Customers: form.Customers, Keywords: form.Keywords, IsSubmit: form.IsSubmit,
|
||||
})
|
||||
@ -751,7 +752,7 @@ func (*Technology) AchievementEdit(c *gin.Context) {
|
||||
err := technology2.NewAchievement()(api.GetSession()(c).(*session.Enterprise), api.GetTenantID()(c).(uint64)).
|
||||
Form(&technology2.AchievementParams{ID: form.Convert(), Mode: form.Mode,
|
||||
Title: form.Title, Image: form.FilterImageURL(), File: form.FilterFile(),
|
||||
Introduce: form.Introduce, Industrys: form.Industrys,
|
||||
Description: form.Description, Introduce: form.Introduce, Industrys: form.Industrys,
|
||||
Maturity: form.Maturity, LeadStandard: form.LeadStandard, CooperationMode: form.CooperationMode,
|
||||
Customers: form.Customers, Keywords: form.Keywords, IsSubmit: form.IsSubmit,
|
||||
})
|
||||
|
@ -173,6 +173,8 @@ func (*User) ConsumeDelete(c *gin.Context) {
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
// 提现管理
|
||||
|
||||
func (*User) Withdrawal(c *gin.Context) {
|
||||
form := &struct {
|
||||
Status int `json:"status" form:"status"`
|
||||
|
@ -22,7 +22,7 @@ type (
|
||||
InstanceLoginParams struct {
|
||||
UID uint64
|
||||
Avatar, Name, Mobile string
|
||||
Vip model2.UserInstanceVipKind
|
||||
Vip uint64
|
||||
VipStatus bool
|
||||
VipDeadline time.Time
|
||||
Currency float64
|
||||
|
@ -1 +0,0 @@
|
||||
package config
|
1
app/api/enterprise/controller/sys/instance.go
Normal file
1
app/api/enterprise/controller/sys/instance.go
Normal file
@ -0,0 +1 @@
|
||||
package sys
|
54
app/api/enterprise/controller/sys/vip.go
Normal file
54
app/api/enterprise/controller/sys/vip.go
Normal file
@ -0,0 +1,54 @@
|
||||
package sys
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
)
|
||||
|
||||
type Vip struct {
|
||||
*session.Enterprise
|
||||
}
|
||||
|
||||
type VipHandle func(session *session.Enterprise) *Vip
|
||||
|
||||
type (
|
||||
// VipInfo 会员信息
|
||||
VipInfo struct {
|
||||
ID string `json:"id"`
|
||||
*model2.SysVip
|
||||
}
|
||||
// VipInstance 会员首页信息
|
||||
VipInstance struct {
|
||||
Data []*VipInfo `json:"data"`
|
||||
Functions map[int]string `json:"functions"`
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
func (c *Vip) Instance() (*VipInstance, error) {
|
||||
mSysVip := model.NewSysVip()
|
||||
|
||||
out := make([]*model2.SysVip, 0)
|
||||
|
||||
if err := model2.Scan(mSysVip.SysVip, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data := make([]*VipInfo, 0)
|
||||
|
||||
for _, v := range out {
|
||||
data = append(data, &VipInfo{
|
||||
ID: v.GetEncodeID(), SysVip: v,
|
||||
})
|
||||
}
|
||||
return &VipInstance{
|
||||
Data: data,
|
||||
Functions: mSysVip.GetFunctions(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewVip() VipHandle {
|
||||
return func(session *session.Enterprise) *Vip {
|
||||
return &Vip{session}
|
||||
}
|
||||
}
|
@ -45,7 +45,7 @@ type (
|
||||
// AchievementParams 成果参数信息
|
||||
AchievementParams struct {
|
||||
ID uint64
|
||||
Title, Image, File, Introduce, Source string
|
||||
Title, Image, File, Introduce, Description string
|
||||
Mode, Maturity, LeadStandard, CooperationMode int // 技术成熟度 领先标准 合作模式
|
||||
Industrys, Customers, Keywords []string // 所属客户 关键词
|
||||
IsSubmit int // 是否提交审核
|
||||
@ -177,7 +177,7 @@ func (c *Achievement) Form(params *AchievementParams) error {
|
||||
mTechnologyAchievement.CooperationMode = config.TechnologyCooperationMode(params.CooperationMode)
|
||||
mTechnologyAchievement.SetKeywordAttribute(params.Keywords)
|
||||
mTechnologyAchievement.Introduce = params.Introduce
|
||||
mTechnologyAchievement.Source = params.Source
|
||||
mTechnologyAchievement.Description = params.Description
|
||||
|
||||
if mTechnologyAchievement.ID > 0 {
|
||||
mTechnologyAchievement.Status = model2.TechnologyStatusKindForExamining
|
||||
|
68
app/api/enterprise/controller/user/vip.go
Normal file
68
app/api/enterprise/controller/user/vip.go
Normal file
@ -0,0 +1,68 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"SciencesServer/app/api/enterprise/model"
|
||||
"SciencesServer/app/basic/controller"
|
||||
model2 "SciencesServer/app/common/model"
|
||||
"SciencesServer/app/session"
|
||||
"SciencesServer/lib"
|
||||
"errors"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Vip struct {
|
||||
*session.Enterprise
|
||||
}
|
||||
|
||||
type VipHandle func(session *session.Enterprise) *Vip
|
||||
|
||||
// Open 开通会员
|
||||
func (c *Vip) Open(id uint64) (*controller.ReturnPayment, error) {
|
||||
mSysVip := model.NewSysVip()
|
||||
mSysVip.ID = id
|
||||
|
||||
isExist, err := model2.FirstField(mSysVip.SysVip, []string{"id", "level", "effect_time", "price", "is_disabled"})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !isExist {
|
||||
return nil, errors.New("操作错误,会员信息不存在或已删除")
|
||||
} else if mSysVip.IsDeleted > 0 {
|
||||
return nil, errors.New("操作错误,当前会员不允许开通")
|
||||
}
|
||||
// 查询用户会员信息
|
||||
mUserInstance := model.NewUserInstance()
|
||||
|
||||
if _, err = model2.FirstField(mUserInstance.UserInstance, []string{"id", "vip", "vip_deadline"},
|
||||
model2.NewWhere("uuid", c.UID)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 会员状态有效期内,不可降级
|
||||
if mUserInstance.VipStatus() {
|
||||
mSysVip2 := model.NewSysVip()
|
||||
mSysVip2.ID = mUserInstance.Vip
|
||||
|
||||
if isExist, err = model2.FirstField(mSysVip2.SysVip, []string{"id", "level"}); err != nil {
|
||||
return nil, err
|
||||
} else if isExist && mSysVip2.Level > mSysVip.Level {
|
||||
return nil, errors.New("操作错误,会员有效期间内不可以降级")
|
||||
}
|
||||
}
|
||||
mOrderInstance := model.NewOrderInstance()
|
||||
mOrderInstance.UID = c.UID
|
||||
mOrderInstance.OrderNo = lib.OrderNo()
|
||||
mOrderInstance.Amount = mSysVip.Price
|
||||
mOrderInstance.SetParamsAttribute(model2.OrderInstanceParamsKindForVIP, &model2.OrderInstanceParamsForVip{
|
||||
ID: mSysVip.ID, EffectTime: mSysVip.EffectTime,
|
||||
})
|
||||
return &controller.ReturnPayment{
|
||||
Auth: mOrderInstance.GetEncodeID(),
|
||||
Timestamp: time.Now().Unix(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewVip() VipHandle {
|
||||
return func(session *session.Enterprise) *Vip {
|
||||
return &Vip{session}
|
||||
}
|
||||
}
|
11
app/api/enterprise/model/sys_vip.go
Normal file
11
app/api/enterprise/model/sys_vip.go
Normal file
@ -0,0 +1,11 @@
|
||||
package model
|
||||
|
||||
import "SciencesServer/app/common/model"
|
||||
|
||||
type SysVip struct {
|
||||
*model.SysVip
|
||||
}
|
||||
|
||||
func NewSysVip() *SysVip {
|
||||
return &SysVip{model.NewSysVip()}
|
||||
}
|
Reference in New Issue
Block a user