- 移除旧的 FactoryId 和 PurchaseProductIds 字段 - 新增 PurchaseId、FactoryId 和 Products 字段- 新增 ProductChangeFactoryProductItem 和 BatchItem 结构体
		
			
				
	
	
		
			175 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			175 lines
		
	
	
		
			5.6 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 {
 | |
| 	PurchaseId int64                             // 采购合同id
 | |
| 	FactoryId  int64                             // 工厂id
 | |
| 	Products   []ProductChangeFactoryProductItem // 采购商品id
 | |
| }
 | |
| 
 | |
| type ProductChangeFactoryProductItem struct {
 | |
| 	PurchaseProductId int64       // 采购产品id
 | |
| 	Batches           []BatchItem // 产品批次
 | |
| }
 | |
| type BatchItem struct {
 | |
| 	BatchNo       int64 // 批次号
 | |
| 	PurchaseCount int64 // 采购数量
 | |
| }
 | |
| 
 | |
| // 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
 | |
| 	HasAccounting       int64   // 做账 1=可做账 2=不可做账
 | |
| }
 | |
| 
 | |
| 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"`
 | |
| 	PurchasedCount      int64            `json:"purchasedCount"`
 | |
| 	AccountingCount     int64            `json:"accountingCount"`
 | |
| 	AccountedCount      int64            `json:"accountedCount"`
 | |
| 	ShippedCount        int64            `json:"shippedCount"`
 | |
| }
 | |
| 
 | |
| // 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
 | |
| }
 | |
| 
 | |
| type ProductBatchCountItem struct {
 | |
| 	PurchaseProductId int64              `json:"purchaseProductId"`
 | |
| 	SaleCount         int64              `json:"saleCount"`
 | |
| 	Batches           []ProductBatchItem `json:"batch"`
 | |
| }
 | |
| type ProductBatchItem struct {
 | |
| 	BatchNo       int64 `json:"batchNo"`
 | |
| 	PurchaseCount int64 `json:"purchaseCount"`
 | |
| }
 | |
| 
 | |
| // BatchCount @TITLE 批次数量
 | |
| func (p *product) BatchCount(ctx context.Context, purchaseProductIds []int64) (reply []ProductBatchCountItem, err error) {
 | |
| 	xClient, err := client.GetClient(p)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	err = xClient.Call(ctx, "BatchCount", purchaseProductIds, &reply)
 | |
| 	return
 | |
| }
 |