order_good.go 2.5 KB
package domain

import "time"

const (
	TO_BE_DIVIDENDED = iota + 1 // 待分红
	DIVIDENDED                  // 已分红
)

// OrderGood 订单产品领域实体(包括分红订单、分红退货单)
type OrderGood struct {
	// 订单产品
	OrderGoodId int64 `json:"orderGoodId,string"`
	// 订单产品金额
	OrderGoodAmount float64 `json:"orderGoodAmount"`
	// 订单产品名称
	OrderGoodName string `json:"orderGoodName"`
	// 订单产品单价
	OrderGoodPrice float64 `json:"orderGoodPrice"`
	// 订单产品数量
	OrderGoodQuantity int64 `json:"orderGoodQuantity,string"`
	// 关联分红订单号
	DividendsOrderNumber string `json:"dividendsOrderNumber"`
	// 关联的分红退货单号
	DividendsReturnedOrderNumber string `json:"dividendsReturnedOrderNumber"`
	// 关联的共创合约编号
	CooperationContractNumber string `json:"cooperationContractNumber"`
	// 订单产品支出费用
	OrderGoodExpense float64 `json:"orderGoodExpense"`
	// 订单产品分红状态, 1待分红,2已分红
	OrderGoodDividendsStatus int32 `json:"OrderGoodDividendsStatus"`
	// 组织机构ID
	OrgId int64 `json:"orgId"`
	// 公司ID
	CompanyId int64 `json:"companyId"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
}

type OrderGoodRepository interface {
	Save(orderGood *OrderGood) (*OrderGood, error)
	Remove(orderGood *OrderGood) (*OrderGood, error)
	FindOne(queryOptions map[string]interface{}) (*OrderGood, error)
	Find(queryOptions map[string]interface{}) (int64, []*OrderGood, error)
}

func (orderGood *OrderGood) Identify() interface{} {
	if orderGood.OrderGoodId == 0 {
		return nil
	}
	return orderGood.OrderGoodId
}

func (orderGood *OrderGood) Update(data map[string]interface{}) error {
	if orderGoodAmount, ok := data["orderGoodAmount"]; ok {
		orderGood.OrderGoodAmount = orderGoodAmount.(float64)
	}
	if orderGoodName, ok := data["orderGoodName"]; ok {
		orderGood.OrderGoodName = orderGoodName.(string)
	}
	if orderGoodPrice, ok := data["orderGoodPrice"]; ok {
		orderGood.OrderGoodPrice = orderGoodPrice.(float64)
	}
	if orderGoodQuantity, ok := data["orderGoodQuantity"]; ok {
		orderGood.OrderGoodQuantity = orderGoodQuantity.(int64)
	}
	if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
		orderGood.CooperationContractNumber = cooperationContractNumber.(string)
	}
	if orderGoodExpense, ok := data["orderGoodExpense"]; ok {
		orderGood.OrderGoodExpense = orderGoodExpense.(float64)
	}
	return nil
}