dividends_order.go 4.5 KB
package domain

import "time"

// DividendsOrder 分红订单实体
type DividendsOrder struct {
	// 分红订单ID
	DividendsOrderId int64 `json:"dividendsOrderId,string"`
	// 分红订单号
	DividendsOrderNumber string `json:"dividendsOrderNumber"`
	// 分红订单原单号
	DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"`
	// 分红订单金额
	DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
	// 订单业务员
	OrderSalesman *Salesman `json:"orderSalesman"`
	// 订单日期
	OrderTime time.Time `json:"orderTime"`
	// 分红订单分红时间
	DividendTime time.Time `json:"dividendTime"`
	// 分红订单分红状态,1待分红,2已分红,3部分分红
	DividendStatus int32 `json:"dividendStatus"`
	// 区域
	Region *RegionInfo `json:"region"`
	// 客户姓名
	CustomerName string `json:"customerName"`
	// 订单产品列表
	Goods []*OrderGood `json:"goods"`
	// 数据所属组织机构
	Org *Org `json:"org"`
	// 公司
	Company *Company `json:"company"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
	// 操作时间
	OperateTime time.Time `json:"operateTime"`
	// 操作人
	Operator *User `json:"operator"`
	// 备注
	Remarks string `json:"remarks"`
}

type DividendsOrderRepository interface {
	Save(dividendsOrder *DividendsOrder) (*DividendsOrder, error)
	Remove(dividendsOrder *DividendsOrder) (*DividendsOrder, error)
	BatchRemove(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error)
	FindOne(queryOptions map[string]interface{}) (*DividendsOrder, error)
	Find(queryOptions map[string]interface{}) (int64, []*DividendsOrder, error)
}

func (dividendsOrder *DividendsOrder) Identify() interface{} {
	if dividendsOrder.DividendsOrderId == 0 {
		return nil
	}
	return dividendsOrder.DividendsOrderId
}

func (dividendsOrder *DividendsOrder) Update(data map[string]interface{}) error {
	if dividendsOrderNumber, ok := data["dividendsOrderNumber"]; ok {
		dividendsOrder.DividendsOrderNumber = dividendsOrderNumber.(string)
	}
	if dividendsOriginalOrderNum, ok := data["dividendsOriginalOrderNum"]; ok {
		dividendsOrder.DividendsOriginalOrderNum = dividendsOriginalOrderNum.(string)
	}
	if dividendsOrderAmount, ok := data["dividendsOrderAmount"]; ok {
		dividendsOrder.DividendsOrderAmount = dividendsOrderAmount.(float64)
	}
	if userId, ok := data["userId"]; ok {
		dividendsOrder.OrderSalesman.UserId = userId.(int64)
	}
	if userBaseId, ok := data["userBaseId"]; ok {
		dividendsOrder.OrderSalesman.UserBaseId = userBaseId.(int64)
	}
	if orgId, ok := data["orgId"]; ok {
		dividendsOrder.OrderSalesman.Org.OrgId = orgId.(int64)
	}
	if orgName, ok := data["orgName"]; ok {
		dividendsOrder.OrderSalesman.Org.OrgName = orgName.(string)
	}
	if companyId, ok := data["companyId"]; ok {
		dividendsOrder.OrderSalesman.Org.Company.CompanyId = companyId.(int64)
	}
	if companyLogo, ok := data["companyLogo"]; ok {
		dividendsOrder.OrderSalesman.Org.Company.CompanyLogo = companyLogo.(string)
	}
	if companyName, ok := data["companyName"]; ok {
		dividendsOrder.OrderSalesman.Org.Company.CompanyName = companyName.(string)
	}
	if userAvatar, ok := data["userAvatar"]; ok {
		dividendsOrder.OrderSalesman.UserInfo.UserAvatar = userAvatar.(string)
	}
	if userEmail, ok := data["userEmail"]; ok {
		dividendsOrder.OrderSalesman.UserInfo.UserEmail = userEmail.(string)
	}
	if userName, ok := data["userName"]; ok {
		dividendsOrder.OrderSalesman.UserInfo.UserName = userName.(string)
	}
	if userPhone, ok := data["userPhone"]; ok {
		dividendsOrder.OrderSalesman.UserInfo.UserPhone = userPhone.(string)
	}
	if userAccount, ok := data["userAccount"]; ok {
		dividendsOrder.OrderSalesman.UserInfo.UserAccount = userAccount.(string)
	}
	if userType, ok := data["userType"]; ok {
		dividendsOrder.OrderSalesman.UserType = userType.(int32)
	}
	if orderTime, ok := data["orderTime"]; ok {
		dividendsOrder.OrderTime = orderTime.(time.Time)
	}
	if dividendTime, ok := data["dividendTime"]; ok {
		dividendsOrder.DividendTime = dividendTime.(time.Time)
	}
	if dividendStatus, ok := data["dividendStatus"]; ok {
		dividendsOrder.DividendStatus = dividendStatus.(int32)
	}
	if regionNumber, ok := data["regionNumber"]; ok {
		dividendsOrder.Region.RegionNumber = regionNumber.(string)
	}
	if regionName, ok := data["regionName"]; ok {
		dividendsOrder.Region.RegionName = regionName.(string)
	}
	if customerName, ok := data["customerName"]; ok {
		dividendsOrder.CustomerName = customerName.(string)
	}
	return nil
}