140 lines
4.3 KiB
Go
140 lines
4.3 KiB
Go
package purchase
|
|
|
|
import (
|
|
"context"
|
|
"git.kumo.work/shama/service/client"
|
|
"git.kumo.work/shama/service/lib/bean"
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
type product struct {
|
|
}
|
|
type ProductItem struct {
|
|
Id int64 `json:"id"`
|
|
SaleProductId int64 `json:"saleProductId"`
|
|
PurchasePrice decimal.Decimal `json:"purchasePrice"`
|
|
PurchaseCount int64 `json:"purchaseCount"`
|
|
BoxCount int64 `json:"boxCount"`
|
|
Info string `json:"info"`
|
|
Po string `json:"po"`
|
|
Mold int64 `json:"mold"`
|
|
Serial string `json:"serial"`
|
|
CustomSerial string `json:"customSerial"`
|
|
Name string `json:"name"`
|
|
EngName string `json:"engName"`
|
|
Description string `json:"description"`
|
|
EngDescription string `json:"engDescription"`
|
|
ImgFilePaths []string `json:"imgFilePaths"`
|
|
PurchaseAmount decimal.Decimal `json:"purchaseAmount"`
|
|
Num *int64 `json:"num"`
|
|
Volume *decimal.Decimal `json:"volume"`
|
|
GrossWeight *decimal.Decimal `json:"grossWeight"`
|
|
NetWeight *decimal.Decimal `json:"netWeight"`
|
|
MeasureUnit string `json:"measureUnit"`
|
|
}
|
|
|
|
// All @TITLE 获取产品
|
|
func (p *product) All(ctx context.Context, purchaseId int64) (reply []ProductItem, err error) {
|
|
xClient, err := client.GetClient(p)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(ctx, "All", purchaseId, &reply)
|
|
return
|
|
}
|
|
|
|
type ArgsProductEdit struct {
|
|
PurchaseId int64 // 采购合同id
|
|
Products []ProductEdit
|
|
}
|
|
|
|
type ProductEdit struct {
|
|
PurchaseProductId int64 // 采购合同产品id
|
|
Po string // 产品po
|
|
Name string // 产品名称
|
|
Description string // 产品中文描述
|
|
PurchasePrice decimal.Decimal // 采购单价
|
|
PurchaseCount int64 // 采购数量
|
|
Info string // 备注
|
|
Sort int64 // 排序
|
|
}
|
|
|
|
// Edit @TITLE 编辑产品
|
|
func (p *product) Edit(ctx context.Context, args ArgsProductEdit) (err error) {
|
|
xClient, err := client.GetClient(p)
|
|
if err != nil {
|
|
return
|
|
}
|
|
reply := 0
|
|
err = xClient.Call(ctx, "Edit", args, &reply)
|
|
return
|
|
}
|
|
|
|
type ArgsProductChangeFactory struct {
|
|
FactoryId int64 // 工厂id
|
|
PurchaseProductIds []int64 // 采购商品id
|
|
}
|
|
|
|
// ChangeFactory @TITLE 更换工厂
|
|
func (p *product) ChangeFactory(ctx context.Context, args ArgsProductChangeFactory) (err error) {
|
|
xClient, err := client.GetClient(p)
|
|
if err != nil {
|
|
return
|
|
}
|
|
reply := 0
|
|
err = xClient.Call(ctx, "ChangeFactory", args, &reply)
|
|
return
|
|
}
|
|
|
|
// Delete @TITLE 删除产品
|
|
func (p *product) Delete(ctx context.Context, purchaseProductIds []int64) (err error) {
|
|
xClient, err := client.GetClient(p)
|
|
if err != nil {
|
|
return
|
|
}
|
|
reply := 0
|
|
err = xClient.Call(ctx, "Delete", purchaseProductIds, &reply)
|
|
return
|
|
}
|
|
|
|
type ArgsListAccounting struct {
|
|
Page bean.Page
|
|
Search ListAccountingSearch
|
|
}
|
|
type ListAccountingSearch struct {
|
|
CustomIds []int64 // 客户
|
|
PiSerial string // PI
|
|
ProductSerial string // 货号
|
|
ProductCustomSerial string // 客户货号
|
|
PoSerial string // PO
|
|
}
|
|
|
|
type ReplyListAccounting struct {
|
|
List []ListAccountingItem `json:"list"`
|
|
Total int64 `json:"total"`
|
|
}
|
|
type ListAccountingItem struct {
|
|
Id int64 `json:"id"`
|
|
PiSerial string `json:"piSerial"`
|
|
PoSerial string `json:"poSerial"`
|
|
FactoryName string `json:"factoryName"`
|
|
ProductSerial string `json:"productSerial"`
|
|
ProductCustomSerial string `json:"productCustomSerial"`
|
|
ProductName string `json:"productName"`
|
|
HasAccountingCount int64 `json:"hasAccountingCount"`
|
|
NetWeight *decimal.Decimal `json:"netWeight"`
|
|
Num *int64 `json:"num"`
|
|
Volume *decimal.Decimal `json:"volume"`
|
|
GrossWeight *decimal.Decimal `json:"grossWeight"`
|
|
}
|
|
|
|
// ListAccounting @TITLE 做账商品列表
|
|
func (p *product) ListAccounting(ctx context.Context, args ArgsListAccounting) (reply ReplyListAccounting, err error) {
|
|
xClient, err := client.GetClient(p)
|
|
if err != nil {
|
|
return
|
|
}
|
|
err = xClient.Call(ctx, "ListAccounting", args, &reply)
|
|
return
|
|
}
|