dividends_order.go 3.5 KB
package domain

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/command"
	"time"
)

const (
	TO_BE_DIVIDEND = iota + 1
	ALL_DIVIDENDED
	PART_DIVIDENDED
)

// DividendsOrder 分红订单实体
type DividendsOrder struct {
	// 分红订单ID
	DividendsOrderId int64 `json:"dividendsOrderId,string"`
	// 分红订单号
	DividendsOrderNumber string `json:"dividendsOrderNumber"`
	// 分红订单原单号
	DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"`
	// 分红订单金额
	DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
	// 订单日期
	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"`
}

// ImportInfo 导入错误信息
type ImportInfo struct {
	Error       error          `json:"error"`
	LineNumbers []int          `json:"lineNumbers"`
	GoodLine    map[int]string `json:"goodLine"`
}

// FailInfo 返回的失败信息
type FailInfo struct {
	FailReason string `json:"failReason"`
	*command.ImportDividendsOrderData
}

type DividendsOrderRepository interface {
	Save(dividendsOrder *DividendsOrder) (*DividendsOrder, error)
	SaveMany(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error)
	UpdateMany(dividendsOrders []*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 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)
	}
	dividendsOrder.UpdatedAt = time.Now()
	return nil
}