From fce4272da9f8692348a8f9c6518a74752534d252 Mon Sep 17 00:00:00 2001 From: kanade Date: Fri, 12 Dec 2025 15:57:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(erp):=20=E6=B7=BB=E5=8A=A0=E6=8A=A5?= =?UTF-8?q?=E9=94=80=E5=8D=95=E5=8F=8A=E5=85=B6=E8=B4=B9=E7=94=A8=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 ERP 服务中新增 Request 模块,用于处理报销单相关逻辑 - 实现报销单的增删改查接口,支持列表、详情及编辑操作 - 新增费用管理模块 Cost,支持费用项的添加、修改、删除和列表查询 - 定义完整的请求与响应结构体,包括分页、搜索条件和返回数据格式 - 集成客户端调用逻辑,通过 RPC 方式与其他服务通信 - 引入 decimal 包处理金额字段,确保数值精度 - 添加时间戳字段用于记录创建和更新时间 --- erp/erp.go | 1 + erp/request.go | 125 +++++++++++++++++++++++++++++++++++++++++ erp/request/cost.go | 90 +++++++++++++++++++++++++++++ erp/request/request.go | 5 ++ 4 files changed, 221 insertions(+) create mode 100644 erp/request.go create mode 100644 erp/request/cost.go create mode 100644 erp/request/request.go diff --git a/erp/erp.go b/erp/erp.go index 00b18a0..f2087cc 100644 --- a/erp/erp.go +++ b/erp/erp.go @@ -16,4 +16,5 @@ type Erp struct { Receivable receivable Receipt receipt Expense expense + Request request } diff --git a/erp/request.go b/erp/request.go new file mode 100644 index 0000000..6b14892 --- /dev/null +++ b/erp/request.go @@ -0,0 +1,125 @@ +package erp + +import ( + "context" + "time" + + "git.kumo.work/shama/service/client" + request2 "git.kumo.work/shama/service/erp/request" + "git.kumo.work/shama/service/lib/bean" + "github.com/shopspring/decimal" +) + +type request struct { + request2.Request +} +type ArgsRequestList struct { + Page bean.Page + Search RequestSearch +} +type RequestSearch struct { + RequestSerial string // 报销单号 + CreatedAtStart *time.Time // 创建开始时间 + CreatedAtEnd *time.Time // 创建结束时间 +} +type ReplyRequestList struct { + List []RequestItem `json:"list"` + Total int64 `json:"total"` +} +type RequestItem struct { + Id int64 `json:"id"` + FactoryId int64 `json:"factoryId"` + FactoryName string `json:"factoryName"` + FactoryBank string `json:"factoryBank"` + FactoryBankAccount string `json:"factoryBankAccount"` + RequestSerial string `json:"requestSerial"` + Currency string `json:"currency"` + CurrencyName string `json:"currencyName"` + CurrencySymbol string `json:"currencySymbol"` + CurrencyRate decimal.Decimal `json:"currencyRate"` + Remarks string `json:"remarks"` + Amount decimal.Decimal `json:"amount"` + CreatedStaffId int64 `json:"createdStaffId"` + CreatedAt *time.Time `json:"createdAt"` + UpdatedAt *time.Time `json:"updatedAt"` +} + +// List @TITLE 列表 +func (r *request) List(ctx context.Context, args ArgsRequestList) (reply ReplyRequestList, err error) { + xClient, err := client.GetClient(r) + if err != nil { + return + } + err = xClient.Call(ctx, "List", args, &reply) + return +} + +type ArgsRequestAdd struct { + StaffId int64 + RequestAdd +} +type RequestAdd struct { + FactoryId int64 // 工厂id + FactoryName string // 工厂名称 + FactoryBank string // 银行 + FactoryBankAccount string // 银行账号 + Currency string // 币种 + CurrencyName string // 币种名称 + CurrencySymbol string // 币种符号 + CurrencyRate decimal.Decimal // 币种汇率 + Remarks string // 备注 + Amount decimal.Decimal // 金额 +} + +// Add @TITLE 添加 +func (r *request) Add(ctx context.Context, args ArgsRequestAdd) (requestId int64, err error) { + xClient, err := client.GetClient(r) + if err != nil { + return + } + err = xClient.Call(ctx, "Add", args, &requestId) + return +} + +type ReplyRequestInfo struct { + Id int64 `json:"id"` + RequestSerial string `json:"requestSerial"` + FactoryId int64 `json:"factoryId"` + FactoryName string `json:"factoryName"` + FactoryBank string `json:"factoryBank"` + FactoryBankAccount string `json:"factoryBankAccount"` + Currency string `json:"currency"` + CurrencyName string `json:"currencyName"` + CurrencySymbol string `json:"currencySymbol"` + CurrencyRate decimal.Decimal `json:"currencyRate"` + Amount decimal.Decimal `json:"amount"` + Remarks string `json:"remarks"` + CreatedStaffId int64 `json:"createdStaffId"` + CreatedAt *time.Time `json:"createdAt"` + UpdatedAt *time.Time `json:"updatedAt"` +} + +// Info @TITLE 详情 +func (r *request) Info(ctx context.Context, requestId int64) (reply ReplyRequestInfo, err error) { + xClient, err := client.GetClient(r) + if err != nil { + return + } + err = xClient.Call(ctx, "Info", requestId, &reply) + return +} + +type ArgsRequestEdit struct { + RequestId int64 + RequestAdd +} + +// Edit @TITLE 编辑 +func (r *request) Edit(ctx context.Context, args ArgsRequestEdit) (err error) { + xClient, err := client.GetClient(r) + if err != nil { + return + } + reply := 0 + return xClient.Call(ctx, "Edit", args, &reply) +} diff --git a/erp/request/cost.go b/erp/request/cost.go new file mode 100644 index 0000000..5290caa --- /dev/null +++ b/erp/request/cost.go @@ -0,0 +1,90 @@ +package request + +import ( + "context" + "time" + + "git.kumo.work/shama/service/client" + "git.kumo.work/shama/service/lib/bean" + "github.com/shopspring/decimal" +) + +type cost struct { +} +type ArgsCostList struct { + Page bean.Page + Search CostSearch +} +type CostSearch struct { + RequestId int64 // 报销单ID +} +type ReplyCostList struct { + List []CostItem `json:"list"` + Total int64 `json:"total"` +} +type CostItem struct { + Id int64 `json:"id"` + RequestId int64 `json:"requestId"` + Amount decimal.Decimal `json:"amount"` + DepartmentId int64 `json:"departmentId"` + Remarks string `json:"remarks"` + CreatedAt *time.Time `json:"createdAt"` + UpdatedAt *time.Time `json:"updatedAt"` +} + +// List @TITLE 列表 +func (c *cost) List(ctx context.Context, args ArgsCostList) (reply ReplyCostList, err error) { + xClient, err := client.GetClient(c) + if err != nil { + return + } + err = xClient.Call(ctx, "List", args, &reply) + return +} + +type ArgsCostAdd struct { + RequestId int64 // 报销单ID + Amount decimal.Decimal // 金额 + DepartmentId int64 // 部门 + Remarks string // 备注 +} + +// Add @TITLE 添加 +func (c *cost) Add(ctx context.Context, args ArgsCostAdd) (err error) { + xClient, err := client.GetClient(c) + if err != nil { + return + } + reply := 0 + return xClient.Call(ctx, "Add", args, &reply) +} + +type ArgsCostEdit struct { + CostId int64 + ArgsCostAdd +} + +// Edit @TITLE 编辑 +func (c *cost) Edit(ctx context.Context, args ArgsCostEdit) (err error) { + xClient, err := client.GetClient(c) + if err != nil { + return + } + reply := 0 + return xClient.Call(ctx, "Edit", args, &reply) +} + +type ArgsCostDelete struct { + RequestId int64 // 报销单ID + CostIds []int64 +} + +// Delete @TITLE 删除 +func (c *cost) Delete(ctx context.Context, args ArgsCostDelete) (err error) { + xClient, err := client.GetClient(c) + if err != nil { + return + } + reply := 0 + return xClient.Call(ctx, "Delete", args, &reply) +} diff --git a/erp/request/request.go b/erp/request/request.go new file mode 100644 index 0000000..f7008d3 --- /dev/null +++ b/erp/request/request.go @@ -0,0 +1,5 @@ +package request + +type Request struct { + Cost cost +}