77 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package purchase
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"git.kumo.work/shama/service/client"
 | |
| 	"github.com/shopspring/decimal"
 | |
| 	"time"
 | |
| )
 | |
| 
 | |
| type cost struct {
 | |
| }
 | |
| 
 | |
| type CostItem struct {
 | |
| 	Id        int64           `json:"id"`
 | |
| 	Name      string          `json:"name"`
 | |
| 	Amount    decimal.Decimal `json:"amount"`
 | |
| 	Remarks   string          `json:"remarks"`
 | |
| 	CreatedAt *time.Time      `json:"createdAt"`
 | |
| 	UpdatedAt *time.Time      `json:"updatedAt"`
 | |
| }
 | |
| 
 | |
| // All @TITLE 获取费用
 | |
| func (c *cost) All(ctx context.Context, purchaseId int64) (reply []CostItem, err error) {
 | |
| 	xClient, err := client.GetClient(c)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	err = xClient.Call(ctx, "All", purchaseId, &reply)
 | |
| 	return
 | |
| }
 | |
| 
 | |
| type ArgsCostAdd struct {
 | |
| 	PurchaseId int64 // 采购合同ID
 | |
| 	CostAdd
 | |
| }
 | |
| 
 | |
| type CostAdd struct {
 | |
| 	Name    string          // 费用名
 | |
| 	Amount  decimal.Decimal // 金额
 | |
| 	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 // 费用ID
 | |
| 	CostAdd
 | |
| }
 | |
| 
 | |
| // 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)
 | |
| }
 | |
| 
 | |
| // Delete @TITLE 删除费用
 | |
| func (c *cost) Delete(ctx context.Context, costIds []int64) (err error) {
 | |
| 	xClient, err := client.GetClient(c)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	reply := 0
 | |
| 	return xClient.Call(ctx, "Delete", costIds, &reply)
 | |
| }
 |