dividends_estimate.go 5.6 KB
package domain

import "time"

// DividendsEstimate 分红预算实体
type DividendsEstimate struct {
	// 承接人分红预算记录ID
	DividendsEstimateId int64 `json:"dividendsEstimateId,string"`
	// 分红结算状态
	DividendsAccountStatus int32 `json:"dividendsAccountStatus"`
	// 分红金额
	DividendsAmount float64 `json:"dividendsAmount"`
	// 承接人分红预算单号
	DividendsEstimateOrderNumber string `json:"dividendsEstimateOrderNumber"`
	// 分红预算时间
	DividendsEstimateTime time.Time `json:"dividendsEstimateTime"`
	// 参与分红类型,1承接人,2推荐人,3关联业务员
	DividendsParticipateType int32 `json:"dividendsParticipateType"`
	// 分红类型,1订单分红,2退货冲销,3金额激励
	DividendsType int32 `json:"dividendsType"`
	// 分红订单号或退货单号
	OrderOrReturnedOrderNum string `json:"orderOrReturnedOrderNum"`
	// 共创项目编号,自生成,生成规则:XM+6位年月日+#+3位流水,例XM210601#001
	CooperationProjectNumber string `json:"cooperationProjectNumber"`
	// 分红用户
	DividendsUser *User `json:"dividendsUser"`
	// 数据所属组织机构
	Org *Org `json:"org"`
	// 公司
	Company *Company `json:"company"`
	// 操作人
	Operator *User `json:"operator"`
	// 操作时间
	OperateTime time.Time `json:"operateTime"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
}

type DividendsEstimateRepository interface {
	Save(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error)
	Remove(dividendsEstimate *DividendsEstimate) (*DividendsEstimate, error)
	FindOne(queryOptions map[string]interface{}) (*DividendsEstimate, error)
	Find(queryOptions map[string]interface{}) (int64, []*DividendsEstimate, error)
}

func (dividendsEstimate *DividendsEstimate) Identify() interface{} {
	if dividendsEstimate.DividendsEstimateId == 0 {
		return nil
	}
	return dividendsEstimate.DividendsEstimateId
}

func (dividendsEstimate *DividendsEstimate) Update(data map[string]interface{}) error {
	if dividendsEstimateId, ok := data["dividendsEstimateId"]; ok {
		dividendsEstimate.DividendsEstimateId = dividendsEstimateId.(int64)
	}
	if dividendsAccountStatus, ok := data["dividendsAccountStatus"]; ok {
		dividendsEstimate.DividendsAccountStatus = dividendsAccountStatus.(int32)
	}
	if dividendsAmount, ok := data["dividendsAmount"]; ok {
		dividendsEstimate.DividendsAmount = dividendsAmount.(float64)
	}
	if dividendsEstimateOrderNumber, ok := data["dividendsEstimateOrderNumber"]; ok {
		dividendsEstimate.DividendsEstimateOrderNumber = dividendsEstimateOrderNumber.(string)
	}
	if dividendsEstimateTime, ok := data["dividendsEstimateTime"]; ok {
		dividendsEstimate.DividendsEstimateTime = dividendsEstimateTime.(time.Time)
	}
	if dividendsParticipateType, ok := data["dividendsParticipateType"]; ok {
		dividendsEstimate.DividendsParticipateType = dividendsParticipateType.(int32)
	}
	if dividendsType, ok := data["dividendsType"]; ok {
		dividendsEstimate.DividendsType = dividendsType.(int32)
	}
	if orderOrReturnedOrderNum, ok := data["orderOrReturnedOrderNum"]; ok {
		dividendsEstimate.OrderOrReturnedOrderNum = orderOrReturnedOrderNum.(string)
	}
	if cooperationProjectNumber, ok := data["cooperationProjectNumber"]; ok {
		dividendsEstimate.CooperationProjectNumber = cooperationProjectNumber.(string)
	}
	if userId, ok := data["userId"]; ok {
		dividendsEstimate.DividendsUser.UserId = userId.(int64)
	}
	if userBaseId, ok := data["userBaseId"]; ok {
		dividendsEstimate.DividendsUser.UserBaseId = userBaseId.(int64)
	}
	if orgId, ok := data["orgId"]; ok {
		dividendsEstimate.DividendsUser.Org.OrgId = orgId.(int64)
	}
	if orgName, ok := data["orgName"]; ok {
		dividendsEstimate.DividendsUser.Org.OrgName = orgName.(string)
	}
	if companyId, ok := data["companyId"]; ok {
		dividendsEstimate.DividendsUser.Org.Company.CompanyId = companyId.(int64)
	}
	if companyLogo, ok := data["companyLogo"]; ok {
		dividendsEstimate.DividendsUser.Org.Company.CompanyLogo = companyLogo.(string)
	}
	if companyName, ok := data["companyName"]; ok {
		dividendsEstimate.DividendsUser.Org.Company.CompanyName = companyName.(string)
	}
	if orgs, ok := data["orgs"]; ok {
		dividendsEstimate.DividendsUser.Orgs = orgs.([]*Org)
	}
	if departmentId, ok := data["departmentId"]; ok {
		dividendsEstimate.DividendsUser.Department.DepartmentId = departmentId.(int64)
	}
	if departmentName, ok := data["departmentName"]; ok {
		dividendsEstimate.DividendsUser.Department.DepartmentName = departmentName.(string)
	}
	if departmentNumber, ok := data["departmentNumber"]; ok {
		dividendsEstimate.DividendsUser.Department.DepartmentNumber = departmentNumber.(string)
	}
	if isOrganization, ok := data["isOrganization"]; ok {
		dividendsEstimate.DividendsUser.Department.IsOrganization = isOrganization.(bool)
	}
	if userAvatar, ok := data["userAvatar"]; ok {
		dividendsEstimate.DividendsUser.UserInfo.UserAvatar = userAvatar.(string)
	}
	if userEmail, ok := data["userEmail"]; ok {
		dividendsEstimate.DividendsUser.UserInfo.UserEmail = userEmail.(string)
	}
	if userName, ok := data["userName"]; ok {
		dividendsEstimate.DividendsUser.UserInfo.UserName = userName.(string)
	}
	if userPhone, ok := data["userPhone"]; ok {
		dividendsEstimate.DividendsUser.UserInfo.UserPhone = userPhone.(string)
	}
	if userAccount, ok := data["userAccount"]; ok {
		dividendsEstimate.DividendsUser.UserInfo.UserAccount = userAccount.(string)
	}
	if userType, ok := data["userType"]; ok {
		dividendsEstimate.DividendsUser.UserType = userType.(int32)
	}
	if status, ok := data["status"]; ok {
		dividendsEstimate.DividendsUser.Status = status.(int32)
	}
	return nil
}