From 8614837410d7665303ce03ba999b65413baed4c5 Mon Sep 17 00:00:00 2001 From: kanade Date: Tue, 9 Dec 2025 13:11:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(erp):=20=E6=B7=BB=E5=8A=A0=E5=BA=94?= =?UTF-8?q?=E4=BB=98=E6=A8=A1=E5=9D=97=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增应付模块,支持应付列表和详情接口 - 添加应付单据的保存功能 - 实现与客户端的通信调用逻辑 - 定义应付相关的数据结构和参数类型 - 支持分页查询和搜索条件过滤 --- client/client.go | 15 ++++- erp/erp.go | 1 + erp/payable.go | 105 ++++++++++++++++++++++++++++++++++ ik3cloud/constant/constant.go | 3 +- ik3cloud/ik3cloud.go | 3 +- ik3cloud/payable.go | 26 +++++++++ ik3cloud/payment.go | 25 -------- ik3cloud/receivable.go | 25 ++++++++ 8 files changed, 173 insertions(+), 30 deletions(-) create mode 100644 erp/payable.go create mode 100644 ik3cloud/payable.go delete mode 100644 ik3cloud/payment.go create mode 100644 ik3cloud/receivable.go diff --git a/client/client.go b/client/client.go index 8b498d4..df6bd10 100644 --- a/client/client.go +++ b/client/client.go @@ -61,9 +61,18 @@ func GetClient(s interface{}) (*RpcClient, error) { mutex.Lock() xClient, ok = mClient.Load(key) if !ok { - d, err := consulClient.NewConsulDiscovery(basePath, servicePath, config.RpcConfig.RegistryServer, nil) - if err != nil { - return nil, errors.New("系统异常") + var d client.ServiceDiscovery + var err error + if basePath == "ik3cloud" { + d, err = client.NewPeer2PeerDiscovery("tcp@localhost:8081", "") + if err != nil { + return nil, errors.New("系统异常") + } + } else { + d, err = consulClient.NewConsulDiscovery(basePath, servicePath, config.RpcConfig.RegistryServer, nil) + if err != nil { + return nil, errors.New("系统异常") + } } option := client.DefaultOption option.Retries = 3 diff --git a/erp/erp.go b/erp/erp.go index 779d3dd..03784d0 100644 --- a/erp/erp.go +++ b/erp/erp.go @@ -12,4 +12,5 @@ type Erp struct { Contact contact Template template Accounting accounting + Payable payable } diff --git a/erp/payable.go b/erp/payable.go new file mode 100644 index 0000000..165700a --- /dev/null +++ b/erp/payable.go @@ -0,0 +1,105 @@ +package erp + +import ( + "context" + "time" + + "git.kumo.work/shama/service/client" + "git.kumo.work/shama/service/lib/bean" + "github.com/shopspring/decimal" +) + +type payable struct { +} +type ArgsPayableList struct { + Page bean.Page + Search PayableSearch +} +type PayableSearch struct { + PayableSerial string // 付款单据号 + FactoryId int64 // 工厂id + AccountingSerial string // 做账单号 + CreatedAtStart *time.Time // 创建开始时间 + CreatedAtEnd *time.Time // 创建结束时间 + IsConfirm int64 // 是否确认 +} +type ReplyPayableList struct { + List []PayableItem `json:"list"` + Total int64 `json:"total"` +} +type PayableItem struct { + Id int64 `json:"id"` + PayableSerial string `json:"payableSerial"` + FactoryName string `json:"factoryName"` + AccountingSerial string `json:"accountingSerial"` + Amount decimal.Decimal `json:"amount"` + Currency string `json:"currency"` + CurrencyName string `json:"currencyName"` + CurrencyRate decimal.Decimal `json:"currencyRate"` + CurrencySymbol string `json:"currencySymbol"` + IsConfirm int64 `json:"isConfirm"` + PurchaseStaffId int64 `json:"purchaseStaffId"` + CreatedAt *time.Time `json:"createdAt"` + UpdatedAt *time.Time `json:"updatedAt"` +} + +// List @TITLE 列表 +func (p *payable) List(ctx context.Context, args ArgsPayableList) (reply ReplyPayableList, total int64) { + xClient, err := client.GetClient(p) + if err != nil { + return + } + err = xClient.Call(ctx, "List", args, &reply) + return +} + +type ReplyPayableInfo struct { + Id int64 `json:"id"` + PayableSerial string `json:"payableSerial"` + AccountingSerial string `json:"accountingSerial"` + FactoryName string `json:"factoryName"` + FactoryBank string `json:"factoryBank"` + FactoryBankAccount string `json:"factoryBankAccount"` + Amount decimal.Decimal `json:"amount"` + Currency string `json:"currency"` + CurrencyName string `json:"currencyName"` + CurrencyRate decimal.Decimal `json:"currencyRate"` + CurrencySymbol string `json:"currencySymbol"` + PurchaseStaffId int64 `json:"purchaseStaffId"` + IsConfirm int64 `json:"isConfirm"` + CreatedAt *time.Time `json:"createdAt"` + UpdatedAt *time.Time `json:"updatedAt"` + Products []PayableProductItem `json:"products"` + Costs []PayableCostItem `json:"costs"` +} + +type PayableProductItem struct { + Id int64 `json:"id"` + AccountingProductId int64 `json:"accountingProductId"` + Name string `json:"name"` + Serial string `json:"serial"` + PayableCount int64 `json:"payableCount"` + AddTaxRate decimal.Decimal `json:"addTaxRate"` + UnitPrice decimal.Decimal `json:"unitPrice"` + ExTaxUnitPrice decimal.Decimal `json:"exTaxUnitPrice"` + UnitAmount decimal.Decimal `json:"unitAmount"` + ExTaxUnitAmount decimal.Decimal `json:"exTaxUnitAmount"` + TaxAmount decimal.Decimal `json:"taxAmount"` +} + +type PayableCostItem struct { + Id int64 `json:"id"` + Name string `json:"name"` + Amount decimal.Decimal `json:"amount"` + Remarks string `json:"remarks"` +} + +// Info @TITLE 详情 +func (p *payable) Info(ctx context.Context, payableId int64) (reply ReplyPayableInfo, err error) { + xClient, err := client.GetClient(p) + if err != nil { + return + } + err = xClient.Call(ctx, "List", payableId, &reply) + return +} diff --git a/ik3cloud/constant/constant.go b/ik3cloud/constant/constant.go index 1fe9b0c..fa9afc1 100644 --- a/ik3cloud/constant/constant.go +++ b/ik3cloud/constant/constant.go @@ -11,7 +11,8 @@ const ( ActionFactory Action = "BD_Supplier" // 工厂 ActionContact Action = "BD_CommonContact" // 联系人 ActionCustom Action = "BD_Customer" // 客户 - ActionPayment Action = "AR_receivable" // 付款单 + ActionReceivable Action = "AR_receivable" // 付款单 + ActionPayable Action = "AP_Payable" // 付款单 ActionProduct Action = "BD_MATERIAL" // 物料 ) diff --git a/ik3cloud/ik3cloud.go b/ik3cloud/ik3cloud.go index 1a38c40..cd1362b 100644 --- a/ik3cloud/ik3cloud.go +++ b/ik3cloud/ik3cloud.go @@ -7,8 +7,9 @@ type Ik3cloud struct { Contact contact // 联系人 Factory factory // 工厂 Custom custom // 客户 - Payment payment // 付款 Product product // 产品 + Receivable receivable // 应收 + Payable payable // 应付 } type Entity struct { Id int64 `json:"Id"` diff --git a/ik3cloud/payable.go b/ik3cloud/payable.go new file mode 100644 index 0000000..1a6009a --- /dev/null +++ b/ik3cloud/payable.go @@ -0,0 +1,26 @@ +package ik3cloud + +import ( + "context" + + "git.kumo.work/shama/service/client" +) + +type payable struct { +} +type ArgsPayableSave struct { + PayableId int64 // 应付单id + Number string // 编码 + CustomNumber string // 客户编码 + FactoryNumber string // 工厂编码 +} + +// Save @TITLE 保存应付 +func (p *payable) Save(ctx context.Context, args ArgsPayableSave) (entity Entity, err error) { + xClient, err := client.GetClient(p) + if err != nil { + return + } + err = xClient.Call(ctx, "Save", args, &entity) + return +} diff --git a/ik3cloud/payment.go b/ik3cloud/payment.go deleted file mode 100644 index e02dad6..0000000 --- a/ik3cloud/payment.go +++ /dev/null @@ -1,25 +0,0 @@ -package ik3cloud - -import ( - "context" - - "git.kumo.work/shama/service/client" -) - -type payment struct { -} -type ArgsPaymentSave struct { - PaymentId int64 // 付款单id - Number string // 编码 - CustomNumber string // 客户编码 -} - -// Save @TITLE 保存客户 -func (p *payment) Save(ctx context.Context, args ArgsPaymentSave) (entity Entity, err error) { - xClient, err := client.GetClient(p) - if err != nil { - return - } - err = xClient.Call(ctx, "Save", args, &entity) - return -} diff --git a/ik3cloud/receivable.go b/ik3cloud/receivable.go new file mode 100644 index 0000000..e2bc9bd --- /dev/null +++ b/ik3cloud/receivable.go @@ -0,0 +1,25 @@ +package ik3cloud + +import ( + "context" + + "git.kumo.work/shama/service/client" +) + +type receivable struct { +} +type ArgsReceivableSave struct { + ReceivableId int64 // 应收单id + Number string // 编码 + CustomNumber string // 客户编码 +} + +// Save @TITLE 保存应收 +func (r *receivable) Save(ctx context.Context, args ArgsReceivableSave) (entity Entity, err error) { + xClient, err := client.GetClient(r) + if err != nil { + return + } + err = xClient.Call(ctx, "Save", args, &entity) + return +}