service/erp/sale.go
2024-10-23 15:16:45 +08:00

318 lines
14 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package erp
import (
"context"
"git.kumo.work/shama/service/client"
sale2 "git.kumo.work/shama/service/erp/sale"
"git.kumo.work/shama/service/lib/bean"
"github.com/shopspring/decimal"
"time"
)
type sale struct {
sale2.Sale
}
type ArgsSaleList struct {
Page bean.Page
Search SaleSearch
}
type SaleSearch struct {
PiSerial string // pi
PoSerial string // po
CustomIds []int64 // 客户
CustomShortName string // 客户简称
PurchaseStatus []int64 // 采购状态
ShipmentStatus []int64 // 出舱状态
CreatedStaffIds []int64 // 业务员
StaffIds []int64 // 业务员
SaleIds []int64 // 销售id
ContractDateStart *time.Time // 合同日期
ContractDateEnd *time.Time // 合同日期
BanFlag int64 // 禁用标记 1=禁用2=可用
WorkflowStatus []int64 // 审批状态
}
type ReplySaleList struct {
List []SaleItem `json:"list"`
Total int64 `json:"total"`
}
type SaleItem struct {
Id int64 `json:"id"`
PiSerial string `json:"piSerial"`
PoSerial string `json:"poSerial"`
ContractDate time.Time `json:"contractDate"`
CustomId int64 `json:"customId"`
CustomShortName string `json:"customShortName"`
CustomName string `json:"customName"`
CustomContactName string `json:"customContactName"`
CustomContactFax string `json:"customContactFax"`
CustomConsigneeName string `json:"customConsigneeName"`
CustomConsigneeAddress string `json:"customConsigneeAddress"`
EstShipDate time.Time `json:"estShipDate"`
EstShipDateEnd *time.Time `json:"estShipDateEnd"`
EstRecDate *time.Time `json:"estRecDate"`
RecBank string `json:"recBank"`
RecBankEng string `json:"recBankEng"`
RecBankName string `json:"recBankName"`
RecBankNameEng string `json:"recBankNameEng"`
RecBankCardNo string `json:"recBankCardNo"`
RecBankCardName string `json:"recBankCardName"`
RecBankAddress string `json:"recBankAddress"`
Currency string `json:"currency"`
CurrencyName string `json:"currencyName"`
CurrencySymbol string `json:"currencySymbol"`
CurrencyRate decimal.Decimal `json:"currencyRate"`
PaymentType string `json:"paymentType"`
PaymentDepositRate *decimal.Decimal `json:"paymentDepositRate"`
PaymentDepositAmount *decimal.Decimal `json:"paymentDepositAmount"`
PaymentCycle *int64 `json:"paymentCycle"`
PaymentTerms string `json:"paymentTerms"`
ShipPort string `json:"shipPort"`
DischargePort string `json:"dischargePort"`
DischargePortEng string `json:"dischargePortEng"`
DeliveryCountry string `json:"deliveryCountry"`
DeliveryCountryEng string `json:"deliveryCountryEng"`
TradeCountry string `json:"tradeCountry"`
FreightCurrency string `json:"freightCurrency"`
FreightCurrencyName string `json:"freightCurrencyName"`
FreightCurrencySymbol string `json:"freightCurrencySymbol"`
FreightCurrencyRate *decimal.Decimal `json:"freightCurrencyRate"`
CommissionRate *decimal.Decimal `json:"commissionRate"`
ShipMode string `json:"shipMode"`
MarkText string `json:"markText"`
MarkImg string `json:"markImg"`
FrontMark string `json:"frontMark"`
SideMark string `json:"sideMark"`
InnerBoxText string `json:"innerBoxText"`
Remarks string `json:"remarks"`
WorkflowId int64 `json:"workflowId"`
WorkflowStatus int64 `json:"workflowStatus"`
HasPurchase int64 `json:"hasPurchase"`
PurchaseStatus int64 `json:"purchaseStatus"`
ShipmentStatus int64 `json:"shipmentStatus"`
TotalSaleAmount decimal.Decimal `json:"totalSaleAmount"`
CreatedStaffId int64 `json:"createdStaffId"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
CloseWorkflowId int64 `json:"closeWorkflowId"`
CloseWorkflowStatus int64 `json:"closeWorkflowStatus"`
BanFlag int64 `json:"banFlag"`
}
// List @TITLE 销售合同列表
func (s *sale) List(ctx context.Context, args ArgsSaleList) (reply ReplySaleList, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "List", args, &reply)
return
}
type ArgsSaleAdd struct {
StaffId int64 // 员工id
SaleAdd
}
type SaleAdd struct {
PiSerial string // PI number
PoSerial string // PO number
ContractDate time.Time // 合同日期
CustomId int64 // 客户ID
CustomShortName string // 客户简称
CustomName string // 客户名称
CustomContactName string // 客户联系人
CustomContactFax string // 客户联系人传真
CustomConsigneeName string // 客户收货人
CustomConsigneeAddress string // 客户收货人地址
EstShipDate time.Time // 预计出运日期
EstShipDateEnd *time.Time // 预计出运日期结束
EstRecDate *time.Time // 预计收汇日期
RecBank string // 收汇银行
RecBankEng string // 收汇银行英文
RecBankName string // 收汇银行名称
RecBankNameEng string // 收汇银行名称英文
RecBankCardNo string // 收汇银行卡号
RecBankCardName string // 收汇银行卡名
RecBankAddress string // 收汇银行地址
OurCompany string // 我方公司
Currency string // 币种
CurrencyName string // 币种名称
CurrencySymbol string // 币种符号
CurrencyRate decimal.Decimal // 币种汇率
PaymentType string // 付款方式
PaymentDepositRate *decimal.Decimal // 订金比例
PaymentDepositAmount *decimal.Decimal // 订金金额
PaymentCycle *int64 // 付款周期
PaymentTerms string // 价格条款
ShipPort string // 出运港口
DischargePort string // 卸货港口
DischargePortEng string // 出运港口英文
DeliveryCountry string // 抵运国家
DeliveryCountryEng string // 卸货港口英文
TradeCountry string // 贸易国别
FreightCurrency string // 运费币种
FreightCurrencyName string // 运费币种名称
FreightCurrencySymbol string // 运费币种符号
FreightCurrencyRate *decimal.Decimal // 运费币种汇率
CommissionRate *decimal.Decimal // 佣金比例
ShipMode string // 运输方式
MarkText string // 文字唛头
MarkImg string // 图片唛头
FrontMark string // 正面唛头
SideMark string // 侧面唛头
InnerBoxText string // 内盒文字
Remarks string // 合同备注
}
// Add @TITLE 添加销售合同
func (s *sale) Add(ctx context.Context, args ArgsSaleAdd) (saleId int64, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "Add", args, &saleId)
return
}
type ReplySaleInfo struct {
Id int64 `json:"id"`
PiSerial string `json:"piSerial"`
PoSerial string `json:"poSerial"`
ContractDate time.Time `json:"contractDate"`
CustomId int64 `json:"customId"`
CustomShortName string `json:"customShortName"`
CustomName string `json:"customName"`
CustomContactName string `json:"customContactName"`
CustomContactFax string `json:"customContactFax"`
CustomConsigneeName string `json:"customConsigneeName"`
CustomConsigneeAddress string `json:"customConsigneeAddress"`
EstShipDate time.Time `json:"estShipDate"`
EstShipDateEnd *time.Time `json:"estShipDateEnd"`
EstRecDate *time.Time `json:"estRecDate"`
RecBank string `json:"recBank"`
RecBankEng string `json:"recBankEng"`
RecBankName string `json:"recBankName"`
RecBankNameEng string `json:"recBankNameEng"`
RecBankCardNo string `json:"recBankCardNo"`
RecBankCardName string `json:"recBankCardName"`
RecBankAddress string `json:"recBankAddress"`
OurCompany string `json:"ourCompany"`
Currency string `json:"currency"`
CurrencyName string `json:"currencyName"`
CurrencySymbol string `json:"currencySymbol"`
CurrencyRate decimal.Decimal `json:"currencyRate"`
PaymentType string `json:"paymentType"`
PaymentDepositRate *decimal.Decimal `json:"paymentDepositRate"`
PaymentDepositAmount *decimal.Decimal `json:"paymentDepositAmount"`
PaymentCycle *int64 `json:"paymentCycle"`
PaymentTerms string `json:"paymentTerms"`
ShipPort string `json:"shipPort"`
DischargePort string `json:"dischargePort"`
DischargePortEng string `json:"dischargePortEng"`
DeliveryCountry string `json:"deliveryCountry"`
DeliveryCountryEng string `json:"deliveryCountryEng"`
TradeCountry string `json:"tradeCountry"`
FreightCurrency string `json:"freightCurrency"`
FreightCurrencyName string `json:"freightCurrencyName"`
FreightCurrencySymbol string `json:"freightCurrencySymbol"`
FreightCurrencyRate *decimal.Decimal `json:"freightCurrencyRate"`
CommissionRate *decimal.Decimal `json:"commissionRate"`
ShipMode string `json:"shipMode"`
MarkText string `json:"markText"`
MarkImg string `json:"markImg"`
FrontMark string `json:"frontMark"`
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"`
HasPurchase int64 `json:"hasPurchase"`
CreatedStaffId int64 `json:"createdStaffId"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
BanFlag int64 `json:"banFlag"`
CloseWorkflowId int64 `json:"closeWorkflowId"`
CloseWorkflowStatus int64 `json:"closeWorkflowStatus"`
CloseWorkflowReason string `json:"closeWorkflowReason"`
}
// Info @TITLE 销售合同详情
func (s *sale) Info(ctx context.Context, saleId int64) (reply ReplySaleInfo, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "Info", saleId, &reply)
return
}
type ArgsSaleEdit struct {
SaleId int64 // 销售合同
SaleAdd
}
// Edit @TITLE 编辑销售合同
func (s *sale) Edit(ctx context.Context, args ArgsSaleEdit) (err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Edit", args, &reply)
}
type ArgsSaleClone struct {
StaffId int64 // 员工id
SaleId int64 // saleId
PiSerial string // PI number
}
// Clone @TITLE 销售合同克隆
func (s *sale) Clone(ctx context.Context, args ArgsSaleClone) (reply int64, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "Clone", args, &reply)
return
}
type ArgsSaleHistory struct {
Page bean.Page
Search SaleHistorySearch
}
type SaleHistorySearch struct {
ProductId int64 // 产品id
}
type ReplySaleHistory struct {
List []SaleHistoryItem `json:"list"`
Total int64 `json:"total"`
}
type SaleHistoryItem struct {
SaleId int64 `json:"saleId"`
PiSerial string `json:"piSerial"`
ContractDate time.Time `json:"contractDate"`
CustomName string `json:"customName"`
CustomShortName string `json:"customShortName"`
SalePrice decimal.Decimal `json:"salePrice"`
SaleCount int64 `json:"saleCount"`
SaleAmount decimal.Decimal `json:"saleAmount"`
SaleCurrency string `json:"saleCurrency"`
SaleCurrencyName string `json:"saleCurrencyName"`
SaleCurrencySymbol string `json:"saleCurrencySymbol"`
SaleCurrencyRate decimal.Decimal `json:"saleCurrencyRate"`
CreatedStaffId int64 `json:"createdStaffId"`
}
// History @TITLE 历史记录
func (s *sale) History(ctx context.Context, args ArgsSaleHistory) (reply ReplySaleHistory, err error) {
xClient, err := client.GetClient(s)
if err != nil {
return
}
err = xClient.Call(ctx, "History", args, &reply)
return
}