Beispiel #1
0
func calcTimely(queryParams t.Params) (noDelay int64, total int64, rat string) {
	sqlBuilder := wbo.NewSqlBuilder()
	for k, v := range queryParams {
		sqlBuilder.Filter(k, v)
	}
	where := sqlBuilder.GetConditonSql()
	noDelaySql := "SELECT count(id) as count FROM purchase WHERE godowndate != '' AND godowndate < requireddate " + "AND " + where
	noDelay = wbo.QueryRawCount(noDelaySql, sqlBuilder.GetValues())
	totalSql := "SELECT count(id) as count FROM purchase WHERE " + where + " AND (godowndate != '' OR requireddate < '?')"
	total = wbo.QueryRawCount(totalSql, append(sqlBuilder.GetValues(), u.GetToday()))
	if total == 0 || noDelay == 0 {
		rat = "0%"
		return
	}
	rat = fmt.Sprintf("%.2f", float64(noDelay)*100/float64(total)) + "%"
	return
}
Beispiel #2
0
func GetPurchaseTotal(sqlBuilder *wbo.SqlBuilder) int64 {
	query := sqlBuilder.GetCustomerSql(purchaseCountSql)
	values := sqlBuilder.GetValues()
	beego.Debug("GetPurchaseTotal: ", query, ":", values)
	return wbo.QueryRawCount(query, values)
}