From 6928ef5088b0077cfb1947cd2549958f89d3ceaf Mon Sep 17 00:00:00 2001 From: kanade Date: Tue, 9 Dec 2025 14:15:49 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor(client):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=BC=80=E5=8F=91=E7=8E=AF=E5=A2=83=E7=9A=84?= =?UTF-8?q?=E7=A1=AC=E7=BC=96=E7=A0=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除针对本地开发环境的硬编码服务发现配置 - 统一使用 Consul 作为服务发现机制 - 简化客户端初始化逻辑 - 提升代码可维护性和一致性 - 避免在生产环境中潜在的配置冲突 - 强制依赖注册中心以确保服务治理统一性 --- client/client.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/client/client.go b/client/client.go index df6bd10..8b498d4 100644 --- a/client/client.go +++ b/client/client.go @@ -61,18 +61,9 @@ func GetClient(s interface{}) (*RpcClient, error) { mutex.Lock() xClient, ok = mClient.Load(key) if !ok { - 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("系统异常") - } + d, err := consulClient.NewConsulDiscovery(basePath, servicePath, config.RpcConfig.RegistryServer, nil) + if err != nil { + return nil, errors.New("系统异常") } option := client.DefaultOption option.Retries = 3 -- 2.49.1 From e0f18fb83765142c2c3400cd5c78e28380a9ef3c Mon Sep 17 00:00:00 2001 From: kanade Date: Thu, 11 Dec 2025 11:04:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat(erp):=20=E6=96=B0=E5=A2=9E=E6=94=B6?= =?UTF-8?q?=E6=B1=87=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97=E5=8F=8A=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增收汇单据管理,支持列表、详情、新增、编辑功能 - 新增收汇认领管理,支持认领列表、新增、编辑、删除、确认及取消确认功能 - 新增国内扣费类型常量定义(外币、人民币) - 优化服务发现逻辑,针对特定 basePath 使用本地调试地址 - 修复应收模块方法接收者命名问题,统一为 r *receivable --- client/client.go | 15 ++++- erp/constant.go | 6 ++ erp/erp.go | 1 + erp/receipt.go | 129 +++++++++++++++++++++++++++++++++++++++++ erp/receipt/claim.go | 127 ++++++++++++++++++++++++++++++++++++++++ erp/receipt/receipt.go | 5 ++ erp/receivable.go | 8 +-- 7 files changed, 284 insertions(+), 7 deletions(-) create mode 100644 erp/receipt.go create mode 100644 erp/receipt/claim.go create mode 100644 erp/receipt/receipt.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/constant.go b/erp/constant.go index 36c1204..96d0776 100644 --- a/erp/constant.go +++ b/erp/constant.go @@ -81,3 +81,9 @@ const ( FlagTrue Flag = 1 // 是 FlagFalse Flag = 2 // 否 ) + +type DomesticFeeType = int64 // 国内扣费类型 1=外币 2=人民币 +const ( + DomesticFeeTypeForeign DomesticFeeType = 1 // 外币 + DomesticFeeTypeRMB DomesticFeeType = 2 // 人民币 +) diff --git a/erp/erp.go b/erp/erp.go index d69171a..70d9f00 100644 --- a/erp/erp.go +++ b/erp/erp.go @@ -14,4 +14,5 @@ type Erp struct { Accounting accounting Payable payable Receivable receivable + Receipt receipt } diff --git a/erp/receipt.go b/erp/receipt.go new file mode 100644 index 0000000..d071f20 --- /dev/null +++ b/erp/receipt.go @@ -0,0 +1,129 @@ +package erp + +import ( + "context" + "time" + + "git.kumo.work/shama/service/client" + receipt2 "git.kumo.work/shama/service/erp/receipt" + "git.kumo.work/shama/service/lib/bean" + "github.com/shopspring/decimal" +) + +type receipt struct { + receipt2.Receipt +} +type ArgsReceiptList struct { + Page bean.Page + Search ReceiptSearch +} +type ReceiptSearch struct { + ReceiptSerial string // 收汇单号 + PayName string // 付款单位 + BankName string // 结汇银行 + ReceiptDateStart *time.Time // 创建开始时间 + ReceiptDateEnd *time.Time // 创建结束时间 +} +type ReplyReceiptList struct { + List []ReceiptItem `json:"list"` + Total int64 `json:"total"` +} +type ReceiptItem struct { + Id int64 `json:"id"` + ReceiptSerial string `json:"receiptSerial"` + PayName string `json:"payName"` + ReceiptDate time.Time `json:"receiptDate"` + Currency string `json:"currency"` + CurrencyName string `json:"currencyName"` + CurrencySymbol string `json:"currencySymbol"` + CurrencyRate decimal.Decimal `json:"currencyRate"` + BankName string `json:"bankName"` + EntryAmount decimal.Decimal `json:"entryAmount"` + ReceivableFxAmount decimal.Decimal `json:"receivableFxAmount"` + CreatedStaffId int64 `json:"createdStaffId"` + CreatedAt *time.Time `json:"createdAt"` + UpdatedAt *time.Time `json:"updatedAt"` +} + +// List @TITLE 列表 +func (r *receipt) List(ctx context.Context, args ArgsReceiptList) (reply ReplyReceiptList, err error) { + xClient, err := client.GetClient(r) + if err != nil { + return + } + err = xClient.Call(ctx, "List", args, &reply) + return +} + +type ArgsReceiptAdd struct { + StaffId int64 + ReceiptAdd +} +type ReceiptAdd struct { + ReceiptDate time.Time // 收汇日期 + Currency string // 币种 + CurrencyName string // 币种名称 + CurrencySymbol string // 币种符号 + CurrencyRate decimal.Decimal // 币种汇率 + PayName string // 付款单位 + BankName string // 结汇银行 + EntryAmount decimal.Decimal // 外币入账金额 + ForeignFee decimal.Decimal // 国外扣费 + DomesticFee decimal.Decimal // 国内扣费 + DomesticFeeType DomesticFeeType // 国内扣费类型 1=外币 2=人民币 +} + +// Add @TITLE 添加 +func (r *receipt) Add(ctx context.Context, args ArgsReceiptAdd) (receiptId int64, err error) { + xClient, err := client.GetClient(r) + if err != nil { + return + } + err = xClient.Call(ctx, "Add", args, &receiptId) + return +} + +type ReplyReceiptInfo struct { + Id int64 `json:"id"` + ReceiptSerial string `json:"receiptSerial"` + ReceiptDate time.Time `json:"receiptDate"` + Currency string `json:"currency"` + CurrencyName string `json:"currencyName"` + CurrencySymbol string `json:"currencySymbol"` + CurrencyRate decimal.Decimal `json:"currencyRate"` + PayName string `json:"payName"` + BankName string `json:"bankName"` + EntryAmount decimal.Decimal `json:"entryAmount"` + ForeignFee decimal.Decimal `json:"foreignFee"` + DomesticFee decimal.Decimal `json:"domesticFee"` + DomesticFeeType int64 `json:"domesticFeeType"` + ReceivableFxAmount decimal.Decimal `json:"receivableFxAmount"` + CreatedStaffId int64 `json:"createdStaffId"` + CreatedAt *time.Time `json:"createdAt"` + UpdatedAt *time.Time `json:"updatedAt"` +} + +// Info @TITLE 详情 +func (r *receipt) Info(ctx context.Context, receiptId int64) (reply ReplyReceiptInfo, err error) { + xClient, err := client.GetClient(r) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", receiptId, &reply) + return +} + +type ArgsReceiptEdit struct { + ReceiptId int64 + ReceiptAdd +} + +// Edit @TITLE 编辑 +func (r *receipt) Edit(ctx context.Context, args ArgsReceiptEdit) (err error) { + xClient, err := client.GetClient(r) + if err != nil { + return + } + reply := 0 + return xClient.Call(ctx, "Edit", args, &reply) +} diff --git a/erp/receipt/claim.go b/erp/receipt/claim.go new file mode 100644 index 0000000..4177861 --- /dev/null +++ b/erp/receipt/claim.go @@ -0,0 +1,127 @@ +package receipt + +import ( + "context" + "time" + + "git.kumo.work/shama/service/client" + "git.kumo.work/shama/service/lib/bean" + "github.com/shopspring/decimal" +) + +type claim struct { +} + +type ArgsClaimList struct { + Page bean.Page + Search ClaimSearch +} +type ClaimSearch struct { + ReceiptId int64 // 收汇单ID +} +type ReplyClaimList struct { + List []ClaimItem `json:"list"` + Total int64 `json:"total"` +} +type ClaimItem struct { + Id int64 `json:"id"` + ReceivableId int64 `json:"receivableId"` + InvoiceSerial string `json:"invoiceSerial"` + Amount decimal.Decimal `json:"amount"` + CustomName string `json:"customName"` + IsConfirm int64 `json:"isConfirm"` + CreatedStaffId int64 `json:"createdStaffId"` + CreatedAt *time.Time `json:"createdAt"` + UpdatedAt *time.Time `json:"updatedAt"` +} + +// List @TITLE 列表 +func (c *claim) List(ctx context.Context, args ArgsClaimList) (reply ReplyClaimList, err error) { + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "List", args, &reply) + return +} + +type ArgsClaimAdd struct { + StaffId int64 + ClaimAdd +} +type ClaimAdd struct { + ReceiptId int64 // 收汇单ID + ReceivableId int64 // 应收单ID + Amount decimal.Decimal // 应收金额 + Remarks string // 备注 +} + +// Add @TITLE 添加 +func (c *claim) Add(ctx context.Context, args ArgsClaimAdd) (err error) { + xClient, err := client.GetClient(c) + if err != nil { + return + } + reply := 0 + return xClient.Call(ctx, "Add", args, &reply) +} + +type ArgsClaimEdit struct { + ClaimId int64 + ClaimAdd +} + +// Edit @TITLE 编辑 +func (c *claim) Edit(ctx context.Context, args ArgsClaimEdit) (err error) { + xClient, err := client.GetClient(c) + if err != nil { + return + } + reply := 0 + return xClient.Call(ctx, "Edit", args, &reply) +} + +type ArgsClaimDelete struct { + ReceiptId int64 // 收汇单ID + ClaimIds []int64 +} + +// Delete @TITLE 删除 +func (c *claim) Delete(ctx context.Context, args ArgsClaimDelete) (err error) { + xClient, err := client.GetClient(c) + if err != nil { + return + } + reply := 0 + return xClient.Call(ctx, "Delete", args, &reply) +} + +type ArgsClaimConfirm struct { + ReceiptId int64 // 收汇单ID + ClaimIds []int64 +} + +// Confirm @TITLE 确认 +func (c *claim) Confirm(ctx context.Context, args ArgsClaimConfirm) (err error) { + xClient, err := client.GetClient(c) + if err != nil { + return + } + reply := 0 + return xClient.Call(ctx, "Confirm", args, &reply) +} + +type ArgsClaimCancelConfirm struct { + ReceiptId int64 // 收汇单ID + ClaimIds []int64 +} + +// CancelConfirm @TITLE 取消确认 +func (c *claim) CancelConfirm(ctx context.Context, args ArgsClaimCancelConfirm) (err error) { + xClient, err := client.GetClient(c) + if err != nil { + return + } + reply := 0 + return xClient.Call(ctx, "CancelConfirm", args, &reply) +} diff --git a/erp/receipt/receipt.go b/erp/receipt/receipt.go new file mode 100644 index 0000000..7e0d311 --- /dev/null +++ b/erp/receipt/receipt.go @@ -0,0 +1,5 @@ +package receipt + +type Receipt struct { + Claim claim +} diff --git a/erp/receivable.go b/erp/receivable.go index a76d429..e83b3cb 100644 --- a/erp/receivable.go +++ b/erp/receivable.go @@ -44,8 +44,8 @@ type ReceivableItem struct { } // List @TITLE 列表 -func (p *receivable) List(ctx context.Context, args ArgsReceivableList) (reply ReplyReceivableList, err error) { - xClient, err := client.GetClient(p) +func (r *receivable) List(ctx context.Context, args ArgsReceivableList) (reply ReplyReceivableList, err error) { + xClient, err := client.GetClient(r) if err != nil { return } @@ -86,8 +86,8 @@ type ReceivableProductItem struct { } // Info @TITLE 详情 -func (p *receivable) Info(ctx context.Context, receivableId int64) (reply ReplyReceivableInfo, err error) { - xClient, err := client.GetClient(p) +func (r *receivable) Info(ctx context.Context, receivableId int64) (reply ReplyReceivableInfo, err error) { + xClient, err := client.GetClient(r) if err != nil { return } -- 2.49.1 From 11b4f6fdf2a27493a394c0d2ee9b37608f0cc2fb Mon Sep 17 00:00:00 2001 From: kanade Date: Thu, 11 Dec 2025 16:12:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore(client):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改了客户端模块的依赖配置 - 更新了模块版本号 - 优化了模块导入路径 - 修复了模块间的依赖冲突 - 清理了冗余的模块引用 - 提升了模块加载性能 --- client/client.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/client/client.go b/client/client.go index df6bd10..8b498d4 100644 --- a/client/client.go +++ b/client/client.go @@ -61,18 +61,9 @@ func GetClient(s interface{}) (*RpcClient, error) { mutex.Lock() xClient, ok = mClient.Load(key) if !ok { - 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("系统异常") - } + d, err := consulClient.NewConsulDiscovery(basePath, servicePath, config.RpcConfig.RegistryServer, nil) + if err != nil { + return nil, errors.New("系统异常") } option := client.DefaultOption option.Retries = 3 -- 2.49.1