From 246c7a49220ff6385bb9679a7c4004719f340c63 Mon Sep 17 00:00:00 2001
From: kanade <kanade@kumo.work>
Date: Mon, 19 Aug 2024 17:49:26 +0800
Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E7=BD=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 erp/constant.go             |  12 +++
 erp/contact.go              |   7 ++
 erp/contact/contact.go      |   5 ++
 erp/contact/template.go     |  73 ++++++++++++++++
 erp/erp.go                  |   2 +
 erp/purchase/purchase.go    |   1 +
 erp/sale.go                 |   8 +-
 erp/shipment/sale.go        |  12 +--
 erp/shipment/saleProduct.go |  91 ++++++++++++++++++++
 erp/shipment/shipment.go    |   5 +-
 erp/template.go             | 165 ++++++++++++++++++++++++++++++++++++
 11 files changed, 371 insertions(+), 10 deletions(-)
 create mode 100644 erp/contact.go
 create mode 100644 erp/contact/contact.go
 create mode 100644 erp/contact/template.go
 create mode 100644 erp/shipment/saleProduct.go
 create mode 100644 erp/template.go

diff --git a/erp/constant.go b/erp/constant.go
index 7403d8d..48754c1 100644
--- a/erp/constant.go
+++ b/erp/constant.go
@@ -18,3 +18,15 @@ const (
 	AuditStatusAdopt  AuditStatus = 3 // 审核通过
 	AuditStatusReject AuditStatus = 4 // 审核驳回
 )
+
+type IsOpen = int64 // 开启状态
+const (
+	IsOpenTrue  IsOpen = 1 // 开启
+	IsOpenFalse IsOpen = 2 // 关闭
+)
+
+type ExportType = string // 导出类型
+
+const (
+	ExportTypeSalePi = "salePi" // 销售pi导出
+)
diff --git a/erp/contact.go b/erp/contact.go
new file mode 100644
index 0000000..f2589e9
--- /dev/null
+++ b/erp/contact.go
@@ -0,0 +1,7 @@
+package erp
+
+import contact2 "git.kumo.work/shama/service/erp/contact"
+
+type contact struct {
+	contact2.Contact
+}
diff --git a/erp/contact/contact.go b/erp/contact/contact.go
new file mode 100644
index 0000000..c34211a
--- /dev/null
+++ b/erp/contact/contact.go
@@ -0,0 +1,5 @@
+package contact
+
+type Contact struct {
+	Template template
+}
diff --git a/erp/contact/template.go b/erp/contact/template.go
new file mode 100644
index 0000000..0b9c835
--- /dev/null
+++ b/erp/contact/template.go
@@ -0,0 +1,73 @@
+package contact
+
+import (
+	"context"
+	client2 "git.kumo.work/shama/service/client"
+	"git.kumo.work/shama/service/lib/bean"
+	"time"
+)
+
+type template struct {
+}
+type ArgsTemplateList struct {
+	Page   bean.Page
+	Search TemplateSearch
+}
+type TemplateSearch struct {
+	Type        int64   // 类型
+	Title       string  // 标题
+	StaffIds    []int64 // 创建人
+	TemplateIds []int64 // 模板id
+}
+type ReplyTemplateList struct {
+	List  []TemplateItem `json:"list"`
+	Total int64          `json:"total"`
+}
+
+type TemplateItem struct {
+	Id             int64      `json:"id"`
+	Type           int64      `json:"type"`
+	Title          string     `json:"title"`
+	Content        string     `json:"content"`
+	CreatedStaffId int64      `json:"createdStaffId"`
+	CreatedAt      *time.Time `json:"createdAt"`
+}
+
+// List @TITLE 列表
+func (t *template) List(ctx context.Context, args ArgsTemplateList) (reply ReplyTemplateList, err error) {
+	xClient, err := client2.GetClient(t)
+	if err != nil {
+		return
+	}
+	err = xClient.Call(ctx, "List", args, &reply)
+	return
+}
+
+type ArgsTemplateAdd struct {
+	Type    int64  // 类型
+	Title   string // 标题
+	Content string // 内容
+	StaffId int64  // 员工id
+}
+
+// Add @TITLE 添加
+func (t *template) Add(ctx context.Context, args ArgsTemplateAdd) (err error) {
+	xClient, err := client2.GetClient(t)
+	if err != nil {
+		return
+	}
+	reply := 0
+	err = xClient.Call(ctx, "Add", args, &reply)
+	return
+}
+
+// Delete @TITLE 删除
+func (t *template) Delete(ctx context.Context, templateIds []int64) (err error) {
+	xClient, err := client2.GetClient(t)
+	if err != nil {
+		return
+	}
+	reply := 0
+	err = xClient.Call(ctx, "Delete", templateIds, &reply)
+	return
+}
diff --git a/erp/erp.go b/erp/erp.go
index 44d7cb5..c7d02f5 100644
--- a/erp/erp.go
+++ b/erp/erp.go
@@ -9,4 +9,6 @@ type Erp struct {
 	LogisticsCompany logisticsCompany
 	Workflow         workflow
 	Shipment         shipment
+	Contact          contact
+	Template         template
 }
diff --git a/erp/purchase/purchase.go b/erp/purchase/purchase.go
index 5cf5f00..e9c845b 100644
--- a/erp/purchase/purchase.go
+++ b/erp/purchase/purchase.go
@@ -1,6 +1,7 @@
 package purchase
 
 type Purchase struct {
+	Audit       audit
 	Cost        cost
 	Clause      clause
 	Annotations annotations
diff --git a/erp/sale.go b/erp/sale.go
index 0cbb9c2..9c0712b 100644
--- a/erp/sale.go
+++ b/erp/sale.go
@@ -17,8 +17,12 @@ type ArgsSaleList struct {
 	Search SaleSearch
 }
 type SaleSearch struct {
-	PiSerial string // pi
-	PoSerial string // po
+	PiSerial        string  // pi
+	PoSerial        string  // po
+	CustomIds       []int64 // 客户
+	PurchaseStatus  []int64 // 采购状态
+	ShipmentStatus  []int64 // 出舱状态
+	CreatedStaffIds []int64 // 业务员
 }
 type ReplySaleList struct {
 	List  []SaleItem `json:"list"`
diff --git a/erp/shipment/sale.go b/erp/shipment/sale.go
index fa6beea..ba3d474 100644
--- a/erp/shipment/sale.go
+++ b/erp/shipment/sale.go
@@ -16,8 +16,8 @@ type SaleItem struct {
 }
 
 // All @TITLE 获取销售合同
-func (c *sale) All(ctx context.Context, shipmentId int64) (reply []SaleItem, err error) {
-	xClient, err := client.GetClient(c)
+func (s *sale) All(ctx context.Context, shipmentId int64) (reply []SaleItem, err error) {
+	xClient, err := client.GetClient(s)
 	if err != nil {
 		return
 	}
@@ -31,8 +31,8 @@ type ArgsSaleAdd struct {
 }
 
 // Add @TITLE 添加销售合同
-func (c *sale) Add(ctx context.Context, args ArgsSaleAdd) (err error) {
-	xClient, err := client.GetClient(c)
+func (s *sale) Add(ctx context.Context, args ArgsSaleAdd) (err error) {
+	xClient, err := client.GetClient(s)
 	if err != nil {
 		return
 	}
@@ -46,8 +46,8 @@ type ArgsSaleDelete struct {
 }
 
 // Delete @TITLE 删除销售合同
-func (c *sale) Delete(ctx context.Context, args ArgsSaleDelete) (err error) {
-	xClient, err := client.GetClient(c)
+func (s *sale) Delete(ctx context.Context, args ArgsSaleDelete) (err error) {
+	xClient, err := client.GetClient(s)
 	if err != nil {
 		return
 	}
diff --git a/erp/shipment/saleProduct.go b/erp/shipment/saleProduct.go
new file mode 100644
index 0000000..17b3f16
--- /dev/null
+++ b/erp/shipment/saleProduct.go
@@ -0,0 +1,91 @@
+package shipment
+
+import (
+	"context"
+	"git.kumo.work/shama/service/client"
+	"github.com/shopspring/decimal"
+	"time"
+)
+
+type saleProduct struct {
+}
+
+type SaleProductItem struct {
+	Id                    int64           `json:"id"`
+	PiSerial              string          `json:"piSerial"`
+	Sort                  int64           `json:"sort"`
+	Po                    string          `json:"po"`
+	Serial                string          `json:"serial"`
+	CustomSerial          string          `json:"customSerial"`
+	PackageDescription    string          `json:"packageDescription"`
+	PackageEngDescription string          `json:"packageEngDescription"`
+	EngName               string          `json:"engName"`
+	Name                  string          `json:"name"`
+	CustomsName           string          `json:"customsName"`
+	CustomsSerial         string          `json:"customsSerial"`
+	CustomsMeasureUnit    string          `json:"customsMeasureUnit"`
+	CustomsInvoiceUnit    string          `json:"customsInvoiceUnit"`
+	CustomsDetail         string          `json:"customsDetail"`
+	BlEngName             string          `json:"blEngName"`
+	BoxCount              int64           `json:"boxCount"`
+	InnerNum              int64           `json:"innerNum"`
+	InnerBoxCount         *int64          `json:"innerBoxCount"`
+	BoxNumUnit            string          `json:"boxNumUnit"`
+	OuterNum              int64           `json:"outerNum"`
+	ShipmentCount         int64           `json:"shipmentCount"`
+	ShipmentCountUnit     string          `json:"shipmentCountUnit"`
+	Length                decimal.Decimal `json:"length"`
+	Width                 decimal.Decimal `json:"width"`
+	Height                decimal.Decimal `json:"height"`
+	Volume                decimal.Decimal `json:"volume"`
+	TotalVolume           decimal.Decimal `json:"totalVolume"`
+	NetGrossVolume        int64           `json:"netGrossVolume"`
+	GrossWeight           decimal.Decimal `json:"grossWeight"`
+	TotalGrossWeight      decimal.Decimal `json:"totalGrossWeight"`
+	NetWeight             decimal.Decimal `json:"netWeight"`
+	TotalNetWeight        decimal.Decimal `json:"totalNetWeight"`
+	SalePrice             decimal.Decimal `json:"salePrice"`
+	CurrencyRate          decimal.Decimal `json:"currencyRate"`
+	Brand                 string          `json:"brand"`
+	DomesticSupply        string          `json:"domesticSupply"`
+	EpmNo                 string          `json:"epmNo"`
+	HsSerial              int64           `json:"hsSerial"`
+	TaxExemption          string          `json:"taxExemption"`
+	ItemNumber            string          `json:"itemNumber"`
+	Texture               string          `json:"texture"`
+	Remark1               string          `json:"remark1"`
+	Remark2               string          `json:"remark2"`
+	Remark3               string          `json:"remark3"`
+	Remark4               string          `json:"remark4"`
+	Remark5               string          `json:"remark5"`
+	Remark6               string          `json:"remark6"`
+	ContainerNumber       string          `json:"containerNumber"`
+	SealNumber            string          `json:"sealNumber"`
+	CreatedAt             *time.Time      `json:"createdAt"`
+	UpdatedAt             *time.Time      `json:"updatedAt"`
+}
+
+// All @TITLE 获取商品
+func (s *saleProduct) All(ctx context.Context, shipmentId int64) (reply []SaleProductItem, err error) {
+	xClient, err := client.GetClient(s)
+	if err != nil {
+		return
+	}
+	err = xClient.Call(ctx, "All", shipmentId, &reply)
+	return
+}
+
+type ArgsSaleProductDelete struct {
+	ShipmentId             int64   // 订舱单id
+	ShipmentSaleProductIds []int64 // 出运参评id
+}
+
+// Delete @TITLE 删除出运产品
+func (s *saleProduct) Delete(ctx context.Context, args ArgsSaleProductDelete) (err error) {
+	xClient, err := client.GetClient(s)
+	if err != nil {
+		return
+	}
+	reply := 0
+	return xClient.Call(ctx, "Delete", args, &reply)
+}
diff --git a/erp/shipment/shipment.go b/erp/shipment/shipment.go
index 45f21a6..3207e33 100644
--- a/erp/shipment/shipment.go
+++ b/erp/shipment/shipment.go
@@ -1,6 +1,7 @@
 package shipment
 
 type Shipment struct {
-	Sale sale
-	Cost cost
+	Sale        sale
+	Cost        cost
+	SaleProduct saleProduct
 }
diff --git a/erp/template.go b/erp/template.go
new file mode 100644
index 0000000..217831a
--- /dev/null
+++ b/erp/template.go
@@ -0,0 +1,165 @@
+package erp
+
+import (
+	"context"
+	"git.kumo.work/shama/service/client"
+	"git.kumo.work/shama/service/lib/bean"
+	"time"
+)
+
+type template struct {
+}
+type ArgsTemplateList struct {
+	Page   bean.Page
+	Search TemplateSearch
+}
+type TemplateSearch struct {
+	Name   string   // 模板名称
+	Types  []string // 模板类型
+	IsOpen int64    // 是否开启
+}
+type ReplyTemplateList struct {
+	List  []TemplateItem `json:"list"`
+	Total int64          `json:"total"`
+}
+type TemplateItem struct {
+	Id             int64      `json:"id"`
+	Name           string     `json:"name"`
+	Type           string     `json:"type"`
+	Path           string     `json:"path"`
+	Sort           int64      `json:"sort"`
+	PdfConfig      string     `json:"pdfConfig"`
+	IsOpen         int64      `json:"isOpen"`
+	CreatedStaffId int64      `json:"createdStaffId"`
+	CreatedAt      *time.Time `json:"createdAt"`
+}
+
+// List @TITLE 列表
+func (t *template) List(ctx context.Context, args ArgsTemplateList) (reply ReplyTemplateList, err error) {
+	xClient, err := client.GetClient(t)
+	if err != nil {
+		return
+	}
+	err = xClient.Call(ctx, "List", args, &reply)
+	return
+}
+
+type ArgsTemplateAdd struct {
+	StaffId     int64 // 员工id
+	TemplateAdd TemplateAdd
+}
+
+type TemplateAdd struct {
+	Name      string // 模板名称
+	Type      string // 模板类型
+	Path      string // 模板文件地址
+	Sort      int64  // 排序
+	PdfConfig string // pdf配置
+}
+
+// Add @TITLE 添加
+func (t *template) Add(ctx context.Context, args ArgsTemplateAdd) (err error) {
+	xClient, err := client.GetClient(t)
+	if err != nil {
+		return
+	}
+	reply := 0
+	err = xClient.Call(ctx, "Add", args, &reply)
+	return
+}
+
+type TemplateInfo struct {
+	Id             int64      `json:"id"`
+	Name           string     `json:"name"`
+	Type           string     `json:"type"`
+	Path           string     `json:"path"`
+	Sort           int64      `json:"sort"`
+	PdfConfig      string     `json:"pdfConfig"`
+	IsOpen         int64      `json:"isOpen"`
+	CreatedStaffId int64      `json:"createdStaffId"`
+	CreatedAt      *time.Time `json:"createdAt"`
+}
+
+// Info @TITLE 详情
+func (t *template) Info(ctx context.Context, templateId int64) (reply TemplateInfo, err error) {
+	xClient, err := client.GetClient(t)
+	if err != nil {
+		return
+	}
+	err = xClient.Call(ctx, "Info", templateId, &reply)
+	return
+}
+
+type ArgsTemplateEdit struct {
+	TemplateId  int64 // 模板id
+	TemplateAdd TemplateAdd
+}
+
+// Edit @TITLE 编辑
+func (t *template) Edit(ctx context.Context, args ArgsTemplateEdit) (err error) {
+	xClient, err := client.GetClient(t)
+	if err != nil {
+		return
+	}
+	reply := 0
+	err = xClient.Call(ctx, "Edit", args, &reply)
+	return
+}
+
+// Open @TITLE 开启
+func (t *template) Open(ctx context.Context, templateIds []int64) (err error) {
+	xClient, err := client.GetClient(t)
+	if err != nil {
+		return
+	}
+	reply := 0
+	err = xClient.Call(ctx, "Open", templateIds, &reply)
+	return
+}
+
+// Close @TITLE 关闭
+func (t *template) Close(ctx context.Context, templateIds []int64) (err error) {
+	xClient, err := client.GetClient(t)
+	if err != nil {
+		return
+	}
+	reply := 0
+	err = xClient.Call(ctx, "Close", templateIds, &reply)
+	return
+}
+
+// Delete @TITLE 删除
+func (t *template) Delete(ctx context.Context, templateIds []int64) (err error) {
+	xClient, err := client.GetClient(t)
+	if err != nil {
+		return
+	}
+	reply := 0
+	err = xClient.Call(ctx, "Delete", templateIds, &reply)
+	return
+}
+
+type ArgsTemplateExportData struct {
+	ExportType ExportType // 导出类型
+	DataId     int64      // 导出数据id
+}
+
+// ExportData @TITLE 导出数据
+func (t *template) ExportData(ctx context.Context, args ArgsTemplateExportData) (reply interface{}, err error) {
+	xClient, err := client.GetClient(t)
+	if err != nil {
+		return
+	}
+	err = xClient.Call(ctx, "ExportData", args, &reply)
+	return
+}
+
+// ExportStruct @TITLE 导出数据结构
+func (t *template) ExportStruct(ctx context.Context, exportType ExportType) (reply interface{}, err error) {
+	xClient, err := client.GetClient(t)
+	if err != nil {
+		return
+	}
+	err = xClient.Call(ctx, "ExportStruct", exportType, &reply)
+	return
+}