credit_account_item.go 3.8 KB
package dto

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_cooperation"
)

type CreditAccountItem struct {
	CreditAccountId           int     `json:"creditAccountId"`           // 账期结算单ID
	ActuallyPaidAmount        float64 `json:"actuallyPaidAmount"`        // 账期结算实付金额
	CreditAccountOrderNum     string  `json:"creditAccountOrderNum"`     // 账期结算单号
	PaymentStatus             int     `json:"paymentStatus"`             // 账期结算支付状态,1待支付,2已支付
	PaymentTime               int64   `json:"paymentTime"`               // 共创账期结算支付时间
	SettlementAmount          float64 `json:"settlementAmount"`          // 账期结算金额
	SettlementTime            int64   `json:"settlementTime"`            // 共创账期结算时间
	CooperationContractNumber string  `json:"cooperationContractNumber"` // 关联共创合约编号
	Participator              struct {
		UserName  string `json:"userName"`  // 用户姓名
		UserPhone string `json:"userPhone"` // 用户手机号
		UserType  int    `json:"userType"`  // 用户类型,1员工,2共创用户,3公开
		UserInfo  struct {
			// 用户姓名
			UserName string `json:"userName,omitempty"`
			// 手机号码
			UserPhone string `json:"userPhone,omitempty"`
			// 头像
			//Avatar string `json:"avatar,omitempty"`
			// 邮箱
			//Email string `json:"email,omitempty"`
		} `json:"userInfo"`
	} `json:"participator"` // 参与人
	ParticipateType           string              `json:"participateType"`           // 参与类型
	PaymentDocumentAttachment []domain.Attachment `json:"paymentDocumentAttachment"` // 支付凭证附件,复数
	Org                       domain.Org          `json:"org"`                       // 数据所属组织机构
	Company                   domain.CompanyData  `json:"company"`                   // 公司
	CreatedAt                 int64               `json:"createdAt"`                 // 创建时间
	UpdatedAt                 int64               `json:"updatedAt"`                 // 更新时间
	AccountDetail             []struct {
		DividendsEstimateOrderNumber string  `json:"dividendsEstimateOrderNumber"`
		DividendsType                int     `json:"dividendsType"`
		DividendsAmount              float64 `json:"dividendsAmount"`
	} `json:"accountDetail"` //结算明细
	//备注
	Remarks string `json:"remark"`
}

func ToCreditAccountItem(param *allied_creation_cooperation.CreditAccount) *CreditAccountItem {
	data := CreditAccountItem{
		CreditAccountId:           param.CreditAccountId,
		ActuallyPaidAmount:        param.ActuallyPaidAmount,
		CreditAccountOrderNum:     param.CreditAccountOrderNum,
		PaymentStatus:             param.PaymentStatus,
		PaymentTime:               param.PaymentTime.Unix() * 1000,
		SettlementAmount:          param.SettlementAmount,
		SettlementTime:            param.SettlementTime.Unix() * 1000,
		CooperationContractNumber: param.CooperationContractNumber,
		ParticipateType:           param.ParticipateType,            // 参与类型
		PaymentDocumentAttachment: param.PaymentDocumentAttachments, // 支付凭证附件
		Org: domain.Org{
			OrgID:   param.Org.OrgID,
			OrgName: param.Org.OrgName,
		}, // 数据所属组织机构
		Company:       param.Company,                 // 公司
		CreatedAt:     param.CreatedAt.Unix() * 1000, // 创建时间
		UpdatedAt:     param.UpdatedAt.Unix() * 1000, // 更新时间
		AccountDetail: param.AccountDetail,
		Remarks:       param.Remarks,
	}
	data.Participator.UserInfo.UserName = param.Participator.UserInfo.UsersName
	data.Participator.UserInfo.UserPhone = param.Participator.UserInfo.Phone
	data.Participator.UserType = param.Participator.UserType
	return &data
}