78 lines
1.7 KiB
Go
78 lines
1.7 KiB
Go
package payment
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"git.kumo.work/shama/service/client"
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
type prepaid struct {
|
|
}
|
|
|
|
type PrepaidItem struct {
|
|
Id int64 `json:"id"`
|
|
InvoiceSerial string `json:"invoiceSerial"`
|
|
Amount decimal.Decimal `json:"amount"`
|
|
Remark string `json:"remark"`
|
|
CreatedAt *time.Time `json:"createdAt"`
|
|
UpdatedAt *time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
// All @TITLE 获取费用
|
|
func (c *prepaid) All(ctx context.Context, paymentId int64) (reply []PrepaidItem, err error) {
|
|
xClient, err := client.GetClient(c)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(ctx, "All", paymentId, &reply)
|
|
return
|
|
}
|
|
|
|
type ArgsPrepaidAdd struct {
|
|
PaymentId int64 // 付款单ID
|
|
PrepaidAdd
|
|
}
|
|
|
|
type PrepaidAdd struct {
|
|
InvoiceSerial string // 发票编号
|
|
Amount decimal.Decimal // 金额
|
|
Remark string // 备注
|
|
}
|
|
|
|
// Add @TITLE 添加费用
|
|
func (c *prepaid) Add(ctx context.Context, args ArgsPrepaidAdd) (err error) {
|
|
xClient, err := client.GetClient(c)
|
|
if err != nil {
|
|
return
|
|
}
|
|
reply := 0
|
|
return xClient.Call(ctx, "Add", args, &reply)
|
|
}
|
|
|
|
type ArgsPrepaidEdit struct {
|
|
PrepaidId int64 // 费用ID
|
|
PrepaidAdd
|
|
}
|
|
|
|
// Edit @TITLE 编辑费用
|
|
func (c *prepaid) Edit(ctx context.Context, args ArgsPrepaidEdit) (err error) {
|
|
xClient, err := client.GetClient(c)
|
|
if err != nil {
|
|
return
|
|
}
|
|
reply := 0
|
|
return xClient.Call(ctx, "Edit", args, &reply)
|
|
}
|
|
|
|
// Delete @TITLE 删除费用
|
|
func (c *prepaid) Delete(ctx context.Context, prepaidIds []int64) (err error) {
|
|
xClient, err := client.GetClient(c)
|
|
if err != nil {
|
|
return
|
|
}
|
|
reply := 0
|
|
return xClient.Call(ctx, "Delete", prepaidIds, &reply)
|
|
}
|