Files
service/ik3cloud/ik3cloud.go
kanade 6a8dcfdc75 feat(paymentRefund): 新增付款退款单功能
- 添加付款退款单常量定义及类型枚举
- 在 Ik3cloud 结构体中注册付款退款单模块
- 实现付款退款单保存接口 Save
- 实现付款退款单作废接口 Cancel
- 定义付款退款单参数结构体及费用明细项
2026-10-16 16:12:33 +08:00

77 lines
1.7 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 // 收款单
PaymentRefund paymentRefund // 付款退款单
}
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
}