Files
service/erp/receipt.go
kanade 25069c5280 feat(erp): 新增货币汇率服务及收汇水单批量生成
- 新增 currencyRate 模块,支持按货币和日期查询汇率信息
- 定义汇率响应结构,包含中间价、现钞卖出价、买入价等字段
- 在 ERP 服务结构体中注册 CurrencyRate 客户端
- 新增收汇水单批量生成接口 Gen,支持按交易明细ID批量生成
- 定义 ArgsReceiptGen 参数结构,包含员工ID和交易明细ID列表
2026-10-19 11:25:54 +08:00

216 lines
7.8 KiB
Go

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
Order []OrderItem
}
type ReceiptSearch struct {
ReceiptSerial string // 收汇单号
CustomId int64 // 客户筛选
CustomName string // 客户筛选
PayCustomId int64 // 付款客户
PayCustomName string // 付款客户名称
BankName string // 结汇银行
ReceiptDateStart *time.Time // 创建开始时间
ReceiptDateEnd *time.Time // 创建结束时间
BanFlag int64 // 禁用标记 1=禁用 2=启用
ClaimStatus int64 // 认领状态 1=待认领 2=部分认领 3=已认领
InvoiceSerialEq string // 发票号
InvoiceSerial string // 发票号
PayCompany string // 付款公司
BankAccount string // 结汇银行账号
EntryAmountStart *decimal.Decimal // 入账金额开始
EntryAmountEnd *decimal.Decimal // 入账金额结束
Ik3cloudStatus int64 // 金蝶同步状态 1=待同步 2=同步成功 3=同步失败
IsConfirm int64 // 确认状态 1=已确认 2=待确认
BankNameEq *string // 结汇银行完全匹配
BankAccountEq *string // 结汇银行账号完全匹配
PermissionStaffIds []int64 // 权限员工id
CurrencyEq *string // 币种
Ik3cloudStatuses []int64 // 金蝶推送状态
Ik3cloudAtStart *time.Time // 金蝶推送开始时间
Ik3cloudAtEnd *time.Time // 金蝶推送结束时间
}
type ReplyReceiptList struct {
List []ReceiptItem `json:"list"`
Total int64 `json:"total"`
Count ReceiptCount `json:"count"`
}
type ReceiptItem struct {
Id int64 `json:"id"`
ReceiptSerial string `json:"receiptSerial"`
CustomId int64 `json:"customId"`
CustomName string `json:"customName"`
PayCustomId int64 `json:"payCustomId"`
PayCustomName string `json:"payCustomName"`
PayCompany string `json:"payCompany"`
ReceiptDate time.Time `json:"receiptDate"`
Currency string `json:"currency"`
CurrencyName string `json:"currencyName"`
CurrencySymbol string `json:"currencySymbol"`
CurrencyRate decimal.Decimal `json:"currencyRate"`
BankAccount string `json:"bankAccount"`
BankName string `json:"bankName"`
EntryAmount decimal.Decimal `json:"entryAmount"`
ReceivableFxAmount decimal.Decimal `json:"receivableFxAmount"`
ClaimAmount decimal.Decimal `json:"claimAmount"`
CreatedStaffId int64 `json:"createdStaffId"`
BanFlag int64 `json:"banFlag"`
IsConfirm int64 `json:"isConfirm"`
Ik3cloudStatus int64 `json:"ik3CloudStatus"`
Ik3cloudErrMsg string `json:"ik3CloudErrMsg"`
Ik3cloudUpdatedAt *time.Time `json:"ik3CloudUpdatedAt"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
type ReceiptCount struct {
EntryAmount decimal.Decimal `json:"entryAmount"`
ReceivableFxAmount decimal.Decimal `json:"receivableFxAmount"`
ClaimAmount decimal.Decimal `json:"claimAmount"`
}
// 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 // 币种汇率
PayCustomId int64 // 付款客户id
PayCompany string // 付款公司
BankAccount 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"`
CustomId int64 `json:"customId"`
CustomName string `json:"customName"`
PayCustomId int64 `json:"payCustomId"`
PayCustomName string `json:"payCustomName"`
PayCompany string `json:"payCompany"`
BankAccount string `json:"bankAccount"`
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"`
ClaimAmount decimal.Decimal `json:"claimAmount"`
CreatedStaffId int64 `json:"createdStaffId"`
BanFlag int64 `json:"banFlag"`
Ik3cloudStatus int64 `json:"ik3CloudStatus"`
Ik3cloudErrMsg string `json:"ik3CloudErrMsg"`
Ik3cloudUpdatedAt *time.Time `json:"ik3CloudUpdatedAt"`
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)
}
// Ik3cloud @TITLE 金蝶同步
func (r *receipt) Ik3cloud(ctx context.Context, receiptId int64) (err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Ik3cloud", receiptId, &reply)
}
// Cancel @TITLE 作废
func (r *receipt) Cancel(ctx context.Context, receiptId int64) (err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Cancel", receiptId, &reply)
}
type ArgsReceiptGen struct {
StaffId int64
BankStatementIds []int64 // 交易明细id
}
// Gen @TITLE 批量生成收汇水单
func (r *receipt) Gen(ctx context.Context, args ArgsReceiptGen) (receiptIds []int64, err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
err = xClient.Call(ctx, "Gen", args, &receiptIds)
return
}