diff --git a/erp/constant.go b/erp/constant.go new file mode 100644 index 0000000..7403d8d --- /dev/null +++ b/erp/constant.go @@ -0,0 +1,20 @@ +package erp + +type BusinessType = string // 业务类型 +const ( + BusinessTypeSaleAudit BusinessType = "saleAudit" // 销售合同审核 + BusinessTypePurchaseAudit BusinessType = "purchaseAudit" // 销售合同审核 +) + +var BusinessTypeName = map[BusinessType]string{ + BusinessTypeSaleAudit: "销售合同审核", + BusinessTypePurchaseAudit: "采购合同审核", +} + +type AuditStatus = int64 // 审核状态 +const ( + AuditStatusNone AuditStatus = 1 // 待提交 + AuditStatusIng AuditStatus = 2 // 审核中 + AuditStatusAdopt AuditStatus = 3 // 审核通过 + AuditStatusReject AuditStatus = 4 // 审核驳回 +) diff --git a/erp/purchase.go b/erp/purchase.go index 72c4cbc..0239aca 100644 --- a/erp/purchase.go +++ b/erp/purchase.go @@ -4,6 +4,7 @@ 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" ) @@ -11,6 +12,50 @@ import ( type purchase struct { purchase2.Purchase } +type ArgsPurchaseList struct { + Page bean.Page + Search PurchaseSearch +} +type PurchaseSearch struct { + PiSerial string // 采购合同编号 + PoSerial string // po + CustomShortName string // 客户简称 + CreatedStaffIds []int64 // 创建人筛选 + FactoryName string // 采购工厂 +} +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"` + 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"` + 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 @@ -38,11 +83,51 @@ func (p *purchase) Add(ctx context.Context, args ArgsPurchaseAdd) (err error) { return } +type ReplyPurchaseInfo struct { + PurchaseId int64 `json:"purchaseId"` + 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"` + 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"` + 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 Po string // po OrderDate *time.Time // 下单日期 FactoryAddress string // 工厂地址 + FactoryContact string // 工厂联系人 FactoryPhone string // 工厂电话 FactoryFax string // 工厂传真 DeliveryDate *time.Time // 采购交期 diff --git a/erp/purchase/audit.go b/erp/purchase/audit.go new file mode 100644 index 0000000..12ea170 --- /dev/null +++ b/erp/purchase/audit.go @@ -0,0 +1,25 @@ +package purchase + +import ( + "context" + "git.kumo.work/shama/service/client" +) + +type audit struct { +} +type ArgsAuditSubmit struct { + StaffId int64 // 操作人 + PurchaseId int64 // 采购合同id + AuditStaffIds []int64 // 审核人 +} + +// Submit @TITLE 提交审核 +func (a *audit) Submit(ctx context.Context, args ArgsAuditSubmit) (err error) { + xClient, err := client.GetClient(a) + if err != nil { + return + } + reply := 0 + err = xClient.Call(ctx, "Submit", args, &reply) + return +} diff --git a/erp/sale.go b/erp/sale.go index 7369350..0cbb9c2 100644 --- a/erp/sale.go +++ b/erp/sale.go @@ -72,6 +72,8 @@ type SaleItem struct { SideMark string `json:"sideMark"` InnerBoxText string `json:"innerBoxText"` Remarks string `json:"remarks"` + WorkflowId int64 `json:"workflowId"` + WorkflowStatus int64 `json:"workflowStatus"` CreatedStaffId int64 `json:"createdStaffId"` CreatedAt *time.Time `json:"createdAt"` UpdatedAt *time.Time `json:"updatedAt"` @@ -112,6 +114,7 @@ type SaleAdd struct { RecBankNameEng string // 收汇银行名称英文 RecBankCardNo string // 收汇银行卡号 RecBankCardName string // 收汇银行卡名 + OurCompany string // 我方公司 Currency string // 币种 CurrencyName string // 币种名称 CurrencySymbol string // 币种符号 @@ -172,6 +175,7 @@ type ReplySaleInfo struct { RecBankNameEng string `json:"recBankNameEng"` RecBankCardNo string `json:"recBankCardNo"` RecBankCardName string `json:"recBankCardName"` + OurCompany string `json:"ourCompany"` Currency string `json:"currency"` CurrencyName string `json:"currencyName"` CurrencySymbol string `json:"currencySymbol"` @@ -199,6 +203,10 @@ type ReplySaleInfo struct { SideMark string `json:"sideMark"` InnerBoxText string `json:"innerBoxText"` Remarks string `json:"remarks"` + HasEdit bool `json:"hasEdit"` + WorkflowId int64 `json:"workflowId"` + WorkflowStatus int64 `json:"workflowStatus"` + WorkflowReason string `json:"workflowReason"` CreatedStaffId int64 `json:"createdStaffId"` CreatedAt *time.Time `json:"createdAt"` UpdatedAt *time.Time `json:"updatedAt"` diff --git a/erp/sale/product.go b/erp/sale/product.go index 2cf466f..afe1179 100644 --- a/erp/sale/product.go +++ b/erp/sale/product.go @@ -35,7 +35,7 @@ type ProductItem struct { BoxCount int64 `json:"boxCount"` QuotePrice decimal.Decimal `json:"quotePrice"` QuoteFactorySerial string `json:"quoteFactorySerial"` - QuoteFactoryID int64 `json:"quoteFactoryID"` + QuoteFactoryId int64 `json:"quoteFactoryId"` QuoteFactoryName string `json:"quoteFactoryName"` QuoteStartNum int64 `json:"quoteStartNum"` QuoteMeasureUnit string `json:"quoteMeasureUnit"` diff --git a/erp/workflow.go b/erp/workflow.go index 18a4691..c300245 100644 --- a/erp/workflow.go +++ b/erp/workflow.go @@ -3,39 +3,82 @@ package erp import ( "context" "git.kumo.work/shama/service/client" + workflow2 "git.kumo.work/shama/service/erp/workflow" + "git.kumo.work/shama/service/lib/bean" + "time" ) type workflow struct { + workflow2.Workflow } -type ArgsWorkflowAdopt struct { - StaffId int64 // 审核人 - WorkflowId int64 // 工作流 +type ArgsWorkflowList struct { + Page bean.Page + Search WorkflowSearch } -// Adopt @TITLE 审核通过 -func (w *workflow) Adopt(ctx context.Context, args ArgsWorkflowAdopt) (err error) { +type WorkflowSearch struct { + BusinessId int64 // 业务id + BusinessType string + Status AuditStatus +} +type ReplyWorkflowList struct { + List []WorkflowItem + Total int64 +} +type WorkflowItem struct { + Id int64 `json:"id"` // 审批流id + BusinessId int64 `json:"businessId"` // 业务id + BusinessType string `json:"businessType"` // 业务类型 + BusinessName string `json:"businessName"` // 业务名称 + Title string `json:"title"` // 审批流标题 + Content string `json:"content"` // 审批流内容 + Status AuditStatus `json:"status"` // 审批流状态 + CreatedStaffId int64 `json:"createdStaffId"` // 创建人 + CreatedAt *time.Time `json:"createdAt"` // 创建时间 +} + +// List @TITLE 审核列表 +func (w *workflow) List(ctx context.Context, args ArgsWorkflowList) (reply ReplyWorkflowList, err error) { xClient, err := client.GetClient(w) if err != nil { return } - reply := 0 - err = xClient.Call(ctx, "Adopt", args, &reply) + err = xClient.Call(ctx, "List", args, &reply) return } -type ArgsWorkflowReject struct { - StaffId int64 // 审核人 - WorkflowId int64 // 工作流 - Reason string // 审核结果 +type ReplyWorkflowInfo struct { + Id int64 `json:"id"` // 审批流id + BusinessId int64 `json:"businessId"` // 业务id + BusinessType string `json:"businessType"` // 业务类型 + BusinessName string `json:"businessName"` // 业务名称 + Title string `json:"title"` // 审批流标题 + Content string `json:"content"` // 审批流内容 + Status AuditStatus `json:"status"` // 审批流状态 + CreatedStaffId int64 `json:"createdStaffId"` // 创建人 + CreatedAt *time.Time `json:"createdAt"` // 创建时间 + Nodes []WorkflowNodeItem `json:"nodes"` +} +type WorkflowNodeItem struct { + Id int64 `json:"id"` // 审批流节点id + Status AuditStatus `json:"status"` // 审批流节点状态 + ReviewStaffId int64 `json:"reviewStaffId"` // 审批流节点审核人 + ReviewAt *time.Time `json:"reviewAt"` // 审批流节点审核时间 + ReviewComments string `json:"reviewComments"` // 审批流节点审核意见 + Index int64 `json:"index"` // 审批流节点顺序 + +} +type ArgsWorkflowInfo struct { + WorkflowId int64 // 审批流id + WorkflowNodeId int64 // 审批流节点 } -// Reject @TITLE 审核驳回 -func (w *workflow) Reject(ctx context.Context, args ArgsWorkflowReject) (err error) { +// Info @TITLE 审核详情 +func (w *workflow) Info(ctx context.Context, args ArgsWorkflowInfo) (reply ReplyWorkflowInfo, err error) { xClient, err := client.GetClient(w) if err != nil { return } - reply := 0 - err = xClient.Call(ctx, "Reject", args, &reply) + err = xClient.Call(ctx, "Info", args, &reply) return } diff --git a/erp/workflow/node.go b/erp/workflow/node.go new file mode 100644 index 0000000..a0d7d33 --- /dev/null +++ b/erp/workflow/node.go @@ -0,0 +1,96 @@ +package workflow + +import ( + "context" + "git.kumo.work/shama/service/client" + "git.kumo.work/shama/service/lib/bean" + "time" +) + +type node struct { +} + +type ArgsNodeCountSearch struct { + StaffIds []int64 // 员工筛选 + Status []int64 // 状态筛选 +} + +type NodeCountItem struct { + BusinessType string `json:"businessType"` + Count int64 `json:"count"` +} + +// Count @TITLE 节点统计 +func (n *node) Count(ctx context.Context, args ArgsNodeCountSearch) (reply []NodeCountItem, err error) { + xClient, err := client.GetClient(n) + if err != nil { + return + } + err = xClient.Call(ctx, "Count", args, &reply) + return +} + +type ArgsNodeList struct { + Page bean.Page + Search NodeSearch +} +type NodeSearch struct { + StaffIds []int64 // 员工筛选 + Status []int64 // 状态筛选 + BusinessType string // 业务类型 +} +type ReplyNodeList struct { + List []NodeItem `json:"list"` + Total int64 `json:"total"` +} +type NodeItem struct { + Id int64 `json:"id"` + BusinessId int64 `json:"businessId"` + BusinessName string `json:"businessName"` + BusinessType string `json:"businessType"` + Status int64 `json:"status"` + CreatedAt *time.Time `json:"createdAt"` +} + +// List @TITLE 节点列表 +func (n *node) List(ctx context.Context, args ArgsNodeList) (reply ReplyNodeList, err error) { + xClient, err := client.GetClient(n) + if err != nil { + return + } + err = xClient.Call(ctx, "List", args, &reply) + return +} + +type ArgsNodeAdopt struct { + StaffId int64 // 审核人 + NodeId int64 // 节点id +} + +// Adopt @TITLE 审核通过 +func (n *node) Adopt(ctx context.Context, args ArgsNodeAdopt) (err error) { + xClient, err := client.GetClient(n) + if err != nil { + return + } + reply := 0 + err = xClient.Call(ctx, "Adopt", args, &reply) + return +} + +type ArgsNodeReject struct { + StaffId int64 // 审核人 + NodeId int64 // 节点id + Reason string // 审核结果 +} + +// Reject @TITLE 审核驳回 +func (n *node) Reject(ctx context.Context, args ArgsNodeReject) (err error) { + xClient, err := client.GetClient(n) + if err != nil { + return + } + reply := 0 + err = xClient.Call(ctx, "Reject", args, &reply) + return +} diff --git a/erp/workflow/workflow.go b/erp/workflow/workflow.go new file mode 100644 index 0000000..8e2106e --- /dev/null +++ b/erp/workflow/workflow.go @@ -0,0 +1,5 @@ +package workflow + +type Workflow struct { + Node node +}