partner_info.go 2.0 KB
package domain

import (
	"time"
)

// 状态(1:启用或者0:禁用)
const (
	PARTNER_STATUS_NO  int = 0
	PARTNER_STATUS_YES int = 1
)

//合伙类别 (1.事业合伙人 2.业务合伙人  3.研发合伙人)
const (
	PARTNER_CATEGORY_1 int = 1
	PARTNER_CATEGORY_2 int = 2
	PARTNER_CATEGORY_3 int = 3
	PARTNER_CATEGORY_4 int = 4
)

//partnerCategoryMap 合伙类别键值对 (只读,请勿在运行时修改)
var partnerCategoryMap = map[int]string{
	PARTNER_CATEGORY_1: "事业合伙人",
	PARTNER_CATEGORY_2: "业务合伙人",
	PARTNER_CATEGORY_3: "研发合伙人",
	PARTNER_CATEGORY_4: "业务-产品应用合伙人",
}

type PartnerInfo struct {
	Partner Partner `json:"partner"`
	//合伙类别
	PartnerCategory int `json:"partnerCategory"`
	// 登录密码
	Password string `json:"password"`
	// 状态(1:启用或者0:禁用)
	Status int `json:"status"`
	//创建时间
	CreateAt time.Time `json:"createAt"`
	//更新时间
	UpdateAt time.Time `json:"updateAt"`
	//合作时间
	CooperateTime time.Time `json:"cooperateTime"`
	//关联业务员//所属区域信息
	RegionInfo *RegionInfo `json:"regionInfo"`

	Salesman []Salesman `json:"salesman"`
}

func (p *PartnerInfo) GetPartnerCategory() map[int]string {
	categoryMap := map[int]string{}
	if v, ok := partnerCategoryMap[p.PartnerCategory]; ok {
		categoryMap[p.PartnerCategory] = v
	}
	return categoryMap
}

func (p *PartnerInfo) IsUsable() bool {
	return p.Status == PARTNER_STATUS_YES
}

type PartnerFindOneQuery struct {
	UserId       int64
	AccountEqual string
}

type PartnerFindQuery struct {
	Offset          int
	Limit           int
	PartnerCategory []int       //合伙人类型
	RegionInfo      *RegionInfo //区域
	PartnerName     string      //合伙人姓名
}

type PartnerInfoRepository interface {
	Save(dm PartnerInfo) (*PartnerInfo, error)
	FindOne(queryOptions PartnerFindOneQuery) (*PartnerInfo, error)
	Find(queryOptions PartnerFindQuery) ([]PartnerInfo, error)
	CountAll(queryOptions PartnerFindQuery) (int, error)
}