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 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 }