package customer import ( "context" "git.oa00.com/supply-chain/service/client" user2 "git.oa00.com/supply-chain/service/customer/user" "git.oa00.com/supply-chain/service/lib/bean" "github.com/shopspring/decimal" ) const ( UserStatusDisabled = 1 // 停用 UserStatusEnabled = 2 // 启用 UserTypeManage = 1 // 后台创建 UserTypeSelf = 2 // 自主创建 ) type user struct { user2.User } type UserSearch struct { Status uint // 状态 Name string // 客户名称 } type ArgsUserList struct { Search UserSearch Page bean.Page } type UserItem struct { Id uint `json:"id"` Name string `json:"name"` Account string `json:"account"` Liaison string `json:"liaison"` Phone string `json:"phone"` Amount decimal.Decimal `json:"amount"` Status uint `json:"status"` CreatedType uint `json:"createdType"` CreatedUserId uint `json:"createdUserId"` CreatedAt int64 `json:"createdAt"` } type ReplyUserList struct { Lists []UserItem `json:"lists"` Total int64 `json:"total"` } // Lists @Title 获取客户列表 func (u *user) Lists(ctx context.Context, args ArgsUserList) (reply ReplyUserList, err error) { xClient, err := client.GetClient(u) if err != nil { return } err = xClient.Call(ctx, "Lists", args, &reply) return } type ArgsUserAdd struct { Name string // 名称 Account string // 账号 Liaison string // 联系人 Phone string // 手机号 Password string // 密码 CreatedType uint // 创建账号类型 1=后台创建 2=自主创建 CreatedUserId uint // 创建人Id } // Add @Title 添加客户 func (u *user) Add(ctx context.Context, args ArgsUserAdd) error { reply := 0 xClient, err := client.GetClient(u) if err != nil { return err } return xClient.Call(ctx, "Add", args, &reply) } type ReplyUserInfo struct { Id uint `json:"id"` Name string `json:"name"` Liaison string `json:"liaison"` Phone string `json:"phone"` Account string `json:"account"` } // Info @Title 客户详情 func (u *user) Info(ctx context.Context, userId uint) (result ReplyUserInfo, err error) { xClient, err := client.GetClient(u) if err != nil { return } err = xClient.Call(ctx, "Info", userId, &result) return } type ArgsUserEdit struct { Id uint // 客户id Name string // 名称 Liaison string // 联系人 Phone string // 手机号 Password string // 密码 空=不修改 } // Edit @Title 编辑客户 func (u *user) Edit(ctx context.Context, args ArgsUserEdit) error { reply := 0 xClient, err := client.GetClient(u) if err != nil { return err } return xClient.Call(ctx, "Edit", args, &reply) } // Enable @Title 启用 func (u *user) Enable(ctx context.Context, userId uint) error { reply := 0 xClient, err := client.GetClient(u) if err != nil { return err } return xClient.Call(ctx, "Enable", userId, &reply) } // Disable @Title 停用 func (u *user) Disable(ctx context.Context, userId uint) error { reply := 0 xClient, err := client.GetClient(u) if err != nil { return err } return xClient.Call(ctx, "Disable", userId, &reply) } type ArgsUserServiceInfo struct { ServiceId serviceId // 服务id AppKey string // 渠道appKey } type ReplyUserServiceInfo struct { CustomerId uint `json:"customerId"` AppSecret string `json:"appSecret"` ExpirationAt int64 `json:"expirationAt"` } // ServiceInfo @Title 获取服务信息 func (u *user) ServiceInfo(ctx context.Context, args ArgsUserServiceInfo) (reply ReplyUserServiceInfo, err error) { xClient, err := client.GetClient(u) if err != nil { return } err = xClient.Call(ctx, "ServiceInfo", args, &reply) return }