diff --git a/src/super/dao/agent_list_dao.go b/src/super/dao/agent_list_dao.go index 8b46fd8..529f216 100644 --- a/src/super/dao/agent_list_dao.go +++ b/src/super/dao/agent_list_dao.go @@ -11,4 +11,5 @@ type AgentListDao interface { AgentListInsert(m *model.AgentList) (int64, error) UpdateAgentList(m *model.AgentList, columns ...string) (int64, error) FindAgentList(uuid, name, state string, minState, page, limit int) (list []model.AgentList, total int64, err error) + FindAgentListBySettleType(uuid, agentId, settleType string, page, limit int) (list []model.AgentList, total int64, err error) } diff --git a/src/super/dao/agent_settlement_dao.go b/src/super/dao/agent_settlement_dao.go index 6ab6a0c..f997ca7 100644 --- a/src/super/dao/agent_settlement_dao.go +++ b/src/super/dao/agent_settlement_dao.go @@ -1,4 +1,4 @@ -package dao +package dao import ( "code.fnuoos.com/zhimeng/model.git/src/super/model" @@ -9,4 +9,5 @@ type AgentSettlementDao interface { GetAgentSettlementForAvailable(agentId int) (agentSettlement *model.AgentSettlement, err error) AgentSettlementInsertBySession(session *xorm.Session, m *model.AgentSettlement) (int64, error) UpdateAgentSettlementBySession(session *xorm.Session, agentSettlement *model.AgentSettlement, columns ...string) (int64, error) + FindAgentSettlementList(uuid, mediumId, appId, payState, state, startDate, endDate string, page, limit int) (list []model.AgentSettlement, total int64, err error) } diff --git a/src/super/dao/generate_wx_ad_data_dao.go b/src/super/dao/generate_wx_ad_data_dao.go index 1de4333..f7d935c 100644 --- a/src/super/dao/generate_wx_ad_data_dao.go +++ b/src/super/dao/generate_wx_ad_data_dao.go @@ -1,4 +1,4 @@ -package dao +package dao import ( "code.fnuoos.com/zhimeng/model.git/src/super/model" @@ -9,4 +9,5 @@ type GenerateWxAdDataDao interface { GenerateWxAdDataInsertBySession(session *xorm.Session, m *model.GenerateWxAdData) (int64, error) GetGenerateWxAdData(id int) (data *model.GenerateWxAdData, err error) UpdateGenerateWxAdDataBySession(session *xorm.Session, m *model.GenerateWxAdData, columns ...string) (int64, error) + FindGenerateWxAdDataList(uuid, appId, slotId, startDate, endDate string, page, limit int) (list []model.GenerateWxAdData, total int64, err error) } diff --git a/src/super/dao/medium_list_dao.go b/src/super/dao/medium_list_dao.go index 7420fcd..3cf3198 100644 --- a/src/super/dao/medium_list_dao.go +++ b/src/super/dao/medium_list_dao.go @@ -11,4 +11,5 @@ type MediumListDao interface { MediumListInsert(m *model.MediumList) (int64, error) UpdateMediumList(m *model.MediumList, columns ...string) (int64, error) FindMediumList(uuid, name, state string, minState, page, limit int) (list []model.MediumList, total int64, err error) + FindMediumListBySettleType(uuid, mediumId, settleType string, page, limit int) (list []model.MediumList, total int64, err error) } diff --git a/src/super/dao/medium_settlement_dao.go b/src/super/dao/medium_settlement_dao.go index d543603..fd7ed35 100644 --- a/src/super/dao/medium_settlement_dao.go +++ b/src/super/dao/medium_settlement_dao.go @@ -1,4 +1,4 @@ -package dao +package dao import ( "code.fnuoos.com/zhimeng/model.git/src/super/model" @@ -7,6 +7,8 @@ import ( type MediumSettlementDao interface { GetMediumSettlementForAvailable(mediumId int) (mediumSettlement *model.MediumSettlement, err error) + GetMediumSettlementById(id int) (mediumSettlement *model.MediumSettlement, err error) MediumSettlementInsertBySession(session *xorm.Session, m *model.MediumSettlement) (int64, error) UpdateMediumSettlementBySession(session *xorm.Session, mediumSettlement *model.MediumSettlement, columns ...string) (int64, error) + FindMediumSettlementList(uuid, mediumId, appId, payState, state, startDate, endDate string, page, limit int) (list []model.MediumSettlement, total int64, err error) } diff --git a/src/super/dao/original_wx_ad_data_dao.go b/src/super/dao/original_wx_ad_data_dao.go index 41904a6..f10cf8e 100644 --- a/src/super/dao/original_wx_ad_data_dao.go +++ b/src/super/dao/original_wx_ad_data_dao.go @@ -10,5 +10,5 @@ type OriginalWxAdDataDao interface { GetOriginalWxAdDataSess(sess *xorm.Session, id int) (data *model.OriginalWxAdData, err error) UpdateOriginalWxAdData(m *model.OriginalWxAdData, columns ...string) (int64, error) UpdateOriginalWxAdDataBySession(session *xorm.Session, m *model.OriginalWxAdData, columns ...string) (int64, error) - FindOriginalWxAdDataList(uuid, appId, slotId, date string, page, limit int) (list []model.OriginalWxAdData, total int64, err error) + FindOriginalWxAdDataList(uuid, appId, slotId, startDate, endDate string, page, limit int) (list []model.OriginalWxAdData, total int64, err error) } diff --git a/src/super/implement/agent_list_implement.go b/src/super/implement/agent_list_implement.go index 8cee054..05969f2 100644 --- a/src/super/implement/agent_list_implement.go +++ b/src/super/implement/agent_list_implement.go @@ -4,6 +4,7 @@ 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" + "strings" "xorm.io/xorm" ) @@ -71,3 +72,22 @@ func (a AgentListDb) FindAgentList(uuid, name, state string, minState, page, lim } return } + +func (a AgentListDb) FindAgentListBySettleType(uuid, agentId, settleType string, page, limit int) (list []model.AgentList, total int64, err error) { + sess := a.Db.Desc("id").Limit(limit, (page-1)*limit) + + if settleType != "" { + sess.And("settle_type = ?", settleType) + } + if agentId != "" { + sess.In("agent_id", strings.Split(agentId, ",")) + } + if uuid != "" { + sess.And("uuid = ?", uuid) + } + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/implement/agent_settlement_implement.go b/src/super/implement/agent_settlement_implement.go index 2d73b82..dade613 100644 --- a/src/super/implement/agent_settlement_implement.go +++ b/src/super/implement/agent_settlement_implement.go @@ -1,9 +1,10 @@ -package implement +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" + "strings" "xorm.io/xorm" ) @@ -42,3 +43,32 @@ func (a AgentSettlementDb) AgentSettlementInsertBySession(session *xorm.Session, } return insertAffected, nil } +func (a AgentSettlementDb) FindAgentSettlementList(uuid, agentId, appId, payState, state, startDate, endDate string, page, limit int) (list []model.AgentSettlement, total int64, err error) { + sess := a.Db.OrderBy("start_date desc,id desc").Limit(limit, (page-1)*limit) + if uuid != "" { + sess.And("uuid = ?", uuid) + } + if payState != "" { + sess.And("pay_state = ?", payState) + } + if state != "" { + sess.And("state = ?", state) + } + if startDate != "" { + sess.And("start_date>=", startDate) + } + if endDate != "" { + sess.And("end_date<=", endDate) + } + if appId != "" { + sess.In("app_id", strings.Split(appId, ",")) + } + if agentId != "" { + sess.In("agent_id", strings.Split(agentId, ",")) + } + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/implement/generate_wx_ad_data_implement.go b/src/super/implement/generate_wx_ad_data_implement.go index 2a7954a..60ba9c6 100644 --- a/src/super/implement/generate_wx_ad_data_implement.go +++ b/src/super/implement/generate_wx_ad_data_implement.go @@ -1,9 +1,10 @@ -package implement +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" + "strings" "xorm.io/xorm" ) @@ -42,3 +43,26 @@ func (g GenerateWxAdDataDb) GenerateWxAdDataInsertBySession(session *xorm.Sessio } return insertAffected, nil } +func (g GenerateWxAdDataDb) FindGenerateWxAdDataList(uuid, appId, slotId, startDate, endDate string, page, limit int) (list []model.GenerateWxAdData, total int64, err error) { + sess := g.Db.OrderBy("date desc,id desc").Limit(limit, (page-1)*limit) + if uuid != "" { + sess.And("uuid = ?", uuid) + } + if startDate != "" { + sess.And("date>=", startDate) + } + if endDate != "" { + sess.And("date<=", endDate) + } + if appId != "" { + sess.In("app_id", strings.Split(appId, ",")) + } + if slotId != "" { + sess.In("slot_id", strings.Split(slotId, ",")) + } + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/implement/generate_wx_ad_data_with_agent_flow_implement.go b/src/super/implement/generate_wx_ad_data_with_agent_flow_implement.go index 397429b..b29dbe0 100644 --- a/src/super/implement/generate_wx_ad_data_with_agent_flow_implement.go +++ b/src/super/implement/generate_wx_ad_data_with_agent_flow_implement.go @@ -1,4 +1,4 @@ -package implement +package implement import ( "code.fnuoos.com/zhimeng/model.git/src/super/dao" @@ -25,7 +25,7 @@ func (g GenerateWxAdDataWithAgentFlowDb) BatchAddGenerateWxAdDataWithAgentFlow(s func (g GenerateWxAdDataWithAgentFlowDb) FindGenerateWxAdDataWithAgentFlowByStrategyId(strategyId int) (*[]model.GenerateWxAdDataWithAgentFlow, error) { var m []model.GenerateWxAdDataWithAgentFlow - if err := g.Db.Where("strategy_id = ?", strategyId).Asc("id").Find(&m); err != nil { + if err := g.Db.Where("generate_data_id = ?", strategyId).Asc("id").Find(&m); err != nil { return nil, zhios_order_relate_logx.Error(err) } return &m, nil diff --git a/src/super/implement/medium_list_implement.go b/src/super/implement/medium_list_implement.go index e4a4415..26528eb 100644 --- a/src/super/implement/medium_list_implement.go +++ b/src/super/implement/medium_list_implement.go @@ -4,6 +4,7 @@ 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" + "strings" "xorm.io/xorm" ) @@ -71,3 +72,22 @@ func (m MediumListDb) FindMediumList(uuid, name, state string, minState, page, l } return } + +func (m MediumListDb) FindMediumListBySettleType(uuid, mediumId, settleType string, page, limit int) (list []model.MediumList, total int64, err error) { + sess := m.Db.Desc("id").Limit(limit, (page-1)*limit) + + if settleType != "" { + sess.And("settle_type = ?", settleType) + } + if mediumId != "" { + sess.In("medium_id", strings.Split(mediumId, ",")) + } + if uuid != "" { + sess.And("uuid = ?", uuid) + } + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/implement/medium_settlement_implement.go b/src/super/implement/medium_settlement_implement.go index b4b933d..7d1ba60 100644 --- a/src/super/implement/medium_settlement_implement.go +++ b/src/super/implement/medium_settlement_implement.go @@ -1,9 +1,10 @@ -package implement +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" + "strings" "xorm.io/xorm" ) @@ -42,3 +43,43 @@ func (m MediumSettlementDb) GetMediumSettlementForAvailable(mediumId int) (mediu } return mediumSettlement, nil } +func (m MediumSettlementDb) GetMediumSettlementById(id int) (mediumSettlement *model.MediumSettlement, err error) { + mediumSettlement = new(model.MediumSettlement) + has, err := m.Db.Where("id =?", id).Get(mediumSettlement) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return mediumSettlement, nil +} +func (m MediumSettlementDb) FindMediumSettlementList(uuid, mediumId, appId, payState, state, startDate, endDate string, page, limit int) (list []model.MediumSettlement, total int64, err error) { + sess := m.Db.OrderBy("start_date desc,id desc").Limit(limit, (page-1)*limit) + if uuid != "" { + sess.And("uuid = ?", uuid) + } + if payState != "" { + sess.And("pay_state = ?", payState) + } + if state != "" { + sess.And("state = ?", state) + } + if startDate != "" { + sess.And("start_date>=", startDate) + } + if endDate != "" { + sess.And("end_date<=", endDate) + } + if appId != "" { + sess.In("app_id", strings.Split(appId, ",")) + } + if mediumId != "" { + sess.In("medium_id", strings.Split(mediumId, ",")) + } + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/implement/original_wx_ad_data_implement.go b/src/super/implement/original_wx_ad_data_implement.go index c0e52c2..d60295f 100644 --- a/src/super/implement/original_wx_ad_data_implement.go +++ b/src/super/implement/original_wx_ad_data_implement.go @@ -54,13 +54,16 @@ func (o OriginalWxAdDataDb) GetOriginalWxAdDataSess(sess *xorm.Session, id int) } return data, nil } -func (o OriginalWxAdDataDb) FindOriginalWxAdDataList(uuid, appId, slotId, date string, page, limit int) (list []model.OriginalWxAdData, total int64, err error) { +func (o OriginalWxAdDataDb) FindOriginalWxAdDataList(uuid, appId, slotId, startDate, endDate string, page, limit int) (list []model.OriginalWxAdData, total int64, err error) { sess := o.Db.OrderBy("date desc,id desc").Limit(limit, (page-1)*limit) if uuid != "" { sess.And("uuid = ?", uuid) } - if date != "" { - sess.In("date", strings.Split(date, ",")) + if startDate != "" { + sess.And("date>=", startDate) + } + if endDate != "" { + sess.And("date<=", endDate) } if appId != "" { sess.In("app_id", strings.Split(appId, ",")) diff --git a/src/super/model/agent_invoice.go b/src/super/model/agent_invoice.go new file mode 100644 index 0000000..3192f6a --- /dev/null +++ b/src/super/model/agent_invoice.go @@ -0,0 +1,12 @@ +package model + +type AgentInvoice struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + SettlementId int `json:"settlement_id" xorm:"not null default 0 comment('结算id') index unique INT(11)"` + CreateAt string `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + File string `json:"file" xorm:"VARCHAR(5000)"` + Count int `json:"count" xorm:"default 0 INT(11)"` + Type int `json:"type" xorm:"default 0 comment('0电子发票 1纸质发票') INT(1)"` + State int `json:"state" xorm:"default 0 comment('0待审核 1审核通过 2审核拒绝') INT(1)"` +} diff --git a/src/super/model/agent_settlement.go b/src/super/model/agent_settlement.go index 128c15f..ab73bd4 100644 --- a/src/super/model/agent_settlement.go +++ b/src/super/model/agent_settlement.go @@ -14,6 +14,7 @@ type AgentSettlement struct { State int `json:"state" xorm:"not null default 0 comment('结算单状态(0:未开始 1:核算中 2:待签订 3:完成签订)') TINYINT(1)"` StartDate string `json:"start_date" xorm:"not null default '0000-00-00' comment('开始时间') CHAR(50)"` EndDate string `json:"end_date" xorm:"not null default '0000-00-00' comment('结束时间') CHAR(50)"` - CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + CreateAt string `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + SettleFile string `json:"settle_file" xorm:"comment('结算单文件') VARCHAR(255)"` } diff --git a/src/super/model/generate_wx_ad_data.go b/src/super/model/generate_wx_ad_data.go index 3699642..5173d67 100644 --- a/src/super/model/generate_wx_ad_data.go +++ b/src/super/model/generate_wx_ad_data.go @@ -31,4 +31,5 @@ type GenerateWxAdData struct { IsGenerateReport int `json:"is_generate_report" xorm:"not null default 0 comment('是否已生成报表(0:未 1:已)') TINYINT(1)"` CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + Platform string `json:"platform" xorm:"not null default '' comment('来源平台') CHAR(50)"` } diff --git a/src/super/model/medium_invoice.go b/src/super/model/medium_invoice.go new file mode 100644 index 0000000..c608936 --- /dev/null +++ b/src/super/model/medium_invoice.go @@ -0,0 +1,12 @@ +package model + +type MediumInvoice struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + SettlementId int `json:"settlement_id" xorm:"not null default 0 comment('结算id') index unique INT(11)"` + CreateAt string `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + File string `json:"file" xorm:"VARCHAR(5000)"` + Count int `json:"count" xorm:"default 0 INT(11)"` + Type int `json:"type" xorm:"default 0 comment('0电子发票 1纸质发票') INT(1)"` + State int `json:"state" xorm:"default 0 comment('0待审核 1审核通过 2审核拒绝') INT(1)"` +} diff --git a/src/super/model/medium_settlement.go b/src/super/model/medium_settlement.go index 1b11350..343fd47 100644 --- a/src/super/model/medium_settlement.go +++ b/src/super/model/medium_settlement.go @@ -11,8 +11,9 @@ type MediumSettlement struct { OtherIncome int `json:"other_income" xorm:"not null default 0 comment('其他收益(分)') INT(11)"` PayState int `json:"pay_state" xorm:"not null default 0 comment('结算单支付状态(0:未开始 1:待审核发票 2:发票审核中 3:发票审核拒绝 4:付款中 5:已付款)') TINYINT(1)"` State int `json:"state" xorm:"not null default 0 comment('结算单状态(0:未开始 1:核算中 2:待签订 3:完成签订)') TINYINT(1)"` - StartDate string `json:"start_date" xorm:"not null default '0000-00-00' comment('开始时间') CHAR(50)"` - EndDate string `json:"end_date" xorm:"not null default '0000-00-00' comment('结束时间') CHAR(50)"` - CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + StartDate string `json:"start_date" xorm:"not null comment('开始时间') DATE"` + EndDate string `json:"end_date" xorm:"not null comment('结束时间') DATE"` + CreateAt string `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + SettleFile string `json:"settle_file" xorm:"comment('结算单文件') VARCHAR(255)"` } diff --git a/src/super/model/original_wx_ad_data.go b/src/super/model/original_wx_ad_data.go index af5b2b9..4b9972a 100644 --- a/src/super/model/original_wx_ad_data.go +++ b/src/super/model/original_wx_ad_data.go @@ -18,4 +18,5 @@ type OriginalWxAdData struct { IsApply int `json:"is_apply" xorm:"not null default 0 comment('是否已应用(0:未 1:已)') TINYINT(1)"` CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + Platform string `json:"platform" xorm:"not null default '' comment('来源平台') CHAR(50)"` }