From 046c30582759dbb0782b3fc8e4ce5b73ee1414d0 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 30 Aug 2024 16:53:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/super/dao/agent_invoice_dao.go | 16 +++++++ src/super/dao/medium_invoice_dao.go | 17 +++++++ src/super/implement/agent_invoice_db.go | 43 ++++++++++++++++++ src/super/implement/medium_invoice_db.go | 58 ++++++++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 src/super/dao/agent_invoice_dao.go create mode 100644 src/super/dao/medium_invoice_dao.go create mode 100644 src/super/implement/agent_invoice_db.go create mode 100644 src/super/implement/medium_invoice_db.go diff --git a/src/super/dao/agent_invoice_dao.go b/src/super/dao/agent_invoice_dao.go new file mode 100644 index 0000000..3884b10 --- /dev/null +++ b/src/super/dao/agent_invoice_dao.go @@ -0,0 +1,16 @@ +package dao + +import "code.fnuoos.com/zhimeng/model.git/src/super/model" + +type AgentInvoiceDao interface { + GetAgentInvoice(settlementId int) (data *model.AgentInvoice, err error) + FindAgentInvoiceList(uuid, types string, page, limit int) (list []AgentInvoiceGroup, total int64, err error) +} +type AgentInvoiceGroup struct { + model.AgentInvoice `xorm:"extends"` + model.AgentSettlement `xorm:"extends"` +} + +func (AgentInvoiceGroup) TableName() string { + return "agent_invoice" +} diff --git a/src/super/dao/medium_invoice_dao.go b/src/super/dao/medium_invoice_dao.go new file mode 100644 index 0000000..b6dd72a --- /dev/null +++ b/src/super/dao/medium_invoice_dao.go @@ -0,0 +1,17 @@ +package dao + +import "code.fnuoos.com/zhimeng/model.git/src/super/model" + +type MediumInvoiceDao interface { + GetMediumInvoice(settlementId int) (data *model.MediumInvoice, err error) + GetMediumInvoiceById(id int) (data *model.MediumInvoice, err error) + FindMediumInvoiceList(uuid, types, mediumId string, page, limit int) (list []MediumInvoiceGroup, total int64, err error) +} +type MediumInvoiceGroup struct { + model.MediumInvoice `xorm:"extends"` + model.MediumSettlement `xorm:"extends"` +} + +func (MediumInvoiceGroup) TableName() string { + return "medium_invoice" +} diff --git a/src/super/implement/agent_invoice_db.go b/src/super/implement/agent_invoice_db.go new file mode 100644 index 0000000..26dc5b2 --- /dev/null +++ b/src/super/implement/agent_invoice_db.go @@ -0,0 +1,43 @@ +package implement + +import ( + "code.fnuoos.com/zhimeng/model.git/src/super/dao" + "code.fnuoos.com/zhimeng/model.git/src/super/model" + zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" + "xorm.io/xorm" +) + +func NewAgentInvoiceDb(engine *xorm.Engine) dao.AgentInvoiceDao { + return &AgentInvoiceDb{Db: engine} +} + +type AgentInvoiceDb struct { + Db *xorm.Engine +} + +func (m AgentInvoiceDb) GetAgentInvoice(settlementId int) (data *model.AgentInvoice, err error) { + data = new(model.AgentInvoice) + has, err := m.Db.Where("settlement_id =?", settlementId).Get(data) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return data, nil +} +func (m AgentInvoiceDb) FindAgentInvoiceList(uuid, types string, page, limit int) (list []dao.AgentInvoiceGroup, total int64, err error) { + sess := m.Db.OrderBy("agent_invoice.update_at desc,agent_invoice.id desc").Limit(limit, (page-1)*limit) + if uuid != "" { + sess.And("agent_settlement.uuid = ?", uuid) + } + if types != "" { + sess.And("agent_invoice.type = ?", types) + } + sess.Join("LEFT", "agent_settlement", "agent_settlement.id = agent_invoice.settlement_id") + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/implement/medium_invoice_db.go b/src/super/implement/medium_invoice_db.go new file mode 100644 index 0000000..2a5e721 --- /dev/null +++ b/src/super/implement/medium_invoice_db.go @@ -0,0 +1,58 @@ +package implement + +import ( + "code.fnuoos.com/zhimeng/model.git/src/super/dao" + "code.fnuoos.com/zhimeng/model.git/src/super/model" + zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" + "xorm.io/xorm" +) + +func NewMediumInvoiceDb(engine *xorm.Engine) dao.MediumInvoiceDao { + return &MediumInvoiceDb{Db: engine} +} + +type MediumInvoiceDb struct { + Db *xorm.Engine +} + +func (m MediumInvoiceDb) GetMediumInvoice(settlementId int) (data *model.MediumInvoice, err error) { + data = new(model.MediumInvoice) + has, err := m.Db.Where("settlement_id =?", settlementId).Get(data) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return data, nil +} + +func (m MediumInvoiceDb) GetMediumInvoiceById(id int) (data *model.MediumInvoice, err error) { + data = new(model.MediumInvoice) + has, err := m.Db.Where("id =?", id).Get(data) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return data, nil +} +func (m MediumInvoiceDb) FindMediumInvoiceList(uuid, types, mediumId string, page, limit int) (list []dao.MediumInvoiceGroup, total int64, err error) { + sess := m.Db.OrderBy("medium_invoice.update_at desc,medium_invoice.id desc").Limit(limit, (page-1)*limit) + if uuid != "" { + sess.And("medium_settlement.uuid = ?", uuid) + } + if types != "" { + sess.And("medium_invoice.type = ?", types) + } + if mediumId != "" { + sess.And("medium_settlement.medium_id = ?", mediumId) + } + sess.Join("LEFT", "medium_settlement", "medium_settlement.id = medium_invoice.settlement_id") + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +}