@@ -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" | |||||
} |
@@ -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" | |||||
} |
@@ -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 | |||||
} |
@@ -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 | |||||
} |