rows, err := db.Table("service_goods_orders").Select("name ,goods_id , sum(buy_number) AS total").Group("goods_id").Having("goods_id = ? ", goodsId).Where("deleted_at IS NULL OR deleted_at <= '0001-01-02' ").Rows()
if err != nil {
common.Log.Error("报错1 %v", err)
//return 0, err
}
defer rows.Close()
if rows.Next() {
name := ""
total := 0
goodsId := ""
err := rows.Scan(&name, &goodsId, &total)
if err != nil {
common.Log.Error("报错2 %v", err)
//return 0, err
}
common.Log.Debug("查询结果 = %v ----- %v", name, total)
//return total, nil
}