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