Files
service/erp/expense.go
kanade 3371938767 fix(logic): 添加 Ik3cloudID 验证防止无效取消操作
- 在 expense.go 中添加 expenseThird.Ik3cloudID > 0 的验证条件
- 在 receipt.go 中添加 receiptThird.Ik3cloudID > 0 的验证条件
- 在 request.go 中添加 requestThird.Ik3cloudID > 0 的验证条件
- 避免对 Ik3cloudID 为 0 的记录执行取消操作
- 防止因无效 ID 导致的第三方支付取消失败
2026-01-04 11:38:12 +08:00

152 lines
4.7 KiB
Go

package erp
import (
"context"
"time"
"git.kumo.work/shama/service/client"
expense2 "git.kumo.work/shama/service/erp/expense"
"git.kumo.work/shama/service/lib/bean"
"github.com/shopspring/decimal"
)
type expense struct {
expense2.Expense
}
type ArgsExpenseList struct {
Page bean.Page
Search ExpenseSearch
}
type ExpenseSearch struct {
ExpenseSerial string // 报销单号
CreatedAtStart *time.Time // 创建开始时间
CreatedAtEnd *time.Time // 创建结束时间
ExpenseIds []int64 // 报销单id
BanFlag int64 // 禁用标记 1=禁用 2=启用
}
type ReplyExpenseList struct {
List []ExpenseItem `json:"list"`
Total int64 `json:"total"`
}
type ExpenseItem struct {
Id int64 `json:"id"`
ExpenseSerial string `json:"expenseSerial"`
Currency string `json:"currency"`
CurrencyName string `json:"currencyName"`
CurrencySymbol string `json:"currencySymbol"`
CurrencyRate decimal.Decimal `json:"currencyRate"`
Remarks string `json:"remarks"`
Amount decimal.Decimal `json:"amount"`
WorkflowId int64 `json:"workflowId"`
WorkflowStatus int64 `json:"workflowStatus"`
WorkflowReason string `json:"workflowReason"`
ExpenseStaffId int64 `json:"expenseStaffId"`
CreatedStaffId int64 `json:"createdStaffId"`
BanFlag int64 `json:"banFlag"`
Ik3cloudStatus int64 `json:"ik3CloudStatus"`
Ik3cloudErrMsg string `json:"ik3CloudErrMsg"`
Ik3cloudUpdatedAt *time.Time `json:"ik3CloudUpdatedAt"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
// List @TITLE 列表
func (r *expense) List(ctx context.Context, args ArgsExpenseList) (reply ReplyExpenseList, err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
err = xClient.Call(ctx, "List", args, &reply)
return
}
type ArgsExpenseAdd struct {
StaffId int64
ExpenseAdd
}
type ExpenseAdd struct {
Currency string // 币种
CurrencyName string // 币种名称
CurrencySymbol string // 币种符号
CurrencyRate decimal.Decimal // 币种汇率
Remarks string // 备注
ExpenseStaffId int64 // 报销人
}
// Add @TITLE 添加
func (r *expense) Add(ctx context.Context, args ArgsExpenseAdd) (expenseId int64, err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
err = xClient.Call(ctx, "Add", args, &expenseId)
return
}
type ReplyExpenseInfo struct {
Id int64 `json:"id"`
ExpenseSerial string `json:"expenseSerial"`
Currency string `json:"currency"`
CurrencyName string `json:"currencyName"`
CurrencySymbol string `json:"currencySymbol"`
CurrencyRate decimal.Decimal `json:"currencyRate"`
Amount decimal.Decimal `json:"amount"`
Remarks string `json:"remarks"`
WorkflowId int64 `json:"workflowId"`
WorkflowStatus int64 `json:"workflowStatus"`
WorkflowReason string `json:"workflowReason"`
ExpenseStaffId int64 `json:"expenseStaffId"`
CreatedStaffId int64 `json:"createdStaffId"`
BanFlag int64 `json:"banFlag"`
Ik3cloudStatus int64 `json:"ik3CloudStatus"`
Ik3cloudErrMsg string `json:"ik3CloudErrMsg"`
Ik3cloudUpdatedAt *time.Time `json:"ik3CloudUpdatedAt"`
CreatedAt *time.Time `json:"createdAt"`
UpdatedAt *time.Time `json:"updatedAt"`
}
// Info @TITLE 详情
func (r *expense) Info(ctx context.Context, expenseId int64) (reply ReplyExpenseInfo, err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
err = xClient.Call(ctx, "Info", expenseId, &reply)
return
}
type ArgsExpenseEdit struct {
ExpenseId int64
ExpenseAdd
}
// Edit @TITLE 编辑
func (r *expense) Edit(ctx context.Context, args ArgsExpenseEdit) (err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Edit", args, &reply)
}
// Ik3cloud @TITLE 同步
func (r *expense) Ik3cloud(ctx context.Context, expenseId int64) (err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Ik3cloud", expenseId, &reply)
}
// Cancel @TITLE 作废
func (r *expense) Cancel(ctx context.Context, expenseId int64) (err error) {
xClient, err := client.GetClient(r)
if err != nil {
return
}
reply := 0
return xClient.Call(ctx, "Cancel", expenseId, &reply)
}