- 新增收款单常量定义及映射配置 - 新增收款单类型枚举定义 - 新增收款单服务模块,支持保存和作废操作 - 在应付、应收、付款模块中补充作废接口实现 - 定义收款单保存参数结构体及费用明细结构体
76 lines
1.6 KiB
Go
76 lines
1.6 KiB
Go
package ik3cloud
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
)
|
|
|
|
type Ik3cloud struct {
|
|
Department department // 部门
|
|
Staff staff // 员工
|
|
Position position // 职位
|
|
Contact contact // 联系人
|
|
Factory factory // 工厂
|
|
Custom custom // 客户
|
|
Product product // 产品
|
|
Receivable receivable // 应收
|
|
Payable payable // 应付
|
|
Dict dict // 字典
|
|
Payment payment // 付款单
|
|
Information information // 资料
|
|
Receipt receipt // 收款单
|
|
}
|
|
|
|
type Entity struct {
|
|
Id int64 `json:"Id"`
|
|
Number string `json:"Number"`
|
|
DIndex int `json:"DIndex"`
|
|
}
|
|
|
|
// SetStringId @TITLE 设置字符串id
|
|
func (e *Entity) SetStringId(stringId string) {
|
|
e.Id, _ = strconv.ParseInt(stringId, 16, 64)
|
|
}
|
|
|
|
// GetStringId @TITLE 获取字符串id
|
|
func (e *Entity) GetStringId() string {
|
|
return strconv.FormatInt(e.Id, 16)
|
|
}
|
|
|
|
func (e *Entity) UnmarshalJSON(data []byte) error {
|
|
var raw map[string]interface{}
|
|
if err := json.Unmarshal(data, &raw); err != nil {
|
|
return err
|
|
}
|
|
|
|
// 处理 Id 字段,支持字符串和数字类型
|
|
if idVal, ok := raw["Id"]; ok {
|
|
switch v := idVal.(type) {
|
|
case string:
|
|
e.SetStringId(v)
|
|
case float64: // JSON 中的数字默认为 float64
|
|
e.Id = int64(v)
|
|
case int64:
|
|
e.Id = v
|
|
default:
|
|
return fmt.Errorf("unsupported type for Id: %T", v)
|
|
}
|
|
}
|
|
|
|
// 其他字段处理
|
|
if num, ok := raw["Number"].(string); ok {
|
|
e.Number = num
|
|
}
|
|
if dIndex, ok := raw["DIndex"].(float64); ok {
|
|
e.DIndex = int(dIndex)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type Unique struct {
|
|
Numbers []string // 编码
|
|
Ids []int64 // id
|
|
}
|