Bladeren bron

更新

master
huangjiajun 3 maanden geleden
bovenliggende
commit
046c305827
4 gewijzigde bestanden met toevoegingen van 134 en 0 verwijderingen
  1. +16
    -0
      src/super/dao/agent_invoice_dao.go
  2. +17
    -0
      src/super/dao/medium_invoice_dao.go
  3. +43
    -0
      src/super/implement/agent_invoice_db.go
  4. +58
    -0
      src/super/implement/medium_invoice_db.go

+ 16
- 0
src/super/dao/agent_invoice_dao.go Bestand weergeven

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

+ 17
- 0
src/super/dao/medium_invoice_dao.go Bestand weergeven

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

+ 43
- 0
src/super/implement/agent_invoice_db.go Bestand weergeven

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

+ 58
- 0
src/super/implement/medium_invoice_db.go Bestand weergeven

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

Laden…
Annuleren
Opslaan