credit_account.go 2.8 KB
package domain

import "time"

// CreditAccount 账期结算单实体
type CreditAccount struct {
	// 账期结算单ID
	CreditAccountId int64 `json:"creditAccountId,string"`
	// 账期结算实付金额
	ActuallyPaidAmount float64 `json:"actuallyPaidAmount"`
	// 账期结算单号
	CreditAccountOrderNum string `json:"creditAccountOrderNum"`
	// 账期结算支付状态,1待支付,2已支付
	PaymentStatus int32 `json:"paymentStatus"`
	// 共创账期结算支付时间
	PaymentTime time.Time `json:"paymentTime"`
	// 账期结算金额
	SettlementAmount float64 `json:"settlementAmount"`
	// 共创账期结算时间
	SettlementTime time.Time `json:"settlementTime"`
	// 关联共创合约编号
	CooperationContractNumber string `json:"cooperationContractNumber"`
	// 参与人uid,包括承接人、推荐人、关联业务员
	Participator *Participator `json:"participator"`
	// 参与类型
	ParticipateType string `json:"participateType"`
	// 结算明细
	AccountDetail []*AccountDetail `json:"accountDetail"`
	// 支付凭证附件
	PaymentDocumentAttachment *Attachment `json:"paymentDocumentAttachment"`
	// 数据所属组织机构
	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"`
	//备注
	Remarks string `json:"remarks"`
}

type CreditAccountRepository interface {
	Save(creditAccount *CreditAccount) (*CreditAccount, error)
	Remove(creditAccount *CreditAccount) (*CreditAccount, error)
	FindOne(queryOptions map[string]interface{}) (*CreditAccount, error)
	Find(queryOptions map[string]interface{}) (int64, []*CreditAccount, error)
}

func (creditAccount *CreditAccount) Identify() interface{} {
	if creditAccount.CreditAccountId == 0 {
		return nil
	}
	return creditAccount.CreditAccountId
}

func (creditAccount *CreditAccount) Update(data map[string]interface{}) error {
	if actuallyPaidAmount, ok := data["actuallyPaidAmount"]; ok {
		creditAccount.ActuallyPaidAmount = actuallyPaidAmount.(float64)
	}
	if creditAccountOrderNum, ok := data["creditAccountOrderNum"]; ok {
		creditAccount.CreditAccountOrderNum = creditAccountOrderNum.(string)
	}
	if paymentStatus, ok := data["paymentStatus"]; ok {
		creditAccount.PaymentStatus = paymentStatus.(int32)
	}
	if paymentDocumentAttachment, ok := data["paymentDocumentAttachment"]; ok {
		creditAccount.PaymentDocumentAttachment = paymentDocumentAttachment.(*Attachment)
	}
	if remarks, ok := data["remarks"]; ok {
		creditAccount.Remarks = remarks.(string)
	}
	if actuallyPaidAmount, ok := data["actuallyPaidAmount"]; ok {
		creditAccount.ActuallyPaidAmount = actuallyPaidAmount.(float64)
	}
	return nil
}