279 lines
		
	
	
		
			9.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			279 lines
		
	
	
		
			9.6 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package erp
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"git.kumo.work/shama/service/client"
 | |
| 	purchase2 "git.kumo.work/shama/service/erp/purchase"
 | |
| 	"git.kumo.work/shama/service/lib/bean"
 | |
| 	"github.com/shopspring/decimal"
 | |
| 	"time"
 | |
| )
 | |
| 
 | |
| type purchase struct {
 | |
| 	purchase2.Purchase
 | |
| }
 | |
| type ArgsPurchaseList struct {
 | |
| 	Page   bean.Page
 | |
| 	Search PurchaseSearch
 | |
| }
 | |
| type PurchaseSearch struct {
 | |
| 	PiSerial        string     // 采购合同编号
 | |
| 	PoSerial        string     // po
 | |
| 	Remark          string     // 备注
 | |
| 	CustomId        int64      // 客户id
 | |
| 	CustomShortName string     // 客户简称
 | |
| 	CreatedStaffIds []int64    // 创建人筛选
 | |
| 	StaffIds        []int64    // 业务员
 | |
| 	FactoryName     string     // 采购工厂
 | |
| 	PurchaseIds     []int64    // 采购id
 | |
| 	OrderDateStart  *time.Time // 下单日期
 | |
| 	OrderDateEnd    *time.Time // 下单日期
 | |
| 	WorkflowStatus  []int64    // 状态
 | |
| }
 | |
| type ReplyPurchaseList struct {
 | |
| 	List  []PurchaseItem `json:"list"`
 | |
| 	Total int64          `json:"total"`
 | |
| }
 | |
| type PurchaseItem struct {
 | |
| 	Id              int64           `json:"id"`
 | |
| 	SaleId          int64           `json:"saleId"`
 | |
| 	PiSerial        string          `json:"piSerial"`
 | |
| 	PoSerial        string          `json:"poSerial"`
 | |
| 	BatchNo         int64           `json:"batchNo"`
 | |
| 	Remark          string          `json:"remark"`
 | |
| 	CustomName      string          `json:"customName"`
 | |
| 	CustomShortName string          `json:"customShortName"`
 | |
| 	DeliveryDate    *time.Time      `json:"deliveryDate"`
 | |
| 	DeliveryDateEnd *time.Time      `json:"deliveryDateEnd"`
 | |
| 	OrderDate       time.Time       `json:"orderDate"`
 | |
| 	CreatedStaffId  int64           `json:"createdStaffId"`
 | |
| 	WorkflowId      int64           `json:"workflowId"`
 | |
| 	WorkflowStatus  int64           `json:"workflowStatus"`
 | |
| 	FactoryName     string          `json:"factoryName"`
 | |
| 	FactoryId       int64           `json:"factoryId"`
 | |
| 	ProductAmount   decimal.Decimal `json:"productAmount"`
 | |
| 	CostAmount      decimal.Decimal `json:"costAmount"`
 | |
| 	CreatedAt       *time.Time      `json:"createdAt"`
 | |
| 	UpdatedAt       *time.Time      `json:"updatedAt"`
 | |
| }
 | |
| 
 | |
| // List @TITLE 采购合同列表
 | |
| func (p *purchase) List(ctx context.Context, args ArgsPurchaseList) (reply ReplyPurchaseList, err error) {
 | |
| 	xClient, err := client.GetClient(p)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	err = xClient.Call(ctx, "List", args, &reply)
 | |
| 	return
 | |
| }
 | |
| 
 | |
| type ArgsPurchaseAdd struct {
 | |
| 	SaleId   int64 // 销售合同
 | |
| 	Products []PurchaseProduct
 | |
| }
 | |
| type PurchaseProduct struct {
 | |
| 	SaleProductId  int64                  // 销售合同产品id
 | |
| 	FactoryId      int64                  // 采购工厂id
 | |
| 	Price          decimal.Decimal        // 采购单价
 | |
| 	Currency       string                 // 币种
 | |
| 	CurrencyName   string                 // 币种名称
 | |
| 	CurrencySymbol string                 // 币种符号
 | |
| 	CurrencyRate   decimal.Decimal        // 币种汇率
 | |
| 	Batches        []PurchaseProductBatch // 产品批次
 | |
| }
 | |
| type PurchaseProductBatch struct {
 | |
| 	BatchNo int64 `binding:"required" label:"批次号"`
 | |
| 	Num     int64 // 采购数量
 | |
| }
 | |
| 
 | |
| // Add @TITLE 添加采购合同
 | |
| func (p *purchase) Add(ctx context.Context, args ArgsPurchaseAdd) (err error) {
 | |
| 	xClient, err := client.GetClient(p)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	reply := 0
 | |
| 	err = xClient.Call(ctx, "Add", args, &reply)
 | |
| 	return
 | |
| }
 | |
| 
 | |
| type ReplyPurchaseInfo struct {
 | |
| 	PurchaseId      int64            `json:"purchaseId"`
 | |
| 	SaleId          int64            `json:"saleId"`
 | |
| 	FactoryId       int64            `json:"factoryId"`
 | |
| 	FactoryName     string           `json:"factoryName"`
 | |
| 	FactoryAddress  string           `json:"factoryAddress"`
 | |
| 	FactoryContact  string           `json:"factoryContact"`
 | |
| 	FactoryPhone    string           `json:"factoryPhone"`
 | |
| 	FactoryFax      string           `json:"factoryFax"`
 | |
| 	DeliveryDate    *time.Time       `json:"deliveryDate"`
 | |
| 	DeliveryDateEnd *time.Time       `json:"deliveryDateEnd"`
 | |
| 	DeliveryPlace   string           `json:"deliveryPlace"`
 | |
| 	AdvancePayment  *decimal.Decimal `json:"advancePayment"`
 | |
| 	PoSerial        string           `json:"poSerial"`
 | |
| 	PiSerial        string           `json:"piSerial"`
 | |
| 	BatchNo         int64            `json:"batchNo"`
 | |
| 	Remark          string           `json:"remark"`
 | |
| 	WorkflowId      int64            `json:"workflowId"`
 | |
| 	WorkflowStatus  int64            `json:"workflowStatus"`
 | |
| 	WorkflowReason  string           `json:"workflowReason"`
 | |
| 	OrderDate       time.Time        `json:"orderDate"`
 | |
| 	CustomShortName string           `json:"customShortName"`
 | |
| 	OurCompany      string           `json:"ourCompany"`
 | |
| 	CreatedStaffId  int64            `json:"createdStaffId"`
 | |
| 	FrontMark       string           `json:"frontMark"`
 | |
| 	SideMark        string           `json:"sideMark"`
 | |
| 	InnerBoxText    string           `json:"innerBoxText"`
 | |
| 	Remarks         string           `json:"remarks"`
 | |
| 	Currency        string           `json:"currency"`
 | |
| 	CurrencyName    string           `json:"currencyName"`
 | |
| 	CurrencySymbol  string           `json:"currencySymbol"`
 | |
| 	CurrencyRate    decimal.Decimal  `json:"currencyRate"`
 | |
| 	CreatedAt       *time.Time       `json:"createdAt"`
 | |
| 	UpdatedAt       *time.Time       `json:"updatedAt"`
 | |
| }
 | |
| 
 | |
| // Info @TITLE 采购合同详情
 | |
| func (p *purchase) Info(ctx context.Context, purchaseId int64) (reply ReplyPurchaseInfo, err error) {
 | |
| 	xClient, err := client.GetClient(p)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	err = xClient.Call(ctx, "Info", purchaseId, &reply)
 | |
| 	return
 | |
| }
 | |
| 
 | |
| type ArgsPurchaseEdit struct {
 | |
| 	PurchaseId      int64            // 采购合同id
 | |
| 	PoSerial        string           // PoSerial
 | |
| 	BatchNo         int64            // 批次号
 | |
| 	Remark          string           // 备注
 | |
| 	OrderDate       *time.Time       // 下单日期
 | |
| 	FactoryAddress  string           // 工厂地址
 | |
| 	FactoryContact  string           // 工厂联系人
 | |
| 	FactoryPhone    string           // 工厂电话
 | |
| 	FactoryFax      string           // 工厂传真
 | |
| 	DeliveryDate    *time.Time       // 采购交期
 | |
| 	DeliveryDateEnd *time.Time       // 采购交期结束
 | |
| 	DeliveryPlace   string           // 交货地点
 | |
| 	AdvancePayment  *decimal.Decimal // 预付款货
 | |
| 	FrontMark       string           // 正面唛头
 | |
| 	SideMark        string           // 侧面唛头
 | |
| 	InnerBoxText    string           // 内盒文字
 | |
| 	Remarks         string           // 合同备注
 | |
| 	Currency        string           // 币种
 | |
| 	CurrencyName    string           // 币种名称
 | |
| 	CurrencySymbol  string           // 币种符号
 | |
| 	CurrencyRate    decimal.Decimal  // 币种汇率
 | |
| }
 | |
| 
 | |
| // Edit @TITLE 编辑采购合同
 | |
| func (p *purchase) Edit(ctx context.Context, args ArgsPurchaseEdit) (err error) {
 | |
| 	xClient, err := client.GetClient(p)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	reply := 0
 | |
| 	err = xClient.Call(ctx, "Edit", args, &reply)
 | |
| 	return
 | |
| }
 | |
| 
 | |
| // Cancel @TITLE 作废采购合同
 | |
| func (p *purchase) Cancel(ctx context.Context, purchaseId int64) (err error) {
 | |
| 	xClient, err := client.GetClient(p)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	reply := 0
 | |
| 	err = xClient.Call(ctx, "Cancel", purchaseId, &reply)
 | |
| 	return
 | |
| }
 | |
| 
 | |
| type ArgsPurchaseHistory struct {
 | |
| 	Page   bean.Page
 | |
| 	Search PurchaseHistorySearch
 | |
| }
 | |
| type PurchaseHistorySearch struct {
 | |
| 	ProductId int64 // 产品id
 | |
| }
 | |
| type ReplyPurchaseHistory struct {
 | |
| 	List  []PurchaseHistoryItem `json:"list"`
 | |
| 	Total int64                 `json:"total"`
 | |
| }
 | |
| type PurchaseHistoryItem struct {
 | |
| 	PurchaseId             int64           `json:"purchaseId"`
 | |
| 	PiSerial               string          `json:"piSerial"`
 | |
| 	OrderDate              time.Time       `json:"orderDate"`
 | |
| 	FactorySerial          string          `json:"factorySerial"`
 | |
| 	FactoryName            string          `json:"factoryName"`
 | |
| 	PurchasePrice          decimal.Decimal `json:"purchasePrice"`
 | |
| 	PurchaseCount          int64           `json:"purchaseCount"`
 | |
| 	PurchaseAmount         decimal.Decimal `json:"purchaseAmount"`
 | |
| 	PurchaseCurrency       string          `json:"purchaseCurrency"`
 | |
| 	PurchaseCurrencyName   string          `json:"purchaseCurrencyName"`
 | |
| 	PurchaseCurrencySymbol string          `json:"purchaseCurrencySymbol"`
 | |
| 	PurchaseCurrencyRate   decimal.Decimal `json:"purchaseCurrencyRate"`
 | |
| 	CreatedStaffId         int64           `json:"createdStaffId"`
 | |
| }
 | |
| 
 | |
| // History @TITLE 历史记录
 | |
| func (p *purchase) History(ctx context.Context, args ArgsPurchaseHistory) (reply ReplyPurchaseHistory, err error) {
 | |
| 	xClient, err := client.GetClient(p)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	err = xClient.Call(ctx, "History", args, &reply)
 | |
| 	return
 | |
| }
 | |
| 
 | |
| // CancelAudit @TITLE 反审
 | |
| func (p *purchase) CancelAudit(ctx context.Context, purchaseId int64) (err error) {
 | |
| 	xClient, err := client.GetClient(p)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	reply := 0
 | |
| 	err = xClient.Call(ctx, "CancelAudit", purchaseId, &reply)
 | |
| 	return
 | |
| }
 | |
| 
 | |
| type ArgsPurchaseFactoryBatch struct {
 | |
| 	PurchaseId int64 // 采购合同id
 | |
| 	FactoryId  int64 // 采购工厂id
 | |
| }
 | |
| type PurchaseFactoryBatchItem struct {
 | |
| 	PurchaseId int64 `json:"purchaseId"`
 | |
| 	BatchNo    int64 `json:"batchNo"`
 | |
| 	HasEdit    bool  `json:"hasEdit"`
 | |
| }
 | |
| 
 | |
| // FactoryBatch @TITLE 工厂批次数据
 | |
| func (p *purchase) FactoryBatch(ctx context.Context, args ArgsPurchaseFactoryBatch) (reply []PurchaseFactoryBatchItem, err error) {
 | |
| 	xClient, err := client.GetClient(p)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	err = xClient.Call(ctx, "FactoryBatch", args, &reply)
 | |
| 	return
 | |
| }
 | |
| 
 | |
| type PurchaseAssociationItem struct {
 | |
| 	Id          int64  `json:"id"`
 | |
| 	FactoryId   int64  `json:"factoryId"`
 | |
| 	SaleId      int64  `json:"saleId"`
 | |
| 	PoSerial    string `json:"poSerial"`
 | |
| 	BatchNo     int64  `json:"batchNo"`
 | |
| 	WorkflowId  int64  `json:"workflowId"`
 | |
| 	FactoryName string `json:"factoryName"`
 | |
| }
 | |
| 
 | |
| // Association @TITLE 关联采购合同
 | |
| func (p *purchase) Association(ctx context.Context, purchaseId int64) (reply []PurchaseAssociationItem, err error) {
 | |
| 	xClient, err := client.GetClient(p)
 | |
| 	if err != nil {
 | |
| 		return
 | |
| 	}
 | |
| 	err = xClient.Call(ctx, "Association", purchaseId, &reply)
 | |
| 	return
 | |
| }
 |