252 lines
12 KiB
Go
252 lines
12 KiB
Go
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 // 客户
|
||
PurchaseStatus []int64 // 采购状态
|
||
ShipmentStatus []int64 // 出舱状态
|
||
CreatedStaffIds []int64 // 业务员
|
||
BanFlag int64 // 禁用标记 1=禁用,2=可用
|
||
}
|
||
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"`
|
||
}
|
||
|
||
// 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"`
|
||
}
|
||
|
||
// 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)
|
||
}
|