Skip to content

Commit

Permalink
feat: add workorder
Browse files Browse the repository at this point in the history
  • Loading branch information
ixre committed Jul 20, 2024
1 parent a96274e commit 2cb95a8
Show file tree
Hide file tree
Showing 26 changed files with 2,097 additions and 88 deletions.
14 changes: 7 additions & 7 deletions core/domain/interface/domain/enum/defined.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
// 未设置
ReviewNotSet int32 = 0
// 待审核
ReviewAwaiting int32 = 1
ReviewPending int32 = 1
// 审核未通过
ReviewReject int32 = 2
// 审核成功
Expand All @@ -31,12 +31,12 @@ const (

// 审核文本字典
var ReviewTextMap = map[int32]string{
ReviewNotSet: "未提交",
ReviewAwaiting: "待审核",
ReviewReject: "审核未通过",
ReviewPass: "审核通过",
ReviewConfirm: "已确认",
ReviewAbort: "已取消",
ReviewNotSet: "未提交",
ReviewPending: "待审核",
ReviewReject: "审核未通过",
ReviewPass: "审核通过",
ReviewConfirm: "已确认",
ReviewAbort: "已取消",
}

// 审核状态名称
Expand Down
2 changes: 1 addition & 1 deletion core/domain/interface/invoice/invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (

const (
// 发票状态: 待开票
IssueAwaiting = 1
IssuePending = 1
// 发票状态: 开票完成
IssueSuccess = 2
// 发票状态: 开票失败
Expand Down
4 changes: 2 additions & 2 deletions core/domain/interface/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const (
const (
// 未设置
ReviewNotSet = 0
// ReviewAwaiting 等待审核
ReviewAwaiting = 1
// ReviewPending 等待审核
ReviewPending = 1
// ReviewReject 审核失败
ReviewReject = 2
// ReviewPass 审核成功
Expand Down
3 changes: 3 additions & 0 deletions core/domain/interface/work/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Work

包括工单,审批及工作流等包
130 changes: 130 additions & 0 deletions core/domain/interface/work/workorder/workorder.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/**
* Copyright (C) 2009-2024 56X.NET, All rights reserved.
*
* name : model_gen.go
* author : jarrysix
* date : 2024/07/20 16:22:23
* description :
* history :
*/
package workorder

import (
"github.com/ixre/go2o/core/domain"
"github.com/ixre/go2o/core/infrastructure/fw"
)

const (
StatusPending = 1 // 待处理
StatusProcessing = 2 // 处理中
StatusFinished = 3 // 已完结
)

const (
FlagUserClosed = 1 // 用户关闭
)

const (
ClassSuggest = 1 // 建议
ClassAppeal = 2 // 申诉
)

type (
// 工单聚合根
IWorkorderAggregateRoot interface {
domain.IAggregateRoot
// 获取工单数
Value() *Workorder
// 提交工单
Submit() error
// 分配客服
AllocateAgentId(userId int) error
// 完结
Finish() error
// 用户关闭工单
Close() error
// 评价
Apprise(isUsefully bool, rank int, apprise string) error
// 提交回复
SubmitComment(content string, isReplay bool, refCommentId int) error
}
)

// IWorkorderRepo 工单仓储
type IWorkorderRepo interface {
fw.Repository[Workorder]
// 评论仓储
CommentRepo() fw.Repository[WorkorderComment]
// 创建工单
CreateWorkorder(value *Workorder) IWorkorderAggregateRoot
// 获取工单
GetWorkorder(id int) IWorkorderAggregateRoot
}

// Workorder Workorder
type Workorder struct {
// 编号
Id int `json:"id" db:"id" gorm:"column:id" pk:"yes" auto:"yes" bson:"id"`
// 会员编号
MemberId int `json:"memberId" db:"member_id" gorm:"column:member_id" bson:"memberId"`
// 反馈类型, 1: 建议 2:申诉
ClassId int `json:"classId" db:"class_id" gorm:"column:class_id" bson:"classId"`
// 关联商户
MchId int `json:"mchId" db:"mch_id" gorm:"column:mch_id" bson:"mchId"`
// 标志, 1:用户关闭
Flag int `json:"flag" db:"flag" gorm:"column:flag" bson:"flag"`
// 关联业务, 如:CHARGE:2014050060
Wip string `json:"wip" db:"wip" gorm:"column:wip" bson:"wip"`
// Subject
Subject string `json:"subject" db:"subject" gorm:"column:subject" bson:"subject"`
// 投诉内容
Content string `json:"content" db:"content" gorm:"column:content" bson:"content"`
// 是否开放评论
IsOpened int `json:"isOpened" db:"is_opened" gorm:"column:is_opened" bson:"isOpened"`
// 诉求描述
HopeDesc string `json:"hopeDesc" db:"hope_desc" gorm:"column:hope_desc" bson:"hopeDesc"`
// 图片
FirstPhoto string `json:"firstPhoto" db:"first_photo" gorm:"column:first_photo" bson:"firstPhoto"`
// 图片列表
PhotoList string `json:"photoList" db:"photo_list" gorm:"column:photo_list" bson:"photoList"`
// 状态,1:待处理 2:处理中 3:已完结
Status int `json:"status" db:"status" gorm:"column:status" bson:"status"`
// 分配的客服编号
AllocateAid int `json:"allocateAid" db:"allocate_aid" gorm:"column:allocate_aid" bson:"allocateAid"`
// 服务评分
ServiceRank int `json:"serviceRank" db:"service_rank" gorm:"column:service_rank" bson:"serviceRank"`
// 服务评价
ServiceApprise string `json:"serviceApprise" db:"service_apprise" gorm:"column:service_apprise" bson:"serviceApprise"`
// 是否有用 0:未评价 1:是 2:否
IsUsefully int `json:"isUsefully" db:"is_usefully" gorm:"column:is_usefully" bson:"isUsefully"`
// 创建时间
CreateTime int `json:"createTime" db:"create_time" gorm:"column:create_time" bson:"createTime"`
// 更新时间
UpdateTime int `json:"updateTime" db:"update_time" gorm:"column:update_time" bson:"updateTime"`
}

func (w Workorder) TableName() string {
return "workorder"
}

// WorkorderComment 工单详情
type WorkorderComment struct {
// 编号
Id int `json:"id" db:"id" gorm:"column:id" pk:"yes" auto:"yes" bson:"id"`
// 案件编号
OrderId int `json:"orderId" db:"order_id" gorm:"column:order_id" bson:"orderId"`
// 是否为回复信息,0:用户信息 1: 回复信息
IsReplay int `json:"isReplay" db:"is_replay" gorm:"column:is_replay" bson:"isReplay"`
// Content
Content string `json:"content" db:"content" gorm:"column:content" bson:"content"`
// 是否撤回 0:否 1:是
IsRevert int `json:"isRevert" db:"is_revert" gorm:"column:is_revert" bson:"isRevert"`
// 引用评论编号
RefCid int `json:"refCid" db:"ref_cid" gorm:"column:ref_cid" bson:"refCid"`
// 创建时间
CreateTime int `json:"createTime" db:"create_time" gorm:"column:create_time" bson:"createTime"`
}

func (w WorkorderComment) TableName() string {
return "workorder_comment"
}
6 changes: 3 additions & 3 deletions core/domain/invoice/invoice_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (i *invoiceTenantAggregateRootImpl) RequestInvoice(v *invoice.InvoiceReques
IssueRemark: "",
InvoicePic: "",
ReceiveEmail: v.ReceiveEmail,
InvoiceStatus: invoice.IssueAwaiting,
InvoiceStatus: invoice.IssuePending,
}
// 申请人信息
h := i.repo.Title().Get(v.TitleId)
Expand Down Expand Up @@ -184,7 +184,7 @@ func (i *invoiceRecordDomainImpl) GetItems() []*invoice.InvoiceItem {

// Issue implements invoice.InvoiceDomain.
func (i *invoiceRecordDomainImpl) Issue(picture string) error {
if i.value.InvoiceStatus != invoice.IssueAwaiting {
if i.value.InvoiceStatus != invoice.IssuePending {
return errors.New("invoice status error")
}
i.value.InvoiceStatus = invoice.IssueSuccess
Expand All @@ -210,7 +210,7 @@ func (i *invoiceRecordDomainImpl) Revert(reason string) error {
i.value.InvoiceStatus = invoice.IssueRevert
i.value.IssueRemark = reason
i.value.UpdateTime = int(time.Now().Unix())
_,err := i.repo.Save(i.value)
_, err := i.repo.Save(i.value)
return err
}

Expand Down
6 changes: 3 additions & 3 deletions core/domain/item/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func (i *itemImpl) copyFromProduct(v *item.GoodsItem) error {
func (i *itemImpl) resetReview() {
ir := i.registryRepo.Get(registry.ItemGenerateSnapshotReviewEnabled)
if ir != nil && ir.BoolValue() {
i.value.ReviewStatus = enum.ReviewAwaiting
i.value.ReviewStatus = enum.ReviewPending
}
}

Expand Down Expand Up @@ -505,7 +505,7 @@ func (i *itemImpl) Save() (_ int64, err error) {
if i.GetAggregateRootId() == 0 {
if domain.TestFlag(i.value.ItemFlag, item.FlagSelfSales) {
i.value.ShelveState = item.ShelvesOn
i.value.ReviewStatus = enum.ReviewAwaiting
i.value.ReviewStatus = enum.ReviewPending
}
}

Expand Down Expand Up @@ -625,7 +625,7 @@ func (i *itemImpl) SetShelve(state int32, remark string) error {
}
i.value.ShelveState = state
if i.value.ReviewStatus != enum.ReviewPass {
i.value.ReviewStatus = enum.ReviewAwaiting
i.value.ReviewStatus = enum.ReviewPending
}
i.value.ReviewRemark = remark
_, err := i.Save()
Expand Down
8 changes: 4 additions & 4 deletions core/domain/member/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func (a *accountImpl) carryToBalance(d member.AccountOperateData, freeze bool, p
l, err := a.createBalanceLog(member.KindCarry, d.Title, d.Amount, d.OuterNo, true)
if freeze {
a.value.FreezeBalance += int64(d.Amount)
l.ReviewStatus = enum.ReviewAwaiting
l.ReviewStatus = enum.ReviewPending
l.Remark = "待审核"
} else {
a.value.Balance += int64(d.Amount)
Expand All @@ -400,7 +400,7 @@ func (a *accountImpl) carryToBalance(d member.AccountOperateData, freeze bool, p

func (a *accountImpl) reviewBalanceCarryTo(requestId int, pass bool, reason string) error {
l := a.rep.GetBalanceLog(requestId)
if l.ReviewStatus != int32(enum.ReviewAwaiting) {
if l.ReviewStatus != int32(enum.ReviewPending) {
return wallet.ErrNotSupport
}
a.value.FreezeBalance -= l.Amount
Expand Down Expand Up @@ -429,7 +429,7 @@ func (a *accountImpl) carryToIntegral(d member.AccountOperateData, freeze bool)
l, err := a.createIntegralLog(member.KindCarry, d.Title, d.Amount, d.OuterNo, true)
if freeze {
a.value.FreezeIntegral += d.Amount
l.ReviewStatus = int16(enum.ReviewAwaiting)
l.ReviewStatus = int16(enum.ReviewPending)
l.Remark = "待审核"
} else {
a.value.Integral += d.Amount
Expand All @@ -449,7 +449,7 @@ func (a *accountImpl) carryToIntegral(d member.AccountOperateData, freeze bool)

func (a *accountImpl) reviewIntegralCarryTo(requestId int, pass bool, reason string) error {
l := a.rep.GetIntegralLog(requestId)
if l.ReviewStatus != int16(enum.ReviewAwaiting) {
if l.ReviewStatus != int16(enum.ReviewPending) {
return wallet.ErrNotSupport
}
a.value.FreezeIntegral -= l.Value
Expand Down
6 changes: 3 additions & 3 deletions core/domain/member/profile_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ func (p *profileManagerImpl) copyCertificationInfo(src member.CerticationInfo, d
if dst == nil {
dst = &member.CerticationInfo{
MemberId: p.memberId,
ReviewStatus: int(enum.ReviewAwaiting),
ReviewStatus: int(enum.ReviewPending),
}
}
dst.RealName = src.RealName
Expand All @@ -601,7 +601,7 @@ func (p *profileManagerImpl) GetCertificationInfo() *member.CerticationInfo {
if p.trustedInfo == nil {
p.trustedInfo = &member.CerticationInfo{
MemberId: p.memberId,
ReviewStatus: int(enum.ReviewAwaiting),
ReviewStatus: int(enum.ReviewPending),
}
}
}
Expand Down Expand Up @@ -676,7 +676,7 @@ func (p *profileManagerImpl) SaveCertificationInfo(v *member.CerticationInfo) er
err = p.copyCertificationInfo(*v, current)
if err == nil {
current.Remark = ""
current.ReviewStatus = int(enum.ReviewAwaiting) //标记为待处理
current.ReviewStatus = int(enum.ReviewPending) //标记为待处理
current.UpdateTime = time.Now().Unix()
p.trustedInfo = current
_, err = p.repo.SaveCertificationInfo(p.trustedInfo)
Expand Down
4 changes: 2 additions & 2 deletions core/domain/merchant/profile_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (p *profileManagerImpl) SaveAuthenticate(v *merchant.Authenticate) (int, er
return 0, err
}
v.MchId = int(p.GetAggregateRootId())
v.ReviewStatus = int(enum.ReviewAwaiting)
v.ReviewStatus = int(enum.ReviewPending)
v.ReviewRemark = ""
v.ReviewTime = 0
// aName := p.valRepo.GetDistrictNames([]int32{e.Province, e.City, e.District})
Expand Down Expand Up @@ -100,7 +100,7 @@ func (p *profileManagerImpl) ReviewAuthenticate(pass bool, message string) error
if e == nil {
return errors.New("未找到企业认证信息")
}
if e.ReviewStatus != int(enum.ReviewAwaiting) {
if e.ReviewStatus != int(enum.ReviewPending) {
return errors.New("企业认证信息已审核")
}
e.ReviewTime = int(time.Now().Unix())
Expand Down
2 changes: 1 addition & 1 deletion core/domain/merchant/wholesale/wholesale.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (w *wholesalerImpl) Value() *wholesaler.WsWholesaler {

// 审核批发商
func (w *wholesalerImpl) Review(pass bool, reason string) error {
if w.value.ReviewStatus == enum.ReviewAwaiting {
if w.value.ReviewStatus == enum.ReviewPending {
if pass {
w.value.ReviewStatus = enum.ReviewPass
} else {
Expand Down
8 changes: 4 additions & 4 deletions core/domain/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func (w *WalletImpl) CarryTo(d wallet.OperateData, review bool, procedureFee int
l := w.createWalletLog(wallet.KCarry, d.Amount, d.Title, 0, "")
if review {
w._value.FreezeAmount += d.Amount
l.ReviewStatus = wallet.ReviewAwaiting
l.ReviewStatus = wallet.ReviewPending
l.ReviewRemark = "待审核"
} else {
w._value.Balance += int64(d.Amount)
Expand All @@ -419,7 +419,7 @@ func (w *WalletImpl) CarryTo(d wallet.OperateData, review bool, procedureFee int
// ReviewCarryTo 审核入账
func (w *WalletImpl) ReviewCarryTo(requestId int, pass bool, reason string) error {
l := w._repo.GetLog(w.GetAggregateRootId(), int64(requestId))
if l.ReviewStatus != int(enum.ReviewAwaiting) {
if l.ReviewStatus != int(enum.ReviewPending) {
return wallet.ErrNotSupport
}
w._value.FreezeAmount -= int(l.ChangeValue)
Expand Down Expand Up @@ -591,7 +591,7 @@ func (w *WalletImpl) RequestWithdrawal(amount int, tradeFee int, kind int, title
l := w.createWalletLog(kind, -(amount - tradeFee), title, 0, "")
l.ProcedureFee = -tradeFee
l.OuterNo = tradeNo
l.ReviewStatus = wallet.ReviewAwaiting
l.ReviewStatus = wallet.ReviewPending
l.ReviewRemark = ""
l.BankName = bankName
l.AccountNo = accountNo
Expand All @@ -615,7 +615,7 @@ func (w *WalletImpl) ReviewWithdrawal(requestId int64, pass bool, remark string,
if l.Kind != wallet.KWithdrawToBankCard && l.Kind != wallet.KWithdrawToThirdPart {
return wallet.ErrNotSupport
}
if l.ReviewStatus != wallet.ReviewAwaiting {
if l.ReviewStatus != wallet.ReviewPending {
return wallet.ErrWithdrawState
}
l.ReviewTime = time.Now().Unix()
Expand Down
Loading

0 comments on commit 2cb95a8

Please sign in to comment.