|
|
@@ -0,0 +1,40 @@ |
|
|
|
package implement |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/dao" |
|
|
|
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func NewServiceAwardReturnFlowDb(engine *xorm.Engine) dao.ServiceAwardReturnFlowDao { |
|
|
|
return &ServiceAwardReturnFlowDb{Db: engine} |
|
|
|
} |
|
|
|
|
|
|
|
type ServiceAwardReturnFlowDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (s ServiceAwardReturnFlowDb) GetServiceAwardReturnFlowTotal(types, createTime string) (sum float64, hasReturnMoney float64, err error) { |
|
|
|
sess := s.Db.Where("sum-has_return_money>0 and type>?", 0) |
|
|
|
if types != "" { |
|
|
|
sess.And("type=?", types) |
|
|
|
} |
|
|
|
if createTime != "" { |
|
|
|
sess.And("date<?", createTime) |
|
|
|
} |
|
|
|
sum, _ = sess.Sum(&models.ServiceAwardReturnFlow{}, "sum") |
|
|
|
hasReturnMoney, _ = sess.Sum(&models.ServiceAwardReturnFlow{}, "has_return_money") |
|
|
|
return sum, hasReturnMoney, nil |
|
|
|
} |
|
|
|
func (s ServiceAwardReturnFlowDb) GetServiceAwardReturnFlowList(types, p, size int, createTime string) (mm *[]models.ServiceAwardReturnFlow, err error) { |
|
|
|
var m []models.ServiceAwardReturnFlow |
|
|
|
sess := s.Db.Where("sum-has_return_money>0 and type=?", types) |
|
|
|
if createTime != "" { |
|
|
|
sess.And("date<?", createTime) |
|
|
|
} |
|
|
|
err = sess.Limit(size, (p-1)*size).Find(&m) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |